comparison lisp/textmodes/outline.el @ 17687:e6d5322b810c

Use defgroup and defcustom.
author Richard M. Stallman <rms@gnu.org>
date Wed, 07 May 1997 03:54:03 +0000
parents 2dfc334bdc6f
children b02bb31c98b0
comparison
equal deleted inserted replaced
17686:a2708b339766 17687:e6d5322b810c
1 ;;; outline.el --- outline mode commands for Emacs 1 ;;; outline.el --- outline mode commands for Emacs
2 2
3 ;; Copyright (C) 1986, 1993, 1994, 1995 Free Software Foundation, Inc. 3 ;; Copyright (C) 1986, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
4 4
5 ;; Maintainer: FSF 5 ;; Maintainer: FSF
6 ;; Keywords: outlines 6 ;; Keywords: outlines
7 7
8 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
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 ;;; Code: 31 ;;; Code:
32 32
33 ;; Jan '86, Some new features added by Peter Desnoyers and rewritten by RMS. 33 (defgroup outlines nil
34 34 "Support for hierarchical outlining"
35 (defvar outline-regexp nil 35 :prefix "outline-"
36 :group 'editing)
37
38 (defcustom outline-regexp nil
36 "*Regular expression to match the beginning of a heading. 39 "*Regular expression to match the beginning of a heading.
37 Any line whose beginning matches this regexp is considered to start a heading. 40 Any line whose beginning matches this regexp is considered to start a heading.
38 The recommended way to set this is with a Local Variables: list 41 The recommended way to set this is with a Local Variables: list
39 in the file it applies to. See also outline-heading-end-regexp.") 42 in the file it applies to. See also outline-heading-end-regexp."
43 :type '(choice regexp (const nil))
44 :group 'outlines)
40 45
41 ;; Can't initialize this in the defvar above -- some major modes have 46 ;; Can't initialize this in the defvar above -- some major modes have
42 ;; already assigned a local value to it. 47 ;; already assigned a local value to it.
43 (or (default-value 'outline-regexp) 48 (or (default-value 'outline-regexp)
44 (setq-default outline-regexp "[*\^L]+")) 49 (setq-default outline-regexp "[*\^L]+"))
45 50
46 (defvar outline-heading-end-regexp "\n" 51 (defcustom outline-heading-end-regexp "\n"
47 "*Regular expression to match the end of a heading line. 52 "*Regular expression to match the end of a heading line.
48 You can assume that point is at the beginning of a heading when this 53 You can assume that point is at the beginning of a heading when this
49 regexp is searched for. The heading ends at the end of the match. 54 regexp is searched for. The heading ends at the end of the match.
50 The recommended way to set this is with a `Local Variables:' list 55 The recommended way to set this is with a `Local Variables:' list
51 in the file it applies to.") 56 in the file it applies to."
57 :type 'regexp
58 :group 'outlines)
52 59
53 (defvar outline-mode-prefix-map nil) 60 (defvar outline-mode-prefix-map nil)
54 61
55 (if outline-mode-prefix-map 62 (if outline-mode-prefix-map
56 nil 63 nil
128 nil 135 nil
129 (setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map)) 136 (setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map))
130 (define-key outline-mode-map "\C-c" outline-mode-prefix-map) 137 (define-key outline-mode-map "\C-c" outline-mode-prefix-map)
131 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map)) 138 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map))
132 139
133 (defvar outline-minor-mode nil 140 (defcustom outline-minor-mode nil
134 "Non-nil if using Outline mode as a minor mode of some other mode.") 141 "Non-nil if using Outline mode as a minor mode of some other mode."
142 :type 'boolean
143 :group 'outlines)
135 (make-variable-buffer-local 'outline-minor-mode) 144 (make-variable-buffer-local 'outline-minor-mode)
136 (or (assq 'outline-minor-mode minor-mode-alist) 145 (or (assq 'outline-minor-mode minor-mode-alist)
137 (setq minor-mode-alist (append minor-mode-alist 146 (setq minor-mode-alist (append minor-mode-alist
138 (list '(outline-minor-mode " Outl"))))) 147 (list '(outline-minor-mode " Outl")))))
139 148
219 (setq font-lock-defaults '(outline-font-lock-keywords t)) 228 (setq font-lock-defaults '(outline-font-lock-keywords t))
220 (make-local-variable 'change-major-mode-hook) 229 (make-local-variable 'change-major-mode-hook)
221 (add-hook 'change-major-mode-hook 'show-all) 230 (add-hook 'change-major-mode-hook 'show-all)
222 (run-hooks 'text-mode-hook 'outline-mode-hook)) 231 (run-hooks 'text-mode-hook 'outline-mode-hook))
223 232
224 (defvar outline-minor-mode-prefix "\C-c@" 233 (defcustom outline-minor-mode-prefix "\C-c@"
225 "*Prefix key to use for Outline commands in Outline minor mode. 234 "*Prefix key to use for Outline commands in Outline minor mode.
226 The value of this variable is checked as part of loading Outline mode. 235 The value of this variable is checked as part of loading Outline mode.
227 After that, changing the prefix key requires manipulating keymaps.") 236 After that, changing the prefix key requires manipulating keymaps."
237 :type 'string
238 :group 'outlines)
228 239
229 (defvar outline-minor-mode-map nil) 240 (defvar outline-minor-mode-map nil)
230 (if outline-minor-mode-map 241 (if outline-minor-mode-map
231 nil 242 nil
232 (setq outline-minor-mode-map (make-sparse-keymap)) 243 (setq outline-minor-mode-map (make-sparse-keymap))
267 ;; When turning off outline mode, get rid of any outline hiding. 278 ;; When turning off outline mode, get rid of any outline hiding.
268 (or outline-minor-mode 279 (or outline-minor-mode
269 (show-all)) 280 (show-all))
270 (force-mode-line-update)) 281 (force-mode-line-update))
271 282
272 (defvar outline-level 'outline-level 283 (defcustom outline-level 'outline-level
273 "Function of no args to compute a header's nesting level in an outline. 284 "*Function of no args to compute a header's nesting level in an outline.
274 It can assume point is at the beginning of a header line.") 285 It can assume point is at the beginning of a header line."
286 :type 'function
287 :group outlines)
275 288
276 ;; This used to count columns rather than characters, but that made ^L 289 ;; This used to count columns rather than characters, but that made ^L
277 ;; appear to be at level 2 instead of 1. Columns would be better for 290 ;; appear to be at level 2 instead of 1. Columns would be better for
278 ;; tab handling, but the default regexp doesn't use tabs, and anyone 291 ;; tab handling, but the default regexp doesn't use tabs, and anyone
279 ;; who changes the regexp can also redefine the outline-level variable 292 ;; who changes the regexp can also redefine the outline-level variable