chiark / gitweb /
emacs, dot-emacs: Hacking outline mode.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 9 May 2008 22:49:12 +0000 (23:49 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 9 May 2008 22:49:12 +0000 (23:49 +0100)
  * C-c ... C-r (`reveal-mode') turns on or off reveal-mode.

  * C-c ... C-- (`mdw-outline-collapse-all') collapses the entire
    buffer.  C mode in particular doesn't collapse comments unless
    beaten over the head rather vigorously.  This command does the
    beating.

dot-emacs.el
emacs

index 7e44b6fad4cd03ac2074a778ce1dd4d2ca87fcdf..88bfcab8b501f4633f7c3dbdc4e7694e2bb29bc4 100644 (file)
@@ -562,6 +562,7 @@ (defun mdw-misc-mode-config ()
   (auto-fill-mode 1)
   (setq fill-column 77)
   (setq show-trailing-whitespace t)
+  (outline-minor-mode t)
   (mdw-set-font))
 
 ;; --- Set up all sorts of faces ---
@@ -1978,6 +1979,17 @@ (defun mdw-text-mode ()
    "\\([ \t]*\\([>#|:] ?\\)*[ \t]*\\)" 3)
   (auto-fill-mode 1))
 
+;;;----- Outline mode -------------------------------------------------------
+
+(defun mdw-outline-collapse-all ()
+  "Completely collapse everything in the entire buffer."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (while (< (point) (point-max))
+      (hide-subtree)
+      (forward-line))))
+
 ;;;----- Shell mode ---------------------------------------------------------
 
 (defun mdw-sh-mode-setup ()
diff --git a/emacs b/emacs
index d1fb1412e6b13ecb4fbc056aa9be9f8fc0586339..5980490f515eee586d3d3921c46778060c5b6688 100644 (file)
--- a/emacs
+++ b/emacs
 
 (defvar mdw-black-background t)
 
-(eval-after-load "outline" '(require 'foldout))
+(eval-after-load "outline"
+  '(progn
+     (trap (require 'foldout))
+     (define-key outline-mode-prefix-map [?\C-r] 'reveal-mode)
+     (define-key outline-mode-prefix-map [?\C--] 'mdw-outline-collapse-all)))
 
 (setq cltl2-root-url (mdw-config 'cltl-url))
 (setq common-lisp-hyperspec-root (mdw-config 'hyperspec-url))