Hi List, [this is only relevant for Emacs users]
I recently discovered a trick how to enhance editing and navigation in large PicoLisp source files that need a lot of comments too, and I thought I might share it, just in case somebody isn't aware of this. I know this is a bit against the PicoLisp philosophy of purity and minimalism, it makes PicoLisp sources look a lot like Emacs Lisp sources, but sometimes I want a nested structure when a file gets big, and I might need more comments than the usual one-liner. The trick is to enable outline-minor-mode in the .l source file and locally redefine the outline-regexp so that it knows how to deal with the PicoLisp comment-style (#). For all sections of the source file I want to be nodes of the outline tree, I define headers like this: ,---------------- | * first level | ** second level | (de ...) | ** second level | *** third level | (de ...) `---------------- (Org-mode user will recognize the syntax) Then I mark the headlines and comment them out with ,---------------------------------------------------- | It is bound to M-;. | | (comment-dwim ARG) | | Call the comment command you want (Do What I Mean). `---------------------------------------------------- i.e. with M-x comment-region in this case, and end up with ,------------------- | ## * first level | ## ** second level | (de ...) | ## ** second level | ## *** third level | (de ...) `------------------- At the end of the .l file, I put ## Local Variables: ## coding: utf-8 ## mode: picolisp ## eval: (outline-minor-mode) ## eval: (rainbow-mode) ## ispell-local-dictionary: "en_US" ## outline-regexp: "^## [*]+ " ## End: so that the headings defined above are recognized by outline-minor-mode as nodes of the outline tree. Then, the nodes can be folded and unfolded, and its possible to navigate directly from header to header: ,------------------------------------------------- | Global Bindings Starting With M-o: | key binding | --- ------- | | M-o a show-all | M-o b outline-backward-same-level | M-o c hide-entry | M-o d hide-subtree | M-o e show-entry | M-o f outline-forward-same-level | M-o i show-children | M-o k show-branches | M-o l hide-leaves | M-o n outline-next-visible-heading | M-o o hide-other | M-o p outline-previous-visible-heading | M-o q hide-sublevels | M-o s show-subtree | M-o t hide-body | M-o u outline-up-heading `------------------------------------------------- C-h f outline- TAB shows even some more commands without keybindingsthat can be used via M-x outline-XXX: ,------------------------------------------------------------------- | org-display-outline-path outline-backward-same-level | outline-demote outline-forward-same-level | outline-headers-as-kill outline-insert-heading | outline-mark-subtree outline-minor-mode | outline-mode outline-move-subtree-down | outline-move-subtree-up outline-next-heading | outline-next-visible-heading outline-previous-heading | outline-previous-visible-heading outline-promote | outline-toggle-children outline-up-heading `------------------------------------------------------------------- I find this very convenient, maybe someone else finds it usefull too. PS to replace the unusable original keybindings of outline-minor-mode with the much better bindings shown above, I put the following in my .emacs: ,---------------------------------------------------------- | ;; Outline-minor-mode key map | (define-prefix-command 'cm-map nil "Outline-") | | ;; HIDE | ; Hide everything but the top-level headings | (define-key cm-map "q" 'hide-sublevels) | ; Hide everything but headings (all body lines) | (define-key cm-map "t" 'hide-body) | ; Hide other branches | (define-key cm-map "o" 'hide-other) | ; Hide this entry's body | (define-key cm-map "c" 'hide-entry) | ; Hide body lines in this entry and sub-entries | (define-key cm-map "l" 'hide-leaves) | ; Hide everything in this entry and sub-entries | (define-key cm-map "d" 'hide-subtree) | | ;; SHOW | ; Show (expand) everything | (define-key cm-map "a" 'show-all) | ; Show this heading's body | (define-key cm-map "e" 'show-entry) | ; Show this heading's immediate child sub-headings | (define-key cm-map "i" 'show-children) | ; Show all sub-headings under this heading | (define-key cm-map "k" 'show-branches) | ; Show (expand) everything in this heading & below | (define-key cm-map "s" 'show-subtree) | | ;; MOVE | ; Up | (define-key cm-map "u" 'outline-up-heading) | ; Next | (define-key cm-map "n" 'outline-next-visible-heading) | ; Previous | (define-key cm-map "p" 'outline-previous-visible-heading) | ; Forward - same level | (define-key cm-map "f" 'outline-forward-same-level) | ; Backward - same level | (define-key cm-map "b" 'outline-backward-same-level) | (global-set-key "\M-o" cm-map) `---------------------------------------------------------- -- cheers, Thorsten -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe