diff options
| author | Stefan Monnier | 2000-09-29 03:36:26 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-29 03:36:26 +0000 |
| commit | d8c201f535dc3573b0c7b0baa11b1fdface9f8f4 (patch) | |
| tree | 12bf14f742e24c5213f18ff7a6750426e8f6d7d2 /lisp/textmodes | |
| parent | be5e3be3acf8bc9d9b55fb6f84b5c665b530f503 (diff) | |
| download | emacs-d8c201f535dc3573b0c7b0baa11b1fdface9f8f4.tar.gz emacs-d8c201f535dc3573b0c7b0baa11b1fdface9f8f4.zip | |
(outline-minor-mode): Use define-minor-mode.
(outline-mode): Use define-derived-mode.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/outline.el | 76 |
1 files changed, 19 insertions, 57 deletions
diff --git a/lisp/textmodes/outline.el b/lisp/textmodes/outline.el index 38a66239aa7..a42d2a1013d 100644 --- a/lisp/textmodes/outline.el +++ b/lisp/textmodes/outline.el | |||
| @@ -28,6 +28,10 @@ | |||
| 28 | ;; An outline can be `abstracted' to show headers at any given level, | 28 | ;; An outline can be `abstracted' to show headers at any given level, |
| 29 | ;; with all stuff below hidden. See the Emacs manual for details. | 29 | ;; with all stuff below hidden. See the Emacs manual for details. |
| 30 | 30 | ||
| 31 | ;;; Todo: | ||
| 32 | |||
| 33 | ;; - subtree-terminators | ||
| 34 | |||
| 31 | ;;; Code: | 35 | ;;; Code: |
| 32 | 36 | ||
| 33 | (defgroup outlines nil | 37 | (defgroup outlines nil |
| @@ -140,15 +144,6 @@ in the file it applies to." | |||
| 140 | (define-key outline-mode-map "\C-c" outline-mode-prefix-map) | 144 | (define-key outline-mode-map "\C-c" outline-mode-prefix-map) |
| 141 | (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map)) | 145 | (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map)) |
| 142 | 146 | ||
| 143 | (defcustom outline-minor-mode nil | ||
| 144 | "Non-nil if using Outline mode as a minor mode of some other mode." | ||
| 145 | :type 'boolean | ||
| 146 | :group 'outlines) | ||
| 147 | (make-variable-buffer-local 'outline-minor-mode) | ||
| 148 | (or (assq 'outline-minor-mode minor-mode-alist) | ||
| 149 | (setq minor-mode-alist (append minor-mode-alist | ||
| 150 | (list '(outline-minor-mode " Outl"))))) | ||
| 151 | |||
| 152 | (defvar outline-font-lock-keywords | 147 | (defvar outline-font-lock-keywords |
| 153 | '(;; | 148 | '(;; |
| 154 | ;; Highlight headings according to the level. | 149 | ;; Highlight headings according to the level. |
| @@ -181,7 +176,7 @@ in the file it applies to." | |||
| 181 | "Normal hook to be run after outline visibility changes.") | 176 | "Normal hook to be run after outline visibility changes.") |
| 182 | 177 | ||
| 183 | ;;;###autoload | 178 | ;;;###autoload |
| 184 | (defun outline-mode () | 179 | (define-derived-mode outline-mode text-mode "Outline" |
| 185 | "Set major mode for editing outlines with selective display. | 180 | "Set major mode for editing outlines with selective display. |
| 186 | Headings are lines which start with asterisks: one for major headings, | 181 | Headings are lines which start with asterisks: one for major headings, |
| 187 | two for subheadings, etc. Lines not starting with asterisks are body lines. | 182 | two for subheadings, etc. Lines not starting with asterisks are body lines. |
| @@ -220,34 +215,21 @@ beginning of the line. The longer the match, the deeper the level. | |||
| 220 | 215 | ||
| 221 | Turning on outline mode calls the value of `text-mode-hook' and then of | 216 | Turning on outline mode calls the value of `text-mode-hook' and then of |
| 222 | `outline-mode-hook', if they are non-nil." | 217 | `outline-mode-hook', if they are non-nil." |
| 223 | (interactive) | ||
| 224 | (kill-all-local-variables) | ||
| 225 | (use-local-map outline-mode-map) | ||
| 226 | (setq mode-name "Outline") | ||
| 227 | (setq major-mode 'outline-mode) | ||
| 228 | (define-abbrev-table 'text-mode-abbrev-table ()) | ||
| 229 | (setq local-abbrev-table text-mode-abbrev-table) | ||
| 230 | (set-syntax-table text-mode-syntax-table) | ||
| 231 | (make-local-variable 'line-move-ignore-invisible) | 218 | (make-local-variable 'line-move-ignore-invisible) |
| 232 | (setq line-move-ignore-invisible t) | 219 | (setq line-move-ignore-invisible t) |
| 233 | ;; Cause use of ellipses for invisible text. | 220 | ;; Cause use of ellipses for invisible text. |
| 234 | (add-to-invisibility-spec '(outline . t)) | 221 | (add-to-invisibility-spec '(outline . t)) |
| 235 | (make-local-variable 'paragraph-start) | 222 | (set (make-local-variable 'paragraph-start) |
| 236 | (setq paragraph-start (concat paragraph-start "\\|\\(" | 223 | (concat paragraph-start "\\|\\(" outline-regexp "\\)")) |
| 237 | outline-regexp "\\)")) | ||
| 238 | ;; Inhibit auto-filling of header lines. | 224 | ;; Inhibit auto-filling of header lines. |
| 239 | (make-local-variable 'auto-fill-inhibit-regexp) | 225 | (set (make-local-variable 'auto-fill-inhibit-regexp) outline-regexp) |
| 240 | (setq auto-fill-inhibit-regexp outline-regexp) | 226 | (set (make-local-variable 'paragraph-separate) |
| 241 | (make-local-variable 'paragraph-separate) | 227 | (concat paragraph-separate "\\|\\(" outline-regexp "\\)")) |
| 242 | (setq paragraph-separate (concat paragraph-separate "\\|\\(" | 228 | (set (make-local-variable 'font-lock-defaults) |
| 243 | outline-regexp "\\)")) | 229 | '(outline-font-lock-keywords t)) |
| 244 | (make-local-variable 'font-lock-defaults) | ||
| 245 | (setq font-lock-defaults '(outline-font-lock-keywords t)) | ||
| 246 | (make-local-variable 'change-major-mode-hook) | ||
| 247 | (setq imenu-generic-expression | 230 | (setq imenu-generic-expression |
| 248 | (list (list nil (concat outline-regexp ".*$") 0))) | 231 | (list (list nil (concat outline-regexp ".*$") 0))) |
| 249 | (add-hook 'change-major-mode-hook 'show-all) | 232 | (add-hook 'change-major-mode-hook 'show-all nil t)) |
| 250 | (run-hooks 'text-mode-hook 'outline-mode-hook)) | ||
| 251 | 233 | ||
| 252 | (defcustom outline-minor-mode-prefix "\C-c@" | 234 | (defcustom outline-minor-mode-prefix "\C-c@" |
| 253 | "*Prefix key to use for Outline commands in Outline minor mode. | 235 | "*Prefix key to use for Outline commands in Outline minor mode. |
| @@ -256,48 +238,28 @@ After that, changing the prefix key requires manipulating keymaps." | |||
| 256 | :type 'string | 238 | :type 'string |
| 257 | :group 'outlines) | 239 | :group 'outlines) |
| 258 | 240 | ||
| 259 | (defvar outline-minor-mode-map nil) | ||
| 260 | (if outline-minor-mode-map | ||
| 261 | nil | ||
| 262 | (setq outline-minor-mode-map (make-sparse-keymap)) | ||
| 263 | (define-key outline-minor-mode-map [menu-bar] | ||
| 264 | outline-mode-menu-bar-map) | ||
| 265 | (define-key outline-minor-mode-map outline-minor-mode-prefix | ||
| 266 | outline-mode-prefix-map)) | ||
| 267 | |||
| 268 | (or (assq 'outline-minor-mode minor-mode-map-alist) | ||
| 269 | (setq minor-mode-map-alist | ||
| 270 | (cons (cons 'outline-minor-mode outline-minor-mode-map) | ||
| 271 | minor-mode-map-alist))) | ||
| 272 | |||
| 273 | ;;;###autoload | 241 | ;;;###autoload |
| 274 | (defun outline-minor-mode (&optional arg) | 242 | (define-minor-mode outline-minor-mode |
| 275 | "Toggle Outline minor mode. | 243 | "Toggle Outline minor mode. |
| 276 | With arg, turn Outline minor mode on if arg is positive, off otherwise. | 244 | With arg, turn Outline minor mode on if arg is positive, off otherwise. |
| 277 | See the command `outline-mode' for more information on this mode." | 245 | See the command `outline-mode' for more information on this mode." |
| 278 | (interactive "P") | 246 | nil " Outl" (list (cons [menu-bar] outline-mode-menu-bar-map) |
| 279 | (setq outline-minor-mode | 247 | (cons outline-minor-mode-prefix outline-mode-prefix-map)) |
| 280 | (if (null arg) (not outline-minor-mode) | ||
| 281 | (> (prefix-numeric-value arg) 0))) | ||
| 282 | (if outline-minor-mode | 248 | (if outline-minor-mode |
| 283 | (progn | 249 | (progn |
| 284 | (make-local-hook 'change-major-mode-hook) | ||
| 285 | ;; Turn off this mode if we change major modes. | 250 | ;; Turn off this mode if we change major modes. |
| 286 | (add-hook 'change-major-mode-hook | 251 | (add-hook 'change-major-mode-hook |
| 287 | (lambda () (outline-minor-mode -1)) | 252 | (lambda () (outline-minor-mode -1)) |
| 288 | nil t) | 253 | nil t) |
| 289 | (make-local-variable 'line-move-ignore-invisible) | 254 | (set (make-local-variable 'line-move-ignore-invisible) t) |
| 290 | (setq line-move-ignore-invisible t) | ||
| 291 | ;; Cause use of ellipses for invisible text. | 255 | ;; Cause use of ellipses for invisible text. |
| 292 | (add-to-invisibility-spec '(outline . t)) | 256 | (add-to-invisibility-spec '(outline . t))) |
| 293 | (run-hooks 'outline-minor-mode-hook)) | ||
| 294 | (setq line-move-ignore-invisible nil) | 257 | (setq line-move-ignore-invisible nil) |
| 295 | ;; Cause use of ellipses for invisible text. | 258 | ;; Cause use of ellipses for invisible text. |
| 296 | (remove-from-invisibility-spec '(outline . t))) | 259 | (remove-from-invisibility-spec '(outline . t))) |
| 297 | ;; When turning off outline mode, get rid of any outline hiding. | 260 | ;; When turning off outline mode, get rid of any outline hiding. |
| 298 | (or outline-minor-mode | 261 | (or outline-minor-mode |
| 299 | (show-all)) | 262 | (show-all))) |
| 300 | (force-mode-line-update)) | ||
| 301 | 263 | ||
| 302 | (defcustom outline-level 'outline-level | 264 | (defcustom outline-level 'outline-level |
| 303 | "*Function of no args to compute a header's nesting level in an outline. | 265 | "*Function of no args to compute a header's nesting level in an outline. |