annotate lisp/modes/outline.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents ac2d302a0011
children 56c54cf7c5b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; outline.el --- outline mode commands for Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1986, 1993, 1994 Free Software Foundation, Inc.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
5 ;; Maintainer: FSF
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: outlines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
25 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This package is a major mode for editing outline-format documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; An outline can be `abstracted' to show headers at any given level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; with all stuff below hidden. See the Emacs manual for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Jan '86, Some new features added by Peter Desnoyers and rewritten by RMS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar outline-regexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "*Regular expression to match the beginning of a heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Any line whose beginning matches this regexp is considered to start a heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 The recommended way to set this is with a Local Variables: list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 in the file it applies to. See also outline-heading-end-regexp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Can't initialize this in the defvar above -- some major modes have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; already assigned a local value to it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (or (default-value 'outline-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq-default outline-regexp "[*\^L]+"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
48 ;; XEmacs change
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar outline-heading-end-regexp (purecopy "[\n\^M]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "*Regular expression to match the end of a heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 You can assume that point is at the beginning of a heading when this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 regexp is searched for. The heading ends at the end of the match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 The recommended way to set this is with a \"Local Variables:\" list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 in the file it applies to.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
56 ;; XEmacs: There is no point in doing this differently now. -sb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
57 (defvar outline-mode-prefix-map nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
58
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
59 (if outline-mode-prefix-map
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
60 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61 (setq outline-mode-prefix-map (make-sparse-keymap))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
62 (define-key outline-mode-prefix-map "\C-n" 'outline-next-visible-heading)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
63 (define-key outline-mode-prefix-map "\C-p" 'outline-previous-visible-heading)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
64 (define-key outline-mode-prefix-map "\C-i" 'show-children)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
65 (define-key outline-mode-prefix-map "\C-s" 'show-subtree)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
66 (define-key outline-mode-prefix-map "\C-d" 'hide-subtree)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
67 (define-key outline-mode-prefix-map "\C-u" 'outline-up-heading)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68 (define-key outline-mode-prefix-map "\C-f" 'outline-forward-same-level)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
69 (define-key outline-mode-prefix-map "\C-b" 'outline-backward-same-level)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
70 (define-key outline-mode-prefix-map "\C-t" 'hide-body)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
71 (define-key outline-mode-prefix-map "\C-a" 'show-all)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
72 (define-key outline-mode-prefix-map "\C-c" 'hide-entry)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
73 (define-key outline-mode-prefix-map "\C-e" 'show-entry)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 (define-key outline-mode-prefix-map "\C-l" 'hide-leaves)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
75 (define-key outline-mode-prefix-map "\C-k" 'show-branches)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 (define-key outline-mode-prefix-map "\C-q" 'hide-sublevels)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 (define-key outline-mode-prefix-map "\C-o" 'hide-other))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
78
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
79 (defvar outline-mode-menu-bar-map nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
80 (if outline-mode-menu-bar-map
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
81 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
82 (setq outline-mode-menu-bar-map (make-sparse-keymap))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
83
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
84 (define-key outline-mode-menu-bar-map [hide]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
85 (cons "Hide" (make-sparse-keymap "Hide")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
86
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
87 (define-key outline-mode-menu-bar-map [hide hide-other]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
88 '("Hide Other" . hide-other))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
89 (define-key outline-mode-menu-bar-map [hide hide-sublevels]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 '("Hide Sublevels" . hide-sublevels))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
91 (define-key outline-mode-menu-bar-map [hide hide-subtree]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 '("Hide Subtree" . hide-subtree))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 (define-key outline-mode-menu-bar-map [hide hide-entry]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94 '("Hide Entry" . hide-entry))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 (define-key outline-mode-menu-bar-map [hide hide-body]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 '("Hide Body" . hide-body))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 (define-key outline-mode-menu-bar-map [hide hide-leaves]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 '("Hide Leaves" . hide-leaves))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
99
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100 (define-key outline-mode-menu-bar-map [show]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
101 (cons "Show" (make-sparse-keymap "Show")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
103 (define-key outline-mode-menu-bar-map [show show-subtree]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
104 '("Show Subtree" . show-subtree))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
105 (define-key outline-mode-menu-bar-map [show show-children]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
106 '("Show Children" . show-children))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
107 (define-key outline-mode-menu-bar-map [show show-branches]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
108 '("Show Branches" . show-branches))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
109 (define-key outline-mode-menu-bar-map [show show-entry]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 '("Show Entry" . show-entry))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
111 (define-key outline-mode-menu-bar-map [show show-all]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
112 '("Show All" . show-all))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 (define-key outline-mode-menu-bar-map [headings]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
115 (cons "Headings" (make-sparse-keymap "Headings")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
116
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 (define-key outline-mode-menu-bar-map [headings outline-backward-same-level]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 '("Previous Same Level" . outline-backward-same-level))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 (define-key outline-mode-menu-bar-map [headings outline-forward-same-level]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 '("Next Same Level" . outline-forward-same-level))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 (define-key outline-mode-menu-bar-map [headings outline-previous-visible-heading]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 '("Previous" . outline-previous-visible-heading))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 (define-key outline-mode-menu-bar-map [headings outline-next-visible-heading]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 '("Next" . outline-next-visible-heading))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125 (define-key outline-mode-menu-bar-map [headings outline-up-heading]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 '("Up" . outline-up-heading)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defvar outline-mode-map nil "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if outline-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 ;; XEmacs change
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 ;(setq outline-mode-map (nconc (make-sparse-keymap) text-mode-map))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 (setq outline-mode-map (make-sparse-keymap 'text-mode-map))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 (define-key outline-mode-map "\C-c" outline-mode-prefix-map)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 (define-key outline-mode-map [menu-bar] outline-mode-menu-bar-map))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defvar outline-mode-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; This is the RB menu which also makes 3 menus in the menubar (like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; FSF rather than because it's good)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 '("Outline"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ("Headings"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ["Up" outline-up-heading t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ["Next" outline-next-visible-heading t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ["Previous" outline-previous-visible-heading t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ["Next Same Level" outline-forward-same-level t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ["Previous Same Level" outline-backward-same-level t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ("Show"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ["Show All" show-all t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ["Show Entry" show-entry t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ["Show Branches" show-branches t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ["Show Children" show-children t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ["Show Subtree" show-subtree t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ("Hide"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ["Hide Leaves" hide-leaves t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ["Hide Body" hide-body t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ["Hide Entry" hide-entry t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ["Hide Subtree" hide-subtree t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ["Hide Other" hide-other t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ["Hide Sublevels" hide-sublevels t])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun outline-mode-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (popup-menu outline-mode-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;; ?? Is this OK & if so should it be in minor mode too?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (define-key outline-mode-map [button3] 'outline-mode-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defun outline-install-menubar (&optional remove)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; install or remove the outline menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (let ((menus (cdr outline-mode-menu)) path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (and (not remove)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (set-buffer-menubar (copy-sequence current-menubar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (while menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq path (list (car (car menus))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (if (and remove (find-menu-item current-menubar path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (delete-menu-item path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (or (car (find-menu-item current-menubar path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (add-menu nil (car (car menus)) (cdr (car menus)) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq menus (cdr menus)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defvar outline-minor-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Non-nil if using Outline mode as a minor mode of some other mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (make-variable-buffer-local 'outline-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (put 'outline-minor-mode 'permanent-local t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;(or (assq 'outline-minor-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ; (setq minor-mode-alist (append minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ; (list '(outline-minor-mode " Outl")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; XEmacs: do it right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (add-minor-mode 'outline-minor-mode " Outl")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 (defvar outline-font-lock-keywords
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 '(;; Highlight headings according to the level.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 ("^\\(\\*+\\)[ \t]*\\(.+\\)?[ \t]*$"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 (1 font-lock-string-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 (2 (let ((len (- (match-end 1) (match-beginning 1))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 (or (cdr (assq len '((1 . font-lock-function-name-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 (2 . font-lock-keyword-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 (3 . font-lock-comment-face))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208 font-lock-variable-name-face))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 nil t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 ;; Highlight citations of the form [1] and [Mar94].
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 ("\\[\\([A-Z][A-Za-z]+\\)*[0-9]+\\]" . font-lock-type-face))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 "Additional expressions to highlight in Outline mode.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun outline-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Set major mode for editing outlines with selective display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 Headings are lines which start with asterisks: one for major headings,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 two for subheadings, etc. Lines not starting with asterisks are body lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 Body text or subheadings under a heading can be made temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 invisible, or visible again. Invisible lines are attached to the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 of the heading, so they move with it, if the line is killed and yanked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 back. A heading with text hidden under it is marked with an ellipsis (...).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 Commands:\\<outline-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 \\[outline-previous-visible-heading] outline-previous-visible-heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 \\[outline-backward-same-level] outline-backward-same-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 \\[outline-up-heading] outline-up-heading move from subheading to heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 \\[hide-body] make all text invisible (not headings).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 \\[show-all] make everything in buffer visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 The remaining commands are used when point is on a heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 They apply to some of the body or subheadings of that heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 \\[hide-subtree] hide-subtree make body and subheadings invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 \\[show-subtree] show-subtree make body and subheadings visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 \\[show-children] show-children make direct subheadings visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 No effect on body, or subheadings 2 or more levels down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 With arg N, affects subheadings N levels down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 \\[hide-entry] make immediately following body invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 \\[show-entry] make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 \\[hide-leaves] make body under heading and under its subheadings invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 The subheadings remain visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 \\[show-branches] make all subheadings at all levels visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 The variable `outline-regexp' can be changed to control what is a heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 A line is a heading if `outline-regexp' matches something at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 beginning of the line. The longer the match, the deeper the level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 Turning on outline mode calls the value of `text-mode-hook' and then of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 `outline-mode-hook', if they are non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (setq selective-display t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (use-local-map outline-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq mode-name "Outline")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq major-mode 'outline-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (define-abbrev-table 'text-mode-abbrev-table ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (set-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (make-local-variable 'paragraph-start)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
264 (setq paragraph-start (concat paragraph-start "\\|\\("
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 outline-regexp "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; Inhibit auto-filling of header lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (make-local-variable 'auto-fill-inhibit-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (setq auto-fill-inhibit-regexp outline-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (make-local-variable 'paragraph-separate)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
270 (setq paragraph-separate (concat paragraph-separate "\\|\\("
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 outline-regexp "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (outline-install-menubar)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
274 (make-local-variable 'font-lock-defaults)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
275 (setq font-lock-defaults '(outline-font-lock-keywords t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
276 (make-local-variable 'change-major-mode-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (add-hook 'change-major-mode-hook 'show-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (run-hooks 'text-mode-hook 'outline-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
280 (defvar outline-minor-mode-prefix "\C-c@"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
281 "*Prefix key to use for Outline commands in Outline minor mode.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
282 The value of this variable is checked as part of loading Outline mode.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
283 After that, changing the prefix key requires manipulating keymaps.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defvar outline-minor-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (if outline-minor-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq outline-minor-mode-map (make-sparse-keymap))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
289 (define-key outline-minor-mode-map [menu-bar]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
290 outline-mode-menu-bar-map)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (define-key outline-minor-mode-map outline-minor-mode-prefix
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
292 outline-mode-prefix-map))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (or (assq 'outline-minor-mode minor-mode-map-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq minor-mode-map-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (cons (cons 'outline-minor-mode outline-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 minor-mode-map-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun outline-minor-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Toggle Outline minor mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 With arg, turn Outline minor mode on if arg is positive, off otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 See the command `outline-mode' for more information on this mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (setq outline-minor-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (if (null arg) (not outline-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (> (prefix-numeric-value arg) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (if outline-minor-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq selective-display t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (outline-install-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (run-hooks 'outline-minor-mode-hook))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
314 (setq selective-display nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
315 ;; When turning off outline mode, get rid of any ^M's.
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
316 (unless outline-minor-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
317 (outline-flag-region (point-min) (point-max) ?\n)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
318 ;; XEmacs change
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
319 (set-buffer-modified-p (buffer-modified-p))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
320 ;; #+XEmacs
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
321 (outline-install-menubar 'remove))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
322 ;; XEmacs change
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
323 (redraw-modeline))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defvar outline-level 'outline-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "Function of no args to compute a header's nesting level in an outline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 It can assume point is at the beginning of a header line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; This used to count columns rather than characters, but that made ^L
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; appear to be at level 2 instead of 1. Columns would be better for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; tab handling, but the default regexp doesn't use tabs, and anyone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; who changes the regexp can also redefine the outline-level variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; as appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defun outline-level ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 "Return the depth to which a statement is nested in the outline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 Point must be at the beginning of a header line. This is actually
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
337 the number of characters that `outline-regexp' matches."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (looking-at outline-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (- (match-end 0) (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defun outline-next-preface ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
343 "Skip forward to just before the next heading line.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
344 If there's no following heading line, stop before the newline
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
345 at the end of the buffer."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 nil 'move)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
348 (goto-char (match-beginning 0)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
349 (if (memq (preceding-char) '(?\n ?\^M))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
350 (forward-char -1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun outline-next-heading ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "Move to the next (possibly invisible) heading line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (goto-char (1+ (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (defun outline-back-to-heading ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 "Move to previous heading line, or beg of this line if it's a heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 Only visible heading lines are considered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (or (outline-on-heading-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (error "before first heading")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defun outline-on-heading-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "Return t if point is on a (visible) heading line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (and (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (looking-at outline-regexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defun outline-end-of-heading ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (re-search-forward outline-heading-end-regexp nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (forward-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defun outline-next-visible-heading (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 "Move to the next visible heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 With argument, repeats or can move backward if negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 A heading line is one that starts with a `*' (or that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 `outline-regexp' matches)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (if (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (or (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defun outline-previous-visible-heading (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "Move to the previous heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 With argument, repeats or can move forward if negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 A heading line is one that starts with a `*' (or that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 `outline-regexp' matches)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (outline-next-visible-heading (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defun outline-flag-region (from to flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "Hides or shows lines from FROM to TO, according to FLAG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 If FLAG is `\\n' (newline character) then text is shown,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 while if FLAG is `\\^M' (control-M) the text is hidden."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (subst-char-in-region from to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if (= flag ?\n) ?\^M ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 flag t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defun hide-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 "Hide the body directly following this heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (outline-end-of-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\^M)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (defun show-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "Show the body directly following this heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (defun hide-body ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 "Hide all of buffer except headings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (hide-region-body (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defun hide-region-body (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 "Hide all body lines in the region, but not headings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (if (outline-on-heading-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (outline-end-of-heading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (outline-flag-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (progn (outline-next-preface) (point)) ?\^M)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (forward-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if (looking-at "[\n\^M][\n\^M]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 2 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (outline-end-of-heading)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defun show-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 "Show all of the text in the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (outline-flag-region (point-min) (point-max) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defun hide-subtree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "Hide everything after this heading at deeper levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (outline-flag-subtree ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defun hide-leaves ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "Hide all body after this heading at deeper levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (outline-end-of-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (hide-region-body (point) (progn (outline-end-of-subtree) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun show-subtree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "Show everything after this heading at deeper levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (outline-flag-subtree ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defun hide-sublevels (levels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "Hide everything but the top LEVELS levels of headers, in whole buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (if (< levels 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (error "Must keep at least one level of headers"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (setq levels (1- levels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;; Keep advancing to the next top-level heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (while (or (and (bobp) (outline-on-heading-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (outline-next-heading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (let ((end (save-excursion (outline-end-of-subtree) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;; Hide everything under that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (outline-flag-region (point) end ?\^M)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; Show the first LEVELS levels under that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if (> levels 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (show-children levels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; Move to the next, since we already found it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (goto-char end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defun hide-other ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Hide everything except for the current body and the parent headings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (hide-sublevels 1)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
491 (let ((last (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
492 (pos (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (while (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (and (re-search-backward "[\n\r]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (eq (following-char) ?\r)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (if (eq last (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (outline-next-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (outline-flag-region last (point) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (show-children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (setq last (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (defun outline-flag-subtree (flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (outline-end-of-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (outline-flag-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (progn (outline-end-of-subtree) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 flag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (defun outline-end-of-subtree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (outline-back-to-heading)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
515 (let ((opoint (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
516 (first t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (or first (> (funcall outline-level) level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (setq first nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (outline-next-heading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (if (memq (preceding-char) '(?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; Go to end of line before heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (if (memq (preceding-char) '(?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; leave blank line before heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (forward-char -1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (defun show-branches ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 "Show all subheadings of this heading, but not their bodies."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (show-children 1000))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (defun show-children (&optional level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 "Show all direct subheadings of this heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 Prefix arg LEVEL is how many levels below the current level should be shown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 Default is enough to cause the following heading to appear."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (setq level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (if level (prefix-numeric-value level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (let ((start-level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (outline-next-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (max 1 (- (funcall outline-level) start-level)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq level (+ level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (progn (outline-end-of-subtree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (if (eobp) (point-max) (1+ (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (outline-next-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (not (eobp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (if (<= (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (outline-flag-region (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (if (memq (preceding-char) '(?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (progn (outline-end-of-heading) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ?\n)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defun outline-up-heading (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 "Move to the heading line of which the present line is a subheading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 With argument, move up ARG levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (if (eq (funcall outline-level) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (while (and (> (funcall outline-level) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (not (bobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (let ((present-level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (while (not (< (funcall outline-level) present-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (outline-previous-visible-heading 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq arg (- arg 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (defun outline-forward-same-level (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 "Move forward to the ARG'th subheading at same level as this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 Stop at the first and last subheadings of a superior heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (let ((point-to-move-to (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (outline-get-next-sibling))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (if point-to-move-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (goto-char point-to-move-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (setq arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (error ""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (defun outline-get-next-sibling ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 "Move to next heading of the same level, and return point or nil if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (let ((level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (outline-next-visible-heading 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (while (and (> (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (outline-next-visible-heading 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (if (< (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (defun outline-backward-same-level (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 "Move backward to the ARG'th subheading at same level as this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 Stop at the first and last subheadings of a superior heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (let ((point-to-move-to (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (outline-get-last-sibling))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if point-to-move-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (goto-char point-to-move-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (setq arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (error ""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (defun outline-get-last-sibling ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 "Move to next heading of the same level, and return point or nil if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (let ((level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (outline-previous-visible-heading 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (while (and (> (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (not (bobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (outline-previous-visible-heading 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (if (< (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (provide 'outline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;;; outline.el ends here