[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Hint / Call to use emacs outline mode



 When editing many resource files and regarding debian packages files
I thought, these lines could be of some help for someone.  It is a
hint and a call for using the emacs outline mode, which is great in
folding any files in pieces of information of the desired level.  All
sort of files that allow comments are comfortably managable in this
way:

 Set the search pattern for outline headers with
"outline-regexp" such that:

   - the very first character per line is ignored,
     to enable any sort of comment lines
   - the 3-characters-sequence "*_*" as the 2, 3. and 4. char
     marks an outline header; this sequence is not likely to
     be a regular piece of text or a program.
   - the now following number of starts '*' gives the 
     level of outline header.

examples:
/*_*  This now is regarded as a level 0 header for a C-source */
{*_** this is a level 2 header for a Pascal-Program}
%*_*** a level 3 header for a TeX-text

 and so on.  That way we manage all of our files of any sort,
including /etc/X11/XF86Config, ~/.emacs, /etc/profile and so
on.

 Init the outline mode with: C-r, and then have fun. Hope it
helps. 
   -Andreas.


 Here is an exerpt from my ~/.emacs resource file:
---------- snip ---------- snip ---------- snip ----------

(setq-default outline-regexp ".[*]_[*]+")
(put 'narrow-to-region 'disabled nil)

(fset 'reset_outline
   "\C-[1\C-[xoutline-minor-mode\C-m\C-[xhide-other")
(fset 'show-all-branches
   "\C-cA\C-ca")

; show/hide headers without text
; ==============================
; C-c R show: all levels
; C-c r hide: all but level 0; init/reset outline mode
; C-c S show: subtree
; C-c s hide: subtree
; C-c T show: only this sublevel
; C-c t hide: only this sub level

(define-key Ctl-C-keymap "R" 'show-all-branches)
(define-key Ctl-C-keymap "r" 'reset_outline)
(define-key Ctl-C-keymap "S" 'show-branches)
(define-key Ctl-C-keymap "s" 'hide-subtree)
(define-key Ctl-C-keymap "T" 'show-children)
(define-key Ctl-C-keymap "t" 'hide-subtree)

; show/hide text and headers
; ==========================
; C-c A show all text, e. g. everything
; C-c a hide all text, show only headers
; C-c B show subtree with text
; C-c b hide subtree 
; C-c C show text of this sub level
; C-c c hide text of just this level

(define-key Ctl-C-keymap "A" 'show-all)
(define-key Ctl-C-keymap "a" 'hide-body)
(define-key Ctl-C-keymap "B" 'show-subtree)
(define-key Ctl-C-keymap "b" 'hide-subtree)
(define-key Ctl-C-keymap "C" 'show-entry)
(define-key Ctl-C-keymap "c" 'hide-entry)

; Cursor movement within the outline tree
; =======================================
; C-c p previous header line
; C-c n next header line
; C-c f forward, same level
; C-c b backward, same level
; C-c u upward in the tree

(define-key Ctl-C-keymap "\C-p" 'outline-previous-visible-heading)
(define-key Ctl-C-keymap "\C-n" 'outline-next-visible-heading)
(define-key Ctl-C-keymap "\C-f" 'outline-forward-same-level)
(define-key Ctl-C-keymap "\C-g" 'outline-forward-same-level)
(define-key Ctl-C-keymap "\C-b" 'outline-backward-same-level)
(define-key Ctl-C-keymap "\C-u" 'outline-up-heading)

; my tabulator settings, every 4th character
; ==========================================
(setq-default tab-width 4)
(setq-default tab-stop-list 
         '(4 8 12 16 20 24 28 32 36 40 44
          48 52 56 60 64 68 72 76 ))

---------- snip ---------- snip ---------- snip ----------

-- 
Uni Wuppertal, FB Elektrotechnik, Tel/Fax: (0202) 439 - 3009
Dr. Andreas Wehler;  wehler2@welfa4.elektro.uni-wuppertal.de


--
This message was delayed because the list mail delivery agent was down.


Reply to: