annotate lisp/modes/outline.el @ 48:56c54cf7c5b6 r19-16b90

Import from CVS: tag r19-16b90
author cvs
date Mon, 13 Aug 2007 08:56:04 +0200
parents 4103f0995bd7
children 131b0175ea99
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
48
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
175 ;; This is a nop if menubars aren't available
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
176 (when (and (featurep 'menubar) ; XEmacs
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
177 current-menubar)
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
178 (let ((menus (cdr outline-mode-menu)) path)
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
179 (and (not remove)
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
180 (set-buffer-menubar (copy-sequence current-menubar)))
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
181 (while menus
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
182 (setq path (list (car (car menus))))
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
183 (if (and remove (find-menu-item current-menubar path))
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
184 (delete-menu-item path)
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
185 (or (car (find-menu-item current-menubar path))
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
186 (add-menu nil (car (car menus)) (cdr (car menus)) nil)))
56c54cf7c5b6 Import from CVS: tag r19-16b90
cvs
parents: 24
diff changeset
187 (setq menus (cdr menus))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
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 (defvar outline-minor-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 "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
192 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (make-variable-buffer-local 'outline-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (put 'outline-minor-mode 'permanent-local t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;(or (assq 'outline-minor-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ; (setq minor-mode-alist (append minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ; (list '(outline-minor-mode " Outl")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; XEmacs: do it right.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (add-minor-mode 'outline-minor-mode " Outl")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 (defvar outline-font-lock-keywords
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 '(;; Highlight headings according to the level.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 ("^\\(\\*+\\)[ \t]*\\(.+\\)?[ \t]*$"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 (1 font-lock-string-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 (2 (let ((len (- (match-end 1) (match-beginning 1))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208 (or (cdr (assq len '((1 . font-lock-function-name-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 (2 . font-lock-keyword-face)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 (3 . font-lock-comment-face))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 font-lock-variable-name-face))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 nil t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 ;; Highlight citations of the form [1] and [Mar94].
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 ("\\[\\([A-Z][A-Za-z]+\\)*[0-9]+\\]" . font-lock-type-face))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215 "Additional expressions to highlight in Outline mode.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
216
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun outline-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Set major mode for editing outlines with selective display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 Headings are lines which start with asterisks: one for major headings,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 two for subheadings, etc. Lines not starting with asterisks are body lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 Body text or subheadings under a heading can be made temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 invisible, or visible again. Invisible lines are attached to the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 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
226 back. A heading with text hidden under it is marked with an ellipsis (...).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 Commands:\\<outline-mode-map>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 \\[outline-next-visible-heading] outline-next-visible-heading move by visible headings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 \\[outline-previous-visible-heading] outline-previous-visible-heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 \\[outline-forward-same-level] outline-forward-same-level similar but skip subheadings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 \\[outline-backward-same-level] outline-backward-same-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 \\[outline-up-heading] outline-up-heading move from subheading to heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 \\[hide-body] make all text invisible (not headings).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 \\[show-all] make everything in buffer visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 The remaining commands are used when point is on a heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 They apply to some of the body or subheadings of that heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 \\[hide-subtree] hide-subtree make body and subheadings invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 \\[show-subtree] show-subtree make body and subheadings visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 \\[show-children] show-children make direct subheadings visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 No effect on body, or subheadings 2 or more levels down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 With arg N, affects subheadings N levels down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 \\[hide-entry] make immediately following body invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 \\[show-entry] make it visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 \\[hide-leaves] make body under heading and under its subheadings invisible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 The subheadings remain visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 \\[show-branches] make all subheadings at all levels visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 The variable `outline-regexp' can be changed to control what is a heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 A line is a heading if `outline-regexp' matches something at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 beginning of the line. The longer the match, the deeper the level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 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
256 `outline-mode-hook', if they are non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq selective-display t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (use-local-map outline-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (setq mode-name "Outline")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (setq major-mode 'outline-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (define-abbrev-table 'text-mode-abbrev-table ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (set-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (make-local-variable 'paragraph-start)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 (setq paragraph-start (concat paragraph-start "\\|\\("
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 outline-regexp "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; Inhibit auto-filling of header lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (make-local-variable 'auto-fill-inhibit-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq auto-fill-inhibit-regexp outline-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (make-local-variable 'paragraph-separate)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
273 (setq paragraph-separate (concat paragraph-separate "\\|\\("
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 outline-regexp "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (outline-install-menubar)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
277 (make-local-variable 'font-lock-defaults)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
278 (setq font-lock-defaults '(outline-font-lock-keywords t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
279 (make-local-variable 'change-major-mode-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (add-hook 'change-major-mode-hook 'show-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (run-hooks 'text-mode-hook 'outline-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
283 (defvar outline-minor-mode-prefix "\C-c@"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
284 "*Prefix key to use for Outline commands in Outline minor mode.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
285 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
286 After that, changing the prefix key requires manipulating keymaps.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defvar outline-minor-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (if outline-minor-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq outline-minor-mode-map (make-sparse-keymap))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
292 (define-key outline-minor-mode-map [menu-bar]
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
293 outline-mode-menu-bar-map)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (define-key outline-minor-mode-map outline-minor-mode-prefix
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
295 outline-mode-prefix-map))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (or (assq 'outline-minor-mode minor-mode-map-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq minor-mode-map-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (cons (cons 'outline-minor-mode outline-minor-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 minor-mode-map-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (defun outline-minor-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Toggle Outline minor mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 With arg, turn Outline minor mode on if arg is positive, off otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 See the command `outline-mode' for more information on this mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (setq outline-minor-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (if (null arg) (not outline-minor-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (> (prefix-numeric-value arg) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (if outline-minor-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setq selective-display t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; #+XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (outline-install-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (run-hooks 'outline-minor-mode-hook))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
317 (setq selective-display nil))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
318 ;; When turning off outline mode, get rid of any ^M's.
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
319 (unless outline-minor-mode
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
320 (outline-flag-region (point-min) (point-max) ?\n)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
321 ;; XEmacs change
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
322 (set-buffer-modified-p (buffer-modified-p))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
323 ;; #+XEmacs
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 2
diff changeset
324 (outline-install-menubar 'remove))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
325 ;; XEmacs change
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
326 (redraw-modeline))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defvar outline-level 'outline-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 "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
330 It can assume point is at the beginning of a header line.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; This used to count columns rather than characters, but that made ^L
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; 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
334 ;; tab handling, but the default regexp doesn't use tabs, and anyone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; who changes the regexp can also redefine the outline-level variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; as appropriate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defun outline-level ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "Return the depth to which a statement is nested in the outline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 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
340 the number of characters that `outline-regexp' matches."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (looking-at outline-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (- (match-end 0) (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun outline-next-preface ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
346 "Skip forward to just before the next heading line.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
347 If there's no following heading line, stop before the newline
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
348 at the end of the buffer."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 nil 'move)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
351 (goto-char (match-beginning 0)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
352 (if (memq (preceding-char) '(?\n ?\^M))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
353 (forward-char -1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defun outline-next-heading ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Move to the next (possibly invisible) heading line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (if (re-search-forward (concat "[\n\^M]\\(" outline-regexp "\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (goto-char (1+ (match-beginning 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun outline-back-to-heading ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "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
364 Only visible heading lines are considered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (or (outline-on-heading-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (re-search-backward (concat "^\\(" outline-regexp "\\)") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (error "before first heading")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defun outline-on-heading-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "Return t if point is on a (visible) heading line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (and (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (looking-at outline-regexp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defun outline-end-of-heading ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if (re-search-forward outline-heading-end-regexp nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (forward-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defun outline-next-visible-heading (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "Move to the next visible heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 With argument, repeats or can move backward if negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 A heading line is one that starts with a `*' (or that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 `outline-regexp' matches)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (if (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (or (re-search-forward (concat "^\\(" outline-regexp "\\)") nil t arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defun outline-previous-visible-heading (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "Move to the previous heading line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 With argument, repeats or can move forward if negative.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 A heading line is one that starts with a `*' (or that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 `outline-regexp' matches)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (outline-next-visible-heading (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defun outline-flag-region (from to flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "Hides or shows lines from FROM to TO, according to FLAG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 If FLAG is `\\n' (newline character) then text is shown,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 while if FLAG is `\\^M' (control-M) the text is hidden."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (let (buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (subst-char-in-region from to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (if (= flag ?\n) ?\^M ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 flag t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (defun hide-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 "Hide the body directly following this heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (outline-end-of-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\^M)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defun show-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 "Show the body directly following this heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (outline-flag-region (point) (progn (outline-next-preface) (point)) ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (defun hide-body ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "Hide all of buffer except headings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (hide-region-body (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (defun hide-region-body (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 "Hide all body lines in the region, but not headings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (narrow-to-region start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (if (outline-on-heading-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (outline-end-of-heading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (outline-flag-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (progn (outline-next-preface) (point)) ?\^M)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (if (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (forward-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (looking-at "[\n\^M][\n\^M]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 2 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (outline-end-of-heading)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defun show-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "Show all of the text in the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (outline-flag-region (point-min) (point-max) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (defun hide-subtree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 "Hide everything after this heading at deeper levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (outline-flag-subtree ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun hide-leaves ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "Hide all body after this heading at deeper levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (outline-end-of-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (hide-region-body (point) (progn (outline-end-of-subtree) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (defun show-subtree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "Show everything after this heading at deeper levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (outline-flag-subtree ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defun hide-sublevels (levels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 "Hide everything but the top LEVELS levels of headers, in whole buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (if (< levels 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (error "Must keep at least one level of headers"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (setq levels (1- levels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; Keep advancing to the next top-level heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (while (or (and (bobp) (outline-on-heading-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (outline-next-heading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (let ((end (save-excursion (outline-end-of-subtree) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; Hide everything under that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (outline-flag-region (point) end ?\^M)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; Show the first LEVELS levels under that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (if (> levels 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (show-children levels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; Move to the next, since we already found it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (goto-char end)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (defun hide-other ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 "Hide everything except for the current body and the parent headings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (hide-sublevels 1)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
494 (let ((last (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
495 (pos (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (while (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (and (re-search-backward "[\n\r]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (eq (following-char) ?\r)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (if (eq last (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (outline-next-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (outline-flag-region last (point) ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (show-children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq last (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (defun outline-flag-subtree (flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (outline-end-of-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (outline-flag-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (progn (outline-end-of-subtree) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 flag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (defun outline-end-of-subtree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (outline-back-to-heading)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
518 (let ((opoint (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
519 (first t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (or first (> (funcall outline-level) level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (setq first nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (outline-next-heading))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (if (memq (preceding-char) '(?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; Go to end of 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 (if (memq (preceding-char) '(?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; leave blank line before heading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (forward-char -1))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (defun show-branches ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 "Show all subheadings of this heading, but not their bodies."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (show-children 1000))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defun show-children (&optional level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 "Show all direct subheadings of this heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 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
541 Default is enough to cause the following heading to appear."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (setq level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (if level (prefix-numeric-value level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (let ((start-level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (outline-next-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (max 1 (- (funcall outline-level) start-level)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq level (+ level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (progn (outline-end-of-subtree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (if (eobp) (point-max) (1+ (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (while (and (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (outline-next-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (not (eobp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (if (<= (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (outline-flag-region (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if (memq (preceding-char) '(?\n ?\^M))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (progn (outline-end-of-heading) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ?\n)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (defun outline-up-heading (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 "Move to the heading line of which the present line is a subheading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 With argument, move up ARG levels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (if (eq (funcall outline-level) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (while (and (> (funcall outline-level) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (not (bobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (let ((present-level (funcall outline-level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (while (not (< (funcall outline-level) present-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (outline-previous-visible-heading 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (setq arg (- arg 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (defun outline-forward-same-level (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 "Move forward to the ARG'th subheading at same level as this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 Stop at the first and last subheadings of a superior heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (let ((point-to-move-to (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (outline-get-next-sibling))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (if point-to-move-to
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 (goto-char point-to-move-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (error ""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (defun outline-get-next-sibling ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 "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
607 (let ((level (funcall outline-level)))
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 (while (and (> (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (outline-next-visible-heading 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (if (< (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (defun outline-backward-same-level (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 "Move backward to the ARG'th subheading at same level as this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 Stop at the first and last subheadings of a superior heading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (outline-back-to-heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (let ((point-to-move-to (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (outline-get-last-sibling))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (if point-to-move-to
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 (goto-char point-to-move-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (setq arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (error ""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (defun outline-get-last-sibling ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 "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
634 (let ((level (funcall outline-level)))
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 (while (and (> (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (not (bobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (outline-previous-visible-heading 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if (< (funcall outline-level) level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (provide 'outline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;;; outline.el ends here