1
;; Enable a outline minor mode with Python code
3
;; Copy this document inside your ".emacs".
5
;; arch-tag: 3726247d-4c34-4247-a9aa-c9bc43ee2346
7
(add-hook 'python-mode-hook 'my-python-hook)
9
; this gets called by outline to deteremine the level
10
; just use the length of the whitespace
11
(defun py-outline-level ()
12
(let (buffer-invisibility-spec)
14
(skip-chars-forward "\t ")
17
; this get called after python mode is enabled
18
(defun my-python-hook ()
19
; outline uses this regexp to find headers. I match lines with no
20
; indent and indented "class" and "def" lines.
21
(setq outline-regexp "[^ \t\n]\\|[ \t]*\\(def\\|class\\) ")
22
; enable our level computation
23
(setq outline-level 'py-outline-level)
24
; do not use their \C-c@ prefix, too hard to type. Note this
25
; overides some python mode bindings
26
(setq outline-minor-mode-prefix "\C-c")
27
; turn on outline mode
28
(outline-minor-mode t)
29
; initially hide all but the headers