Mercurial > emacs
annotate lisp/textmodes/ooutline.el @ 13316:373701da47e5
Don't load c-mode.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 28 Oct 1995 16:20:36 +0000 |
parents | 290970a12db9 |
children | 187735b53d52 |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; outline.el --- outline mode commands for Emacs |
7298 | 2 ;; Copyright (C) 1986, 1993, 1994 Free Software Foundation, Inc. |
845 | 3 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
4 ;; Maintainer: FSF |
11455 | 5 ;; Keywords: outlines |
234 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
11 ;; the Free Software Foundation; either version 2, or (at your option) |
234 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
23 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
24 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
25 ;; This package is a major mode for editing outline-format documents. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
26 ;; An outline can be `abstracted' to show headers at any given level, |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
27 ;; with all stuff below hidden. See the Emacs manual for details. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
29 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
730
diff
changeset
|
30 |
234 | 31 ;; Jan '86, Some new features added by Peter Desnoyers and rewritten by RMS. |
32 | |
6274
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
33 (defvar outline-regexp nil |
234 | 34 "*Regular expression to match the beginning of a heading. |
35 Any line whose beginning matches this regexp is considered to start a heading. | |
36 The recommended way to set this is with a Local Variables: list | |
37 in the file it applies to. See also outline-heading-end-regexp.") | |
6274
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
38 |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
39 ;; Can't initialize this in the defvar above -- some major modes have |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
40 ;; already assigned a local value to it. |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
41 (or (default-value 'outline-regexp) |
ec7e22ebd6b3
(outline-regexp): Initialize outside the defvar.
Karl Heuer <kwzh@gnu.org>
parents:
6175
diff
changeset
|
42 (setq-default outline-regexp "[*\^L]+")) |
234 | 43 |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
44 (defvar outline-heading-end-regexp "[\n\^M]" |
234 | 45 "*Regular expression to match the end of a heading line. |
46 You can assume that point is at the beginning of a heading when this | |
47 regexp is searched for. The heading ends at the end of the match. | |
48 The recommended way to set this is with a \"Local Variables:\" list | |
49 in the file it applies to.") | |
50 | |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
51 (defvar outline-mode-prefix-map nil) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
52 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
53 (if outline-mode-prefix-map |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
54 nil |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
55 (setq outline-mode-prefix-map (make-sparse-keymap)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
56 (define-key outline-mode-prefix-map "\C-n" 'outline-next-visible-heading) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
57 (define-key outline-mode-prefix-map "\C-p" 'outline-previous-visible-heading) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
58 (define-key outline-mode-prefix-map "\C-i" 'show-children) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
59 (define-key outline-mode-prefix-map "\C-s" 'show-subtree) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
60 (define-key outline-mode-prefix-map "\C-d" 'hide-subtree) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
61 (define-key outline-mode-prefix-map "\C-u" 'outline-up-heading) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
62 (define-key outline-mode-prefix-map "\C-f" 'outline-forward-same-level) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
63 (define-key outline-mode-prefix-map "\C-b" 'outline-backward-same-level) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
64 (define-key outline-mode-prefix-map "\C-t" 'hide-body) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
65 (define-key outline-mode-prefix-map "\C-a" 'show-all) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
66 (define-key outline-mode-prefix-map "\C-c" 'hide-entry) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
67 (define-key outline-mode-prefix-map "\C-e" 'show-entry) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
68 (define-key outline-mode-prefix-map "\C-l" 'hide-leaves) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
69 (define-key outline-mode-prefix-map "\C-k" 'show-branches) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
70 (define-key outline-mode-prefix-map "\C-q" 'hide-sublevels) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
71 (define-key outline-mode-prefix-map "\C-o" 'hide-other)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
72 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
73 (defvar outline-mode-menu-bar-map nil) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
74 (if outline-mode-menu-bar-map |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
75 nil |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
76 (setq outline-mode-menu-bar-map (make-sparse-keymap)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
77 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
78 (define-key outline-mode-menu-bar-map [hide] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
79 (cons "Hide" (make-sparse-keymap "Hide"))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
80 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
81 (define-key outline-mode-menu-bar-map [hide hide-other] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
82 '("Hide Other" . hide-other)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
83 (define-key outline-mode-menu-bar-map [hide hide-sublevels] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
84 '("Hide Sublevels" . hide-sublevels)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
85 (define-key outline-mode-menu-bar-map [hide hide-subtree] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
86 '("Hide Subtree" . hide-subtree)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
87 (define-key outline-mode-menu-bar-map [hide hide-entry] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
88 '("Hide Entry" . hide-entry)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
89 (define-key outline-mode-menu-bar-map [hide hide-body] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
90 '("Hide Body" . hide-body)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
91 (define-key outline-mode-menu-bar-map [hide hide-leaves] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
92 '("Hide Leaves" . hide-leaves)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
93 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
94 (define-key outline-mode-menu-bar-map [show] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
95 (cons "Show" (make-sparse-keymap "Show"))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
96 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
97 (define-key outline-mode-menu-bar-map [show show-subtree] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
98 '("Show Subtree" . show-subtree)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
99 (define-key outline-mode-menu-bar-map [show show-children] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
100 '("Show Children" . show-children)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
101 (define-key outline-mode-menu-bar-map [show show-branches] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
102 '("Show Branches" . show-branches)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
103 (define-key outline-mode-menu-bar-map [show show-entry] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
104 '("Show Entry" . show-entry)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
105 (define-key outline-mode-menu-bar-map [show show-all] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
106 '("Show All" . show-all)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
107 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
108 (define-key outline-mode-menu-bar-map [headings] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
109 (cons "Headings" (make-sparse-keymap "Headings"))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
110 |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
111 (define-key outline-mode-menu-bar-map [headings outline-backward-same-level] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
112 '("Previous Same Level" . outline-backward-same-level)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
113 (define-key outline-mode-menu-bar-map [headings outline-forward-same-level] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
114 '("Next Same Level" . outline-forward-same-level)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
115 (define-key outline-mode-menu-bar-map [headings outline-previous-visible-heading] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
116 '("Previous" . outline-previous-visible-heading)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
117 (define-key outline-mode-menu-bar-map [headings outline-next-visible-heading] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
118 '("Next" . outline-next-visible-heading)) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
119 (define-key outline-mode-menu-bar-map [headings outline-up-heading] |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
120 '("Up" . outline-up-heading))) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
121 |
234 | 122 (defvar outline-mode-map nil "") |
123 | |
124 (if outline-mode-map | |
125 nil | |
126 (setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map)) | |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
127 (define-key outline-mode-map "\C-c" outline-mode-prefix-map) |
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
128 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map)) |
234 | 129 |
130 (defvar outline-minor-mode nil | |
131 "Non-nil if using Outline mode as a minor mode of some other mode.") | |
2934
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
132 (make-variable-buffer-local 'outline-minor-mode) |
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
133 (put 'outline-minor-mode 'permanent-local t) |
5693
e54c2697692b
(minor-mode-alist): Don't add "Outl" if already added.
Richard M. Stallman <rms@gnu.org>
parents:
5306
diff
changeset
|
134 (or (assq 'outline-minor-mode minor-mode-alist) |
e54c2697692b
(minor-mode-alist): Don't add "Outl" if already added.
Richard M. Stallman <rms@gnu.org>
parents:
5306
diff
changeset
|
135 (setq minor-mode-alist (append minor-mode-alist |
e54c2697692b
(minor-mode-alist): Don't add "Outl" if already added.
Richard M. Stallman <rms@gnu.org>
parents:
5306
diff
changeset
|
136 (list '(outline-minor-mode " Outl"))))) |
234 | 137 |
9378
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
138 (defvar outline-font-lock-keywords |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
139 '(;; Highlight headings according to the level. |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
140 ("^\\(\\*+\\)[ \t]*\\(.+\\)?[ \t]*$" |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
141 (1 font-lock-string-face) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
142 (2 (let ((len (- (match-end 1) (match-beginning 1)))) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
143 (or (cdr (assq len '((1 . font-lock-function-name-face) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
144 (2 . font-lock-keyword-face) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
145 (3 . font-lock-comment-face)))) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
146 font-lock-variable-name-face)) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
147 nil t)) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
148 ;; Highight citations of the form [1] and [Mar94]. |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
149 ("\\[\\([A-Z][A-Za-z]+\\)*[0-9]+\\]" . font-lock-type-face)) |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
150 "Additional expressions to highlight in Outline mode.") |
1c9b8b3971a0
(outline-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8688
diff
changeset
|
151 |
258 | 152 ;;;###autoload |
234 | 153 (defun outline-mode () |
154 "Set major mode for editing outlines with selective display. | |
155 Headings are lines which start with asterisks: one for major headings, | |
156 two for subheadings, etc. Lines not starting with asterisks are body lines. | |
157 | |
158 Body text or subheadings under a heading can be made temporarily | |
159 invisible, or visible again. Invisible lines are attached to the end | |
160 of the heading, so they move with it, if the line is killed and yanked | |
161 back. A heading with text hidden under it is marked with an ellipsis (...). | |
162 | |
163 Commands:\\<outline-mode-map> | |
164 \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings | |
165 \\[outline-previous-visible-heading] outline-previous-visible-heading | |
166 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings | |
167 \\[outline-backward-same-level] outline-backward-same-level | |
168 \\[outline-up-heading] outline-up-heading move from subheading to heading | |
169 | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
170 \\[hide-body] make all text invisible (not headings). |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
171 \\[show-all] make everything in buffer visible. |
234 | 172 |
173 The remaining commands are used when point is on a heading line. | |
174 They apply to some of the body or subheadings of that heading. | |
175 \\[hide-subtree] hide-subtree make body and subheadings invisible. | |
176 \\[show-subtree] show-subtree make body and subheadings visible. | |
177 \\[show-children] show-children make direct subheadings visible. | |
178 No effect on body, or subheadings 2 or more levels down. | |
179 With arg N, affects subheadings N levels down. | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
180 \\[hide-entry] make immediately following body invisible. |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
181 \\[show-entry] make it visible. |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
182 \\[hide-leaves] make body under heading and under its subheadings invisible. |
234 | 183 The subheadings remain visible. |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
184 \\[show-branches] make all subheadings at all levels visible. |
234 | 185 |
186 The variable `outline-regexp' can be changed to control what is a heading. | |
187 A line is a heading if `outline-regexp' matches something at the | |
188 beginning of the line. The longer the match, the deeper the level. | |
189 | |
190 Turning on outline mode calls the value of `text-mode-hook' and then of | |
191 `outline-mode-hook', if they are non-nil." | |
192 (interactive) | |
193 (kill-all-local-variables) | |
194 (setq selective-display t) | |
195 (use-local-map outline-mode-map) | |
196 (setq mode-name "Outline") | |
197 (setq major-mode 'outline-mode) | |
198 (define-abbrev-table 'text-mode-abbrev-table ()) | |
199 (setq local-abbrev-table text-mode-abbrev-table) | |
200 (set-syntax-table text-mode-syntax-table) | |
201 (make-local-variable 'paragraph-start) | |
10888
388da827814c
(outline-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9478
diff
changeset
|
202 (setq paragraph-start (concat paragraph-start "\\|\\(" |
234 | 203 outline-regexp "\\)")) |
204 ;; Inhibit auto-filling of header lines. | |
205 (make-local-variable 'auto-fill-inhibit-regexp) | |
206 (setq auto-fill-inhibit-regexp outline-regexp) | |
207 (make-local-variable 'paragraph-separate) | |
10888
388da827814c
(outline-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9478
diff
changeset
|
208 (setq paragraph-separate (concat paragraph-separate "\\|\\(" |
234 | 209 outline-regexp "\\)")) |
9478
a8077b802b9e
* outline.el: (outline-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9378
diff
changeset
|
210 (make-local-variable 'font-lock-defaults) |
a8077b802b9e
* outline.el: (outline-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9378
diff
changeset
|
211 (setq font-lock-defaults '(outline-font-lock-keywords t)) |
7919
5823cf320f61
(outline-mode): Make change-major-mode-hook buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
7467
diff
changeset
|
212 (make-local-variable 'change-major-mode-hook) |
5876
82e1a78ab625
(outline-mode): Fix spelling of add-hook.
Karl Heuer <kwzh@gnu.org>
parents:
5855
diff
changeset
|
213 (add-hook 'change-major-mode-hook 'show-all) |
234 | 214 (run-hooks 'text-mode-hook 'outline-mode-hook)) |
215 | |
11647
290970a12db9
(outline-minor-mode-prefix): Change to C-c @.
Richard M. Stallman <rms@gnu.org>
parents:
11575
diff
changeset
|
216 (defvar outline-minor-mode-prefix "\C-c@" |
8688
1aba2fd3fd13
(outline-minor-mode-prefix): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8643
diff
changeset
|
217 "*Prefix key to use for Outline commands in Outline minor mode. |
1aba2fd3fd13
(outline-minor-mode-prefix): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8643
diff
changeset
|
218 The value of this variable is checked as part of loading Outline mode. |
1aba2fd3fd13
(outline-minor-mode-prefix): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8643
diff
changeset
|
219 After that, changing the prefix key requires manipulating keymaps.") |
4622
a55b9c08e4af
(outline-minor-mode-prefix): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4187
diff
changeset
|
220 |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
221 (defvar outline-minor-mode-map nil) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
222 (if outline-minor-mode-map |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
223 nil |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
224 (setq outline-minor-mode-map (make-sparse-keymap)) |
3987
4eada6c0b8d4
(outline-mode-map): Add menu bar items.
Richard M. Stallman <rms@gnu.org>
parents:
3531
diff
changeset
|
225 (define-key outline-minor-mode-map [menu-bar] |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
226 outline-mode-menu-bar-map) |
4622
a55b9c08e4af
(outline-minor-mode-prefix): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4187
diff
changeset
|
227 (define-key outline-minor-mode-map outline-minor-mode-prefix |
8643
e98aa03e22c5
(outline-mode-prefix-map): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8153
diff
changeset
|
228 outline-mode-prefix-map)) |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
229 |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
230 (or (assq 'outline-minor-mode minor-mode-map-alist) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
231 (setq minor-mode-map-alist |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
232 (cons (cons 'outline-minor-mode outline-minor-mode-map) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
233 minor-mode-map-alist))) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
234 |
3531
0732700eb6c0
(outline-minor-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
3376
diff
changeset
|
235 ;;;###autoload |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
236 (defun outline-minor-mode (&optional arg) |
2934
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
237 "Toggle Outline minor mode. |
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
238 With arg, turn Outline minor mode on if arg is positive, off otherwise. |
7c4226d1ea65
(outline-minor-mode): Make var permanent local in all buffers.
Richard M. Stallman <rms@gnu.org>
parents:
2900
diff
changeset
|
239 See the command `outline-mode' for more information on this mode." |
234 | 240 (interactive "P") |
241 (setq outline-minor-mode | |
242 (if (null arg) (not outline-minor-mode) | |
243 (> (prefix-numeric-value arg) 0))) | |
244 (if outline-minor-mode | |
245 (progn | |
246 (setq selective-display t) | |
247 (run-hooks 'outline-minor-mode-hook)) | |
4763
a57b0b715c04
(outline-minor-mode): Force update of modeline when outline-minor-mode
Brian Fox <bfox@gnu.org>
parents:
4623
diff
changeset
|
248 (setq selective-display nil)) |
5306
a2f8f9c4e29b
(outline-minor-mode): When turning off the mode, turn ^Ms back to \n's.
Richard M. Stallman <rms@gnu.org>
parents:
4763
diff
changeset
|
249 ;; When turning off outline mode, get rid of any ^M's. |
a2f8f9c4e29b
(outline-minor-mode): When turning off the mode, turn ^Ms back to \n's.
Richard M. Stallman <rms@gnu.org>
parents:
4763
diff
changeset
|
250 (or outline-minor-mode |
a2f8f9c4e29b
(outline-minor-mode): When turning off the mode, turn ^Ms back to \n's.
Richard M. Stallman <rms@gnu.org>
parents:
4763
diff
changeset
|
251 (outline-flag-region (point-min) (point-max) ?\n)) |
11575
090333911dc8
(outline-minor-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11455
diff
changeset
|
252 (force-mode-line-update)) |
234 | 253 |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
254 (defvar outline-level 'outline-level |
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
255 "Function of no args to compute a header's nesting level in an outline. |
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
256 It can assume point is at the beginning of a header line.") |
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
257 |
6299
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
258 ;; This used to count columns rather than characters, but that made ^L |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
259 ;; appear to be at level 2 instead of 1. Columns would be better for |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
260 ;; tab handling, but the default regexp doesn't use tabs, and anyone |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
261 ;; who changes the regexp can also redefine the outline-level variable |
d0a9fa0d0a8d
Add a comment to document the reason for the change in outline-level.
Karl Heuer <kwzh@gnu.org>
parents:
6298
diff
changeset
|
262 ;; as appropriate. |
234 | 263 (defun outline-level () |
264 "Return the depth to which a statement is nested in the outline. | |
265 Point must be at the beginning of a header line. This is actually | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
266 the number of characters that `outline-regexp' matches." |
234 | 267 (save-excursion |
268 (looking-at outline-regexp) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
269 (- (match-end 0) (match-beginning 0)))) |
234 | 270 |
271 (defun outline-next-preface () | |
8153
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
272 "Skip forward to just before the next heading line. |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
273 If there's no following heading line, stop before the newline |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
274 at the end of the buffer." |
234 | 275 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)") |
276 nil 'move) | |
8153
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
277 (goto-char (match-beginning 0))) |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
278 (if (memq (preceding-char) '(?\n ?\^M)) |
d21f64e53295
(outline-next-preface): Undo previous change: do stop before final newline.
Richard M. Stallman <rms@gnu.org>
parents:
7919
diff
changeset
|
279 (forward-char -1))) |
234 | 280 |
281 (defun outline-next-heading () | |
282 "Move to the next (possibly invisible) heading line." | |
283 (interactive) | |
284 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)") | |
285 nil 'move) | |
286 (goto-char (1+ (match-beginning 0))))) | |
287 | |
288 (defun outline-back-to-heading () | |
6175
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
289 "Move to previous heading line, or beg of this line if it's a heading. |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
290 Only visible heading lines are considered." |
234 | 291 (beginning-of-line) |
292 (or (outline-on-heading-p) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
293 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil t) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
294 (error "before first heading"))) |
234 | 295 |
296 (defun outline-on-heading-p () | |
7269 | 297 "Return t if point is on a (visible) heading line." |
234 | 298 (save-excursion |
299 (beginning-of-line) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
300 (and (bolp) |
234 | 301 (looking-at outline-regexp)))) |
302 | |
303 (defun outline-end-of-heading () | |
304 (if (re-search-forward outline-heading-end-regexp nil 'move) | |
305 (forward-char -1))) | |
306 | |
307 (defun outline-next-visible-heading (arg) | |
308 "Move to the next visible heading line. | |
309 With argument, repeats or can move backward if negative. | |
310 A heading line is one that starts with a `*' (or that | |
311 `outline-regexp' matches)." | |
312 (interactive "p") | |
313 (if (< arg 0) | |
314 (beginning-of-line) | |
315 (end-of-line)) | |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
316 (or (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t arg) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
317 (error "")) |
234 | 318 (beginning-of-line)) |
319 | |
320 (defun outline-previous-visible-heading (arg) | |
321 "Move to the previous heading line. | |
322 With argument, repeats or can move forward if negative. | |
323 A heading line is one that starts with a `*' (or that | |
324 `outline-regexp' matches)." | |
325 (interactive "p") | |
326 (outline-next-visible-heading (- arg))) | |
327 | |
328 (defun outline-flag-region (from to flag) | |
329 "Hides or shows lines from FROM to TO, according to FLAG. | |
330 If FLAG is `\\n' (newline character) then text is shown, | |
331 while if FLAG is `\\^M' (control-M) the text is hidden." | |
3376
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
332 (let (buffer-read-only) |
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
333 (subst-char-in-region from to |
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
334 (if (= flag ?\n) ?\^M ?\n) |
898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
Richard M. Stallman <rms@gnu.org>
parents:
2934
diff
changeset
|
335 flag t))) |
234 | 336 |
337 (defun hide-entry () | |
338 "Hide the body directly following this heading." | |
339 (interactive) | |
340 (outline-back-to-heading) | |
341 (outline-end-of-heading) | |
342 (save-excursion | |
343 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\^M))) | |
344 | |
345 (defun show-entry () | |
346 "Show the body directly following this heading." | |
347 (interactive) | |
348 (save-excursion | |
349 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\n))) | |
350 | |
351 (defun hide-body () | |
352 "Hide all of buffer except headings." | |
353 (interactive) | |
354 (hide-region-body (point-min) (point-max))) | |
355 | |
356 (defun hide-region-body (start end) | |
357 "Hide all body lines in the region, but not headings." | |
358 (save-excursion | |
359 (save-restriction | |
360 (narrow-to-region start end) | |
361 (goto-char (point-min)) | |
362 (if (outline-on-heading-p) | |
363 (outline-end-of-heading)) | |
364 (while (not (eobp)) | |
365 (outline-flag-region (point) | |
366 (progn (outline-next-preface) (point)) ?\^M) | |
367 (if (not (eobp)) | |
368 (progn | |
369 (forward-char | |
370 (if (looking-at "[\n\^M][\n\^M]") | |
371 2 1)) | |
372 (outline-end-of-heading))))))) | |
373 | |
374 (defun show-all () | |
375 "Show all of the text in the buffer." | |
376 (interactive) | |
377 (outline-flag-region (point-min) (point-max) ?\n)) | |
378 | |
379 (defun hide-subtree () | |
380 "Hide everything after this heading at deeper levels." | |
381 (interactive) | |
382 (outline-flag-subtree ?\^M)) | |
383 | |
384 (defun hide-leaves () | |
385 "Hide all body after this heading at deeper levels." | |
386 (interactive) | |
387 (outline-back-to-heading) | |
388 (outline-end-of-heading) | |
389 (hide-region-body (point) (progn (outline-end-of-subtree) (point)))) | |
390 | |
391 (defun show-subtree () | |
392 "Show everything after this heading at deeper levels." | |
393 (interactive) | |
394 (outline-flag-subtree ?\n)) | |
395 | |
6320
799e5e721233
(hide-other, hide-sublevels): Renamed from outline-...
Richard M. Stallman <rms@gnu.org>
parents:
6299
diff
changeset
|
396 (defun hide-sublevels (levels) |
7269 | 397 "Hide everything but the top LEVELS levels of headers, in whole buffer." |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
398 (interactive "p") |
6080
2f02deab5b9e
(hide-sublevels): Doc fix. Rename arg.
Richard M. Stallman <rms@gnu.org>
parents:
6077
diff
changeset
|
399 (if (< levels 1) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
400 (error "Must keep at least one level of headers")) |
6080
2f02deab5b9e
(hide-sublevels): Doc fix. Rename arg.
Richard M. Stallman <rms@gnu.org>
parents:
6077
diff
changeset
|
401 (setq levels (1- levels)) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
402 (save-excursion |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
403 (goto-char (point-min)) |
7312
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
404 ;; Keep advancing to the next top-level heading. |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
405 (while (or (and (bobp) (outline-on-heading-p)) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
406 (outline-next-heading)) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
407 (let ((end (save-excursion (outline-end-of-subtree) (point)))) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
408 ;; Hide everything under that. |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
409 (outline-flag-region (point) end ?\^M) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
410 ;; Show the first LEVELS levels under that. |
7316
00e2b88a5a8b
(hide-sublevels): Typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
7312
diff
changeset
|
411 (if (> levels 0) |
7312
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
412 (show-children levels)) |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
413 ;; Move to the next, since we already found it. |
102e78c0fb9a
(hide-sublevels): No need for condition-case.
Richard M. Stallman <rms@gnu.org>
parents:
7298
diff
changeset
|
414 (goto-char end))))) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
415 |
6320
799e5e721233
(hide-other, hide-sublevels): Renamed from outline-...
Richard M. Stallman <rms@gnu.org>
parents:
6299
diff
changeset
|
416 (defun hide-other () |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
417 "Hide everything except for the current body and the parent headings." |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
418 (interactive) |
6320
799e5e721233
(hide-other, hide-sublevels): Renamed from outline-...
Richard M. Stallman <rms@gnu.org>
parents:
6299
diff
changeset
|
419 (hide-sublevels 1) |
6077
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
420 (let ((last (point)) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
421 (pos (point))) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
422 (while (save-excursion |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
423 (and (re-search-backward "[\n\r]" nil t) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
424 (eq (following-char) ?\r))) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
425 (save-excursion |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
426 (beginning-of-line) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
427 (if (eq last (point)) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
428 (progn |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
429 (outline-next-heading) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
430 (outline-flag-region last (point) ?\n)) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
431 (show-children) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
432 (setq last (point))))))) |
7c17887a0daf
(outline-minor-mode-prefix): Change to C-c C-o.
Richard M. Stallman <rms@gnu.org>
parents:
5876
diff
changeset
|
433 |
234 | 434 (defun outline-flag-subtree (flag) |
435 (save-excursion | |
436 (outline-back-to-heading) | |
437 (outline-end-of-heading) | |
438 (outline-flag-region (point) | |
439 (progn (outline-end-of-subtree) (point)) | |
440 flag))) | |
441 | |
442 (defun outline-end-of-subtree () | |
443 (outline-back-to-heading) | |
444 (let ((opoint (point)) | |
445 (first t) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
446 (level (funcall outline-level))) |
234 | 447 (while (and (not (eobp)) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
448 (or first (> (funcall outline-level) level))) |
234 | 449 (setq first nil) |
450 (outline-next-heading)) | |
6953
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
451 (if (memq (preceding-char) '(?\n ?\^M)) |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
452 (progn |
6965 | 453 ;; Go to end of line before heading |
6953
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
454 (forward-char -1) |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
455 (if (memq (preceding-char) '(?\n ?\^M)) |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
456 ;; leave blank line before heading |
cd88b5f54ae3
(outline-end-of-subtree): Stop before final newline.
Karl Heuer <kwzh@gnu.org>
parents:
6320
diff
changeset
|
457 (forward-char -1)))))) |
234 | 458 |
459 (defun show-branches () | |
460 "Show all subheadings of this heading, but not their bodies." | |
461 (interactive) | |
462 (show-children 1000)) | |
463 | |
464 (defun show-children (&optional level) | |
465 "Show all direct subheadings of this heading. | |
466 Prefix arg LEVEL is how many levels below the current level should be shown. | |
467 Default is enough to cause the following heading to appear." | |
468 (interactive "P") | |
469 (setq level | |
470 (if level (prefix-numeric-value level) | |
471 (save-excursion | |
6175
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
472 (outline-back-to-heading) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
473 (let ((start-level (funcall outline-level))) |
234 | 474 (outline-next-heading) |
5711
6f772d7f1289
(show-children): Don't call outline-level at eob.
Richard M. Stallman <rms@gnu.org>
parents:
5693
diff
changeset
|
475 (if (eobp) |
6f772d7f1289
(show-children): Don't call outline-level at eob.
Richard M. Stallman <rms@gnu.org>
parents:
5693
diff
changeset
|
476 1 |
6f772d7f1289
(show-children): Don't call outline-level at eob.
Richard M. Stallman <rms@gnu.org>
parents:
5693
diff
changeset
|
477 (max 1 (- (funcall outline-level) start-level))))))) |
234 | 478 (save-excursion |
6175
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
479 (save-restriction |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
480 (outline-back-to-heading) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
481 (setq level (+ level (funcall outline-level))) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
482 (narrow-to-region (point) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
483 (progn (outline-end-of-subtree) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
484 (if (eobp) (point-max) (1+ (point))))) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
485 (goto-char (point-min)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
486 (while (and (not (eobp)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
487 (progn |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
488 (outline-next-heading) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
489 (not (eobp)))) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
490 (if (<= (funcall outline-level) level) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
491 (save-excursion |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
492 (outline-flag-region (save-excursion |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
493 (forward-char -1) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
494 (if (memq (preceding-char) '(?\n ?\^M)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
495 (forward-char -1)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
496 (point)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
497 (progn (outline-end-of-heading) (point)) |
340f5eb2e8b6
(outline-on-heading-p): Use bolp.
Richard M. Stallman <rms@gnu.org>
parents:
6080
diff
changeset
|
498 ?\n))))))) |
234 | 499 |
500 (defun outline-up-heading (arg) | |
501 "Move to the heading line of which the present line is a subheading. | |
502 With argument, move up ARG levels." | |
503 (interactive "p") | |
504 (outline-back-to-heading) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
505 (if (eq (funcall outline-level) 1) |
234 | 506 (error "")) |
6298
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
507 (while (and (> (funcall outline-level) 1) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
508 (> arg 0) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
509 (not (bobp))) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
510 (let ((present-level (funcall outline-level))) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
511 (while (not (< (funcall outline-level) present-level)) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
512 (outline-previous-visible-heading 1)) |
4f65581e0972
(outline-mode, outline-level): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
6274
diff
changeset
|
513 (setq arg (- arg 1))))) |
234 | 514 |
515 (defun outline-forward-same-level (arg) | |
7269 | 516 "Move forward to the ARG'th subheading at same level as this one. |
517 Stop at the first and last subheadings of a superior heading." | |
234 | 518 (interactive "p") |
519 (outline-back-to-heading) | |
520 (while (> arg 0) | |
521 (let ((point-to-move-to (save-excursion | |
522 (outline-get-next-sibling)))) | |
523 (if point-to-move-to | |
524 (progn | |
525 (goto-char point-to-move-to) | |
526 (setq arg (1- arg))) | |
527 (progn | |
528 (setq arg 0) | |
529 (error "")))))) | |
530 | |
531 (defun outline-get-next-sibling () | |
7269 | 532 "Move to next heading of the same level, and return point or nil if none." |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
533 (let ((level (funcall outline-level))) |
234 | 534 (outline-next-visible-heading 1) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
535 (while (and (> (funcall outline-level) level) |
234 | 536 (not (eobp))) |
537 (outline-next-visible-heading 1)) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
538 (if (< (funcall outline-level) level) |
234 | 539 nil |
540 (point)))) | |
541 | |
542 (defun outline-backward-same-level (arg) | |
7269 | 543 "Move backward to the ARG'th subheading at same level as this one. |
544 Stop at the first and last subheadings of a superior heading." | |
234 | 545 (interactive "p") |
546 (outline-back-to-heading) | |
547 (while (> arg 0) | |
548 (let ((point-to-move-to (save-excursion | |
549 (outline-get-last-sibling)))) | |
550 (if point-to-move-to | |
551 (progn | |
552 (goto-char point-to-move-to) | |
553 (setq arg (1- arg))) | |
554 (progn | |
555 (setq arg 0) | |
556 (error "")))))) | |
557 | |
558 (defun outline-get-last-sibling () | |
7269 | 559 "Move to next heading of the same level, and return point or nil if none." |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
560 (let ((level (funcall outline-level))) |
234 | 561 (outline-previous-visible-heading 1) |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
562 (while (and (> (funcall outline-level) level) |
234 | 563 (not (bobp))) |
564 (outline-previous-visible-heading 1)) | |
4623
3c1c4e9a4464
(outline-level): New var. Everything funcalls this
Richard M. Stallman <rms@gnu.org>
parents:
4622
diff
changeset
|
565 (if (< (funcall outline-level) level) |
234 | 566 nil |
567 (point)))) | |
568 | |
2900
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
569 (provide 'outline) |
443ebd8f59d2
(outline-heading-end-regexp): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
570 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
571 ;;; outline.el ends here |