/[emacs]/emacs/lisp/allout.el
ViewVC logotype

Diff of /emacs/lisp/allout.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by pj, Wed Mar 27 20:13:03 2002 UTC revision 1.32.2.1 by miles, Fri Apr 4 06:20:00 2003 UTC
# Line 1  Line 1 
1  ;;; allout.el --- extensive outline mode for use alone and with other modes  ;;; allout.el --- extensive outline mode for use alone and with other modes
2    
3  ;; Copyright (C) 1992, 1993, 1994, 2001 Free Software Foundation, Inc.  ;; Copyright (C) 1992, 1993, 1994, 2001, 2002 Free Software Foundation, Inc.
4    
5  ;; Author: Ken Manheimer <klm@python.org>  ;; Author: Ken Manheimer <klm@zope.com>
6  ;; Maintainer: Ken Manheimer <klm@python.org>  ;; Maintainer: Ken Manheimer <klm@zope.com>
7  ;; Created: Dec 1991 - first release to usenet  ;; Created: Dec 1991 - first release to usenet
8  ;; Version: $Id$||  ;; Version: $Id$||
9  ;; Keywords: outlines mode wp languages  ;; Keywords: outlines mode wp languages
# Line 33  Line 33 
33  ;; exposure.  It also provides for syntax-sensitive text like  ;; exposure.  It also provides for syntax-sensitive text like
34  ;; programming languages.  (For an example, see the allout code  ;; programming languages.  (For an example, see the allout code
35  ;; itself, which is organized in ;; an outline framework.)  ;; itself, which is organized in ;; an outline framework.)
36  ;;  ;;
37  ;; In addition to outline navigation and exposure, allout includes:  ;; In addition to outline navigation and exposure, allout includes:
38  ;;  ;;
39  ;;  - topic-oriented repositioning, cut, and paste  ;;  - topic-oriented repositioning, cut, and paste
40  ;;  - integral outline exposure-layout  ;;  - integral outline exposure-layout
41  ;;  - incremental search with dynamic exposure and reconcealment of hidden text  ;;  - incremental search with dynamic exposure and reconcealment of hidden text
42  ;;  - automatic topic-number maintenance  ;;  - automatic topic-number maintenance
43  ;;  - "Hot-spot" operation, for single-keystroke maneuvering and  ;;  - "Hot-spot" operation, for single-keystroke maneuvering and
44  ;;    exposure control.  (See the `outline-mode' docstring.)  ;;    exposure control.  (See the `allout-mode' docstring.)
45  ;;  ;;
46  ;; and many other features.  ;; and many other features.
47  ;;  ;;
48  ;; The outline menubar additions provide quick reference to many of  ;; The outline menubar additions provide quick reference to many of
49  ;; the features, and see the docstring of the variable `outline-init'  ;; the features, and see the docstring of the function `allout-init'
50  ;; for instructions on priming your emacs session for automatic  ;; for instructions on priming your emacs session for automatic
51  ;; activation of `outline-mode'.  ;; activation of `allout-mode'.
52  ;;  ;;
53  ;; See the docstring of the variables `outline-layout' and  ;; See the docstring of the variables `allout-layout' and
54  ;; `outline-auto-activation' for details on automatic activation of  ;; `allout-auto-activation' for details on automatic activation of
55  ;; allout `outline-mode' as a minor mode.  (It has changed since allout  ;; allout `allout-mode' as a minor mode.  (It has changed since allout
56  ;; 3.x, for those of you that depend on the old method.)  ;; 3.x, for those of you that depend on the old method.)
57  ;;  ;;
58  ;; Note - the lines beginning with `;;;_' are outline topic headers.  ;; Note - the lines beginning with `;;;_' are outline topic headers.
59  ;;        Just `ESC-x eval-current-buffer' to give it a whirl.  ;;        Just `ESC-x eval-current-buffer' to give it a whirl.
60    
61  ;; Ken Manheimer        klm@python.org  ;; Ken Manheimer        klm@zope.com
62    
63  ;;; Code:  ;;; Code:
64    
65  ;;;_* Provide  ;;;_* Provide
 (provide 'outline)  
66  (provide 'allout)  (provide 'allout)
67    
68  ;;;_* USER CUSTOMIZATION VARIABLES:  ;;;_* USER CUSTOMIZATION VARIABLES:
69  (defgroup allout nil  (defgroup allout nil
70    "Extensive outline mode for use alone and with other modes."    "Extensive outline mode for use alone and with other modes."
71    :prefix "outline-"    :prefix "allout-"
72    :group 'outlines)    :group 'editing)
73    
74  ;;;_ + Layout, Mode, and Topic Header Configuration  ;;;_ + Layout, Mode, and Topic Header Configuration
75    
76  ;;;_  = outline-auto-activation  ;;;_  = allout-auto-activation
77  (defcustom outline-auto-activation nil  (defcustom allout-auto-activation nil
78    "*Regulates auto-activation modality of allout outlines - see `outline-init'.    "*Regulates auto-activation modality of allout outlines - see `allout-init'.
79    
80  Setq-default by `outline-init' to regulate whether or not allout  Setq-default by `allout-init' to regulate whether or not allout
81  outline mode is automatically activated when the buffer-specific  outline mode is automatically activated when the buffer-specific
82  variable `outline-layout' is non-nil, and whether or not the layout  variable `allout-layout' is non-nil, and whether or not the layout
83  dictated by `outline-layout' should be imposed on mode activation.  dictated by `allout-layout' should be imposed on mode activation.
84    
85  With value `t', auto-mode-activation and auto-layout are enabled.  With value `t', auto-mode-activation and auto-layout are enabled.
86  \(This also depends on `outline-find-file-hooks' being installed in  \(This also depends on `allout-find-file-hook' being installed in
87  `find-file-hooks', which is also done by `outline-init'.)  `find-file-hooks', which is also done by `allout-init'.)
88    
89  With value `ask', auto-mode-activation is enabled, and endorsement for  With value `ask', auto-mode-activation is enabled, and endorsement for
90  performing auto-layout is asked of the user each time.  performing auto-layout is asked of the user each time.
91    
92  With value `activate', only auto-mode-activation is enabled,  With value `activate', only auto-mode-activation is enabled,
93  auto-layout is not.  auto-layout is not.
94    
95  With value `nil', neither auto-mode-activation nor auto-layout are  With value `nil', neither auto-mode-activation nor auto-layout are
96  enabled.  enabled.
97    
98  See the docstring for `outline-init' for the proper interface to  See the docstring for `allout-init' for the proper interface to
99  this variable."  this variable."
100    :type '(choice (const :tag "On" t)    :type '(choice (const :tag "On" t)
101                  (const :tag "Ask about layout" "ask")                  (const :tag "Ask about layout" "ask")
102                  (const :tag "Mode only" "activate")                  (const :tag "Mode only" "activate")
103                  (const :tag "Off" nil))                  (const :tag "Off" nil))
104    :group 'allout)    :group 'allout)
105  ;;;_  = outline-layout  ;;;_  = allout-layout
106  (defvar outline-layout nil  (defvar allout-layout nil
107    "*Layout specification and provisional mode trigger for allout outlines.    "*Layout specification and provisional mode trigger for allout outlines.
108    
109  Buffer-specific.  Buffer-specific.
110    
111  A list value specifies a default layout for the current buffer, to be  A list value specifies a default layout for the current buffer, to be
112  applied upon activation of allout `outline-mode'.  Any non-nil value will  applied upon activation of `allout-mode'.  Any non-nil value will
113  automatically trigger allout `outline-mode', provided `outline-init'  automatically trigger `allout-mode', provided `allout-init'
114  has been called to enable it.  has been called to enable it.
115    
116  See the docstring for `outline-init' for details on setting up for  See the docstring for `allout-init' for details on setting up for
117  auto-mode-activation, and for `outline-expose-topic' for the format of  auto-mode-activation, and for `allout-expose-topic' for the format of
118  the layout specification.  the layout specification.
119    
120  You can associate a particular outline layout with a file by setting  You can associate a particular outline layout with a file by setting
# Line 123  this var via the file's local variables. Line 122  this var via the file's local variables.
122  lines at the bottom of an Emacs Lisp file:  lines at the bottom of an Emacs Lisp file:
123    
124  ;;;Local variables:  ;;;Local variables:
125  ;;;outline-layout: \(0 : -1 -1 0)  ;;;allout-layout: \(0 : -1 -1 0)
126  ;;;End:  ;;;End:
127    
128  will, modulo the above-mentioned conditions, cause the mode to be  will, modulo the above-mentioned conditions, cause the mode to be
129  activated when the file is visited, followed by the equivalent of  activated when the file is visited, followed by the equivalent of
130  `\(outline-expose-topic 0 : -1 -1 0)'.  \(This is the layout used for  `\(allout-expose-topic 0 : -1 -1 0)'.  \(This is the layout used for
131  the allout.el, itself.)  the allout.el, itself.)
132    
133  Also, allout's mode-specific provisions will make topic prefixes default  Also, allout's mode-specific provisions will make topic prefixes default
134  to the comment-start string, if any, of the language of the file.  This  to the comment-start string, if any, of the language of the file.  This
135  is modulo the setting of `outline-use-mode-specific-leader', which see.")  is modulo the setting of `allout-use-mode-specific-leader', which see.")
136  (make-variable-buffer-local 'outline-layout)  (make-variable-buffer-local 'allout-layout)
137  ;;;_  = outline-show-bodies  ;;;_  = allout-show-bodies
138  (defcustom outline-show-bodies nil  (defcustom allout-show-bodies nil
139    "*If non-nil, show entire body when exposing a topic, rather than    "*If non-nil, show entire body when exposing a topic, rather than
140  just the header."  just the header."
141    :type 'boolean    :type 'boolean
142    :group 'allout)    :group 'allout)
143  (make-variable-buffer-local 'outline-show-bodies)  (make-variable-buffer-local 'allout-show-bodies)
144    
145  ;;;_  = outline-header-prefix  ;;;_  = allout-header-prefix
146  (defcustom outline-header-prefix "."  (defcustom allout-header-prefix "."
147    "*Leading string which helps distinguish topic headers.    "*Leading string which helps distinguish topic headers.
148    
149  Outline topic header lines are identified by a leading topic  Outline topic header lines are identified by a leading topic
150  header prefix, which mostly have the value of this var at their front.  header prefix, which mostly have the value of this var at their front.
151  \(Level 1 topics are exceptions.  They consist of only a single  \(Level 1 topics are exceptions.  They consist of only a single
152  character, which is typically set to the outline-primary-bullet.  Many  character, which is typically set to the `allout-primary-bullet'.  Many
153  outlines start at level 2 to avoid this discrepancy."  outlines start at level 2 to avoid this discrepancy."
154    :type 'string    :type 'string
155    :group 'allout)    :group 'allout)
156  (make-variable-buffer-local 'outline-header-prefix)  (make-variable-buffer-local 'allout-header-prefix)
157  ;;;_  = outline-primary-bullet  ;;;_  = allout-primary-bullet
158  (defcustom outline-primary-bullet "*"  (defcustom allout-primary-bullet "*"
159    "Bullet used for top-level outline topics.    "Bullet used for top-level outline topics.
160    
161  Outline topic header lines are identified by a leading topic header  Outline topic header lines are identified by a leading topic header
162  prefix, which is concluded by bullets that includes the value of this  prefix, which is concluded by bullets that includes the value of this
163  var and the respective outline-*-bullets-string vars.  var and the respective allout-*-bullets-string vars.
164    
165  The value of an asterisk (`*') provides for backwards compatibility  The value of an asterisk (`*') provides for backwards compatibility
166  with the original emacs outline mode.  See outline-plain-bullets-string  with the original emacs outline mode.  See `allout-plain-bullets-string'
167  and outline-distinctive-bullets-string for the range of available  and `allout-distinctive-bullets-string' for the range of available
168  bullets."  bullets."
169    :type 'string    :type 'string
170    :group 'allout)    :group 'allout)
171  (make-variable-buffer-local 'outline-primary-bullet)  (make-variable-buffer-local 'allout-primary-bullet)
172  ;;;_  = outline-plain-bullets-string  ;;;_  = allout-plain-bullets-string
173  (defcustom outline-plain-bullets-string ".:,;"  (defcustom allout-plain-bullets-string ".:,;"
174    "*The bullets normally used in outline topic prefixes.    "*The bullets normally used in outline topic prefixes.
175    
176  See `outline-distinctive-bullets-string' for the other kind of  See `allout-distinctive-bullets-string' for the other kind of
177  bullets.  bullets.
178    
179  DO NOT include the close-square-bracket, `]', as a bullet.  DO NOT include the close-square-bracket, `]', as a bullet.
# Line 183  Outline mode has to be reactivated in or Line 182  Outline mode has to be reactivated in or
182  of this var to take effect."  of this var to take effect."
183    :type 'string    :type 'string
184    :group 'allout)    :group 'allout)
185  (make-variable-buffer-local 'outline-plain-bullets-string)  (make-variable-buffer-local 'allout-plain-bullets-string)
186  ;;;_  = outline-distinctive-bullets-string  ;;;_  = allout-distinctive-bullets-string
187  (defcustom outline-distinctive-bullets-string "*+-=>([{}&!?#%\"X@$~_\\"  (defcustom allout-distinctive-bullets-string "*+-=>([{}&!?#%\"X@$~_\\"
188    "*Persistent outline header bullets used to distinguish special topics.    "*Persistent outline header bullets used to distinguish special topics.
189    
190  These bullets are used to distinguish topics from the run-of-the-mill  These bullets are used to distinguish topics from the run-of-the-mill
191  ones.  They are not used in the standard topic headers created by  ones.  They are not used in the standard topic headers created by
192  the topic-opening, shifting, and rebulleting \(eg, on topic shift,  the topic-opening, shifting, and rebulleting \(eg, on topic shift,
193  topic paste, blanket rebulleting) routines, but are offered among the  topic paste, blanket rebulleting) routines, but are offered among the
194  choices for rebulleting.  They are not altered by the above automatic  choices for rebulleting.  They are not altered by the above automatic
195  rebulleting, so they can be used to characterize topics, eg:  rebulleting, so they can be used to characterize topics, eg:
# Line 203  rebulleting, so they can be used to char Line 202  rebulleting, so they can be used to char
202   `~' \"more or less\"   `~' \"more or less\"
203    
204  ... just for example.  (`#' typically has a special meaning to the  ... just for example.  (`#' typically has a special meaning to the
205  software, according to the value of `outline-numbered-bullet'.)  software, according to the value of `allout-numbered-bullet'.)
206    
207  See `outline-plain-bullets-string' for the selection of  See `allout-plain-bullets-string' for the selection of
208  alternating bullets.  alternating bullets.
209    
210  You must run `set-outline-regexp' in order for outline mode to  You must run `set-allout-regexp' in order for outline mode to
211  reconcile to changes of this value.  reconcile to changes of this value.
212    
213  DO NOT include the close-square-bracket, `]', on either of the bullet  DO NOT include the close-square-bracket, `]', on either of the bullet
214  strings."  strings."
215    :type 'string    :type 'string
216    :group 'allout)    :group 'allout)
217  (make-variable-buffer-local 'outline-distinctive-bullets-string)  (make-variable-buffer-local 'allout-distinctive-bullets-string)
218    
219  ;;;_  = outline-use-mode-specific-leader  ;;;_  = allout-use-mode-specific-leader
220  (defcustom outline-use-mode-specific-leader t  (defcustom allout-use-mode-specific-leader t
221    "*When non-nil, use mode-specific topic-header prefixes.    "*When non-nil, use mode-specific topic-header prefixes.
222    
223  Allout outline mode will use the mode-specific `outline-mode-leaders'  Allout outline mode will use the mode-specific `allout-mode-leaders'
224  and/or comment-start string, if any, to lead the topic prefix string,  and/or comment-start string, if any, to lead the topic prefix string,
225  so topic headers look like comments in the programming language.  so topic headers look like comments in the programming language.
226    
227  String values are used as they stand.  String values are used as they stand.
228    
229  Value `t' means to first check for assoc value in `outline-mode-leaders'  Value `t' means to first check for assoc value in `allout-mode-leaders'
230  alist, then use comment-start string, if any, then use default \(`.').  alist, then use comment-start string, if any, then use default \(`.').
231  \(See note about use of comment-start strings, below.)  \(See note about use of comment-start strings, below.)
232    
233  Set to the symbol for either of `outline-mode-leaders' or  Set to the symbol for either of `allout-mode-leaders' or
234  `comment-start' to use only one of them, respectively.  `comment-start' to use only one of them, respectively.
235    
236  Value `nil' means to always use the default \(`.').  Value `nil' means to always use the default \(`.').
# Line 241  comment-start strings that do not end in Line 240  comment-start strings that do not end in
240  comment strings.  comment-start strings that do end in spaces are not  comment strings.  comment-start strings that do end in spaces are not
241  tripled, but an underscore is substituted for the space. [This  tripled, but an underscore is substituted for the space. [This
242  presumes that the space is for appearance, not comment syntax.  You  presumes that the space is for appearance, not comment syntax.  You
243  can use `outline-mode-leaders' to override this behavior, when  can use `allout-mode-leaders' to override this behavior, when
244  incorrect.]"  incorrect.]"
245    :type '(choice (const t) (const nil) string    :type '(choice (const t) (const nil) string
246                   (const outline-mode-leaders)                   (const allout-mode-leaders)
247                   (const comment-start))                   (const comment-start))
248    :group 'allout)    :group 'allout)
249  ;;;_  = outline-mode-leaders  ;;;_  = allout-mode-leaders
250  (defvar outline-mode-leaders '()  (defvar allout-mode-leaders '()
251    "Specific outline-prefix leading strings per major modes.    "Specific allout-prefix leading strings per major modes.
252    
253  Entries will be used instead or in lieu of mode-specific  Entries will be used instead or in lieu of mode-specific
254  comment-start strings.  See also `outline-use-mode-specific-leader'.  comment-start strings.  See also `allout-use-mode-specific-leader'.
255    
256  If you're constructing a string that will comment-out outline  If you're constructing a string that will comment-out outline
257  structuring so it can be included in program code, append an extra  structuring so it can be included in program code, append an extra
258  character, like an \"_\" underscore, to distinguish the lead string  character, like an \"_\" underscore, to distinguish the lead string
259  from regular comments that start at bol.")  from regular comments that start at bol.")
260    
261  ;;;_  = outline-old-style-prefixes  ;;;_  = allout-old-style-prefixes
262  (defcustom outline-old-style-prefixes nil  (defcustom allout-old-style-prefixes nil
263    "*When non-nil, use only old-and-crusty outline-mode `*' topic prefixes.    "*When non-nil, use only old-and-crusty `outline-mode' `*' topic prefixes.
264    
265  Non-nil restricts the topic creation and modification  Non-nil restricts the topic creation and modification
266  functions to asterix-padded prefixes, so they look exactly  functions to asterix-padded prefixes, so they look exactly
# Line 271  Whatever the setting of this variable, b Line 270  Whatever the setting of this variable, b
270  are always respected by the topic maneuvering functions."  are always respected by the topic maneuvering functions."
271    :type 'boolean    :type 'boolean
272    :group 'allout)    :group 'allout)
273  (make-variable-buffer-local 'outline-old-style-prefixes)  (make-variable-buffer-local 'allout-old-style-prefixes)
274  ;;;_  = outline-stylish-prefixes - alternating bullets  ;;;_  = allout-stylish-prefixes - alternating bullets
275  (defcustom outline-stylish-prefixes t  (defcustom allout-stylish-prefixes t
276    "*Do fancy stuff with topic prefix bullets according to level, etc.    "*Do fancy stuff with topic prefix bullets according to level, etc.
277    
278  Non-nil enables topic creation, modification, and repositioning  Non-nil enables topic creation, modification, and repositioning
# Line 313  Stylish and constant prefixes (as well a Line 312  Stylish and constant prefixes (as well a
312  always respected by the topic maneuvering functions, regardless of  always respected by the topic maneuvering functions, regardless of
313  this variable setting.  this variable setting.
314    
315  The setting of this var is not relevant when outline-old-style-prefixes  The setting of this var is not relevant when `allout-old-style-prefixes'
316  is non-nil."  is non-nil."
317    :type 'boolean    :type 'boolean
318    :group 'allout)    :group 'allout)
319  (make-variable-buffer-local 'outline-stylish-prefixes)  (make-variable-buffer-local 'allout-stylish-prefixes)
320    
321  ;;;_  = outline-numbered-bullet  ;;;_  = allout-numbered-bullet
322  (defcustom outline-numbered-bullet "#"  (defcustom allout-numbered-bullet "#"
323    "*String designating bullet of topics that have auto-numbering; nil for none.    "*String designating bullet of topics that have auto-numbering; nil for none.
324    
325  Topics having this bullet have automatic maintenance of a sibling  Topics having this bullet have automatic maintenance of a sibling
# Line 329  to \"#\", you can set it to a bullet of Line 328  to \"#\", you can set it to a bullet of
328  disables numbering maintenance."  disables numbering maintenance."
329    :type '(choice (const nil) string)    :type '(choice (const nil) string)
330    :group 'allout)    :group 'allout)
331  (make-variable-buffer-local 'outline-numbered-bullet)  (make-variable-buffer-local 'allout-numbered-bullet)
332  ;;;_  = outline-file-xref-bullet  ;;;_  = allout-file-xref-bullet
333  (defcustom outline-file-xref-bullet "@"  (defcustom allout-file-xref-bullet "@"
334    "*Bullet signifying file cross-references, for `outline-resolve-xref'.    "*Bullet signifying file cross-references, for `allout-resolve-xref'.
335    
336  Set this var to the bullet you want to use for file cross-references."  Set this var to the bullet you want to use for file cross-references."
337    :type '(choice (const nil) string)    :type '(choice (const nil) string)
338    :group 'allout)    :group 'allout)
339    
340  ;;;_  = outline-presentation-padding  ;;;_  = allout-presentation-padding
341  (defcustom outline-presentation-padding 2  (defcustom allout-presentation-padding 2
342    "*Presentation-format white-space padding factor, for greater indent."    "*Presentation-format white-space padding factor, for greater indent."
343    :type 'integer    :type 'integer
344    :group 'allout)    :group 'allout)
345    
346  (make-variable-buffer-local 'outline-presentation-padding)  (make-variable-buffer-local 'allout-presentation-padding)
347    
348  ;;;_  = outline-abbreviate-flattened-numbering  ;;;_  = allout-abbreviate-flattened-numbering
349  (defcustom outline-abbreviate-flattened-numbering nil  (defcustom allout-abbreviate-flattened-numbering nil
350    "*If non-nil, `outline-flatten-exposed-to-buffer' abbreviates topic    "*If non-nil, `allout-flatten-exposed-to-buffer' abbreviates topic
351  numbers to minimal amount with some context.  Otherwise, entire  numbers to minimal amount with some context.  Otherwise, entire
352  numbers are always used."  numbers are always used."
353    :type 'boolean    :type 'boolean
354    :group 'allout)    :group 'allout)
355    
356  ;;;_ + LaTeX formatting  ;;;_ + LaTeX formatting
357  ;;;_  - outline-number-pages  ;;;_  - allout-number-pages
358  (defcustom outline-number-pages nil  (defcustom allout-number-pages nil
359    "*Non-nil turns on page numbering for LaTeX formatting of an outline."    "*Non-nil turns on page numbering for LaTeX formatting of an outline."
360    :type 'boolean    :type 'boolean
361    :group 'allout)    :group 'allout)
362  ;;;_  - outline-label-style  ;;;_  - allout-label-style
363  (defcustom outline-label-style "\\large\\bf"  (defcustom allout-label-style "\\large\\bf"
364    "*Font and size of labels for LaTeX formatting of an outline."    "*Font and size of labels for LaTeX formatting of an outline."
365    :type 'string    :type 'string
366    :group 'allout)    :group 'allout)
367  ;;;_  - outline-head-line-style  ;;;_  - allout-head-line-style
368  (defcustom outline-head-line-style "\\large\\sl "  (defcustom allout-head-line-style "\\large\\sl "
369    "*Font and size of entries for LaTeX formatting of an outline."    "*Font and size of entries for LaTeX formatting of an outline."
370    :type 'string    :type 'string
371    :group 'allout)    :group 'allout)
372  ;;;_  - outline-body-line-style  ;;;_  - allout-body-line-style
373  (defcustom outline-body-line-style " "  (defcustom allout-body-line-style " "
374    "*Font and size of entries for LaTeX formatting of an outline."    "*Font and size of entries for LaTeX formatting of an outline."
375    :type 'string    :type 'string
376    :group 'allout)    :group 'allout)
377  ;;;_  - outline-title-style  ;;;_  - allout-title-style
378  (defcustom outline-title-style "\\Large\\bf"  (defcustom allout-title-style "\\Large\\bf"
379    "*Font and size of titles for LaTeX formatting of an outline."    "*Font and size of titles for LaTeX formatting of an outline."
380    :type 'string    :type 'string
381    :group 'allout)    :group 'allout)
382  ;;;_  - outline-title  ;;;_  - allout-title
383  (defcustom outline-title '(or buffer-file-name (current-buffer-name))  (defcustom allout-title '(or buffer-file-name (current-buffer-name))
384    "*Expression to be evaluated to determine the title for LaTeX    "*Expression to be evaluated to determine the title for LaTeX
385  formatted copy."  formatted copy."
386    :type 'sexp    :type 'sexp
387    :group 'allout)    :group 'allout)
388  ;;;_  - outline-line-skip  ;;;_  - allout-line-skip
389  (defcustom outline-line-skip ".05cm"  (defcustom allout-line-skip ".05cm"
390    "*Space between lines for LaTeX formatting of an outline."    "*Space between lines for LaTeX formatting of an outline."
391    :type 'string    :type 'string
392    :group 'allout)    :group 'allout)
393  ;;;_  - outline-indent  ;;;_  - allout-indent
394  (defcustom outline-indent ".3cm"  (defcustom allout-indent ".3cm"
395    "*LaTeX formatted depth-indent spacing."    "*LaTeX formatted depth-indent spacing."
396    :type 'string    :type 'string
397    :group 'allout)    :group 'allout)
398    
399  ;;;_ + Miscellaneous customization  ;;;_ + Miscellaneous customization
400    
401  ;;;_  = outline-command-prefix  ;;;_  = allout-command-prefix
402  (defcustom outline-command-prefix "\C-c"  (defcustom allout-command-prefix "\C-c"
403    "*Key sequence to be used as prefix for outline mode command key bindings."    "*Key sequence to be used as prefix for outline mode command key bindings."
404    :type 'string    :type 'string
405    :group 'allout)    :group 'allout)
406    
407  ;;;_  = outline-keybindings-list  ;;;_  = allout-keybindings-list
408  ;;; You have to reactivate outline-mode - `(outline-mode t)' - to  ;;; You have to reactivate allout-mode - `(allout-mode t)' - to
409  ;;; institute changes to this var.  ;;; institute changes to this var.
410  (defvar outline-keybindings-list ()  (defvar allout-keybindings-list ()
411    "*List of outline-mode key / function bindings, for outline-mode-map.    "*List of `allout-mode' key / function bindings, for `allout-mode-map'.
412    
413  String or vector key will be prefaced with outline-command-prefix,  String or vector key will be prefaced with `allout-command-prefix',
414  unless optional third, non-nil element is present.")  unless optional third, non-nil element is present.")
415  (setq outline-keybindings-list  (setq allout-keybindings-list
416        '(        '(
417                                          ; Motion commands:                                          ; Motion commands:
418          ("\C-n" outline-next-visible-heading)          ("\C-n" allout-next-visible-heading)
419          ("\C-p" outline-previous-visible-heading)          ("\C-p" allout-previous-visible-heading)
420          ("\C-u" outline-up-current-level)          ("\C-u" allout-up-current-level)
421          ("\C-f" outline-forward-current-level)          ("\C-f" allout-forward-current-level)
422          ("\C-b" outline-backward-current-level)          ("\C-b" allout-backward-current-level)
423          ("\C-a" outline-beginning-of-current-entry)          ("\C-a" allout-beginning-of-current-entry)
424          ("\C-e" outline-end-of-current-entry)          ("\C-e" allout-end-of-current-entry)
425                                          ; Exposure commands:                                          ; Exposure commands:
426          ("\C-i" outline-show-children)          ("\C-i" allout-show-children)
427          ("\C-s" outline-show-current-subtree)          ("\C-s" allout-show-current-subtree)
428          ("\C-h" outline-hide-current-subtree)          ("\C-h" allout-hide-current-subtree)
429          ("\C-o" outline-show-current-entry)          ("\C-o" allout-show-current-entry)
430          ("!" outline-show-all)          ("!" allout-show-all)
431                                          ; Alteration commands:                                          ; Alteration commands:
432          (" " outline-open-sibtopic)          (" " allout-open-sibtopic)
433          ("." outline-open-subtopic)          ("." allout-open-subtopic)
434          ("," outline-open-supertopic)          ("," allout-open-supertopic)
435          ("'" outline-shift-in)          ("'" allout-shift-in)
436          (">" outline-shift-in)          (">" allout-shift-in)
437          ("<" outline-shift-out)          ("<" allout-shift-out)
438          ("\C-m" outline-rebullet-topic)          ("\C-m" allout-rebullet-topic)
439          ("*" outline-rebullet-current-heading)          ("*" allout-rebullet-current-heading)
440          ("#" outline-number-siblings)          ("#" allout-number-siblings)
441          ("\C-k" outline-kill-line t)          ("\C-k" allout-kill-line t)
442          ("\C-y" outline-yank t)          ("\C-y" allout-yank t)
443          ("\M-y" outline-yank-pop t)          ("\M-y" allout-yank-pop t)
444          ("\C-k" outline-kill-topic)          ("\C-k" allout-kill-topic)
445                                          ; Miscellaneous commands:                                          ; Miscellaneous commands:
446          ;([?\C-\ ] outline-mark-topic)          ;([?\C-\ ] allout-mark-topic)
447          ("@" outline-resolve-xref)          ("@" allout-resolve-xref)
448          ("=c" outline-copy-exposed-to-buffer)          ("=c" allout-copy-exposed-to-buffer)
449          ("=i" outline-indented-exposed-to-buffer)          ("=i" allout-indented-exposed-to-buffer)
450          ("=t" outline-latexify-exposed)          ("=t" allout-latexify-exposed)
451          ("=p" outline-flatten-exposed-to-buffer)))          ("=p" allout-flatten-exposed-to-buffer)))
452    
453  ;;;_  = outline-isearch-dynamic-expose  ;;;_  = allout-isearch-dynamic-expose
454  (defcustom outline-isearch-dynamic-expose t  (defcustom allout-isearch-dynamic-expose t
455    "*Non-nil enable dynamic exposure of hidden incremental-search    "*Non-nil enable dynamic exposure of hidden incremental-search
456  targets as they're encountered."  targets as they're encountered."
457    :type 'boolean    :type 'boolean
458    :group 'allout)    :group 'allout)
459  (make-variable-buffer-local 'outline-isearch-dynamic-expose)  (make-variable-buffer-local 'allout-isearch-dynamic-expose)
460    
461  ;;;_  = outline-use-hanging-indents  ;;;_  = allout-use-hanging-indents
462  (defcustom outline-use-hanging-indents t  (defcustom allout-use-hanging-indents t
463    "*If non-nil, topic body text auto-indent defaults to indent of the header.    "*If non-nil, topic body text auto-indent defaults to indent of the header.
464  Ie, it is indented to be just past the header prefix.  This is  Ie, it is indented to be just past the header prefix.  This is
465  relevant mostly for use with indented-text-mode, or other situations  relevant mostly for use with indented-text-mode, or other situations
# Line 470  where auto-fill occurs. Line 469  where auto-fill occurs.
469  lisp-archive package.\]"  lisp-archive package.\]"
470    :type 'boolean    :type 'boolean
471    :group 'allout)    :group 'allout)
472  (make-variable-buffer-local 'outline-use-hanging-indents)  (make-variable-buffer-local 'allout-use-hanging-indents)
473    
474  ;;;_  = outline-reindent-bodies  ;;;_  = allout-reindent-bodies
475  (defcustom outline-reindent-bodies (if outline-use-hanging-indents  (defcustom allout-reindent-bodies (if allout-use-hanging-indents
476                                      'text)                                      'text)
477    "*Non-nil enables auto-adjust of topic body hanging indent with depth shifts.    "*Non-nil enables auto-adjust of topic body hanging indent with depth shifts.
478    
# Line 487  those that do not have the variable `com Line 486  those that do not have the variable `com
486    :type '(choice (const nil) (const t) (const text) (const force))    :type '(choice (const nil) (const t) (const text) (const force))
487    :group 'allout)    :group 'allout)
488    
489  (make-variable-buffer-local 'outline-reindent-bodies)  (make-variable-buffer-local 'allout-reindent-bodies)
490    
491  ;;;_  = outline-inhibit-protection  ;;;_  = allout-inhibit-protection
492  (defcustom outline-inhibit-protection nil  (defcustom allout-inhibit-protection nil
493    "*Non-nil disables warnings and confirmation-checks for concealed-text edits.    "*Non-nil disables warnings and confirmation-checks for concealed-text edits.
494    
495  Outline mode uses emacs change-triggered functions to detect unruly  Outline mode uses emacs change-triggered functions to detect unruly
496  changes to concealed regions.  Set this var non-nil to disable the  changes to concealed regions.  Set this var non-nil to disable the
497  protection, potentially increasing text-entry responsiveness a bit.  protection, potentially increasing text-entry responsiveness a bit.
498    
499  This var takes effect at outline-mode activation, so you may have to  This var takes effect at `allout-mode' activation, so you may have to
500  deactivate and then reactivate the mode if you want to toggle the  deactivate and then reactivate the mode if you want to toggle the
501  behavior."  behavior."
502    :type 'boolean    :type 'boolean
# Line 507  behavior." Line 506  behavior."
506    
507  ;;;_ #1 Internal Outline Formatting and Configuration  ;;;_ #1 Internal Outline Formatting and Configuration
508  ;;;_  : Version  ;;;_  : Version
509  ;;;_   = outline-version  ;;;_   = allout-version
510  (defvar outline-version  (defvar allout-version
511    (let ((rcs-rev "$Revision$"))    (let ((rcs-rev "$Revision$"))
512      (condition-case err      (condition-case err
513          (save-match-data          (save-match-data
# Line 516  behavior." Line 515  behavior."
515            (substring rcs-rev (match-beginning 1) (match-end 1)))            (substring rcs-rev (match-beginning 1) (match-end 1)))
516        ('error rcs-rev)))        ('error rcs-rev)))
517    "Revision number of currently loaded outline package.  \(allout.el)")    "Revision number of currently loaded outline package.  \(allout.el)")
518  ;;;_   > outline-version  ;;;_   > allout-version
519  (defun outline-version (&optional here)  (defun allout-version (&optional here)
520    "Return string describing the loaded outline version."    "Return string describing the loaded outline version."
521    (interactive "P")    (interactive "P")
522    (let ((msg (concat "Allout Outline Mode v " outline-version)))    (let ((msg (concat "Allout Outline Mode v " allout-version)))
523      (if here (insert msg))      (if here (insert msg))
524      (message "%s" msg)      (message "%s" msg)
525      msg))      msg))
526  ;;;_  : Topic header format  ;;;_  : Topic header format
527  ;;;_   = outline-regexp  ;;;_   = allout-regexp
528  (defvar outline-regexp ""  (defvar allout-regexp ""
529    "*Regular expression to match the beginning of a heading line.    "*Regular expression to match the beginning of a heading line.
530    
531  Any line whose beginning matches this regexp is considered a  Any line whose beginning matches this regexp is considered a
532  heading.  This var is set according to the user configuration vars  heading.  This var is set according to the user configuration vars
533  by set-outline-regexp.")  by `set-allout-regexp'.")
534  (make-variable-buffer-local 'outline-regexp)  (make-variable-buffer-local 'allout-regexp)
535  ;;;_   = outline-bullets-string  ;;;_   = allout-bullets-string
536  (defvar outline-bullets-string ""  (defvar allout-bullets-string ""
537    "A string dictating the valid set of outline topic bullets.    "A string dictating the valid set of outline topic bullets.
538    
539  This var should *not* be set by the user - it is set by `set-outline-regexp',  This var should *not* be set by the user - it is set by `set-allout-regexp',
540  and is produced from the elements of `outline-plain-bullets-string'  and is produced from the elements of `allout-plain-bullets-string'
541  and `outline-distinctive-bullets-string'.")  and `allout-distinctive-bullets-string'.")
542  (make-variable-buffer-local 'outline-bullets-string)  (make-variable-buffer-local 'allout-bullets-string)
543  ;;;_   = outline-bullets-string-len  ;;;_   = allout-bullets-string-len
544  (defvar outline-bullets-string-len 0  (defvar allout-bullets-string-len 0
545    "Length of current buffers' outline-plain-bullets-string.")    "Length of current buffers' `allout-plain-bullets-string'.")
546  (make-variable-buffer-local 'outline-bullets-string-len)  (make-variable-buffer-local 'allout-bullets-string-len)
547  ;;;_   = outline-line-boundary-regexp  ;;;_   = allout-line-boundary-regexp
548  (defvar outline-line-boundary-regexp ()  (defvar allout-line-boundary-regexp ()
549    "Outline-regexp with outline-style beginning-of-line anchor.    "`allout-regexp' with outline style beginning-of-line anchor.
550    
551  \(Ie, C-j, *or* C-m, for prefixes of hidden topics).  This is properly  \(Ie, C-j, *or* C-m, for prefixes of hidden topics).  This is properly
552  set when outline-regexp is produced by `set-outline-regexp', so  set when `allout-regexp' is produced by `set-allout-regexp', so
553  that (match-beginning 2) and (match-end 2) delimit the prefix.")  that (match-beginning 2) and (match-end 2) delimit the prefix.")
554  (make-variable-buffer-local 'outline-line-boundary-regexp)  (make-variable-buffer-local 'allout-line-boundary-regexp)
555  ;;;_   = outline-bob-regexp  ;;;_   = allout-bob-regexp
556  (defvar outline-bob-regexp ()  (defvar allout-bob-regexp ()
557    "Like outline-line-boundary-regexp, for headers at beginning of buffer.    "Like `allout-line-boundary-regexp', for headers at beginning of buffer.
558  \(match-beginning 2) and \(match-end 2) delimit the prefix.")  \(match-beginning 2) and \(match-end 2) delimit the prefix.")
559  (make-variable-buffer-local 'outline-bob-regexp)  (make-variable-buffer-local 'allout-bob-regexp)
560  ;;;_   = outline-header-subtraction  ;;;_   = allout-header-subtraction
561  (defvar outline-header-subtraction (1- (length outline-header-prefix))  (defvar allout-header-subtraction (1- (length allout-header-prefix))
562    "Outline-header prefix length to subtract when computing topic depth.")    "Allout-header prefix length to subtract when computing topic depth.")
563  (make-variable-buffer-local 'outline-header-subtraction)  (make-variable-buffer-local 'allout-header-subtraction)
564  ;;;_   = outline-plain-bullets-string-len  ;;;_   = allout-plain-bullets-string-len
565  (defvar outline-plain-bullets-string-len (length outline-plain-bullets-string)  (defvar allout-plain-bullets-string-len (length allout-plain-bullets-string)
566    "Length of outline-plain-bullets-string, updated by set-outline-regexp.")    "Length of `allout-plain-bullets-string', updated by `set-allout-regexp'.")
567  (make-variable-buffer-local 'outline-plain-bullets-string-len)  (make-variable-buffer-local 'allout-plain-bullets-string-len)
568    
569    
570  ;;;_   X outline-reset-header-lead (header-lead)  ;;;_   X allout-reset-header-lead (header-lead)
571  (defun outline-reset-header-lead (header-lead)  (defun allout-reset-header-lead (header-lead)
572    "*Reset the leading string used to identify topic headers."    "*Reset the leading string used to identify topic headers."
573    (interactive "sNew lead string: ")    (interactive "sNew lead string: ")
574    (setq outline-header-prefix header-lead)    (setq allout-header-prefix header-lead)
575    (setq outline-header-subtraction (1- (length outline-header-prefix)))    (setq allout-header-subtraction (1- (length allout-header-prefix)))
576    (set-outline-regexp))    (set-allout-regexp))
577  ;;;_   X outline-lead-with-comment-string (header-lead)  ;;;_   X allout-lead-with-comment-string (header-lead)
578  (defun outline-lead-with-comment-string (&optional header-lead)  (defun allout-lead-with-comment-string (&optional header-lead)
579    "*Set the topic-header leading string to specified string.    "*Set the topic-header leading string to specified string.
580    
581  Useful when for encapsulating outline structure in programming  Useful when for encapsulating outline structure in programming
# Line 586  language comments.  Returns the leading Line 585  language comments.  Returns the leading
585    (if (not (stringp header-lead))    (if (not (stringp header-lead))
586        (setq header-lead (read-string        (setq header-lead (read-string
587                           "String prefix for topic headers: ")))                           "String prefix for topic headers: ")))
588    (setq outline-reindent-bodies nil)    (setq allout-reindent-bodies nil)
589    (outline-reset-header-lead header-lead)    (allout-reset-header-lead header-lead)
590    header-lead)    header-lead)
591  ;;;_   > outline-infer-header-lead ()  ;;;_   > allout-infer-header-lead ()
592  (defun outline-infer-header-lead ()  (defun allout-infer-header-lead ()
593    "Determine appropriate `outline-header-prefix'.    "Determine appropriate `allout-header-prefix'.
594    
595  Works according to settings of:  Works according to settings of:
596    
597         `comment-start'         `comment-start'
598         `outline-header-prefix' (default)         `allout-header-prefix' (default)
599         `outline-use-mode-specific-leader'         `allout-use-mode-specific-leader'
600  and    `outline-mode-leaders'.  and    `allout-mode-leaders'.
601    
602  Apply this via \(re)activation of `outline-mode', rather than  Apply this via \(re)activation of `allout-mode', rather than
603  invoking it directly."  invoking it directly."
604    (let* ((use-leader (and (boundp 'outline-use-mode-specific-leader)    (let* ((use-leader (and (boundp 'allout-use-mode-specific-leader)
605                            (if (or (stringp outline-use-mode-specific-leader)                            (if (or (stringp allout-use-mode-specific-leader)
606                                    (memq outline-use-mode-specific-leader                                    (memq allout-use-mode-specific-leader
607                                          '(outline-mode-leaders                                          '(allout-mode-leaders
608                                            comment-start                                            comment-start
609                                            t)))                                            t)))
610                                outline-use-mode-specific-leader                                allout-use-mode-specific-leader
611                              ;; Oops - garbled value, equate with effect of 't:                              ;; Oops - garbled value, equate with effect of 't:
612                              t)))                              t)))
613           (leader           (leader
# Line 616  invoking it directly." Line 615  invoking it directly."
615             ((not use-leader) nil)             ((not use-leader) nil)
616             ;; Use the explicitly designated leader:             ;; Use the explicitly designated leader:
617             ((stringp use-leader) use-leader)             ((stringp use-leader) use-leader)
618             (t (or (and (memq use-leader '(t outline-mode-leaders))             (t (or (and (memq use-leader '(t allout-mode-leaders))
619                         ;; Get it from outline mode leaders?                         ;; Get it from outline mode leaders?
620                         (cdr (assq major-mode outline-mode-leaders)))                         (cdr (assq major-mode allout-mode-leaders)))
621                    ;; ... didn't get from outline-mode-leaders...                    ;; ... didn't get from allout-mode-leaders...
622                    (and (memq use-leader '(t comment-start))                    (and (memq use-leader '(t comment-start))
623                         comment-start                         comment-start
624                         ;; Use comment-start, maybe tripled, and with                         ;; Use comment-start, maybe tripled, and with
# Line 635  invoking it directly." Line 634  invoking it directly."
634                          "_")))))))                          "_")))))))
635      (if (not leader)      (if (not leader)
636          nil          nil
637        (if (string= leader outline-header-prefix)        (if (string= leader allout-header-prefix)
638            nil                           ; no change, nothing to do.            nil                           ; no change, nothing to do.
639          (setq outline-header-prefix leader)          (setq allout-header-prefix leader)
640          outline-header-prefix))))          allout-header-prefix))))
641  ;;;_   > outline-infer-body-reindent ()  ;;;_   > allout-infer-body-reindent ()
642  (defun outline-infer-body-reindent ()  (defun allout-infer-body-reindent ()
643    "Determine proper setting for `outline-reindent-bodies'.    "Determine proper setting for `allout-reindent-bodies'.
644    
645  Depends on default setting of `outline-reindent-bodies' \(which see)  Depends on default setting of `allout-reindent-bodies' \(which see)
646  and presence of setting for `comment-start', to tell whether the  and presence of setting for `comment-start', to tell whether the
647  file is programming code."  file is programming code."
648    (if (and outline-reindent-bodies    (if (and allout-reindent-bodies
649             comment-start             comment-start
650             (not (eq 'force outline-reindent-bodies)))             (not (eq 'force allout-reindent-bodies)))
651        (setq outline-reindent-bodies nil)))        (setq allout-reindent-bodies nil)))
652  ;;;_   > set-outline-regexp ()  ;;;_   > set-allout-regexp ()
653  (defun set-outline-regexp ()  (defun set-allout-regexp ()
654    "Generate proper topic-header regexp form for outline functions.    "Generate proper topic-header regexp form for outline functions.
655    
656  Works with respect to `outline-plain-bullets-string' and  Works with respect to `allout-plain-bullets-string' and
657  `outline-distinctive-bullets-string'."  `allout-distinctive-bullets-string'."
658    
659    (interactive)    (interactive)
660    ;; Derive outline-bullets-string from user configured components:    ;; Derive allout-bullets-string from user configured components:
661    (setq outline-bullets-string "")    (setq allout-bullets-string "")
662    (let ((strings (list 'outline-plain-bullets-string    (let ((strings (list 'allout-plain-bullets-string
663                         'outline-distinctive-bullets-string                         'allout-distinctive-bullets-string
664                         'outline-primary-bullet))                         'allout-primary-bullet))
665          cur-string          cur-string
666          cur-len          cur-len
667          cur-char          cur-char
# Line 674  Works with respect to `outline-plain-bul Line 673  Works with respect to `outline-plain-bul
673        (setq cur-len (length (setq cur-string (symbol-value (car strings)))))        (setq cur-len (length (setq cur-string (symbol-value (car strings)))))
674        (while (< index cur-len)        (while (< index cur-len)
675          (setq cur-char (aref cur-string index))          (setq cur-char (aref cur-string index))
676          (setq outline-bullets-string          (setq allout-bullets-string
677                (concat outline-bullets-string                (concat allout-bullets-string
678                        (cond                        (cond
679                                          ; Single dash would denote a                                          ; Single dash would denote a
680                                          ; sequence, repeated denotes                                          ; sequence, repeated denotes
# Line 689  Works with respect to `outline-plain-bul Line 688  Works with respect to `outline-plain-bul
688          (setq index (1+ index)))          (setq index (1+ index)))
689        (setq strings (cdr strings)))        (setq strings (cdr strings)))
690      )      )
691    ;; Derive next for repeated use in outline-pending-bullet:    ;; Derive next for repeated use in allout-pending-bullet:
692    (setq outline-plain-bullets-string-len (length outline-plain-bullets-string))    (setq allout-plain-bullets-string-len (length allout-plain-bullets-string))
693    (setq outline-header-subtraction (1- (length outline-header-prefix)))    (setq allout-header-subtraction (1- (length allout-header-prefix)))
694    ;; Produce the new outline-regexp:    ;; Produce the new allout-regexp:
695    (setq outline-regexp (concat "\\(\\"    (setq allout-regexp (concat "\\(\\"
696                                 outline-header-prefix                                 allout-header-prefix
697                                 "[ \t]*["                                 "[ \t]*["
698                                 outline-bullets-string                                 allout-bullets-string
699                                 "]\\)\\|\\"                                 "]\\)\\|\\"
700                                 outline-primary-bullet                                 allout-primary-bullet
701                                 "+\\|\^l"))                                 "+\\|\^l"))
702    (setq outline-line-boundary-regexp    (setq allout-line-boundary-regexp
703          (concat "\\([\n\r]\\)\\(" outline-regexp "\\)"))          (concat "\\([\n\r]\\)\\(" allout-regexp "\\)"))
704    (setq outline-bob-regexp    (setq allout-bob-regexp
705          (concat "\\(\\`\\)\\(" outline-regexp "\\)"))          (concat "\\(\\`\\)\\(" allout-regexp "\\)"))
706    )    )
707  ;;;_  : Key bindings  ;;;_  : Key bindings
708  ;;;_   = outline-mode-map  ;;;_   = allout-mode-map
709  (defvar outline-mode-map nil "Keybindings for (allout) outline minor mode.")  (defvar allout-mode-map nil "Keybindings for (allout) outline minor mode.")
710  ;;;_   > produce-outline-mode-map (keymap-alist &optional base-map)  ;;;_   > produce-allout-mode-map (keymap-alist &optional base-map)
711  (defun produce-outline-mode-map (keymap-list &optional base-map)  (defun produce-allout-mode-map (keymap-list &optional base-map)
712    "Produce keymap for use as outline-mode-map, from keymap-list.    "Produce keymap for use as allout-mode-map, from keymap-list.
713    
714  Built on top of optional BASE-MAP, or empty sparse map if none specified.  Built on top of optional BASE-MAP, or empty sparse map if none specified.
715  See doc string for outline-keybindings-list for format of binding list."  See doc string for allout-keybindings-list for format of binding list."
716    (let ((map (or base-map (make-sparse-keymap)))    (let ((map (or base-map (make-sparse-keymap)))
717          (pref (list outline-command-prefix)))          (pref (list allout-command-prefix)))
718      (mapcar (function      (mapcar (function
719               (lambda (cell)               (lambda (cell)
720                 (let ((add-pref (null (cdr (cdr cell))))                 (let ((add-pref (null (cdr (cdr cell))))
# Line 728  See doc string for outline-keybindings-l Line 727  See doc string for outline-keybindings-l
727                                (car (cdr cell)))))))                                (car (cdr cell)))))))
728              keymap-list)              keymap-list)
729      map))      map))
730  ;;;_   = outline-prior-bindings - being deprecated.  ;;;_   = allout-prior-bindings - being deprecated.
731  (defvar outline-prior-bindings nil  (defvar allout-prior-bindings nil
732    "Variable for use in V18, with outline-added-bindings, for    "Variable for use in V18, with `allout-added-bindings', for
733  resurrecting, on mode deactivation, bindings that existed before  resurrecting, on mode deactivation, bindings that existed before
734  activation.  Being deprecated.")  activation.  Being deprecated.")
735  ;;;_   = outline-added-bindings - being deprecated  ;;;_   = allout-added-bindings - being deprecated
736  (defvar outline-added-bindings nil  (defvar allout-added-bindings nil
737    "Variable for use in V18, with outline-prior-bindings, for    "Variable for use in V18, with `allout-prior-bindings', for
738  resurrecting, on mode deactivation, bindings that existed before  resurrecting, on mode deactivation, bindings that existed before
739  activation.  Being deprecated.")  activation.  Being deprecated.")
740  ;;;_  : Menu bar  ;;;_  : Menu bar
741  (defun produce-outline-mode-menubar-entries ()  (defun produce-allout-mode-menubar-entries ()
742    (require 'easymenu)    (require 'easymenu)
743    (easy-menu-define outline-mode-exposure-menu    (easy-menu-define allout-mode-exposure-menu
744                      outline-mode-map                      allout-mode-map
745                      "Allout outline exposure menu."                      "Allout outline exposure menu."
746                      '("Exposure"                      '("Exposure"
747                        ["Show Entry" outline-show-current-entry t]                        ["Show Entry" allout-show-current-entry t]
748                        ["Show Children" outline-show-children t]                        ["Show Children" allout-show-children t]
749                        ["Show Subtree" outline-show-current-subtree t]                        ["Show Subtree" allout-show-current-subtree t]
750                        ["Hide Subtree" outline-hide-current-subtree t]                        ["Hide Subtree" allout-hide-current-subtree t]
751                        ["Hide Leaves" outline-hide-current-leaves t]                        ["Hide Leaves" allout-hide-current-leaves t]
752                        "----"                        "----"
753                        ["Show All" outline-show-all t]))                        ["Show All" allout-show-all t]))
754    (easy-menu-define outline-mode-editing-menu    (easy-menu-define allout-mode-editing-menu
755                      outline-mode-map                      allout-mode-map
756                      "Allout outline editing menu."                      "Allout outline editing menu."
757                      '("Headings"                      '("Headings"
758                        ["Open Sibling" outline-open-sibtopic t]                        ["Open Sibling" allout-open-sibtopic t]
759                        ["Open Subtopic" outline-open-subtopic t]                        ["Open Subtopic" allout-open-subtopic t]
760                        ["Open Supertopic" outline-open-supertopic t]                        ["Open Supertopic" allout-open-supertopic t]
761                        "----"                        "----"
762                        ["Shift Topic In" outline-shift-in t]                        ["Shift Topic In" allout-shift-in t]
763                        ["Shift Topic Out" outline-shift-out t]                        ["Shift Topic Out" allout-shift-out t]
764                        ["Rebullet Topic" outline-rebullet-topic t]                        ["Rebullet Topic" allout-rebullet-topic t]
765                        ["Rebullet Heading" outline-rebullet-current-heading t]                        ["Rebullet Heading" allout-rebullet-current-heading t]
766                        ["Number Siblings" outline-number-siblings t]))                        ["Number Siblings" allout-number-siblings t]))
767    (easy-menu-define outline-mode-navigation-menu    (easy-menu-define allout-mode-navigation-menu
768                      outline-mode-map                      allout-mode-map
769                      "Allout outline navigation menu."                      "Allout outline navigation menu."
770                      '("Navigation"                      '("Navigation"
771                        ["Next Visible Heading" outline-next-visible-heading t]                        ["Next Visible Heading" allout-next-visible-heading t]
772                        ["Previous Visible Heading"                        ["Previous Visible Heading"
773                         outline-previous-visible-heading t]                         allout-previous-visible-heading t]
774                        "----"                        "----"
775                        ["Up Level" outline-up-current-level t]                        ["Up Level" allout-up-current-level t]
776                        ["Forward Current Level" outline-forward-current-level t]                        ["Forward Current Level" allout-forward-current-level t]
777                        ["Backward Current Level"                        ["Backward Current Level"
778                         outline-backward-current-level t]                         allout-backward-current-level t]
779                        "----"                        "----"
780                        ["Beginning of Entry"                        ["Beginning of Entry"
781                         outline-beginning-of-current-entry t]                         allout-beginning-of-current-entry t]
782                        ["End of Entry" outline-end-of-current-entry t]                        ["End of Entry" allout-end-of-current-entry t]
783                        ["End of Subtree" outline-end-of-current-subtree t]))                        ["End of Subtree" allout-end-of-current-subtree t]))
784    (easy-menu-define outline-mode-misc-menu    (easy-menu-define allout-mode-misc-menu
785                      outline-mode-map                      allout-mode-map
786                      "Allout outlines miscellaneous bindings."                      "Allout outlines miscellaneous bindings."
787                      '("Misc"                      '("Misc"
788                        ["Version" outline-version t]                        ["Version" allout-version t]
789                        "----"                        "----"
790                        ["Duplicate Exposed" outline-copy-exposed-to-buffer t]                        ["Duplicate Exposed" allout-copy-exposed-to-buffer t]
791                        ["Duplicate Exposed, numbered"                        ["Duplicate Exposed, numbered"
792                         outline-flatten-exposed-to-buffer t]                         allout-flatten-exposed-to-buffer t]
793                        ["Duplicate Exposed, indented"                        ["Duplicate Exposed, indented"
794                         outline-indented-exposed-to-buffer t]                         allout-indented-exposed-to-buffer t]
795                        "----"                        "----"
796                        ["Set Header Lead" outline-reset-header-lead t]                        ["Set Header Lead" allout-reset-header-lead t]
797                        ["Set New Exposure" outline-expose-topic t])))                        ["Set New Exposure" allout-expose-topic t])))
798  ;;;_  : Mode-Specific Variable Maintenance Utilities  ;;;_  : Mode-Specific Variable Maintenance Utilities
799  ;;;_   = outline-mode-prior-settings  ;;;_   = allout-mode-prior-settings
800  (defvar outline-mode-prior-settings nil  (defvar allout-mode-prior-settings nil
801    "Internal outline mode use; settings to be resumed on mode deactivation.")    "Internal `allout-mode' use; settings to be resumed on mode deactivation.")
802  (make-variable-buffer-local 'outline-mode-prior-settings)  (make-variable-buffer-local 'allout-mode-prior-settings)
803  ;;;_   > outline-resumptions (name &optional value)  ;;;_   > allout-resumptions (name &optional value)
804  (defun outline-resumptions (name &optional value)  (defun allout-resumptions (name &optional value)
805    
806    "Registers or resumes settings over outline-mode activation/deactivation.    "Registers or resumes settings over `allout-mode' activation/deactivation.
807    
808  First arg is NAME of variable affected.  Optional second arg is list  First arg is NAME of variable affected.  Optional second arg is list
809  containing outline-mode-specific VALUE to be imposed on named  containing allout-mode-specific VALUE to be imposed on named
810  variable, and to be registered.  (It's a list so you can specify  variable, and to be registered.  (It's a list so you can specify
811  registrations of null values.)  If no value is specified, the  registrations of null values.)  If no value is specified, the
812  registered value is returned (encapsulated in the list, so the caller  registered value is returned (encapsulated in the list, so the caller
813  can distinguish nil vs no value), and the registration is popped  can distinguish nil vs no value), and the registration is popped
814  from the list."  from the list."
815    
816    (let ((on-list (assq name outline-mode-prior-settings))    (let ((on-list (assq name allout-mode-prior-settings))
817          prior-capsule                   ; By `capsule' i mean a list          prior-capsule                   ; By `capsule' i mean a list
818                                          ; containing a value, so we can                                          ; containing a value, so we can
819                                          ; distinguish nil from no value.                                          ; distinguish nil from no value.
# Line 827  from the list." Line 826  from the list."
826            (if on-list            (if on-list
827                nil       ; Already preserved prior value - don't mess with it.                nil       ; Already preserved prior value - don't mess with it.
828              ;; Register the old value, or nil if previously unbound:              ;; Register the old value, or nil if previously unbound:
829              (setq outline-mode-prior-settings              (setq allout-mode-prior-settings
830                    (cons (list name                    (cons (list name
831                                (if (boundp name) (list (symbol-value name))))                                (if (boundp name) (list (symbol-value name))))
832                          outline-mode-prior-settings)))                          allout-mode-prior-settings)))
833                                          ; And impose the new value, locally:                                          ; And impose the new value, locally:
834            (progn (make-local-variable name)            (progn (make-local-variable name)
835                   (set name (car value))))                   (set name (car value))))
# Line 849  from the list." Line 848  from the list."
848            (makunbound name))            ; Previously unbound - demolish var.            (makunbound name))            ; Previously unbound - demolish var.
849                                          ; Remove registration:                                          ; Remove registration:
850          (let (rebuild)          (let (rebuild)
851            (while outline-mode-prior-settings            (while allout-mode-prior-settings
852              (if (not (eq (car outline-mode-prior-settings)              (if (not (eq (car allout-mode-prior-settings)
853                           on-list))                           on-list))
854                  (setq rebuild                  (setq rebuild
855                        (cons (car outline-mode-prior-settings)                        (cons (car allout-mode-prior-settings)
856                              rebuild)))                              rebuild)))
857              (setq outline-mode-prior-settings              (setq allout-mode-prior-settings
858                    (cdr outline-mode-prior-settings)))                    (cdr allout-mode-prior-settings)))
859            (setq outline-mode-prior-settings rebuild)))))            (setq allout-mode-prior-settings rebuild)))))
860    )    )
861  ;;;_  : Mode-specific incidentals  ;;;_  : Mode-specific incidentals
862  ;;;_   = outline-during-write-cue nil  ;;;_   = allout-during-write-cue nil
863  (defvar outline-during-write-cue nil  (defvar allout-during-write-cue nil
864    "Used to inhibit outline change-protection during file write.    "Used to inhibit outline change-protection during file write.
865    
866  See also `outline-post-command-business', `outline-write-file-hook',  See also `allout-post-command-business', `allout-write-file-hook',
867  `outline-before-change-protect', and `outline-post-command-business'  `allout-before-change-protect', and `allout-post-command-business'
868  functions.")  functions.")
869  ;;;_   = outline-pre-was-isearching nil  ;;;_   = allout-pre-was-isearching nil
870  (defvar outline-pre-was-isearching nil  (defvar allout-pre-was-isearching nil
871    "Cue for isearch-dynamic-exposure mechanism, implemented in    "Cue for isearch-dynamic-exposure mechanism, implemented in
872  outline-pre- and -post-command-hooks.")  allout-pre- and -post-command-hooks.")
873  (make-variable-buffer-local 'outline-pre-was-isearching)  (make-variable-buffer-local 'allout-pre-was-isearching)
874  ;;;_   = outline-isearch-prior-pos nil  ;;;_   = allout-isearch-prior-pos nil
875  (defvar outline-isearch-prior-pos nil  (defvar allout-isearch-prior-pos nil
876    "Cue for isearch-dynamic-exposure tracking, used by outline-isearch-expose.")    "Cue for isearch-dynamic-exposure tracking, used by allout-isearch-expose.")
877  (make-variable-buffer-local 'outline-isearch-prior-pos)  (make-variable-buffer-local 'allout-isearch-prior-pos)
878  ;;;_   = outline-isearch-did-quit  ;;;_   = allout-isearch-did-quit
879  (defvar outline-isearch-did-quit nil  (defvar allout-isearch-did-quit nil
880    "Distinguishes isearch conclusion and cancellation.    "Distinguishes isearch conclusion and cancellation.
881    
882  Maintained by outline-isearch-abort \(which is wrapped around the real  Maintained by `allout-isearch-abort' \(which is wrapped around the real
883  isearch-abort), and monitored by outline-isearch-expose for action.")  isearch-abort), and monitored by `allout-isearch-expose' for action.")
884  (make-variable-buffer-local 'outline-isearch-did-quit)  (make-variable-buffer-local 'allout-isearch-did-quit)
885  ;;;_   = outline-override-protect nil  ;;;_   = allout-override-protect nil
886  (defvar outline-override-protect nil  (defvar allout-override-protect nil
887    "Used in outline-mode for regulate of concealed-text protection mechanism.    "Used in `allout-mode' for regulate of concealed-text protection mechanism.
888    
889  Allout outline mode regulates alteration of concealed text to protect  Allout outline mode regulates alteration of concealed text to protect
890  against inadvertent, unnoticed changes.  This is for use by specific,  against inadvertent, unnoticed changes.  This is for use by specific,
891  native outline functions to temporarily override that protection.  native outline functions to temporarily override that protection.
892  It's automatically reset to nil after every buffer modification.")  It's automatically reset to nil after every buffer modification.")
893  (make-variable-buffer-local 'outline-override-protect)  (make-variable-buffer-local 'allout-override-protect)
894  ;;;_   > outline-unprotected (expr)  ;;;_   > allout-unprotected (expr)
895  (defmacro outline-unprotected (expr)  (defmacro allout-unprotected (expr)
896    "Evaluate EXPRESSION with `outline-override-protect' let-bound `t'."    "Evaluate EXPRESSION with `allout-override-protect' let-bound `t'."
897    `(let ((outline-override-protect t))    `(let ((allout-override-protect t))
898       ,expr))       ,expr))
899  ;;;_   = outline-undo-aggregation  ;;;_   = allout-undo-aggregation
900  (defvar outline-undo-aggregation 30  (defvar allout-undo-aggregation 30
901    "Amount of successive self-insert actions to bunch together per undo.    "Amount of successive self-insert actions to bunch together per undo.
902    
903  This is purely a kludge variable, regulating the compensation for a bug in  This is purely a kludge variable, regulating the compensation for a bug in
904  the way that before-change-functions and undo interact.")  the way that before-change-functions and undo interact.")
905  (make-variable-buffer-local 'outline-undo-aggregation)  (make-variable-buffer-local 'allout-undo-aggregation)
906  ;;;_   = file-var-bug hack  ;;;_   = file-var-bug hack
907  (defvar outline-v18/19-file-var-hack nil  (defvar allout-v18/19-file-var-hack nil
908    "Horrible hack used to prevent invalid multiple triggering of outline    "Horrible hack used to prevent invalid multiple triggering of outline
909  mode from prop-line file-var activation.  Used by outline-mode function  mode from prop-line file-var activation.  Used by `allout-mode' function
910  to track repeats.")  to track repeats.")
911  ;;;_   > outline-write-file-hook ()  ;;;_   > allout-write-file-hook ()
912  (defun outline-write-file-hook ()  (defun allout-write-file-hook ()
913    "In outline mode, run as a local-write-file-hooks activity.    "In `allout-mode', run as a `local-write-file-hooks' activity.
914    
915  Currently just sets `outline-during-write-cue', so outline-change-protection  Currently just sets `allout-during-write-cue', so outline change-protection
916  knows to keep inactive during file write."  knows to keep inactive during file write."
917    (setq outline-during-write-cue t)    (setq allout-during-write-cue t)
918    nil)    nil)
919    
920  ;;;_ #2 Mode activation  ;;;_ #2 Mode activation
921  ;;;_  = outline-mode  ;;;_  = allout-mode
922  (defvar outline-mode () "Allout outline mode minor-mode flag.")  (defvar allout-mode () "Allout outline mode minor-mode flag.")
923  (make-variable-buffer-local 'outline-mode)  (make-variable-buffer-local 'allout-mode)
924  ;;;_  > outline-mode-p ()  ;;;_  > allout-mode-p ()
925  (defmacro outline-mode-p ()  (defmacro allout-mode-p ()
926    "Return t if outline-mode is active in current buffer."    "Return t if `allout-mode' is active in current buffer."
927    'outline-mode)    'allout-mode)
928  ;;;_  = outline-explicitly-deactivated  ;;;_  = allout-explicitly-deactivated
929  (defvar outline-explicitly-deactivated nil  (defvar allout-explicitly-deactivated nil
930    "Outline-mode was last deliberately deactivated.    "Non-nil if `allout-mode' was last deliberately deactivated.
931  So outline-post-command-business should not reactivate it...")  So `allout-post-command-business' should not reactivate it...")
932  (make-variable-buffer-local 'outline-explicitly-deactivated)  (make-variable-buffer-local 'allout-explicitly-deactivated)
933  ;;;_  > outline-init (&optional mode)  ;;;_  > allout-init (&optional mode)
934  (defun outline-init (&optional mode)  ;;;###autoload
935    "Prime outline-mode to enable/disable auto-activation, wrt `outline-layout'.  (defun allout-init (&optional mode)
936      "Prime `allout-mode' to enable/disable auto-activation, wrt `allout-layout'.
937    
938  MODE is one of the following symbols:  MODE is one of the following symbols:
939    
# Line 947  MODE is one of the following symbols: Line 947  MODE is one of the following symbols:
947    
948  Use this function to setup your emacs session for automatic activation  Use this function to setup your emacs session for automatic activation
949  of allout outline mode, contingent to the buffer-specific setting of  of allout outline mode, contingent to the buffer-specific setting of
950  the `outline-layout' variable.  (See `outline-layout' and  the `allout-layout' variable.  (See `allout-layout' and
951  `outline-expose-topic' docstrings for more details on auto layout).  `allout-expose-topic' docstrings for more details on auto layout).
952    
953  `outline-init' works by setting up (or removing) the outline-mode  `allout-init' works by setting up (or removing)
954  find-file-hook, and giving `outline-auto-activation' a suitable  `allout-find-file-hook' in `find-file-hooks', and giving
955  setting.  `allout-auto-activation' a suitable setting.
956    
957  To prime your emacs session for full auto-outline operation, include  To prime your emacs session for full auto-outline operation, include
958  the following two lines in your emacs init file:  the following two lines in your emacs init file:
959    
960  \(require 'allout)  \(require 'allout)
961  \(outline-init t)"  \(allout-init t)"
962    
963    (interactive)    (interactive)
964    (if (interactive-p)    (if (interactive-p)
# Line 976  the following two lines in your emacs in Line 976  the following two lines in your emacs in
976            (setq mode (intern-soft mode)))))            (setq mode (intern-soft mode)))))
977    (let    (let
978        ;; convenience aliases, for consistent ref to respective vars:        ;; convenience aliases, for consistent ref to respective vars:
979        ((hook 'outline-find-file-hook)        ((hook 'allout-find-file-hook)
980         (curr-mode 'outline-auto-activation))         (curr-mode 'allout-auto-activation))
981    
982      (cond ((not mode)      (cond ((not mode)
983             (setq find-file-hooks (delq hook find-file-hooks))             (setq find-file-hooks (delq hook find-file-hooks))
984             (if (interactive-p)             (if (interactive-p)
985                 (message "Allout outline mode auto-activation inhibited.")))                 (message "Allout outline mode auto-activation inhibited.")))
986            ((eq mode 'report)            ((eq mode 'report)
987             (if (not (memq hook find-file-hooks))             (if (memq hook find-file-hooks)
988                 (outline-init nil)                 ;; Just punt and use the reports from each of the modes:
989               ;; Just punt and use the reports from each of the modes:                 (allout-init (symbol-value curr-mode))
990               (outline-init (symbol-value curr-mode))))               (allout-init nil)
991                 (message "Allout outline mode auto-activation inhibited.")))
992            (t (add-hook 'find-file-hooks hook)            (t (add-hook 'find-file-hooks hook)
993               (set curr-mode             ; `set', not `setq'!               (set curr-mode             ; `set', not `setq'!
994                    (cond ((eq mode 'activate)                    (cond ((eq mode 'activate)
# Line 996  the following two lines in your emacs in Line 997  the following two lines in your emacs in
997                           'activate)                           'activate)
998                          ((eq mode 'report)                          ((eq mode 'report)
999                           ;; Return the current mode setting:                           ;; Return the current mode setting:
1000                           (outline-init mode))                           (allout-init mode))
1001                          ((eq mode 'ask)                          ((eq mode 'ask)
1002                           (message                           (message
1003                            (concat "Outline mode auto-activation and "                            (concat "Outline mode auto-activation and "
# Line 1005  the following two lines in your emacs in Line 1006  the following two lines in your emacs in
1006                          ((message                          ((message
1007                            "Outline mode auto-activation and -layout enabled.")                            "Outline mode auto-activation and -layout enabled.")
1008                           'full)))))))                           'full)))))))
1009                      
1010  ;;;_  > outline-setup-menubar ()  ;;;_  > allout-setup-menubar ()
1011  (defun outline-setup-menubar ()  (defun allout-setup-menubar ()
1012    "Populate the current buffer's menubar with allout outline-mode stuff."    "Populate the current buffer's menubar with `allout-mode' stuff."
1013    (let ((menus (list outline-mode-exposure-menu    (let ((menus (list allout-mode-exposure-menu
1014                       outline-mode-editing-menu                       allout-mode-editing-menu
1015                       outline-mode-navigation-menu                       allout-mode-navigation-menu
1016                       outline-mode-misc-menu))                       allout-mode-misc-menu))
1017          cur)          cur)
1018      (while menus      (while menus
1019        (setq cur (car menus)        (setq cur (car menus)
1020              menus (cdr menus))              menus (cdr menus))
1021        (easy-menu-add cur))))        (easy-menu-add cur))))
1022  ;;;_  > outline-mode (&optional toggle)  ;;;_  > allout-mode (&optional toggle)
1023  ;;;_   : Defun:  ;;;_   : Defun:
1024  (defun outline-mode (&optional toggle)  (defun allout-mode (&optional toggle)
1025  ;;;_    . Doc string:  ;;;_    . Doc string:
1026    "Toggle minor mode for controlling exposure and editing of text outlines.    "Toggle minor mode for controlling exposure and editing of text outlines.
1027    
1028  Optional arg forces mode to re-initialize iff arg is positive num or  Optional arg forces mode to re-initialize iff arg is positive num or
1029  symbol.  Allout outline mode always runs as a minor mode.  symbol.  Allout outline mode always runs as a minor mode.
1030    
1031  Allout outline mode provides extensive outline-oriented formatting and  Allout outline mode provides extensive outline oriented formatting and
1032  manipulation.  It enables structural editing of outlines, as well as  manipulation.  It enables structural editing of outlines, as well as
1033  navigation and exposure.  It also is specifically aimed at  navigation and exposure.  It also is specifically aimed at
1034  accommodating syntax-sensitive text like programming languages.  \(For  accommodating syntax-sensitive text like programming languages.  \(For
# Line 1041  In addition to outline navigation and ex Line 1042  In addition to outline navigation and ex
1042   - incremental search with dynamic exposure and reconcealment of hidden text   - incremental search with dynamic exposure and reconcealment of hidden text
1043   - automatic topic-number maintenance   - automatic topic-number maintenance
1044   - \"Hot-spot\" operation, for single-keystroke maneuvering and   - \"Hot-spot\" operation, for single-keystroke maneuvering and
1045      exposure control.  \(See the outline-mode docstring.)      exposure control.  \(See the allout-mode docstring.)
1046    
1047  and many other features.  and many other features.
1048    
1049  Below is a description of the bindings, and then explanation of  Below is a description of the bindings, and then explanation of
1050  special outline-mode features and terminology.  See also the outline  special `allout-mode' features and terminology.  See also the outline
1051  menubar additions for quick reference to many of the features, and see  menubar additions for quick reference to many of the features, and see
1052  the docstring of the variable `outline-init' for instructions on  the docstring of the variable `allout-init' for instructions on
1053  priming your emacs session for automatic activation of outline-mode.  priming your emacs session for automatic activation of `allout-mode'.
1054    
1055    
1056  The bindings are dictated by the `outline-keybindings-list' and  The bindings are dictated by the `allout-keybindings-list' and
1057  `outline-command-prefix' variables.  `allout-command-prefix' variables.
1058    
1059          Navigation:                                Exposure Control:          Navigation:                                Exposure Control:
1060          ----------                                 ----------------          ----------                                 ----------------
1061  C-c C-n outline-next-visible-heading     | C-c C-h outline-hide-current-subtree  C-c C-n allout-next-visible-heading     | C-c C-h allout-hide-current-subtree
1062  C-c C-p outline-previous-visible-heading | C-c C-i outline-show-children  C-c C-p allout-previous-visible-heading | C-c C-i allout-show-children
1063  C-c C-u outline-up-current-level         | C-c C-s outline-show-current-subtree  C-c C-u allout-up-current-level         | C-c C-s allout-show-current-subtree
1064  C-c C-f outline-forward-current-level    | C-c C-o outline-show-current-entry  C-c C-f allout-forward-current-level    | C-c C-o allout-show-current-entry
1065  C-c C-b outline-backward-current-level   | ^U C-c C-s outline-show-all  C-c C-b allout-backward-current-level   | ^U C-c C-s allout-show-all
1066  C-c C-e outline-end-of-current-entry     |         outline-hide-current-leaves  C-c C-e allout-end-of-current-entry     |          allout-hide-current-leaves
1067  C-c C-a outline-beginning-of-current-entry, alternately, goes to hot-spot  C-c C-a allout-beginning-of-current-entry, alternately, goes to hot-spot
1068    
1069          Topic Header Production:          Topic Header Production:
1070          -----------------------          -----------------------
1071  C-c<SP> outline-open-sibtopic   Create a new sibling after current topic.  C-c<SP> allout-open-sibtopic    Create a new sibling after current topic.
1072  C-c .   outline-open-subtopic   ... an offspring of current topic.  C-c .   allout-open-subtopic    ... an offspring of current topic.
1073  C-c ,   outline-open-supertopic ... a sibling of the current topic's parent.  C-c ,   allout-open-supertopic  ... a sibling of the current topic's parent.
1074    
1075          Topic Level and Prefix Adjustment:          Topic Level and Prefix Adjustment:
1076          ---------------------------------          ---------------------------------
1077  C-c >   outline-shift-in        Shift current topic and all offspring deeper.  C-c >   allout-shift-in Shift current topic and all offspring deeper.
1078  C-c <   outline-shift-out       ... less deep.  C-c <   allout-shift-out        ... less deep.
1079  C-c<CR> outline-rebullet-topic  Reconcile bullets of topic and its offspring  C-c<CR> allout-rebullet-topic   Reconcile bullets of topic and its offspring
1080                                  - distinctive bullets are not changed, others                                  - distinctive bullets are not changed, others
1081                                    alternated according to nesting depth.                                    alternated according to nesting depth.
1082  C-c b   outline-rebullet-current-heading Prompt for alternate bullet for  C-c b   allout-rebullet-current-heading Prompt for alternate bullet for
1083                                           current topic.                                           current topic.
1084  C-c #   outline-number-siblings Number bullets of topic and siblings - the  C-c #   allout-number-siblings  Number bullets of topic and siblings - the
1085                                  offspring are not affected.  With repeat                                  offspring are not affected.  With repeat
1086                                  count, revoke numbering.                                  count, revoke numbering.
1087    
1088          Topic-oriented Killing and Yanking:          Topic-oriented Killing and Yanking:
1089          ----------------------------------          ----------------------------------
1090  C-c C-k outline-kill-topic      Kill current topic, including offspring.  C-c C-k allout-kill-topic       Kill current topic, including offspring.
1091  C-k     outline-kill-line       Like kill-line, but reconciles numbering, etc.  C-k     allout-kill-line        Like kill-line, but reconciles numbering, etc.
1092  C-y     outline-yank            Yank, adjusting depth of yanked topic to  C-y     allout-yank             Yank, adjusting depth of yanked topic to
1093                                  depth of heading if yanking into bare topic                                  depth of heading if yanking into bare topic
1094                                  heading (ie, prefix sans text).                                  heading (ie, prefix sans text).
1095  M-y     outline-yank-pop        Is to outline-yank as yank-pop is to yank  M-y     allout-yank-pop Is to allout-yank as yank-pop is to yank
1096    
1097          Misc commands:          Misc commands:
1098          -------------          -------------
1099  M-x outlineify-sticky           Activate outline mode for current buffer,  M-x outlineify-sticky           Activate outline mode for current buffer,
1100                                  and establish a default file-var setting                                  and establish a default file-var setting
1101                                  for `outline-layout'.                                  for `allout-layout'.
1102  C-c C-SPC outline-mark-topic  C-c C-SPC allout-mark-topic
1103  C-c = c outline-copy-exposed-to-buffer  C-c = c allout-copy-exposed-to-buffer
1104                                  Duplicate outline, sans concealed text, to                                  Duplicate outline, sans concealed text, to
1105                                  buffer with name derived from derived from                                  buffer with name derived from derived from
1106                                  that of current buffer - \"*XXX exposed*\".                                  that of current buffer - \"*XXX exposed*\".
1107  C-c = p outline-flatten-exposed-to-buffer  C-c = p allout-flatten-exposed-to-buffer
1108                                  Like above 'copy-exposed', but convert topic                                  Like above 'copy-exposed', but convert topic
1109                                  prefixes to section.subsection... numeric                                  prefixes to section.subsection... numeric
1110                                  format.                                  format.
1111  ESC ESC (outline-init t)        Setup emacs session for outline mode  ESC ESC (allout-init t) Setup emacs session for outline mode
1112                                  auto-activation.                                  auto-activation.
1113    
1114                   HOT-SPOT Operation                   HOT-SPOT Operation
# Line 1115  ESC ESC (outline-init t)       Setup emacs ses Line 1116  ESC ESC (outline-init t)       Setup emacs ses
1116  Hot-spot operation provides a means for easy, single-keystroke outline  Hot-spot operation provides a means for easy, single-keystroke outline
1117  navigation and exposure control.  navigation and exposure control.
1118    
1119  \\<outline-mode-map>  \\<allout-mode-map>
1120  When the text cursor is positioned directly on the bullet character of  When the text cursor is positioned directly on the bullet character of
1121  a topic, regular characters (a to z) invoke the commands of the  a topic, regular characters (a to z) invoke the commands of the
1122  corresponding outline-mode keymap control chars.  For example, \"f\"  corresponding allout-mode keymap control chars.  For example, \"f\"
1123  would invoke the command typically bound to \"C-c C-f\"  would invoke the command typically bound to \"C-c C-f\"
1124  \(\\[outline-forward-current-level] `outline-forward-current-level').  \(\\[allout-forward-current-level] `allout-forward-current-level').
1125    
1126  Thus, by positioning the cursor on a topic bullet, you can execute  Thus, by positioning the cursor on a topic bullet, you can execute
1127  the outline navigation and manipulation commands with a single  the outline navigation and manipulation commands with a single
# Line 1128  keystroke.  Non-literal chars never get Line 1129  keystroke.  Non-literal chars never get
1129  you can use them to get away from the hot-spot, and back to normal  you can use them to get away from the hot-spot, and back to normal
1130  operation.  operation.
1131    
1132  Note that the command `outline-beginning-of-current-entry' \(\\[outline-beginning-of-current-entry]\)  Note that the command `allout-beginning-of-current-entry' \(\\[allout-beginning-of-current-entry]\)
1133  will move to the hot-spot when the cursor is already located at the  will move to the hot-spot when the cursor is already located at the
1134  beginning of the current entry, so you can simply hit \\[outline-beginning-of-current-entry]  beginning of the current entry, so you can simply hit \\[allout-beginning-of-current-entry]
1135  twice in a row to get to the hot-spot.  twice in a row to get to the hot-spot.
1136    
1137                              Terminology                              Terminology
# Line 1173  PREFIX: The leading text of a topic whic Line 1174  PREFIX: The leading text of a topic whic
1174  PREFIX-LEAD:  PREFIX-LEAD:
1175          The string at the beginning of a topic prefix, normally a `.'.          The string at the beginning of a topic prefix, normally a `.'.
1176          It can be customized by changing the setting of          It can be customized by changing the setting of
1177          `outline-header-prefix' and then reinitializing outline-mode.          `allout-header-prefix' and then reinitializing `allout-mode'.
1178    
1179          By setting the prefix-lead to the comment-string of a          By setting the prefix-lead to the comment-string of a
1180          programming language, you can embed outline-structuring in          programming language, you can embed outline structuring in
1181          program code without interfering with the language processing          program code without interfering with the language processing
1182          of that code.  See `outline-use-mode-specific-leader'          of that code.  See `allout-use-mode-specific-leader'
1183          docstring for more detail.          docstring for more detail.
1184  PREFIX-PADDING:  PREFIX-PADDING:
1185          Spaces or asterisks which separate the prefix-lead and the          Spaces or asterisks which separate the prefix-lead and the
1186          bullet, according to the depth of the topic.          bullet, according to the depth of the topic.
1187  BULLET: A character at the end of the topic prefix, it must be one of  BULLET: A character at the end of the topic prefix, it must be one of
1188          the characters listed on `outline-plain-bullets-string' or          the characters listed on `allout-plain-bullets-string' or
1189          `outline-distinctive-bullets-string'.  (See the documentation          `allout-distinctive-bullets-string'.  (See the documentation
1190          for these variables for more details.)  The default choice of          for these variables for more details.)  The default choice of
1191          bullet when generating varies in a cycle with the depth of the          bullet when generating varies in a cycle with the depth of the
1192          topic.          topic.
# Line 1208  OPEN:  A topic that is not closed, though Line 1209  OPEN:  A topic that is not closed, though
1209    (interactive "P")    (interactive "P")
1210    
1211    (let* ((active (and (not (equal major-mode 'outline))    (let* ((active (and (not (equal major-mode 'outline))
1212                       (outline-mode-p)))                       (allout-mode-p)))
1213                                         ; Massage universal-arg `toggle' val:                                         ; Massage universal-arg `toggle' val:
1214           (toggle (and toggle           (toggle (and toggle
1215                       (or (and (listp toggle)(car toggle))                       (or (and (listp toggle)(car toggle))
# Line 1220  OPEN:  A topic that is not closed, though Line 1221  OPEN:  A topic that is not closed, though
1221                                     (or (symbolp toggle)                                     (or (symbolp toggle)
1222                                         (and (natnump toggle)                                         (and (natnump toggle)
1223                                              (not (zerop toggle)))))))                                              (not (zerop toggle)))))))
1224           ;; outline-mode already called once during this complex command?           ;; allout-mode already called once during this complex command?
1225           (same-complex-command (eq outline-v18/19-file-var-hack           (same-complex-command (eq allout-v18/19-file-var-hack
1226                                    (car command-history)))                                    (car command-history)))
1227           do-layout           do-layout
1228           )           )
1229    
1230                                         ; See comments below re v19.18,.19 bug.                                         ; See comments below re v19.18,.19 bug.
1231      (setq outline-v18/19-file-var-hack (car command-history))      (setq allout-v18/19-file-var-hack (car command-history))
1232    
1233      (cond      (cond
1234    
# Line 1237  OPEN:  A topic that is not closed, though Line 1238  OPEN:  A topic that is not closed, though
1238       ;; off on second invocation, so we detect it as best we can, and       ;; off on second invocation, so we detect it as best we can, and
1239       ;; skip everything.       ;; skip everything.
1240       ((and same-complex-command         ; Still in same complex command       ((and same-complex-command         ; Still in same complex command
1241                                         ; as last time outline-mode invoked.                                          ; as last time `allout-mode' invoked.
1242            active                        ; Already activated.            active                        ; Already activated.
1243            (not explicit-activation)     ; Prop-line file-vars don't have args.            (not explicit-activation)     ; Prop-line file-vars don't have args.
1244            (string-match "^19.1[89]"     ; Bug only known to be in v19.18 and            (string-match "^19.1[89]"     ; Bug only known to be in v19.18 and
# Line 1251  OPEN:  A topic that is not closed, though Line 1252  OPEN:  A topic that is not closed, though
1252                                         ; requested, and either in                                         ; requested, and either in
1253                                         ; active state or *de*activation                                         ; active state or *de*activation
1254                                         ; specifically requested:                                         ; specifically requested:
1255        (setq outline-explicitly-deactivated t)        (setq allout-explicitly-deactivated t)
1256        (if (string-match "^18\." emacs-version)        (if (string-match "^18\." emacs-version)
1257                                         ; Revoke those keys that remain                                         ; Revoke those keys that remain
1258                                         ; as we set them:                                         ; as we set them:
# Line 1261  OPEN:  A topic that is not closed, though Line 1262  OPEN:  A topic that is not closed, though
1262                        (if (eq (lookup-key curr-loc (car cell))                        (if (eq (lookup-key curr-loc (car cell))
1263                                (car (cdr cell)))                                (car (cdr cell)))
1264                            (define-key curr-loc (car cell)                            (define-key curr-loc (car cell)
1265                              (assq (car cell) outline-prior-bindings)))))                              (assq (car cell) allout-prior-bindings)))))
1266                     outline-added-bindings)                     allout-added-bindings)
1267             (outline-resumptions 'outline-added-bindings)             (allout-resumptions 'allout-added-bindings)
1268             (outline-resumptions 'outline-prior-bindings)))             (allout-resumptions 'allout-prior-bindings)))
1269    
1270        (if outline-old-style-prefixes        (if allout-old-style-prefixes
1271            (progn            (progn
1272             (outline-resumptions 'outline-primary-bullet)             (allout-resumptions 'allout-primary-bullet)
1273             (outline-resumptions 'outline-old-style-prefixes)))             (allout-resumptions 'allout-old-style-prefixes)))
1274        (outline-resumptions 'selective-display)        (allout-resumptions 'selective-display)
1275        (if (and (boundp 'before-change-functions) before-change-functions)        (if (and (boundp 'before-change-functions) before-change-functions)
1276            (outline-resumptions 'before-change-functions))            (allout-resumptions 'before-change-functions))
1277        (setq local-write-file-hooks        (setq local-write-file-hooks
1278             (delq 'outline-write-file-hook             (delq 'allout-write-file-hook
1279                   local-write-file-hooks))                   local-write-file-hooks))
1280        (outline-resumptions 'paragraph-start)        (allout-resumptions 'paragraph-start)
1281        (outline-resumptions 'paragraph-separate)        (allout-resumptions 'paragraph-separate)
1282        (outline-resumptions (if (string-match "^18" emacs-version)        (allout-resumptions (if (string-match "^18" emacs-version)
1283                                'auto-fill-hook                                'auto-fill-hook
1284                              'auto-fill-function))                              'auto-fill-function))
1285        (outline-resumptions 'outline-former-auto-filler)        (allout-resumptions 'allout-former-auto-filler)
1286        (setq outline-mode nil))        (setq allout-mode nil))
1287    
1288       ;; Activation:       ;; Activation:
1289       ((not active)       ((not active)
1290        (setq outline-explicitly-deactivated nil)        (setq allout-explicitly-deactivated nil)
1291        (if outline-old-style-prefixes        (if allout-old-style-prefixes
1292            (progn                        ; Inhibit all the fancy formatting:            (progn                        ; Inhibit all the fancy formatting:
1293             (outline-resumptions 'outline-primary-bullet '("*"))             (allout-resumptions 'allout-primary-bullet '("*"))
1294             (outline-resumptions 'outline-old-style-prefixes '(()))))             (allout-resumptions 'allout-old-style-prefixes '(()))))
1295    
1296        (outline-infer-header-lead)        (allout-infer-header-lead)
1297        (outline-infer-body-reindent)        (allout-infer-body-reindent)
1298    
1299        (set-outline-regexp)        (set-allout-regexp)
1300    
1301                                         ; Produce map from current version                                         ; Produce map from current version
1302                                         ; of outline-keybindings-list:                                         ; of allout-keybindings-list:
1303        (if (boundp 'minor-mode-map-alist)        (if (boundp 'minor-mode-map-alist)
1304    
1305            (progn                        ; V19, and maybe lucid and            (progn                        ; V19, and maybe lucid and
1306                                         ; epoch, minor-mode key bindings:                                         ; epoch, minor-mode key bindings:
1307             (setq outline-mode-map             (setq allout-mode-map
1308                   (produce-outline-mode-map outline-keybindings-list))                   (produce-allout-mode-map allout-keybindings-list))
1309             (produce-outline-mode-menubar-entries)             (produce-allout-mode-menubar-entries)
1310             (fset 'outline-mode-map outline-mode-map)             (fset 'allout-mode-map allout-mode-map)
1311                                         ; Include on minor-mode-map-alist,                                         ; Include on minor-mode-map-alist,
1312                                         ; if not already there:                                         ; if not already there:
1313             (if (not (member '(outline-mode . outline-mode-map)             (if (not (member '(allout-mode . allout-mode-map)
1314                              minor-mode-map-alist))                              minor-mode-map-alist))
1315                 (setq minor-mode-map-alist                 (setq minor-mode-map-alist
1316                       (cons '(outline-mode . outline-mode-map)                       (cons '(allout-mode . allout-mode-map)
1317                             minor-mode-map-alist))))                             minor-mode-map-alist))))
1318    
1319                                         ; V18 minor-mode key bindings:                                         ; V18 minor-mode key bindings:
1320                                         ; Stash record of added bindings                                         ; Stash record of added bindings
1321                                         ; for later revocation:                                         ; for later revocation:
1322          (outline-resumptions 'outline-added-bindings          (allout-resumptions 'allout-added-bindings
1323                              (list outline-keybindings-list))                              (list allout-keybindings-list))
1324          (outline-resumptions 'outline-prior-bindings          (allout-resumptions 'allout-prior-bindings
1325                              (list (current-local-map)))                              (list (current-local-map)))
1326                                         ; and add them:                                         ; and add them:
1327          (use-local-map (produce-outline-mode-map outline-keybindings-list          (use-local-map (produce-allout-mode-map allout-keybindings-list
1328                                                  (current-local-map)))                                                  (current-local-map)))
1329          )          )
1330    
1331                                         ; selective-display is the                                         ; selective-display is the
1332                                         ; emacs conditional exposure                                         ; emacs conditional exposure
1333                                         ; mechanism:                                         ; mechanism:
1334        (outline-resumptions 'selective-display '(t))        (allout-resumptions 'selective-display '(t))
1335        (if outline-inhibit-protection        (if allout-inhibit-protection
1336            t            t
1337          (outline-resumptions 'before-change-functions          (allout-resumptions 'before-change-functions
1338                              '(outline-before-change-protect)))                              '(allout-before-change-protect)))
1339        (add-hook 'pre-command-hook 'outline-pre-command-business)        (add-hook 'pre-command-hook 'allout-pre-command-business)
1340        (add-hook 'post-command-hook 'outline-post-command-business)        (add-hook 'post-command-hook 'allout-post-command-business)
1341                                         ; Temporarily set by any outline                                         ; Temporarily set by any outline
1342                                         ; functions that can be trusted to                                         ; functions that can be trusted to
1343                                         ; deal properly with concealed text.                                         ; deal properly with concealed text.
1344        (add-hook 'local-write-file-hooks 'outline-write-file-hook)        (add-hook 'local-write-file-hooks 'allout-write-file-hook)
1345                                         ; Custom auto-fill func, to support                                         ; Custom auto-fill func, to support
1346                                         ; respect for topic headline,                                         ; respect for topic headline,
1347                                         ; hanging-indents, etc:                                         ; hanging-indents, etc:
# Line 1348  OPEN:  A topic that is not closed, though Line 1349  OPEN:  A topic that is not closed, though
1349                                 'auto-fill-hook                                 'auto-fill-hook
1350                               'auto-fill-function))                               'auto-fill-function))
1351              (fill-func (symbol-value fill-func-var)))              (fill-func (symbol-value fill-func-var)))
1352          ;; Register prevailing fill func for use by outline-auto-fill:          ;; Register prevailing fill func for use by allout-auto-fill:
1353          (outline-resumptions 'outline-former-auto-filler (list fill-func))          (allout-resumptions 'allout-former-auto-filler (list fill-func))
1354          ;; Register outline-auto-fill to be used if filling is active:          ;; Register allout-auto-fill to be used if filling is active:
1355          (outline-resumptions fill-func-var '(outline-auto-fill)))          (allout-resumptions fill-func-var '(allout-auto-fill)))
1356        ;; Paragraphs are broken by topic headlines.        ;; Paragraphs are broken by topic headlines.
1357        (make-local-variable 'paragraph-start)        (make-local-variable 'paragraph-start)
1358        (outline-resumptions 'paragraph-start        (allout-resumptions 'paragraph-start
1359                            (list (concat paragraph-start "\\|^\\("                            (list (concat paragraph-start "\\|^\\("
1360                                          outline-regexp "\\)")))                                          allout-regexp "\\)")))
1361        (make-local-variable 'paragraph-separate)        (make-local-variable 'paragraph-separate)
1362        (outline-resumptions 'paragraph-separate        (allout-resumptions 'paragraph-separate
1363                            (list (concat paragraph-separate "\\|^\\("                            (list (concat paragraph-separate "\\|^\\("
1364                                          outline-regexp "\\)")))                                          allout-regexp "\\)")))
1365    
1366        (or (assq 'outline-mode minor-mode-alist)        (or (assq 'allout-mode minor-mode-alist)
1367            (setq minor-mode-alist            (setq minor-mode-alist
1368                 (cons '(outline-mode " Outl") minor-mode-alist)))                 (cons '(allout-mode " Allout") minor-mode-alist)))
1369    
1370        (outline-setup-menubar)        (allout-setup-menubar)
1371    
1372        (if outline-layout        (if allout-layout
1373            (setq do-layout t))            (setq do-layout t))
1374    
1375        (if (and outline-isearch-dynamic-expose        (if (and allout-isearch-dynamic-expose
1376                 (not (fboundp 'outline-real-isearch-abort)))                 (not (fboundp 'allout-real-isearch-abort)))
1377            (outline-enwrap-isearch))            (allout-enwrap-isearch))
1378    
1379        (run-hooks 'outline-mode-hook)        (run-hooks 'allout-mode-hook)
1380        (setq outline-mode t))        (setq allout-mode t))
1381    
1382       ;; Reactivation:       ;; Reactivation:
1383       ((setq do-layout t)       ((setq do-layout t)
1384        (outline-infer-body-reindent))        (allout-infer-body-reindent))
1385       )                                  ; cond       )                                  ; cond
1386    
1387      (if (and do-layout      (if (and do-layout
1388               outline-auto-activation               allout-auto-activation
1389               (listp outline-layout)               (listp allout-layout)
1390               (and (not (eq outline-auto-activation 'activate))               (and (not (eq allout-auto-activation 'activate))
1391                    (if (eq outline-auto-activation 'ask)                    (if (eq allout-auto-activation 'ask)
1392                        (if (y-or-n-p (format "Expose %s with layout '%s'? "                        (if (y-or-n-p (format "Expose %s with layout '%s'? "
1393                                              (buffer-name)                                              (buffer-name)
1394                                              outline-layout))                                              allout-layout))
1395                            t                            t
1396                          (message "Skipped %s layout." (buffer-name))                          (message "Skipped %s layout." (buffer-name))
1397                          nil)                          nil)
# Line 1398  OPEN:  A topic that is not closed, though Line 1399  OPEN:  A topic that is not closed, though
1399          (save-excursion          (save-excursion
1400            (message "Adjusting '%s' exposure..." (buffer-name))            (message "Adjusting '%s' exposure..." (buffer-name))
1401            (goto-char 0)            (goto-char 0)
1402            (outline-this-or-next-heading)            (allout-this-or-next-heading)
1403            (condition-case err            (condition-case err
1404                (progn                (progn
1405                  (apply 'outline-expose-topic (list outline-layout))                  (apply 'allout-expose-topic (list allout-layout))
1406                  (message "Adjusting '%s' exposure... done." (buffer-name)))                  (message "Adjusting '%s' exposure... done." (buffer-name)))
1407              ;; Problem applying exposure - notify user, but don't              ;; Problem applying exposure - notify user, but don't
1408              ;; interrupt, eg, file visit:              ;; interrupt, eg, file visit:
1409              (error (message "%s" (car (cdr err)))              (error (message "%s" (car (cdr err)))
1410                     (sit-for 1)))))                     (sit-for 1)))))
1411      outline-mode      allout-mode
1412      )                                   ; let*      )                                   ; let*
1413    )                                     ; defun    )                                     ; defun
1414  ;;;_  > outline-minor-mode  ;;;_  > allout-minor-mode
1415  ;;; XXX released verion doesn't do this?  ;;; XXX released verion doesn't do this?
1416  (defalias 'outline-minor-mode 'outline-mode)  (defalias 'allout-minor-mode 'allout-mode)
1417    
1418  ;;;_ #3 Internal Position State-Tracking - "outline-recent-*" funcs  ;;;_ #3 Internal Position State-Tracking - "allout-recent-*" funcs
1419  ;;; All the basic outline functions that directly do string matches to  ;;; All the basic outline functions that directly do string matches to
1420  ;;; evaluate heading prefix location set the variables  ;;; evaluate heading prefix location set the variables
1421  ;;; `outline-recent-prefix-beginning'  and `outline-recent-prefix-end'  ;;; `allout-recent-prefix-beginning'  and `allout-recent-prefix-end'
1422  ;;; when successful.  Functions starting with `outline-recent-' all  ;;; when successful.  Functions starting with `allout-recent-' all
1423  ;;; use this state, providing the means to avoid redundant searches  ;;; use this state, providing the means to avoid redundant searches
1424  ;;; for just-established data.  This optimization can provide  ;;; for just-established data.  This optimization can provide
1425  ;;; significant speed improvement, but it must be employed carefully.  ;;; significant speed improvement, but it must be employed carefully.
1426  ;;;_  = outline-recent-prefix-beginning  ;;;_  = allout-recent-prefix-beginning
1427  (defvar outline-recent-prefix-beginning 0  (defvar allout-recent-prefix-beginning 0
1428    "Buffer point of the start of the last topic prefix encountered.")    "Buffer point of the start of the last topic prefix encountered.")
1429  (make-variable-buffer-local 'outline-recent-prefix-beginning)  (make-variable-buffer-local 'allout-recent-prefix-beginning)
1430  ;;;_  = outline-recent-prefix-end  ;;;_  = allout-recent-prefix-end
1431  (defvar outline-recent-prefix-end 0  (defvar allout-recent-prefix-end 0
1432    "Buffer point of the end of the last topic prefix encountered.")    "Buffer point of the end of the last topic prefix encountered.")
1433  (make-variable-buffer-local 'outline-recent-prefix-end)  (make-variable-buffer-local 'allout-recent-prefix-end)
1434  ;;;_  = outline-recent-end-of-subtree  ;;;_  = allout-recent-end-of-subtree
1435  (defvar outline-recent-end-of-subtree 0  (defvar allout-recent-end-of-subtree 0
1436    "Buffer point last returned by outline-end-of-current-subtree.")    "Buffer point last returned by `allout-end-of-current-subtree'.")
1437  (make-variable-buffer-local 'outline-recent-end-of-subtree)  (make-variable-buffer-local 'allout-recent-end-of-subtree)
1438  ;;;_  > outline-prefix-data (beg end)  ;;;_  > allout-prefix-data (beg end)
1439  (defmacro outline-prefix-data (beg end)  (defmacro allout-prefix-data (beg end)
1440    "Register outline-prefix state data - BEGINNING and END of prefix.    "Register allout-prefix state data - BEGINNING and END of prefix.
1441    
1442  For reference by `outline-recent' funcs.  Returns BEGINNING."  For reference by `allout-recent' funcs.  Returns BEGINNING."
1443    `(setq outline-recent-prefix-end ,end    `(setq allout-recent-prefix-end ,end
1444           outline-recent-prefix-beginning ,beg))           allout-recent-prefix-beginning ,beg))
1445  ;;;_  > outline-recent-depth ()  ;;;_  > allout-recent-depth ()
1446  (defmacro outline-recent-depth ()  (defmacro allout-recent-depth ()
1447    "Return depth of last heading encountered by an outline maneuvering function.    "Return depth of last heading encountered by an outline maneuvering function.
1448    
1449  All outline functions which directly do string matches to assess  All outline functions which directly do string matches to assess
1450  headings set the variables outline-recent-prefix-beginning and  headings set the variables `allout-recent-prefix-beginning' and
1451  outline-recent-prefix-end if successful.  This function uses those settings  `allout-recent-prefix-end' if successful.  This function uses those settings
1452  to return the current depth."  to return the current depth."
1453    
1454    '(max 1 (- outline-recent-prefix-end    '(max 1 (- allout-recent-prefix-end
1455               outline-recent-prefix-beginning               allout-recent-prefix-beginning
1456               outline-header-subtraction)))               allout-header-subtraction)))
1457  ;;;_  > outline-recent-prefix ()  ;;;_  > allout-recent-prefix ()
1458  (defmacro outline-recent-prefix ()  (defmacro allout-recent-prefix ()
1459    "Like outline-recent-depth, but returns text of last encountered prefix.    "Like `allout-recent-depth', but returns text of last encountered prefix.
1460    
1461  All outline functions which directly do string matches to assess  All outline functions which directly do string matches to assess
1462  headings set the variables outline-recent-prefix-beginning and  headings set the variables `allout-recent-prefix-beginning' and
1463  outline-recent-prefix-end if successful.  This function uses those settings  `allout-recent-prefix-end' if successful.  This function uses those settings
1464  to return the current depth."  to return the current depth."
1465    '(buffer-substring outline-recent-prefix-beginning    '(buffer-substring allout-recent-prefix-beginning
1466                       outline-recent-prefix-end))                       allout-recent-prefix-end))
1467  ;;;_  > outline-recent-bullet ()  ;;;_  > allout-recent-bullet ()
1468  (defmacro outline-recent-bullet ()  (defmacro allout-recent-bullet ()
1469    "Like outline-recent-prefix, but returns bullet of last encountered prefix.    "Like allout-recent-prefix, but returns bullet of last encountered prefix.
1470    
1471  All outline functions which directly do string matches to assess  All outline functions which directly do string matches to assess
1472  headings set the variables outline-recent-prefix-beginning and  headings set the variables `allout-recent-prefix-beginning' and
1473  outline-recent-prefix-end if successful.  This function uses those settings  `allout-recent-prefix-end' if successful.  This function uses those settings
1474  to return the current depth of the most recently matched topic."  to return the current depth of the most recently matched topic."
1475    '(buffer-substring (1- outline-recent-prefix-end)    '(buffer-substring (1- allout-recent-prefix-end)
1476                       outline-recent-prefix-end))                       allout-recent-prefix-end))
1477    
1478  ;;;_ #4 Navigation  ;;;_ #4 Navigation
1479    
1480  ;;;_  - Position Assessment  ;;;_  - Position Assessment
1481  ;;;_   : Location Predicates  ;;;_   : Location Predicates
1482  ;;;_    > outline-on-current-heading-p ()  ;;;_    > allout-on-current-heading-p ()
1483  (defun outline-on-current-heading-p ()  (defun allout-on-current-heading-p ()
1484    "Return non-nil if point is on current visible topics' header line.    "Return non-nil if point is on current visible topics' header line.
1485    
1486  Actually, returns prefix beginning point."  Actually, returns prefix beginning point."
1487    (save-excursion    (save-excursion
1488      (beginning-of-line)      (beginning-of-line)
1489      (and (looking-at outline-regexp)      (and (looking-at allout-regexp)
1490           (outline-prefix-data (match-beginning 0) (match-end 0)))))           (allout-prefix-data (match-beginning 0) (match-end 0)))))
1491  ;;;_    > outline-on-heading-p ()  ;;;_    > allout-on-heading-p ()
1492  (defalias 'outline-on-heading-p 'outline-on-current-heading-p)  (defalias 'allout-on-heading-p 'allout-on-current-heading-p)
1493  ;;;_    > outline-e-o-prefix-p ()  ;;;_    > allout-e-o-prefix-p ()
1494  (defun outline-e-o-prefix-p ()  (defun allout-e-o-prefix-p ()
1495    "True if point is located where current topic prefix ends, heading begins."    "True if point is located where current topic prefix ends, heading begins."
1496    (and (save-excursion (beginning-of-line)    (and (save-excursion (beginning-of-line)
1497                         (looking-at outline-regexp))                         (looking-at allout-regexp))
1498         (= (point)(save-excursion (outline-end-of-prefix)(point)))))         (= (point)(save-excursion (allout-end-of-prefix)(point)))))
1499  ;;;_    > outline-hidden-p ()  ;;;_    > allout-hidden-p ()
1500  (defmacro outline-hidden-p ()  (defmacro allout-hidden-p ()
1501    "True if point is in hidden text."    "True if point is in hidden text."
1502    '(save-excursion    '(save-excursion
1503       (and (re-search-backward "[\n\r]" () t)       (and (re-search-backward "[\n\r]" () t)
1504            (= ?\r (following-char)))))            (= ?\r (following-char)))))
1505  ;;;_    > outline-visible-p ()  ;;;_    > allout-visible-p ()
1506  (defmacro outline-visible-p ()  (defmacro allout-visible-p ()
1507    "True if point is not in hidden text."    "True if point is not in hidden text."
1508    (interactive)    (interactive)
1509    '(not (outline-hidden-p)))    '(not (allout-hidden-p)))
1510  ;;;_   : Location attributes  ;;;_   : Location attributes
1511  ;;;_    > outline-depth ()  ;;;_    > allout-depth ()
1512  (defsubst outline-depth ()  (defsubst allout-depth ()
1513    "Like outline-current-depth, but respects hidden as well as visible topics."    "Like `allout-current-depth', but respects hidden as well as visible topics."
1514    (save-excursion    (save-excursion
1515      (if (outline-goto-prefix)      (if (allout-goto-prefix)
1516          (outline-recent-depth)          (allout-recent-depth)
1517        (progn        (progn
1518          ;; Oops, no prefix, zero prefix data:          ;; Oops, no prefix, zero prefix data:
1519          (outline-prefix-data (point)(point))          (allout-prefix-data (point)(point))
1520          ;; ... and return 0:          ;; ... and return 0:
1521          0))))          0))))
1522  ;;;_    > outline-current-depth ()  ;;;_    > allout-current-depth ()
1523  (defmacro outline-current-depth ()  (defmacro allout-current-depth ()
1524    "Return nesting depth of visible topic most immediately containing point."    "Return nesting depth of visible topic most immediately containing point."
1525    '(save-excursion    '(save-excursion
1526       (if (outline-back-to-current-heading)       (if (allout-back-to-current-heading)
1527           (max 1           (max 1
1528                (- outline-recent-prefix-end                (- allout-recent-prefix-end
1529                   outline-recent-prefix-beginning                   allout-recent-prefix-beginning
1530                   outline-header-subtraction))                   allout-header-subtraction))
1531         0)))         0)))
1532  ;;;_    > outline-get-current-prefix ()  ;;;_    > allout-get-current-prefix ()
1533  (defun outline-get-current-prefix ()  (defun allout-get-current-prefix ()
1534    "Topic prefix of the current topic."    "Topic prefix of the current topic."
1535    (save-excursion    (save-excursion
1536      (if (outline-goto-prefix)      (if (allout-goto-prefix)
1537          (outline-recent-prefix))))          (allout-recent-prefix))))
1538  ;;;_    > outline-get-bullet ()  ;;;_    > allout-get-bullet ()
1539  (defun outline-get-bullet ()  (defun allout-get-bullet ()
1540    "Return bullet of containing topic (visible or not)."    "Return bullet of containing topic (visible or not)."
1541    (save-excursion    (save-excursion
1542      (and (outline-goto-prefix)      (and (allout-goto-prefix)
1543           (outline-recent-bullet))))           (allout-recent-bullet))))
1544  ;;;_    > outline-current-bullet ()  ;;;_    > allout-current-bullet ()
1545  (defun outline-current-bullet ()  (defun allout-current-bullet ()
1546    "Return bullet of current (visible) topic heading, or none if none found."    "Return bullet of current (visible) topic heading, or none if none found."
1547    (condition-case err    (condition-case err
1548        (save-excursion        (save-excursion
1549          (outline-back-to-current-heading)          (allout-back-to-current-heading)
1550          (buffer-substring (- outline-recent-prefix-end 1)          (buffer-substring (- allout-recent-prefix-end 1)
1551                            outline-recent-prefix-end))                            allout-recent-prefix-end))
1552      ;; Quick and dirty provision, ostensibly for missing bullet:      ;; Quick and dirty provision, ostensibly for missing bullet:
1553      ('args-out-of-range nil))      ('args-out-of-range nil))
1554    )    )
1555  ;;;_    > outline-get-prefix-bullet (prefix)  ;;;_    > allout-get-prefix-bullet (prefix)
1556  (defun outline-get-prefix-bullet (prefix)  (defun allout-get-prefix-bullet (prefix)
1557    "Return the bullet of the header prefix string PREFIX."    "Return the bullet of the header prefix string PREFIX."
1558    ;; Doesn't make sense if we're old-style prefixes, but this just    ;; Doesn't make sense if we're old-style prefixes, but this just
1559    ;; oughtn't be called then, so forget about it...    ;; oughtn't be called then, so forget about it...
1560    (if (string-match outline-regexp prefix)    (if (string-match allout-regexp prefix)
1561        (substring prefix (1- (match-end 0)) (match-end 0))))        (substring prefix (1- (match-end 0)) (match-end 0))))
1562  ;;;_    > outline-sibling-index (&optional depth)  ;;;_    > allout-sibling-index (&optional depth)
1563  (defun outline-sibling-index (&optional depth)  (defun allout-sibling-index (&optional depth)
1564    "Item number of this prospective topic among its siblings.    "Item number of this prospective topic among its siblings.
1565    
1566  If optional arg depth is greater than current depth, then we're  If optional arg depth is greater than current depth, then we're
# Line 1569  If less than this depth, ascend to that Line 1570  If less than this depth, ascend to that
1570    
1571    (save-excursion    (save-excursion
1572      (cond ((and depth (<= depth 0) 0))      (cond ((and depth (<= depth 0) 0))
1573            ((or (not depth) (= depth (outline-depth)))            ((or (not depth) (= depth (allout-depth)))
1574             (let ((index 1))             (let ((index 1))
1575               (while (outline-previous-sibling (outline-recent-depth) nil)               (while (allout-previous-sibling (allout-recent-depth) nil)
1576                 (setq index (1+ index)))                 (setq index (1+ index)))
1577               index))               index))
1578            ((< depth (outline-recent-depth))            ((< depth (allout-recent-depth))
1579             (outline-ascend-to-depth depth)             (allout-ascend-to-depth depth)
1580             (outline-sibling-index))             (allout-sibling-index))
1581            (0))))            (0))))
1582  ;;;_    > outline-topic-flat-index ()  ;;;_    > allout-topic-flat-index ()
1583  (defun outline-topic-flat-index ()  (defun allout-topic-flat-index ()
1584    "Return a list indicating point's numeric section.subsect.subsubsect...    "Return a list indicating point's numeric section.subsect.subsubsect...
1585  Outermost is first."  Outermost is first."
1586    (let* ((depth (outline-depth))    (let* ((depth (allout-depth))
1587           (next-index (outline-sibling-index depth))           (next-index (allout-sibling-index depth))
1588           (rev-sibls nil))           (rev-sibls nil))
1589      (while (> next-index 0)      (while (> next-index 0)
1590        (setq rev-sibls (cons next-index rev-sibls))        (setq rev-sibls (cons next-index rev-sibls))
1591        (setq depth (1- depth))        (setq depth (1- depth))
1592        (setq next-index (outline-sibling-index depth)))        (setq next-index (allout-sibling-index depth)))
1593      rev-sibls)      rev-sibls)
1594    )    )
1595    
1596  ;;;_  - Navigation macros  ;;;_  - Navigation macros
1597  ;;;_   > outline-next-heading ()  ;;;_   > allout-next-heading ()
1598  (defsubst outline-next-heading ()  (defsubst allout-next-heading ()
1599    "Move to the heading for the topic \(possibly invisible) before this one.    "Move to the heading for the topic \(possibly invisible) before this one.
1600    
1601  Returns the location of the heading, or nil if none found."  Returns the location of the heading, or nil if none found."
# Line 1602  Returns the location of the heading, or Line 1603  Returns the location of the heading, or
1603    (if (and (bobp) (not (eobp)))    (if (and (bobp) (not (eobp)))
1604         (forward-char 1))         (forward-char 1))
1605    
1606    (if (re-search-forward outline-line-boundary-regexp nil 0)    (if (re-search-forward allout-line-boundary-regexp nil 0)
1607        (outline-prefix-data              ; Got valid location state - set vars:        (allout-prefix-data               ; Got valid location state - set vars:
1608         (goto-char (or (match-beginning 2)         (goto-char (or (match-beginning 2)
1609                        outline-recent-prefix-beginning))                        allout-recent-prefix-beginning))
1610         (or (match-end 2) outline-recent-prefix-end))))         (or (match-end 2) allout-recent-prefix-end))))
1611  ;;;_   : outline-this-or-next-heading  ;;;_   : allout-this-or-next-heading
1612  (defun outline-this-or-next-heading ()  (defun allout-this-or-next-heading ()
1613    "Position cursor on current or next heading."    "Position cursor on current or next heading."
1614    ;; A throwaway non-macro that is defined after outline-next-heading    ;; A throwaway non-macro that is defined after allout-next-heading
1615    ;; and usable by outline-mode.    ;; and usable by allout-mode.
1616    (if (not (outline-goto-prefix)) (outline-next-heading)))    (if (not (allout-goto-prefix)) (allout-next-heading)))
1617  ;;;_   > outline-previous-heading ()  ;;;_   > allout-previous-heading ()
1618  (defmacro outline-previous-heading ()  (defmacro allout-previous-heading ()
1619    "Move to the prior \(possibly invisible) heading line.    "Move to the prior \(possibly invisible) heading line.
1620    
1621  Return the location of the beginning of the heading, or nil if not found."  Return the location of the beginning of the heading, or nil if not found."
1622    
1623    '(if (bobp)    '(if (bobp)
1624         nil         nil
1625       (outline-goto-prefix)       (allout-goto-prefix)
1626       (if       (if
1627           ;; searches are unbounded and return nil if failed:           ;; searches are unbounded and return nil if failed:
1628           (or (re-search-backward outline-line-boundary-regexp nil 0)           (or (re-search-backward allout-line-boundary-regexp nil 0)
1629               (looking-at outline-bob-regexp))               (looking-at allout-bob-regexp))
1630           (progn                         ; Got valid location state - set vars:           (progn                         ; Got valid location state - set vars:
1631             (outline-prefix-data             (allout-prefix-data
1632              (goto-char (or (match-beginning 2)              (goto-char (or (match-beginning 2)
1633                             outline-recent-prefix-beginning))                             allout-recent-prefix-beginning))
1634              (or (match-end 2) outline-recent-prefix-end))))))              (or (match-end 2) allout-recent-prefix-end))))))
1635    
1636  ;;;_  - Subtree Charting  ;;;_  - Subtree Charting
1637  ;;;_   " These routines either produce or assess charts, which are  ;;;_   " These routines either produce or assess charts, which are
# Line 1642  Return the location of the beginning of Line 1643  Return the location of the beginning of
1643  ;;; for assessment or adjustment of the subtree, without redundant  ;;; for assessment or adjustment of the subtree, without redundant
1644  ;;; traversal of the structure.  ;;; traversal of the structure.
1645    
1646  ;;;_   > outline-chart-subtree (&optional levels orig-depth prev-depth)  ;;;_   > allout-chart-subtree (&optional levels orig-depth prev-depth)
1647  (defun outline-chart-subtree (&optional levels orig-depth prev-depth)  (defun allout-chart-subtree (&optional levels orig-depth prev-depth)
1648    "Produce a location \"chart\" of subtopics of the containing topic.    "Produce a location \"chart\" of subtopics of the containing topic.
1649    
1650  Optional argument LEVELS specifies the depth \(relative to start  Optional argument LEVELS specifies the depth \(relative to start
1651  depth) for the chart.  Subsequent optional args are not for public  depth) for the chart.  Subsequent optional args are not for public
1652  use.  use.
1653    
1654  Charts are used to capture outline structure, so that outline-altering  Charts are used to capture outline structure, so that outline altering
1655  routines need assess the structure only once, and then use the chart  routines need assess the structure only once, and then use the chart
1656  for their elaborate manipulations.  for their elaborate manipulations.
1657    
# Line 1671  starting point, and PREV-DEPTH is depth Line 1672  starting point, and PREV-DEPTH is depth
1672      (if original                        ; Just starting?      (if original                        ; Just starting?
1673                                          ; Register initial settings and                                          ; Register initial settings and
1674                                          ; position to first offspring:                                          ; position to first offspring:
1675          (progn (setq orig-depth (outline-depth))          (progn (setq orig-depth (allout-depth))
1676                 (or prev-depth (setq prev-depth (1+ orig-depth)))                 (or prev-depth (setq prev-depth (1+ orig-depth)))
1677                 (outline-next-heading)))                 (allout-next-heading)))
1678    
1679      ;; Loop over the current levels' siblings.  Besides being more      ;; Loop over the current levels' siblings.  Besides being more
1680      ;; efficient than tail-recursing over a level, it avoids exceeding      ;; efficient than tail-recursing over a level, it avoids exceeding
# Line 1684  starting point, and PREV-DEPTH is depth Line 1685  starting point, and PREV-DEPTH is depth
1685    
1686      (while (and (not (eobp))      (while (and (not (eobp))
1687                                          ; Still within original topic?                                          ; Still within original topic?
1688                  (< orig-depth (setq curr-depth (outline-recent-depth)))                  (< orig-depth (setq curr-depth (allout-recent-depth)))
1689                  (cond ((= prev-depth curr-depth)                  (cond ((= prev-depth curr-depth)
1690                         ;; Register this one and move on:                         ;; Register this one and move on:
1691                         (setq chart (cons (point) chart))                         (setq chart (cons (point) chart))
1692                         (if (and levels (<= levels 1))                         (if (and levels (<= levels 1))
1693                             ;; At depth limit - skip sublevels:                             ;; At depth limit - skip sublevels:
1694                             (or (outline-next-sibling curr-depth)                             (or (allout-next-sibling curr-depth)
1695                                 ;; or no more siblings - proceed to                                 ;; or no more siblings - proceed to
1696                                 ;; next heading at lesser depth:                                 ;; next heading at lesser depth:
1697                                 (while (and (<= curr-depth                                 (while (and (<= curr-depth
1698                                                 (outline-recent-depth))                                                 (allout-recent-depth))
1699                                             (outline-next-heading))))                                             (allout-next-heading))))
1700                           (outline-next-heading)))                           (allout-next-heading)))
1701    
1702                        ((and (< prev-depth curr-depth)                        ((and (< prev-depth curr-depth)
1703                              (or (not levels)                              (or (not levels)
1704                                  (> levels 0)))                                  (> levels 0)))
1705                         ;; Recurse on deeper level of curr topic:                         ;; Recurse on deeper level of curr topic:
1706                         (setq chart                         (setq chart
1707                               (cons (outline-chart-subtree (and levels                               (cons (allout-chart-subtree (and levels
1708                                                                 (1- levels))                                                                 (1- levels))
1709                                                            orig-depth                                                            orig-depth
1710                                                            curr-depth)                                                            curr-depth)
# Line 1725  starting point, and PREV-DEPTH is depth Line 1726  starting point, and PREV-DEPTH is depth
1726                                  1)                                  1)
1727                            '(?\n ?\r))                            '(?\n ?\r))
1728                      (forward-char -1))                      (forward-char -1))
1729                 (setq outline-recent-end-of-subtree (point))))                 (setq allout-recent-end-of-subtree (point))))
1730    
1731      chart                               ; (nreverse chart) not necessary,      chart                               ; (nreverse chart) not necessary,
1732                                          ; and maybe not preferable.                                          ; and maybe not preferable.
1733      ))      ))
1734  ;;;_   > outline-chart-siblings (&optional start end)  ;;;_   > allout-chart-siblings (&optional start end)
1735  (defun outline-chart-siblings (&optional start end)  (defun allout-chart-siblings (&optional start end)
1736    "Produce a list of locations of this and succeeding sibling topics.    "Produce a list of locations of this and succeeding sibling topics.
1737  Effectively a top-level chart of siblings.  See `outline-chart-subtree'  Effectively a top-level chart of siblings.  See `allout-chart-subtree'
1738  for an explanation of charts."  for an explanation of charts."
1739    (save-excursion    (save-excursion
1740      (if (outline-goto-prefix)      (if (allout-goto-prefix)
1741          (let ((chart (list (point))))          (let ((chart (list (point))))
1742            (while (outline-next-sibling)            (while (allout-next-sibling)
1743              (setq chart (cons (point) chart)))              (setq chart (cons (point) chart)))
1744            (if chart (setq chart (nreverse chart)))))))            (if chart (setq chart (nreverse chart)))))))
1745  ;;;_   > outline-chart-to-reveal (chart depth)  ;;;_   > allout-chart-to-reveal (chart depth)
1746  (defun outline-chart-to-reveal (chart depth)  (defun allout-chart-to-reveal (chart depth)
1747    
1748    "Return a flat list of hidden points in subtree CHART, up to DEPTH.    "Return a flat list of hidden points in subtree CHART, up to DEPTH.
1749    
# Line 1754  start point." Line 1755  start point."
1755                  chart)                  chart)
1756        (setq here (car chart))        (setq here (car chart))
1757        (if (listp here)        (if (listp here)
1758            (let ((further (outline-chart-to-reveal here (or (eq depth t)            (let ((further (allout-chart-to-reveal here (or (eq depth t)
1759                                                             (1- depth)))))                                                             (1- depth)))))
1760              ;; We're on the start of a subtree - recurse with it, if there's              ;; We're on the start of a subtree - recurse with it, if there's
1761              ;; more depth to go:              ;; more depth to go:
# Line 1765  start point." Line 1766  start point."
1766              (setq result (cons here result)))              (setq result (cons here result)))
1767          (setq chart (cdr chart))))          (setq chart (cdr chart))))
1768      result))      result))
1769  ;;;_   X outline-chart-spec (chart spec &optional exposing)  ;;;_   X allout-chart-spec (chart spec &optional exposing)
1770  (defun outline-chart-spec (chart spec &optional exposing)  (defun allout-chart-spec (chart spec &optional exposing)
1771    "Not yet \(if ever) implemented.    "Not yet \(if ever) implemented.
1772    
1773  Produce exposure directives given topic/subtree CHART and an exposure SPEC.  Produce exposure directives given topic/subtree CHART and an exposure SPEC.
# Line 1798  exposed reside. Line 1799  exposed reside.
1799    )    )
1800    
1801  ;;;_  - Within Topic  ;;;_  - Within Topic
1802  ;;;_   > outline-goto-prefix ()  ;;;_   > allout-goto-prefix ()
1803  (defun outline-goto-prefix ()  (defun allout-goto-prefix ()
1804    "Put point at beginning of immediately containing outline topic.    "Put point at beginning of immediately containing outline topic.
1805    
1806  Goes to most immediate subsequent topic if none immediately containing.  Goes to most immediate subsequent topic if none immediately containing.
1807    
1808  Not sensitive to topic visibility.  Not sensitive to topic visibility.
1809    
1810  Returns a the point at the beginning of the prefix, or nil if none."  Returns the point at the beginning of the prefix, or nil if none."
1811    
1812    (let (done)    (let (done)
1813      (while (and (not done)      (while (and (not done)
1814                  (re-search-backward "[\n\r]" nil 1))                  (re-search-backward "[\n\r]" nil 1))
1815        (forward-char 1)        (forward-char 1)
1816        (if (looking-at outline-regexp)        (if (looking-at allout-regexp)
1817            (setq done (outline-prefix-data (match-beginning 0)            (setq done (allout-prefix-data (match-beginning 0)
1818                                            (match-end 0)))                                            (match-end 0)))
1819          (forward-char -1)))          (forward-char -1)))
1820      (if (bobp)      (if (bobp)
1821          (cond ((looking-at outline-regexp)          (cond ((looking-at allout-regexp)
1822                 (outline-prefix-data (match-beginning 0)(match-end 0)))                 (allout-prefix-data (match-beginning 0)(match-end 0)))
1823                ((outline-next-heading))                ((allout-next-heading))
1824                (done))                (done))
1825        done)))        done)))
1826  ;;;_   > outline-end-of-prefix ()  ;;;_   > allout-end-of-prefix ()
1827  (defun outline-end-of-prefix (&optional ignore-decorations)  (defun allout-end-of-prefix (&optional ignore-decorations)
1828    "Position cursor at beginning of header text.    "Position cursor at beginning of header text.
1829    
1830  If optional IGNORE-DECORATIONS is non-nil, put just after bullet,  If optional IGNORE-DECORATIONS is non-nil, put just after bullet,
1831  otherwise skip white space between bullet and ensuing text."  otherwise skip white space between bullet and ensuing text."
1832    
1833    (if (not (outline-goto-prefix))    (if (not (allout-goto-prefix))
1834        nil        nil
1835      (let ((match-data (match-data)))      (let ((match-data (match-data)))
1836        (goto-char (match-end 0))        (goto-char (match-end 0))
# Line 1839  otherwise skip white space between bulle Line 1840  otherwise skip white space between bulle
1840          (if (and (not (eolp)) (looking-at "\\s-")) (forward-char 1)))          (if (and (not (eolp)) (looking-at "\\s-")) (forward-char 1)))
1841        (store-match-data match-data))        (store-match-data match-data))
1842      ;; Reestablish where we are:      ;; Reestablish where we are:
1843      (outline-current-depth)))      (allout-current-depth)))
1844  ;;;_   > outline-current-bullet-pos ()  ;;;_   > allout-current-bullet-pos ()
1845  (defun outline-current-bullet-pos ()  (defun allout-current-bullet-pos ()
1846    "Return position of current \(visible) topic's bullet."    "Return position of current \(visible) topic's bullet."
1847    
1848   (if (not (outline-current-depth))   (if (not (allout-current-depth))
1849        nil        nil
1850     (1- (match-end 0))))     (1- (match-end 0))))
1851  ;;;_   > outline-back-to-current-heading ()  ;;;_   > allout-back-to-current-heading ()
1852  (defun outline-back-to-current-heading ()  (defun allout-back-to-current-heading ()
1853    "Move to heading line of current topic, or beginning if already on the line."    "Move to heading line of current topic, or beginning if already on the line."
1854    
1855    (beginning-of-line)    (beginning-of-line)
1856    (prog1 (or (outline-on-current-heading-p)    (prog1 (or (allout-on-current-heading-p)
1857               (and (re-search-backward (concat "^\\(" outline-regexp "\\)")               (and (re-search-backward (concat "^\\(" allout-regexp "\\)")
1858                                        nil                                        nil
1859                                        'move)                                        'move)
1860                    (outline-prefix-data (match-beginning 1)(match-end 1))))                    (allout-prefix-data (match-beginning 1)(match-end 1))))
1861      (if (interactive-p) (outline-end-of-prefix))))      (if (interactive-p) (allout-end-of-prefix))))
1862  ;;;_   > outline-back-to-heading ()  ;;;_   > allout-back-to-heading ()
1863  (defalias 'outline-back-to-heading 'outline-back-to-current-heading)  (defalias 'allout-back-to-heading 'allout-back-to-current-heading)
1864  ;;;_   > outline-pre-next-preface ()  ;;;_   > allout-pre-next-preface ()
1865  (defun outline-pre-next-preface ()  (defun allout-pre-next-preface ()
1866    "Skip forward to just before the next heading line.    "Skip forward to just before the next heading line.
1867    
1868  Returns that character position."  Returns that character position."
1869    
1870    (if (re-search-forward outline-line-boundary-regexp nil 'move)    (if (re-search-forward allout-line-boundary-regexp nil 'move)
1871        (prog1 (goto-char (match-beginning 0))        (prog1 (goto-char (match-beginning 0))
1872               (outline-prefix-data (match-beginning 2)(match-end 2)))))               (allout-prefix-data (match-beginning 2)(match-end 2)))))
1873  ;;;_   > outline-end-of-current-subtree ()  ;;;_   > allout-end-of-current-subtree ()
1874  (defun outline-end-of-current-subtree ()  (defun allout-end-of-current-subtree ()
1875    "Put point at the end of the last leaf in the currently visible topic."    "Put point at the end of the last leaf in the currently visible topic."
1876    (interactive)    (interactive)
1877    (outline-back-to-current-heading)    (allout-back-to-current-heading)
1878    (let ((level (outline-recent-depth)))    (let ((level (allout-recent-depth)))
1879      (outline-next-heading)      (allout-next-heading)
1880      (while (and (not (eobp))      (while (and (not (eobp))
1881                  (> (outline-recent-depth) level))                  (> (allout-recent-depth) level))
1882        (outline-next-heading))        (allout-next-heading))
1883      (and (not (eobp)) (forward-char -1))      (and (not (eobp)) (forward-char -1))
1884      (and (memq (preceding-char) '(?\n ?\r))      (and (memq (preceding-char) '(?\n ?\r))
1885           (memq (aref (buffer-substring (max 1 (- (point) 3)) (point)) 1)           (memq (aref (buffer-substring (max 1 (- (point) 3)) (point)) 1)
1886                 '(?\n ?\r))                 '(?\n ?\r))
1887           (forward-char -1))           (forward-char -1))
1888      (setq outline-recent-end-of-subtree (point))))      (setq allout-recent-end-of-subtree (point))))
1889  ;;;_   > outline-beginning-of-current-entry ()  ;;;_   > allout-beginning-of-current-entry ()
1890  (defun outline-beginning-of-current-entry ()  (defun allout-beginning-of-current-entry ()
1891    "When not already there, position point at beginning of current topic's body.    "When not already there, position point at beginning of current topic's body.
1892    
1893  If already there, move cursor to bullet for hot-spot operation.  If already there, move cursor to bullet for hot-spot operation.
1894  \(See outline-mode doc string for details on hot-spot operation.)"  \(See `allout-mode' doc string for details on hot-spot operation.)"
1895    (interactive)    (interactive)
1896    (let ((start-point (point)))    (let ((start-point (point)))
1897      (outline-end-of-prefix)      (allout-end-of-prefix)
1898      (if (and (interactive-p)      (if (and (interactive-p)
1899               (= (point) start-point))               (= (point) start-point))
1900          (goto-char (outline-current-bullet-pos)))))          (goto-char (allout-current-bullet-pos)))))
1901  ;;;_   > outline-end-of-current-entry ()  ;;;_   > allout-end-of-current-entry ()
1902  (defun outline-end-of-current-entry ()  (defun allout-end-of-current-entry ()
1903    "Position the point at the end of the current topics' entry."    "Position the point at the end of the current topics' entry."
1904    (interactive)    (interactive)
1905    (outline-show-entry)    (allout-show-entry)
1906    (prog1 (outline-pre-next-preface)    (prog1 (allout-pre-next-preface)
1907      (if (and (not (bobp))(looking-at "^$"))      (if (and (not (bobp))(looking-at "^$"))
1908          (forward-char -1))))          (forward-char -1))))
1909  ;;;_   > outline-end-of-current-heading ()  ;;;_   > allout-end-of-current-heading ()
1910  (defun outline-end-of-current-heading ()  (defun allout-end-of-current-heading ()
1911    (interactive)    (interactive)
1912    (outline-beginning-of-current-entry)    (allout-beginning-of-current-entry)
1913    (forward-line -1)    (forward-line -1)
1914    (end-of-line))    (end-of-line))
1915  (defalias 'outline-end-of-heading 'outline-end-of-current-heading)  (defalias 'allout-end-of-heading 'allout-end-of-current-heading)
1916    
1917  ;;;_  - Depth-wise  ;;;_  - Depth-wise
1918  ;;;_   > outline-ascend-to-depth (depth)  ;;;_   > allout-ascend-to-depth (depth)
1919  (defun outline-ascend-to-depth (depth)  (defun allout-ascend-to-depth (depth)
1920    "Ascend to depth DEPTH, returning depth if successful, nil if not."    "Ascend to depth DEPTH, returning depth if successful, nil if not."
1921    (if (and (> depth 0)(<= depth (outline-depth)))    (if (and (> depth 0)(<= depth (allout-depth)))
1922        (let ((last-good (point)))        (let ((last-good (point)))
1923          (while (and (< depth (outline-depth))          (while (and (< depth (allout-depth))
1924                      (setq last-good (point))                      (setq last-good (point))
1925                      (outline-beginning-of-level)                      (allout-beginning-of-level)
1926                      (outline-previous-heading)))                      (allout-previous-heading)))
1927          (if (= (outline-recent-depth) depth)          (if (= (allout-recent-depth) depth)
1928              (progn (goto-char outline-recent-prefix-beginning)              (progn (goto-char allout-recent-prefix-beginning)
1929                     depth)                     depth)
1930            (goto-char last-good)            (goto-char last-good)
1931            nil))            nil))
1932      (if (interactive-p) (outline-end-of-prefix))))      (if (interactive-p) (allout-end-of-prefix))))
1933  ;;;_   > outline-ascend ()  ;;;_   > allout-ascend ()
1934  (defun outline-ascend ()  (defun allout-ascend ()
1935    "Ascend one level, returning t if successful, nil if not."    "Ascend one level, returning t if successful, nil if not."
1936    (prog1    (prog1
1937        (if (outline-beginning-of-level)        (if (allout-beginning-of-level)
1938            (outline-previous-heading))            (allout-previous-heading))
1939      (if (interactive-p) (outline-end-of-prefix))))      (if (interactive-p) (allout-end-of-prefix))))
1940  ;;;_   > outline-descend-to-depth (depth)  ;;;_   > allout-descend-to-depth (depth)
1941  (defun outline-descend-to-depth (depth)  (defun allout-descend-to-depth (depth)
1942    "Descend to depth DEPTH within current topic.    "Descend to depth DEPTH within current topic.
1943    
1944  Returning depth if successful, nil if not."  Returning depth if successful, nil if not."
1945    (let ((start-point (point))    (let ((start-point (point))
1946          (start-depth (outline-depth)))          (start-depth (allout-depth)))
1947      (while      (while
1948          (and (> (outline-depth) 0)          (and (> (allout-depth) 0)
1949               (not (= depth (outline-recent-depth))) ; ... not there yet               (not (= depth (allout-recent-depth))) ; ... not there yet
1950               (outline-next-heading)     ; ... go further               (allout-next-heading)     ; ... go further
1951               (< start-depth (outline-recent-depth)))) ; ... still in topic               (< start-depth (allout-recent-depth)))) ; ... still in topic
1952      (if (and (> (outline-depth) 0)      (if (and (> (allout-depth) 0)
1953               (= (outline-recent-depth) depth))               (= (allout-recent-depth) depth))
1954          depth          depth
1955        (goto-char start-point)        (goto-char start-point)
1956        nil))        nil))
1957    )    )
1958  ;;;_   > outline-up-current-level (arg &optional dont-complain)  ;;;_   > allout-up-current-level (arg &optional dont-complain)
1959  (defun outline-up-current-level (arg &optional dont-complain)  (defun allout-up-current-level (arg &optional dont-complain)
1960    "Move out ARG levels from current visible topic.    "Move out ARG levels from current visible topic.
1961    
1962  Positions on heading line of containing topic.  Error if unable to  Positions on heading line of containing topic.  Error if unable to
1963  ascend that far, or nil if unable to ascend but optional arg  ascend that far, or nil if unable to ascend but optional arg
1964  DONT-COMPLAIN is non-nil."  DONT-COMPLAIN is non-nil."
1965    (interactive "p")    (interactive "p")
1966    (outline-back-to-current-heading)    (allout-back-to-current-heading)
1967    (let ((present-level (outline-recent-depth))    (let ((present-level (allout-recent-depth))
1968          (last-good (point))          (last-good (point))
1969          failed          failed
1970          return)          return)
1971      ;; Loop for iterating arg:      ;; Loop for iterating arg:
1972      (while (and (> (outline-recent-depth) 1)      (while (and (> (allout-recent-depth) 1)
1973                  (> arg 0)                  (> arg 0)
1974                  (not (bobp))                  (not (bobp))
1975                  (not failed))                  (not failed))
1976        (setq last-good (point))        (setq last-good (point))
1977        ;; Loop for going back over current or greater depth:        ;; Loop for going back over current or greater depth:
1978        (while (and (not (< (outline-recent-depth) present-level))        (while (and (not (< (allout-recent-depth) present-level))
1979                    (or (outline-previous-visible-heading 1)                    (or (allout-previous-visible-heading 1)
1980                        (not (setq failed present-level)))))                        (not (setq failed present-level)))))
1981        (setq present-level (outline-current-depth))        (setq present-level (allout-current-depth))
1982        (setq arg (- arg 1)))        (setq arg (- arg 1)))
1983      (if (or failed      (if (or failed
1984              (> arg 0))              (> arg 0))
1985          (progn (goto-char last-good)          (progn (goto-char last-good)
1986                 (if (interactive-p) (outline-end-of-prefix))                 (if (interactive-p) (allout-end-of-prefix))
1987                 (if (not dont-complain)                 (if (not dont-complain)
1988                     (error "Can't ascend past outermost level")                     (error "Can't ascend past outermost level")
1989                   (if (interactive-p) (outline-end-of-prefix))                   (if (interactive-p) (allout-end-of-prefix))
1990                   nil))                   nil))
1991        (if (interactive-p) (outline-end-of-prefix))        (if (interactive-p) (allout-end-of-prefix))
1992        outline-recent-prefix-beginning)))        allout-recent-prefix-beginning)))
1993    
1994  ;;;_  - Linear  ;;;_  - Linear
1995  ;;;_   > outline-next-sibling (&optional depth backward)  ;;;_   > allout-next-sibling (&optional depth backward)
1996  (defun outline-next-sibling (&optional depth backward)  (defun allout-next-sibling (&optional depth backward)
1997    "Like outline-forward-current-level, but respects invisible topics.    "Like `allout-forward-current-level', but respects invisible topics.
1998    
1999  Traverse at optional DEPTH, or current depth if none specified.  Traverse at optional DEPTH, or current depth if none specified.
2000    
# Line 2003  Return depth if successful, nil otherwis Line 2004  Return depth if successful, nil otherwis
2004    
2005    (if (and backward (bobp))    (if (and backward (bobp))
2006        nil        nil
2007      (let ((start-depth (or depth (outline-depth)))      (let ((start-depth (or depth (allout-depth)))
2008            (start-point (point))            (start-point (point))
2009            last-depth)            last-depth)
2010        (while (and (not (if backward (bobp) (eobp)))        (while (and (not (if backward (bobp) (eobp)))
2011                    (if backward (outline-previous-heading)                    (if backward (allout-previous-heading)
2012                      (outline-next-heading))                      (allout-next-heading))
2013                    (> (setq last-depth (outline-recent-depth)) start-depth)))                    (> (setq last-depth (allout-recent-depth)) start-depth)))
2014        (if (and (not (eobp))        (if (and (not (eobp))
2015                 (and (> (or last-depth (outline-depth)) 0)                 (and (> (or last-depth (allout-depth)) 0)
2016                      (= (outline-recent-depth) start-depth)))                      (= (allout-recent-depth) start-depth)))
2017            outline-recent-prefix-beginning            allout-recent-prefix-beginning
2018          (goto-char start-point)          (goto-char start-point)
2019          (if depth (outline-depth) start-depth)          (if depth (allout-depth) start-depth)
2020          nil))))          nil))))
2021  ;;;_   > outline-previous-sibling (&optional depth backward)  ;;;_   > allout-previous-sibling (&optional depth backward)
2022  (defun outline-previous-sibling (&optional depth backward)  (defun allout-previous-sibling (&optional depth backward)
2023    "Like outline-forward-current-level,but backwards & respect invisible topics.    "Like `allout-forward-current-level', but backwards & respect invisible topics.
2024    
2025  Optional DEPTH specifies depth to traverse, default current depth.  Optional DEPTH specifies depth to traverse, default current depth.
2026    
2027  Optional BACKWARD reverses direction.  Optional BACKWARD reverses direction.
2028    
2029  Return depth if successful, nil otherwise."  Return depth if successful, nil otherwise."
2030    (outline-next-sibling depth (not backward))    (allout-next-sibling depth (not backward))
2031    )    )
2032  ;;;_   > outline-snug-back ()  ;;;_   > allout-snug-back ()
2033  (defun outline-snug-back ()  (defun allout-snug-back ()
2034    "Position cursor at end of previous topic    "Position cursor at end of previous topic
2035    
2036  Presumes point is at the start of a topic prefix."  Presumes point is at the start of a topic prefix."
# Line 2042  Presumes point is at the start of a topi Line 2043  Presumes point is at the start of a topi
2043     (if (or (bobp) (not (memq (preceding-char) '(?\n ?\r))))     (if (or (bobp) (not (memq (preceding-char) '(?\n ?\r))))
2044         (forward-char -1)))         (forward-char -1)))
2045   (point))   (point))
2046  ;;;_   > outline-beginning-of-level ()  ;;;_   > allout-beginning-of-level ()
2047  (defun outline-beginning-of-level ()  (defun allout-beginning-of-level ()
2048    "Go back to the first sibling at this level, visible or not."    "Go back to the first sibling at this level, visible or not."
2049    (outline-end-of-level 'backward))    (allout-end-of-level 'backward))
2050  ;;;_   > outline-end-of-level (&optional backward)  ;;;_   > allout-end-of-level (&optional backward)
2051  (defun outline-end-of-level (&optional backward)  (defun allout-end-of-level (&optional backward)
2052    "Go to the last sibling at this level, visible or not."    "Go to the last sibling at this level, visible or not."
2053    
2054    (let ((depth (outline-depth)))    (let ((depth (allout-depth)))
2055      (while (outline-previous-sibling depth nil))      (while (allout-previous-sibling depth nil))
2056      (prog1 (outline-recent-depth)      (prog1 (allout-recent-depth)
2057        (if (interactive-p) (outline-end-of-prefix)))))        (if (interactive-p) (allout-end-of-prefix)))))
2058  ;;;_   > outline-next-visible-heading (arg)  ;;;_   > allout-next-visible-heading (arg)
2059  (defun outline-next-visible-heading (arg)  (defun allout-next-visible-heading (arg)
2060    "Move to the next ARG'th visible heading line, backward if arg is negative.    "Move to the next ARG'th visible heading line, backward if arg is negative.
2061    
2062  Move as far as possible in indicated direction \(beginning or end of  Move as far as possible in indicated direction \(beginning or end of
# Line 2071  buffer) if headings are exhausted." Line 2072  buffer) if headings are exhausted."
2072        (while (and (not (if backward (bobp)(eobp))) ; boundary condition        (while (and (not (if backward (bobp)(eobp))) ; boundary condition
2073                    ;; Move, skipping over all those concealed lines:                    ;; Move, skipping over all those concealed lines:
2074                    (< -1 (forward-line step))                    (< -1 (forward-line step))
2075                    (not (setq got (looking-at outline-regexp)))))                    (not (setq got (looking-at allout-regexp)))))
2076        ;; Register this got, it may be the last:        ;; Register this got, it may be the last:
2077        (if got (setq prev got))        (if got (setq prev got))
2078        (setq arg (1- arg)))        (setq arg (1- arg)))
2079      (cond (got                          ; Last move was to a prefix:      (cond (got                          ; Last move was to a prefix:
2080             (outline-prefix-data (match-beginning 0) (match-end 0))             (allout-prefix-data (match-beginning 0) (match-end 0))
2081             (outline-end-of-prefix))             (allout-end-of-prefix))
2082            (prev                         ; Last move wasn't, but prev was:            (prev                         ; Last move wasn't, but prev was:
2083             (outline-prefix-data (match-beginning 0) (match-end 0)))             (allout-prefix-data (match-beginning 0) (match-end 0)))
2084            ((not backward) (end-of-line) nil))))            ((not backward) (end-of-line) nil))))
2085  ;;;_   > outline-previous-visible-heading (arg)  ;;;_   > allout-previous-visible-heading (arg)
2086  (defun outline-previous-visible-heading (arg)  (defun allout-previous-visible-heading (arg)
2087    "Move to the previous heading line.    "Move to the previous heading line.
2088    
2089  With argument, repeats or can move forward if negative.  With argument, repeats or can move forward if negative.
2090  A heading line is one that starts with a `*' (or that outline-regexp  A heading line is one that starts with a `*' (or that `allout-regexp'
2091  matches)."  matches)."
2092    (interactive "p")    (interactive "p")
2093    (outline-next-visible-heading (- arg)))    (allout-next-visible-heading (- arg)))
2094  ;;;_   > outline-forward-current-level (arg)  ;;;_   > allout-forward-current-level (arg)
2095  (defun outline-forward-current-level (arg)  (defun allout-forward-current-level (arg)
2096    "Position point at the next heading of the same level.    "Position point at the next heading of the same level.
2097    
2098  Takes optional repeat-count, goes backward if count is negative.  Takes optional repeat-count, goes backward if count is negative.
2099    
2100  Returns resulting position, else nil if none found."  Returns resulting position, else nil if none found."
2101    (interactive "p")    (interactive "p")
2102    (let ((start-depth (outline-current-depth))    (let ((start-depth (allout-current-depth))
2103          (start-point (point))          (start-point (point))
2104          (start-arg arg)          (start-arg arg)
2105          (backward (> 0 arg))          (backward (> 0 arg))
# Line 2111  Returns resulting position, else nil if Line 2112  Returns resulting position, else nil if
2112      (while (not (or (zerop arg)      (while (not (or (zerop arg)
2113                      at-boundary))                      at-boundary))
2114        (while (and (not (if backward (bobp) (eobp)))        (while (and (not (if backward (bobp) (eobp)))
2115                    (if backward (outline-previous-visible-heading 1)                    (if backward (allout-previous-visible-heading 1)
2116                      (outline-next-visible-heading 1))                      (allout-next-visible-heading 1))
2117                    (> (setq last-depth (outline-recent-depth)) start-depth)))                    (> (setq last-depth (allout-recent-depth)) start-depth)))
2118        (if (and last-depth (= last-depth start-depth)        (if (and last-depth (= last-depth start-depth)
2119                 (not (if backward (bobp) (eobp))))                 (not (if backward (bobp) (eobp))))
2120            (setq last-good (point)            (setq last-good (point)
# Line 2121  Returns resulting position, else nil if Line 2122  Returns resulting position, else nil if
2122          (setq at-boundary t)))          (setq at-boundary t)))
2123      (if (and (not (eobp))      (if (and (not (eobp))
2124               (= arg 0)               (= arg 0)
2125               (and (> (or last-depth (outline-depth)) 0)               (and (> (or last-depth (allout-depth)) 0)
2126                    (= (outline-recent-depth) start-depth)))                    (= (allout-recent-depth) start-depth)))
2127          outline-recent-prefix-beginning          allout-recent-prefix-beginning
2128        (goto-char last-good)        (goto-char last-good)
2129        (if (not (interactive-p))        (if (not (interactive-p))
2130            nil            nil
2131          (outline-end-of-prefix)          (allout-end-of-prefix)
2132          (error "Hit %s level %d topic, traversed %d of %d requested"          (error "Hit %s level %d topic, traversed %d of %d requested"
2133                 (if backward "first" "last")                 (if backward "first" "last")
2134                 (outline-recent-depth)                 (allout-recent-depth)
2135                 (- (abs start-arg) arg)                 (- (abs start-arg) arg)
2136                 (abs start-arg))))))                 (abs start-arg))))))
2137  ;;;_   > outline-backward-current-level (arg)  ;;;_   > allout-backward-current-level (arg)
2138  (defun outline-backward-current-level (arg)  (defun allout-backward-current-level (arg)
2139    "Inverse of `outline-forward-current-level'."    "Inverse of `allout-forward-current-level'."
2140    (interactive "p")    (interactive "p")
2141    (if (interactive-p)    (if (interactive-p)
2142        (let ((current-prefix-arg (* -1 arg)))        (let ((current-prefix-arg (* -1 arg)))
2143          (call-interactively 'outline-forward-current-level))          (call-interactively 'allout-forward-current-level))
2144      (outline-forward-current-level (* -1 arg))))      (allout-forward-current-level (* -1 arg))))
2145    
2146  ;;;_ #5 Alteration  ;;;_ #5 Alteration
2147    
2148  ;;;_  - Fundamental  ;;;_  - Fundamental
2149  ;;;_   > outline-before-change-protect (beg end)  ;;;_   > allout-before-change-protect (beg end)
2150  (defun outline-before-change-protect (beg end)  (defun allout-before-change-protect (beg end)
2151    "Outline before-change hook, regulates changes to concealed text.    "Outline before-change hook, regulates changes to concealed text.
2152    
2153  Reveal concealed text that would be changed by current command, and  Reveal concealed text that would be changed by current command, and
# Line 2166  Locally bound in outline buffers to `bef Line 2167  Locally bound in outline buffers to `bef
2167  in emacs 19 is run before any change to the buffer.  in emacs 19 is run before any change to the buffer.
2168    
2169  Any functions which set [`this-command' to `undo', or which set]  Any functions which set [`this-command' to `undo', or which set]
2170  `outline-override-protect' non-nil (as does, eg, outline-flag-chars)  `allout-override-protect' non-nil (as does, eg, allout-flag-chars)
2171  are exempt from this restriction."  are exempt from this restriction."
2172    (if (and (outline-mode-p)    (if (and (allout-mode-p)
2173                                          ; outline-override-protect                                          ; allout-override-protect
2174                                          ; set by functions that know what                                          ; set by functions that know what
2175                                          ; they're doing, eg outline internals:                                          ; they're doing, eg outline internals:
2176             (not outline-override-protect)             (not allout-override-protect)
2177             (not outline-during-write-cue)             (not allout-during-write-cue)
2178             (save-match-data             ; Preserve operation position state.             (save-match-data             ; Preserve operation position state.
2179                                          ; Both beginning and end chars must                                          ; Both beginning and end chars must
2180                                          ; be exposed:                                          ; be exposed:
# Line 2183  are exempt from this restriction." Line 2184  are exempt from this restriction."
2184                                   (setq beg (1+ beg)                                   (setq beg (1+ beg)
2185                                         end (1+ end)))                                         end (1+ end)))
2186                               (goto-char beg)                               (goto-char beg)
2187                               (or (outline-hidden-p)                               (or (allout-hidden-p)
2188                                   (and (not (= beg end))                                   (and (not (= beg end))
2189                                        (goto-char end)                                        (goto-char end)
2190                                        (outline-hidden-p))))))                                        (allout-hidden-p))))))
2191        (save-match-data        (save-match-data
2192          (if (equal this-command 'undo)          (if (equal this-command 'undo)
2193                   ;; Allow undo without inhibition.                   ;; Allow undo without inhibition.
# Line 2197  are exempt from this restriction." Line 2198  are exempt from this restriction."
2198                   ;; - Undo may be users' only recourse in protection faults.                   ;; - Undo may be users' only recourse in protection faults.
2199                   ;; So, expose what getting changed:                   ;; So, expose what getting changed:
2200              (progn (message "Undo! - exposing concealed target...")              (progn (message "Undo! - exposing concealed target...")
2201                     (if (outline-hidden-p)                     (if (allout-hidden-p)
2202                         (outline-show-children))                         (allout-show-children))
2203                     (message "Undo!"))                     (message "Undo!"))
2204            (let (response            (let (response
2205                  (rehide-completely (save-excursion (outline-goto-prefix)                  (rehide-completely (save-excursion (allout-goto-prefix)
2206                                                     (outline-hidden-p)))                                                     (allout-hidden-p)))
2207                  rehide-place)                  rehide-place)
2208    
2209              (save-excursion              (save-excursion
# Line 2212  are exempt from this restriction." Line 2213  are exempt from this restriction."
2213                                          ; Give them a peek where                                          ; Give them a peek where
2214                          (save-excursion                          (save-excursion
2215                            (if (eolp) (setq rehide-place                            (if (eolp) (setq rehide-place
2216                                             (outline-goto-prefix)))                                             (allout-goto-prefix)))
2217                            (outline-show-entry))                            (allout-show-entry))
2218                                          ; Present the message, but...                                          ; Present the message, but...
2219                                          ; leave the cursor at the location                                          ; leave the cursor at the location
2220                                          ; until they respond:                                          ; until they respond:
# Line 2246  are exempt from this restriction." Line 2247  are exempt from this restriction."
2247                        (save-excursion                        (save-excursion
2248                          (if rehide-place (goto-char rehide-place))                          (if rehide-place (goto-char rehide-place))
2249                          (if rehide-completely                          (if rehide-completely
2250                              (outline-hide-current-entry-completely)                              (allout-hide-current-entry-completely)
2251                            (outline-hide-current-entry)))                            (allout-hide-current-entry)))
2252                      (if (outline-ascend-to-depth (1- (outline-recent-depth)))                      (if (allout-ascend-to-depth (1- (allout-recent-depth)))
2253                          (outline-show-children)                          (allout-show-children)
2254                        (outline-show-to-offshoot)))                        (allout-show-to-offshoot)))
2255                                          ; Prevent:                                          ; Prevent:
2256                  (if rehide-completely                  (if rehide-completely
2257                      (save-excursion                      (save-excursion
2258                        (if rehide-place (goto-char rehide-place))                        (if rehide-place (goto-char rehide-place))
2259                        (outline-hide-current-entry-completely))                        (allout-hide-current-entry-completely))
2260                    (outline-hide-current-entry))                    (allout-hide-current-entry))
2261                  (error (concat                  (error (concat
2262                          "Change within concealed region prevented.")))))))                          "Change within concealed region prevented.")))))))
2263      )   ; if      )   ; if
2264    )     ; defun    )     ; defun
2265  ;;;_   = outline-post-goto-bullet  ;;;_   = allout-post-goto-bullet
2266  (defvar outline-post-goto-bullet nil  (defvar allout-post-goto-bullet nil
2267    "Outline internal var, for `outline-pre-command-business' hot-spot operation.    "Outline internal var, for `allout-pre-command-business' hot-spot operation.
2268    
2269  When set, tells post-processing to reposition on topic bullet, and  When set, tells post-processing to reposition on topic bullet, and
2270  then unset it.  Set by outline-pre-command-business when implementing  then unset it.  Set by `allout-pre-command-business' when implementing
2271  hot-spot operation, where literal characters typed over a topic bullet  hot-spot operation, where literal characters typed over a topic bullet
2272  are mapped to the command of the corresponding control-key on the  are mapped to the command of the corresponding control-key on the
2273  outline-mode-map.")  `allout-mode-map'.")
2274  (make-variable-buffer-local 'outline-post-goto-bullet)  (make-variable-buffer-local 'allout-post-goto-bullet)
2275  ;;;_   > outline-post-command-business ()  ;;;_   > allout-post-command-business ()
2276  (defun outline-post-command-business ()  (defun allout-post-command-business ()
2277    "Outline post-command-hook function.    "Outline `post-command-hook' function.
2278    
2279  - Null outline-override-protect, so it's not left open.  - Null `allout-override-protect', so it's not left open.
2280    
2281  - Implement (and clear) outline-post-goto-bullet, for hot-spot  - Implement (and clear) `allout-post-goto-bullet', for hot-spot
2282    outline commands.    outline commands.
2283    
2284  - Massages buffer-undo-list so successive, standard character self-inserts are  - Massages buffer-undo-list so successive, standard character self-inserts are
2285    aggregated.  This kludge compensates for lack of undo bunching when    aggregated.  This kludge compensates for lack of undo bunching when
2286    before-change-functions is used."    `before-change-functions' is used."
2287    
2288                                          ; Apply any external change func:                                          ; Apply any external change func:
2289    (if (not (outline-mode-p))            ; In outline-mode.    (if (not (allout-mode-p))             ; In allout-mode.
2290        nil        nil
2291      (setq outline-override-protect nil)      (setq allout-override-protect nil)
2292      (if outline-isearch-dynamic-expose      (if allout-isearch-dynamic-expose
2293          (outline-isearch-rectification))          (allout-isearch-rectification))
2294      (if outline-during-write-cue      (if allout-during-write-cue
2295          ;; Was used by outline-before-change-protect, done with it now:          ;; Was used by allout-before-change-protect, done with it now:
2296          (setq outline-during-write-cue nil))          (setq allout-during-write-cue nil))
2297      ;; Undo bunching business:      ;; Undo bunching business:
2298      (if (and (listp buffer-undo-list)   ; Undo history being kept.      (if (and (listp buffer-undo-list)   ; Undo history being kept.
2299               (equal this-command 'self-insert-command)               (equal this-command 'self-insert-command)
# Line 2317  outline-mode-map.") Line 2318  outline-mode-map.")
2318                     (numberp (setq prev-from (car prev-cell)))                     (numberp (setq prev-from (car prev-cell)))
2319                     (numberp (setq prev-to (cdr prev-cell)))                     (numberp (setq prev-to (cdr prev-cell)))
2320                                          ; Below threshold:                                          ; Below threshold:
2321                     (> outline-undo-aggregation (- prev-to prev-from)))                     (> allout-undo-aggregation (- prev-to prev-from)))
2322                (setq buffer-undo-list                (setq buffer-undo-list
2323                      (cons (cons prev-from cur-to)                      (cons (cons prev-from cur-to)
2324                            (cdr (cdr (cdr buffer-undo-list))))))))                            (cdr (cdr (cdr buffer-undo-list))))))))
2325      ;; Implement -post-goto-bullet, if set: (must be after undo business)      ;; Implement -post-goto-bullet, if set: (must be after undo business)
2326      (if (and outline-post-goto-bullet      (if (and allout-post-goto-bullet
2327               (outline-current-bullet-pos))               (allout-current-bullet-pos))
2328          (progn (goto-char (outline-current-bullet-pos))          (progn (goto-char (allout-current-bullet-pos))
2329                 (setq outline-post-goto-bullet nil)))                 (setq allout-post-goto-bullet nil)))
2330      ))      ))
2331  ;;;_   > outline-pre-command-business ()  ;;;_   > allout-pre-command-business ()
2332  (defun outline-pre-command-business ()  (defun allout-pre-command-business ()
2333    "Outline pre-command-hook function for outline buffers.    "Outline `pre-command-hook' function for outline buffers.
2334  Implements special behavior when cursor is on bullet char.  Implements special behavior when cursor is on bullet character.
2335    
2336  Self-insert characters are reinterpreted control-character references  When the cursor is on the bullet character, self-insert characters are
2337  into the outline-mode-map.  The outline-mode post-command hook will  reinterpreted as the corresponding control-character in the
2338  position a cursor that has moved as a result of such reinterpretation,  `allout-mode-map'.  The `allout-mode' `post-command-hook' insures that
2339  on the destination topic's bullet, when the cursor wound up in the  the cursor which has moved as a result of such reinterpretation is
2340    positioned on the bullet character of the destination topic.
2341    
2342  The upshot is that you can get easy, single (ie, unmodified) key  The upshot is that you can get easy, single (ie, unmodified) key
2343  outline maneuvering operations by positioning the cursor on the bullet  outline maneuvering operations by positioning the cursor on the bullet
2344  char.  You stay in this mode until you use some regular  char.  When in this mode you can use regular cursor-positioning
2345  cursor-positioning command to relocate the cursor off of a bullet  command/keystrokes to relocate the cursor off of a bullet character to
2346  char."  return to regular interpretation of self-insert characters."
2347      (if (not (allout-mode-p))
2348    (if (not (outline-mode-p))        ;; Shouldn't be invoked if not in allout allout-mode, but just in case:
       ;; Shouldn't be invoked if not in allout outline-mode, but just in case:  
2349        nil        nil
2350      ;; Register isearch status:      ;; Register isearch status:
2351      (if (and (boundp  'isearch-mode) isearch-mode)      (if (and (boundp  'isearch-mode) isearch-mode)
2352          (setq outline-pre-was-isearching t)          (setq allout-pre-was-isearching t)
2353        (setq outline-pre-was-isearching nil))        (setq allout-pre-was-isearching nil))
2354      ;; Hot-spot navigation provisions:      ;; Hot-spot navigation provisions:
2355      (if (and (eq this-command 'self-insert-command)      (if (and (eq this-command 'self-insert-command)
2356               (eq (point)(outline-current-bullet-pos)))               (eq (point)(allout-current-bullet-pos)))
2357          (let* ((this-key-num (cond          (let* ((this-key-num (cond
2358                                ((numberp last-command-char)                                ((numberp last-command-char)
2359                                 last-command-char)                                 last-command-char)
# Line 2372  char." Line 2373  char."
2373              (if (and (<= 64 this-key-num)              (if (and (<= 64 this-key-num)
2374                       (>= 96 this-key-num))                       (>= 96 this-key-num))
2375                  (setq mapped-binding                  (setq mapped-binding
2376                        (lookup-key 'outline-mode-map                        (lookup-key 'allout-mode-map
2377                                    (concat outline-command-prefix                                    (concat allout-command-prefix
2378                                            (char-to-string (- this-key-num                                            (char-to-string (- this-key-num
2379                                                               64))))))                                                               64))))))
2380              (if mapped-binding              (if mapped-binding
2381                  (setq outline-post-goto-bullet t                  (setq allout-post-goto-bullet t
2382                        this-command mapped-binding)))))))                        this-command mapped-binding)))))))
2383  ;;;_   > outline-find-file-hook ()  ;;;_   > allout-find-file-hook ()
2384  (defun outline-find-file-hook ()  (defun allout-find-file-hook ()
2385    "Activate outline-mode when `outline-auto-activation' & `outline-layout' are non-nil.    "Activate `allout-mode' when `allout-auto-activation' & `allout-layout' are non-nil.
2386    
2387  See `outline-init' for setup instructions."  See `allout-init' for setup instructions."
2388    (if (and outline-auto-activation    (if (and allout-auto-activation
2389             (not (outline-mode-p))             (not (allout-mode-p))
2390             outline-layout)             allout-layout)
2391        (outline-mode t)))        (allout-mode t)))
2392  ;;;_   > outline-isearch-rectification  ;;;_   > allout-isearch-rectification
2393  (defun outline-isearch-rectification ()  (defun allout-isearch-rectification ()
2394    "Rectify outline exposure before, during, or after isearch.    "Rectify outline exposure before, during, or after isearch.
2395    
2396  Called as part of outline-post-command-business."  Called as part of `allout-post-command-business'."
2397    
2398    (let ((isearching (and (boundp 'isearch-mode) isearch-mode)))    (let ((isearching (and (boundp 'isearch-mode) isearch-mode)))
2399      (cond ((and isearching (not outline-pre-was-isearching))      (cond ((and isearching (not allout-pre-was-isearching))
2400             (outline-isearch-expose 'start))             (allout-isearch-expose 'start))
2401            ((and isearching outline-pre-was-isearching)            ((and isearching allout-pre-was-isearching)
2402             (outline-isearch-expose 'continue))             (allout-isearch-expose 'continue))
2403            ((and (not isearching) outline-pre-was-isearching)            ((and (not isearching) allout-pre-was-isearching)
2404             (outline-isearch-expose 'final))             (allout-isearch-expose 'final))
2405            ;; Not and wasn't isearching:            ;; Not and wasn't isearching:
2406            (t (setq outline-isearch-prior-pos nil)            (t (setq allout-isearch-prior-pos nil)
2407               (setq outline-isearch-did-quit nil)))))               (setq allout-isearch-did-quit nil)))))
2408  ;;;_   = outline-isearch-was-font-lock  ;;;_   = allout-isearch-was-font-lock
2409  (defvar outline-isearch-was-font-lock  (defvar allout-isearch-was-font-lock
2410    (and (boundp 'font-lock-mode) font-lock-mode))    (and (boundp 'font-lock-mode) font-lock-mode))
2411    
2412  ;;;_   > outline-flag-region (from to flag)  ;;;_   > allout-flag-region (from to flag)
2413  (defmacro outline-flag-region (from to flag)  (defmacro allout-flag-region (from to flag)
2414    "Hide or show lines from FROM to TO, via emacs selective-display FLAG char.    "Hide or show lines from FROM to TO, via emacs selective-display FLAG char.
2415  Ie, text following flag C-m \(carriage-return) is hidden until the  Ie, text following flag C-m \(carriage-return) is hidden until the
2416  next C-j (newline) char.  next C-j (newline) char.
2417    
2418  Returns the endpoint of the region."  Returns the endpoint of the region."
2419    `(let ((buffer-read-only nil)    `(let ((buffer-read-only nil)
2420             (outline-override-protect t))             (allout-override-protect t))
2421         (subst-char-in-region ,from ,to         (subst-char-in-region ,from ,to
2422                               (if (= ,flag ?\n) ?\r ?\n)                               (if (= ,flag ?\n) ?\r ?\n)
2423                               ,flag t)))                               ,flag t)))
2424    
2425  ;;;_   > outline-isearch-expose (mode)  ;;;_   > allout-isearch-expose (mode)
2426  (defun outline-isearch-expose (mode)  (defun allout-isearch-expose (mode)
2427    "Mode is either 'clear, 'start, 'continue, or 'final."    "Mode is either 'clear, 'start, 'continue, or 'final."
2428    ;; outline-isearch-prior-pos encodes exposure status of prior pos:    ;; allout-isearch-prior-pos encodes exposure status of prior pos:
2429    ;; (pos was-vis header-pos end-pos)    ;; (pos was-vis header-pos end-pos)
2430    ;; pos        - point of concern    ;; pos        - point of concern
2431    ;; was-vis    - t, else 'topic if entire topic was exposed, 'entry otherwise    ;; was-vis    - t, else 'topic if entire topic was exposed, 'entry otherwise
2432    ;; Do reclosure or prior pos, as necessary:    ;; Do reclosure or prior pos, as necessary:
2433    (if (eq mode 'start)    (if (eq mode 'start)
2434        (setq outline-isearch-was-font-lock (and (boundp 'font-lock-mode)        (setq allout-isearch-was-font-lock (and (boundp 'font-lock-mode)
2435                                                 font-lock-mode)                                                 font-lock-mode)
2436              font-lock-mode nil)              font-lock-mode nil)
2437      (if (eq mode 'final)      (if (eq mode 'final)
2438          (setq font-lock-mode outline-isearch-was-font-lock))          (setq font-lock-mode allout-isearch-was-font-lock))
2439      (if (and outline-isearch-prior-pos      (if (and allout-isearch-prior-pos
2440               (listp outline-isearch-prior-pos))               (listp allout-isearch-prior-pos))
2441          ;; Conceal prior peek:          ;; Conceal prior peek:
2442          (outline-flag-region (car (cdr outline-isearch-prior-pos))          (allout-flag-region (car (cdr allout-isearch-prior-pos))
2443                               (car (cdr (cdr outline-isearch-prior-pos)))                               (car (cdr (cdr allout-isearch-prior-pos)))
2444                               ?\r)))                               ?\r)))
2445    (if (outline-visible-p)    (if (allout-visible-p)
2446        (setq outline-isearch-prior-pos nil)        (setq allout-isearch-prior-pos nil)
2447      (if (not (eq mode 'final))      (if (not (eq mode 'final))
2448          (setq outline-isearch-prior-pos (cons (point) (outline-show-entry)))          (setq allout-isearch-prior-pos (cons (point) (allout-show-entry)))
2449        (if outline-isearch-did-quit        (if allout-isearch-did-quit
2450            nil            nil
2451          (setq outline-isearch-prior-pos nil)          (setq allout-isearch-prior-pos nil)
2452          (outline-show-children))))          (allout-show-children))))
2453    (setq outline-isearch-did-quit nil))    (setq allout-isearch-did-quit nil))
2454  ;;;_   > outline-enwrap-isearch ()  ;;;_   > allout-enwrap-isearch ()
2455  (defun outline-enwrap-isearch ()  (defun allout-enwrap-isearch ()
2456    "Impose outline-mode isearch-abort wrapper for dynamic exposure in isearch.    "Impose `allout-mode' isearch-abort wrapper for dynamic exposure in isearch.
2457    
2458  The function checks to ensure that the rebinding is done only once."  The function checks to ensure that the rebinding is done only once."
2459    
2460    (add-hook 'isearch-mode-end-hook 'outline-isearch-rectification)    (add-hook 'isearch-mode-end-hook 'allout-isearch-rectification)
2461    (if (fboundp 'outline-real-isearch-abort)    (if (fboundp 'allout-real-isearch-abort)
2462        ;;        ;;
2463        nil        nil
2464                                          ; Ensure load of isearch-mode:                                          ; Ensure load of isearch-mode:
2465      (if (or (and (fboundp 'isearch-mode)      (if (or (and (fboundp 'isearch-mode)
2466                   (fboundp 'isearch-abort))                   (fboundp 'isearch-abort))
2467              (condition-case error              (condition-case error
2468                  (load-library "isearch-mode")                  (load-library "isearch-mode")
2469                ('file-error (message                ('file-error (message
2470                              "Skipping isearch-mode provisions - %s '%s'"                              "Skipping isearch-mode provisions - %s '%s'"
# Line 2471  The function checks to ensure that the r Line 2472  The function checks to ensure that the r
2472                              (car (cdr (cdr error))))                              (car (cdr (cdr error))))
2473                             (sit-for 1)                             (sit-for 1)
2474                             ;; Inhibit subsequent tries and return nil:                             ;; Inhibit subsequent tries and return nil:
2475                             (setq outline-isearch-dynamic-expose nil))))                             (setq allout-isearch-dynamic-expose nil))))
2476          ;; Isearch-mode loaded, encapsulate specific entry points for          ;; Isearch-mode loaded, encapsulate specific entry points for
2477          ;; outline dynamic-exposure business:          ;; outline dynamic-exposure business:
2478          (progn          (progn
2479            ;; stash crucial isearch-mode funcs under known, private            ;; stash crucial isearch-mode funcs under known, private
2480            ;; names, then register wrapper functions under the old            ;; names, then register wrapper functions under the old
2481            ;; names, in their stead:            ;; names, in their stead:
2482            (fset 'outline-real-isearch-abort (symbol-function 'isearch-abort))            (fset 'allout-real-isearch-abort (symbol-function 'isearch-abort))
2483            (fset 'isearch-abort 'outline-isearch-abort)))))            (fset 'isearch-abort 'allout-isearch-abort)))))
2484  ;;;_   > outline-isearch-abort ()  ;;;_   > allout-isearch-abort ()
2485  (defun outline-isearch-abort ()  (defun allout-isearch-abort ()
2486    "Wrapper for outline-real-isearch-abort \(which see), to register    "Wrapper for `allout-real-isearch-abort' \(which see), to register
2487  actual quits."  actual quits."
2488    (interactive)    (interactive)
2489    (setq outline-isearch-did-quit nil)    (setq allout-isearch-did-quit nil)
2490    (condition-case what    (condition-case what
2491        (outline-real-isearch-abort)        (allout-real-isearch-abort)
2492      ('quit (setq outline-isearch-did-quit t)      ('quit (setq allout-isearch-did-quit t)
2493            (signal 'quit nil))))            (signal 'quit nil))))
2494    
2495  ;;; Prevent unnecessary font-lock while isearching!  ;;; Prevent unnecessary font-lock while isearching!
2496  (defvar isearch-was-font-locking nil)  (defvar isearch-was-font-locking nil)
2497  (defun isearch-inhibit-font-lock ()  (defun isearch-inhibit-font-lock ()
2498    "Inhibit font-lock while isearching - for use on isearch-mode-hook."    "Inhibit `font-lock-mode' while isearching - for use on `isearch-mode-hook'."
2499    (if (and (outline-mode-p) (boundp 'font-lock-mode) font-lock-mode)    (if (and (allout-mode-p) (boundp 'font-lock-mode) font-lock-mode)
2500        (setq isearch-was-font-locking t        (setq isearch-was-font-locking t
2501              font-lock-mode nil)))              font-lock-mode nil)))
2502  (add-hook 'isearch-mode-hook 'isearch-inhibit-font-lock)  (add-hook 'isearch-mode-hook 'isearch-inhibit-font-lock)
2503  (defun isearch-reenable-font-lock ()  (defun isearch-reenable-font-lock ()
2504    "Reenable font-lock after isearching - for use on isearch-mode-end-hook."    "Reenable font-lock after isearching - for use on isearch-mode-end-hook."
2505    (if (and (boundp 'font-lock-mode) font-lock-mode)    (if (and (boundp 'font-lock-mode) font-lock-mode)
2506        (if (and (outline-mode-p) isearch-was-font-locking)        (if (and (allout-mode-p) isearch-was-font-locking)
2507            (setq isearch-was-font-locking nil            (setq isearch-was-font-locking nil
2508                  font-lock-mode t))))                  font-lock-mode t))))
2509  (add-hook 'isearch-mode-end-hook 'isearch-reenable-font-lock)  (add-hook 'isearch-mode-end-hook 'isearch-reenable-font-lock)
2510    
2511  ;;;_  - Topic Format Assessment  ;;;_  - Topic Format Assessment
2512  ;;;_   > outline-solicit-alternate-bullet (depth &optional current-bullet)  ;;;_   > allout-solicit-alternate-bullet (depth &optional current-bullet)
2513  (defun outline-solicit-alternate-bullet (depth &optional current-bullet)  (defun allout-solicit-alternate-bullet (depth &optional current-bullet)
2514    
2515    "Prompt for and return a bullet char as an alternative to the current one.    "Prompt for and return a bullet char as an alternative to the current one.
2516    
2517  Offer one suitable for current depth DEPTH as default."  Offer one suitable for current depth DEPTH as default."
2518    
2519    (let* ((default-bullet (or (and (stringp current-bullet) current-bullet)    (let* ((default-bullet (or (and (stringp current-bullet) current-bullet)
2520                               (outline-bullet-for-depth depth)))                               (allout-bullet-for-depth depth)))
2521           (sans-escapes (regexp-sans-escapes outline-bullets-string))           (sans-escapes (regexp-sans-escapes allout-bullets-string))
2522           choice)           choice)
2523      (save-excursion      (save-excursion
2524        (goto-char (outline-current-bullet-pos))        (goto-char (allout-current-bullet-pos))
2525        (setq choice (solicit-char-in-string        (setq choice (solicit-char-in-string
2526                      (format "Select bullet: %s ('%s' default): "                      (format "Select bullet: %s ('%s' default): "
2527                              sans-escapes                              sans-escapes
# Line 2530  Offer one suitable for current depth DEP Line 2531  Offer one suitable for current depth DEP
2531      (message "")      (message "")
2532      (if (string= choice "") default-bullet choice))      (if (string= choice "") default-bullet choice))
2533    )    )
2534  ;;;_   > outline-distinctive-bullet (bullet)  ;;;_   > allout-distinctive-bullet (bullet)
2535  (defun outline-distinctive-bullet (bullet)  (defun allout-distinctive-bullet (bullet)
2536    "True if bullet is one of those on outline-distinctive-bullets-string."    "True if bullet is one of those on `allout-distinctive-bullets-string'."
2537    (string-match (regexp-quote bullet) outline-distinctive-bullets-string))    (string-match (regexp-quote bullet) allout-distinctive-bullets-string))
2538  ;;;_   > outline-numbered-type-prefix (&optional prefix)  ;;;_   > allout-numbered-type-prefix (&optional prefix)
2539  (defun outline-numbered-type-prefix (&optional prefix)  (defun allout-numbered-type-prefix (&optional prefix)
2540    "True if current header prefix bullet is numbered bullet."    "True if current header prefix bullet is numbered bullet."
2541    (and outline-numbered-bullet    (and allout-numbered-bullet
2542          (string= outline-numbered-bullet          (string= allout-numbered-bullet
2543                   (if prefix                   (if prefix
2544                       (outline-get-prefix-bullet prefix)                       (allout-get-prefix-bullet prefix)
2545                     (outline-get-bullet)))))                     (allout-get-bullet)))))
2546  ;;;_   > outline-bullet-for-depth (&optional depth)  ;;;_   > allout-bullet-for-depth (&optional depth)
2547  (defun outline-bullet-for-depth (&optional depth)  (defun allout-bullet-for-depth (&optional depth)
2548    "Return outline topic bullet suited to optional DEPTH, or current depth."    "Return outline topic bullet suited to optional DEPTH, or current depth."
2549    ;; Find bullet in plain-bullets-string modulo DEPTH.    ;; Find bullet in plain-bullets-string modulo DEPTH.
2550    (if outline-stylish-prefixes    (if allout-stylish-prefixes
2551        (char-to-string (aref outline-plain-bullets-string        (char-to-string (aref allout-plain-bullets-string
2552                              (% (max 0 (- depth 2))                              (% (max 0 (- depth 2))
2553                                 outline-plain-bullets-string-len)))                                 allout-plain-bullets-string-len)))
2554      outline-primary-bullet)      allout-primary-bullet)
2555    )    )
2556    
2557  ;;;_  - Topic Production  ;;;_  - Topic Production
2558  ;;;_   > outline-make-topic-prefix (&optional prior-bullet  ;;;_   > allout-make-topic-prefix (&optional prior-bullet
2559  (defun outline-make-topic-prefix (&optional prior-bullet  (defun allout-make-topic-prefix (&optional prior-bullet
2560                                              new                                              new
2561                                              depth                                              depth
2562                                              solicit                                              solicit
# Line 2572  All the arguments are optional. Line 2573  All the arguments are optional.
2573    
2574  PRIOR-BULLET indicates the bullet of the prefix being changed, or  PRIOR-BULLET indicates the bullet of the prefix being changed, or
2575  nil if none.  This bullet may be preserved (other options  nil if none.  This bullet may be preserved (other options
2576  notwithstanding) if it is on the outline-distinctive-bullets-string,  notwithstanding) if it is on the `allout-distinctive-bullets-string',
2577  for instance.  for instance.
2578    
2579  Second arg NEW indicates that a new topic is being opened after the  Second arg NEW indicates that a new topic is being opened after the
# Line 2592  distinction or depth) is offered.  \(Thi Line 2593  distinction or depth) is offered.  \(Thi
2593  including, eg, a distinctive PRIOR-BULLET.)  If non-nil, then the  including, eg, a distinctive PRIOR-BULLET.)  If non-nil, then the
2594  context-specific bullet is used.  context-specific bullet is used.
2595    
2596  Fifth arg, NUMBER-CONTROL, matters only if `outline-numbered-bullet'  Fifth arg, NUMBER-CONTROL, matters only if `allout-numbered-bullet'
2597  is non-nil *and* soliciting was not explicitly invoked.  Then  is non-nil *and* soliciting was not explicitly invoked.  Then
2598  NUMBER-CONTROL non-nil forces prefix to either numbered or  NUMBER-CONTROL non-nil forces prefix to either numbered or
2599  denumbered format, depending on the value of the sixth arg, INDEX.  denumbered format, depending on the value of the sixth arg, INDEX.
# Line 2618  index for each successive sibling)." Line 2619  index for each successive sibling)."
2619    (let* (body    (let* (body
2620           numbering           numbering
2621           denumbering           denumbering
2622           (depth (or depth (outline-depth)))           (depth (or depth (allout-depth)))
2623           (header-lead outline-header-prefix)           (header-lead allout-header-prefix)
2624           (bullet-char           (bullet-char
2625    
2626            ;; Getting value for bullet char is practically the whole job:            ;; Getting value for bullet char is practically the whole job:
2627    
2628            (cond            (cond
2629                                          ; Simplest situation - level 1:                                          ; Simplest situation - level 1:
2630             ((<= depth 1) (setq header-lead "") outline-primary-bullet)             ((<= depth 1) (setq header-lead "") allout-primary-bullet)
2631                                          ; Simple, too: all asterisks:                                          ; Simple, too: all asterisks:
2632             (outline-old-style-prefixes             (allout-old-style-prefixes
2633              ;; Cheat - make body the whole thing, null out header-lead and              ;; Cheat - make body the whole thing, null out header-lead and
2634              ;; bullet-char:              ;; bullet-char:
2635              (setq body (make-string depth              (setq body (make-string depth
2636                                      (string-to-char outline-primary-bullet)))                                      (string-to-char allout-primary-bullet)))
2637              (setq header-lead "")              (setq header-lead "")
2638              "")              "")
2639    
# Line 2643  index for each successive sibling)." Line 2644  index for each successive sibling)."
2644             ((progn (setq body (make-string (- depth 2) ?\ ))             ((progn (setq body (make-string (- depth 2) ?\ ))
2645                     ;; The actual condition:                     ;; The actual condition:
2646                     solicit)                     solicit)
2647              (let* ((got (outline-solicit-alternate-bullet depth solicit)))              (let* ((got (allout-solicit-alternate-bullet depth solicit)))
2648                ;; Gotta check whether we're numbering and got a numbered bullet:                ;; Gotta check whether we're numbering and got a numbered bullet:
2649                (setq numbering (and outline-numbered-bullet                (setq numbering (and allout-numbered-bullet
2650                                     (not (and number-control (not index)))                                     (not (and number-control (not index)))
2651                                     (string= got outline-numbered-bullet)))                                     (string= got allout-numbered-bullet)))
2652                ;; Now return what we got, regardless:                ;; Now return what we got, regardless:
2653                got))                got))
2654    
2655             ;; Numbering invoked through args:             ;; Numbering invoked through args:
2656             ((and outline-numbered-bullet number-control)             ((and allout-numbered-bullet number-control)
2657              (if (setq numbering (not (setq denumbering (not index))))              (if (setq numbering (not (setq denumbering (not index))))
2658                  outline-numbered-bullet                  allout-numbered-bullet
2659                (if (and prior-bullet                (if (and prior-bullet
2660                         (not (string= outline-numbered-bullet                         (not (string= allout-numbered-bullet
2661                                       prior-bullet)))                                       prior-bullet)))
2662                    prior-bullet                    prior-bullet
2663                  (outline-bullet-for-depth depth))))                  (allout-bullet-for-depth depth))))
2664    
2665            ;;; Neither soliciting nor controlled numbering ;;;            ;;; Neither soliciting nor controlled numbering ;;;
2666               ;;; (may be controlled denumbering, tho) ;;;               ;;; (may be controlled denumbering, tho) ;;;
2667    
2668             ;; Check wrt previous sibling:             ;; Check wrt previous sibling:
2669             ((and new                              ; only check for new prefixes             ((and new                              ; only check for new prefixes
2670                   (<= depth (outline-depth))                   (<= depth (allout-depth))
2671                   outline-numbered-bullet              ; ... & numbering enabled                   allout-numbered-bullet       ; ... & numbering enabled
2672                   (not denumbering)                   (not denumbering)
2673                   (let ((sibling-bullet                   (let ((sibling-bullet
2674                          (save-excursion                          (save-excursion
2675                            ;; Locate correct sibling:                            ;; Locate correct sibling:
2676                            (or (>= depth (outline-depth))                            (or (>= depth (allout-depth))
2677                                (outline-ascend-to-depth depth))                                (allout-ascend-to-depth depth))
2678                            (outline-get-bullet))))                            (allout-get-bullet))))
2679                     (if (and sibling-bullet                     (if (and sibling-bullet
2680                              (string= outline-numbered-bullet sibling-bullet))                              (string= allout-numbered-bullet sibling-bullet))
2681                         (setq numbering sibling-bullet)))))                         (setq numbering sibling-bullet)))))
2682    
2683             ;; Distinctive prior bullet?             ;; Distinctive prior bullet?
2684             ((and prior-bullet             ((and prior-bullet
2685                   (outline-distinctive-bullet prior-bullet)                   (allout-distinctive-bullet prior-bullet)
2686                   ;; Either non-numbered:                   ;; Either non-numbered:
2687                   (or (not (and outline-numbered-bullet                   (or (not (and allout-numbered-bullet
2688                                 (string= prior-bullet outline-numbered-bullet)))                                 (string= prior-bullet allout-numbered-bullet)))
2689                       ;; or numbered, and not denumbering:                       ;; or numbered, and not denumbering:
2690                       (setq numbering (not denumbering)))                       (setq numbering (not denumbering)))
2691                   ;; Here 'tis:                   ;; Here 'tis:
2692                   prior-bullet))                   prior-bullet))
2693    
2694             ;; Else, standard bullet per depth:             ;; Else, standard bullet per depth:
2695             ((outline-bullet-for-depth depth)))))             ((allout-bullet-for-depth depth)))))
2696    
2697      (concat header-lead      (concat header-lead
2698              body              body
2699              bullet-char              bullet-char
2700              (if numbering              (if numbering
2701                  (format "%d" (cond ((and index (numberp index)) index)                  (format "%d" (cond ((and index (numberp index)) index)
2702                                     (new (1+ (outline-sibling-index depth)))                                     (new (1+ (allout-sibling-index depth)))
2703                                     ((outline-sibling-index))))))                                     ((allout-sibling-index))))))
2704      )      )
2705    )    )
2706  ;;;_   > outline-open-topic (relative-depth &optional before use_sib_bullet)  ;;;_   > allout-open-topic (relative-depth &optional before use_sib_bullet)
2707  (defun outline-open-topic (relative-depth &optional before use_sib_bullet)  (defun allout-open-topic (relative-depth &optional before use_sib_bullet)
2708    "Open a new topic at depth DEPTH.    "Open a new topic at depth DEPTH.
2709    
2710  New topic is situated after current one, unless optional flag BEFORE  New topic is situated after current one, unless optional flag BEFORE
# Line 2734  Nuances: Line 2735  Nuances:
2735    having to go to its preceding sibling, and then open forward    having to go to its preceding sibling, and then open forward
2736    from there."    from there."
2737    
2738    (let* ((depth (+ (outline-current-depth) relative-depth))    (let* ((depth (+ (allout-current-depth) relative-depth))
2739           (opening-on-blank (if (looking-at "^\$")           (opening-on-blank (if (looking-at "^\$")
2740                                 (not (setq before nil))))                                 (not (setq before nil))))
2741           opening-numbered       ; Will get while computing ref-topic, below           opening-numbered       ; Will get while computing ref-topic, below
# Line 2742  Nuances: Line 2743  Nuances:
2743           ref-bullet             ; Will get while computing ref-topic, next           ref-bullet             ; Will get while computing ref-topic, next
2744           (ref-topic (save-excursion           (ref-topic (save-excursion
2745                        (cond ((< relative-depth 0)                        (cond ((< relative-depth 0)
2746                               (outline-ascend-to-depth depth))                               (allout-ascend-to-depth depth))
2747                              ((>= relative-depth 1) nil)                              ((>= relative-depth 1) nil)
2748                              (t (outline-back-to-current-heading)))                              (t (allout-back-to-current-heading)))
2749                        (setq ref-depth (outline-recent-depth))                        (setq ref-depth (allout-recent-depth))
2750                        (setq ref-bullet                        (setq ref-bullet
2751                              (if (> outline-recent-prefix-end 1)                              (if (> allout-recent-prefix-end 1)
2752                                  (outline-recent-bullet)                                  (allout-recent-bullet)
2753                                ""))                                ""))
2754                        (setq opening-numbered                        (setq opening-numbered
2755                              (save-excursion                              (save-excursion
2756                                (and outline-numbered-bullet                                (and allout-numbered-bullet
2757                                     (or (<= relative-depth 0)                                     (or (<= relative-depth 0)
2758                                         (outline-descend-to-depth depth))                                         (allout-descend-to-depth depth))
2759                                     (if (outline-numbered-type-prefix)                                     (if (allout-numbered-type-prefix)
2760                                         outline-numbered-bullet))))                                         allout-numbered-bullet))))
2761                        (point)))                        (point)))
2762           dbl-space           dbl-space
2763           doing-beginning)           doing-beginning)
# Line 2776  Nuances: Line 2777  Nuances:
2777                                 (bobp)))                                 (bobp)))
2778                           (save-excursion                           (save-excursion
2779                             ;; succeeded by a blank line?                             ;; succeeded by a blank line?
2780                             (outline-end-of-current-subtree)                             (allout-end-of-current-subtree)
2781                             (bolp)))                             (bolp)))
2782                      (and (= ref-depth 1)                      (and (= ref-depth 1)
2783                           (or before                           (or before
# Line 2784  Nuances: Line 2785  Nuances:
2785                               (save-excursion                               (save-excursion
2786                                 ;; Don't already have following                                 ;; Don't already have following
2787                                 ;; vertical padding:                                 ;; vertical padding:
2788                                 (not (outline-pre-next-preface)))))))                                 (not (allout-pre-next-preface)))))))
2789    
2790                                          ; Position to prior heading,                                          ; Position to prior heading,
2791                                          ; if inserting backwards, and                                          ; if inserting backwards, and
2792                                          ; not going outwards:                                          ; not going outwards:
2793            (if (and before (>= relative-depth 0))            (if (and before (>= relative-depth 0))
2794                (progn (outline-back-to-current-heading)                (progn (allout-back-to-current-heading)
2795                              (setq doing-beginning (bobp))                              (setq doing-beginning (bobp))
2796                              (if (not (bobp))                              (if (not (bobp))
2797                                  (outline-previous-heading)))                                  (allout-previous-heading)))
2798              (if (and before (bobp))              (if (and before (bobp))
2799                  (outline-unprotected (open-line 1))))                  (allout-unprotected (open-line 1))))
2800    
2801            (if (<= relative-depth 0)            (if (<= relative-depth 0)
2802                ;; Not going inwards, don't snug up:                ;; Not going inwards, don't snug up:
2803                (if doing-beginning                (if doing-beginning
2804                    (outline-unprotected (open-line (if dbl-space 2 1)))                    (allout-unprotected (open-line (if dbl-space 2 1)))
2805                  (if before                  (if before
2806                      (progn (end-of-line)                      (progn (end-of-line)
2807                             (outline-pre-next-preface)                             (allout-pre-next-preface)
2808                             (while (= ?\r (following-char))                             (while (= ?\r (following-char))
2809                               (forward-char 1))                               (forward-char 1))
2810                             (if (not (looking-at "^$"))                             (if (not (looking-at "^$"))
2811                                 (outline-unprotected (open-line 1))))                                 (allout-unprotected (open-line 1))))
2812                    (outline-end-of-current-subtree)))                    (allout-end-of-current-subtree)))
2813              ;; Going inwards - double-space if first offspring is,              ;; Going inwards - double-space if first offspring is,
2814              ;; otherwise snug up.              ;; otherwise snug up.
2815              (end-of-line)               ; So we skip any concealed progeny.              (end-of-line)               ; So we skip any concealed progeny.
2816              (outline-pre-next-preface)              (allout-pre-next-preface)
2817              (if (bolp)              (if (bolp)
2818                  ;; Blank lines between current header body and next                  ;; Blank lines between current header body and next
2819                  ;; header - get to last substantive (non-white-space)                  ;; header - get to last substantive (non-white-space)
2820                  ;; line in body:                  ;; line in body:
2821                  (re-search-backward "[^ \t\n]" nil t))                  (re-search-backward "[^ \t\n]" nil t))
2822              (if (save-excursion              (if (save-excursion
2823                    (outline-next-heading)                    (allout-next-heading)
2824                    (if (> (outline-recent-depth) ref-depth)                    (if (> (allout-recent-depth) ref-depth)
2825                        ;; This is an offspring.                        ;; This is an offspring.
2826                        (progn (forward-line -1)                        (progn (forward-line -1)
2827                               (looking-at "^\\s-*$"))))                               (looking-at "^\\s-*$"))))
2828                  (progn (forward-line 1)                  (progn (forward-line 1)
2829                         (outline-unprotected (open-line 1))))                         (allout-unprotected (open-line 1))))
2830              (end-of-line))              (end-of-line))
2831            ;;(if doing-beginning (goto-char doing-beginning))            ;;(if doing-beginning (goto-char doing-beginning))
2832            (if (not (bobp))            (if (not (bobp))
2833                (progn (if (and (not (> depth ref-depth))                (progn (if (and (not (> depth ref-depth))
2834                                (not before))                                (not before))
2835                           (outline-unprotected (open-line 1))                           (allout-unprotected (open-line 1))
2836                         (if (> depth ref-depth)                         (if (> depth ref-depth)
2837                             (outline-unprotected (newline 1))                             (allout-unprotected (newline 1))
2838                           (if dbl-space                           (if dbl-space
2839                               (outline-unprotected (open-line 1))                               (allout-unprotected (open-line 1))
2840                             (if (not before)                             (if (not before)
2841                                 (outline-unprotected (newline 1))))))                                 (allout-unprotected (newline 1))))))
2842                       (if dbl-space                       (if dbl-space
2843                           (outline-unprotected (newline  1)))                           (allout-unprotected (newline  1)))
2844                       (if (and (not (eobp))                       (if (and (not (eobp))
2845                                (not (bolp)))                                (not (bolp)))
2846                           (forward-char 1))))                           (forward-char 1))))
2847            ))            ))
2848      (insert (concat (outline-make-topic-prefix opening-numbered      (insert (concat (allout-make-topic-prefix opening-numbered
2849                                                 t                                                 t
2850                                                 depth)                                                 depth)
2851                      " "))                      " "))
# Line 2852  Nuances: Line 2853  Nuances:
2853      ;;(if doing-beginning (save-excursion (newline (if dbl-space 2 1))))      ;;(if doing-beginning (save-excursion (newline (if dbl-space 2 1))))
2854    
2855    
2856      (outline-rebullet-heading (and use_sib_bullet ref-bullet);;; solicit      (allout-rebullet-heading (and use_sib_bullet ref-bullet);;; solicit
2857                                depth                          ;;; depth                                depth                          ;;; depth
2858                                nil                            ;;; number-control                                nil                            ;;; number-control
2859                                nil                            ;;; index                                nil                            ;;; index
# Line 2872  Nuances: Line 2873  Nuances:
2873  ;;;_     ; buffer boundaries - special provisions for beginning and end ob  ;;;_     ; buffer boundaries - special provisions for beginning and end ob
2874  ;;;_     ; level 1 topics have special provisions also - double space.  ;;;_     ; level 1 topics have special provisions also - double space.
2875  ;;;_     ; location of new topic  ;;;_     ; location of new topic
2876  ;;;_   > outline-open-subtopic (arg)  ;;;_   > allout-open-subtopic (arg)
2877  (defun outline-open-subtopic (arg)  (defun allout-open-subtopic (arg)
2878    "Open new topic header at deeper level than the current one.    "Open new topic header at deeper level than the current one.
2879    
2880  Negative universal arg means to open deeper, but place the new topic  Negative universal arg means to open deeper, but place the new topic
2881  prior to the current one."  prior to the current one."
2882    (interactive "p")    (interactive "p")
2883    (outline-open-topic 1 (> 0 arg)))    (allout-open-topic 1 (> 0 arg)))
2884  ;;;_   > outline-open-sibtopic (arg)  ;;;_   > allout-open-sibtopic (arg)
2885  (defun outline-open-sibtopic (arg)  (defun allout-open-sibtopic (arg)
2886    "Open new topic header at same level as the current one.    "Open new topic header at same level as the current one.
2887    
2888  Positive universal arg means to use the bullet of the prior sibling.  Positive universal arg means to use the bullet of the prior sibling.
# Line 2889  Positive universal arg means to use the Line 2890  Positive universal arg means to use the
2890  Negative universal arg means to place the new topic prior to the current  Negative universal arg means to place the new topic prior to the current
2891  one."  one."
2892    (interactive "p")    (interactive "p")
2893    (outline-open-topic 0 (> 0 arg) (< 1 arg)))    (allout-open-topic 0 (> 0 arg) (< 1 arg)))
2894  ;;;_   > outline-open-supertopic (arg)  ;;;_   > allout-open-supertopic (arg)
2895  (defun outline-open-supertopic (arg)  (defun allout-open-supertopic (arg)
2896    "Open new topic header at shallower level than the current one.    "Open new topic header at shallower level than the current one.
2897    
2898  Negative universal arg means to open shallower, but place the new  Negative universal arg means to open shallower, but place the new
2899  topic prior to the current one."  topic prior to the current one."
2900    
2901    (interactive "p")    (interactive "p")
2902    (outline-open-topic -1 (> 0 arg)))    (allout-open-topic -1 (> 0 arg)))
2903    
2904  ;;;_  - Outline Alteration  ;;;_  - Outline Alteration
2905  ;;;_   : Topic Modification  ;;;_   : Topic Modification
2906  ;;;_    = outline-former-auto-filler  ;;;_    = allout-former-auto-filler
2907  (defvar outline-former-auto-filler nil  (defvar allout-former-auto-filler nil
2908    "Name of modal fill function being wrapped by outline-auto-fill.")    "Name of modal fill function being wrapped by `allout-auto-fill'.")
2909  ;;;_    > outline-auto-fill ()  ;;;_    > allout-auto-fill ()
2910  (defun outline-auto-fill ()  (defun allout-auto-fill ()
2911    "Outline-mode autofill function.    "`allout-mode' autofill function.
2912    
2913  Maintains outline hanging topic indentation if  Maintains outline hanging topic indentation if
2914  `outline-use-hanging-indents' is set."  `allout-use-hanging-indents' is set."
2915    (let ((fill-prefix (if outline-use-hanging-indents    (let ((fill-prefix (if allout-use-hanging-indents
2916                           ;; Check for topic header indentation:                           ;; Check for topic header indentation:
2917                           (save-excursion                           (save-excursion
2918                             (beginning-of-line)                             (beginning-of-line)
2919                             (if (looking-at outline-regexp)                             (if (looking-at allout-regexp)
2920                                 ;; ... construct indentation to account for                                 ;; ... construct indentation to account for
2921                                 ;; length of topic prefix:                                 ;; length of topic prefix:
2922                                 (make-string (progn (outline-end-of-prefix)                                 (make-string (progn (allout-end-of-prefix)
2923                                                     (current-column))                                                     (current-column))
2924                                              ?\ ))))))                                              ?\ ))))))
2925      (if (or outline-former-auto-filler outline-use-hanging-indents)      (if (or allout-former-auto-filler allout-use-hanging-indents)
2926          (do-auto-fill))))          (do-auto-fill))))
2927  ;;;_    > outline-reindent-body (old-depth new-depth &optional number)  ;;;_    > allout-reindent-body (old-depth new-depth &optional number)
2928  (defun outline-reindent-body (old-depth new-depth &optional number)  (defun allout-reindent-body (old-depth new-depth &optional number)
2929    "Reindent body lines which were indented at old-depth to new-depth.    "Reindent body lines which were indented at old-depth to new-depth.
2930    
2931  Optional arg NUMBER indicates numbering is being added, and it must  Optional arg NUMBER indicates numbering is being added, and it must
# Line 2933  be accommodated. Line 2934  be accommodated.
2934  Note that refill of indented paragraphs is not done."  Note that refill of indented paragraphs is not done."
2935    
2936    (save-excursion    (save-excursion
2937      (outline-end-of-prefix)      (allout-end-of-prefix)
2938      (let* ((new-margin (current-column))      (let* ((new-margin (current-column))
2939             excess old-indent-begin old-indent-end             excess old-indent-begin old-indent-end
2940             curr-ind             curr-ind
# Line 2943  Note that refill of indented paragraphs Line 2944  Note that refill of indented paragraphs
2944             (old-margin (+ old-depth (- new-margin new-depth))))             (old-margin (+ old-depth (- new-margin new-depth))))
2945    
2946        ;; Process lines up to (but excluding) next topic header:        ;; Process lines up to (but excluding) next topic header:
2947        (outline-unprotected        (allout-unprotected
2948         (save-match-data         (save-match-data
2949           (while           (while
2950               (and (re-search-forward "[\n\r]\\(\\s-*\\)"               (and (re-search-forward "[\n\r]\\(\\s-*\\)"
# Line 2953  Note that refill of indented paragraphs Line 2954  Note that refill of indented paragraphs
2954                    ;; match data with a subsequent `looking-at':                    ;; match data with a subsequent `looking-at':
2955                    (setq old-indent-begin (match-beginning 1)                    (setq old-indent-begin (match-beginning 1)
2956                          old-indent-end (match-end 1))                          old-indent-end (match-end 1))
2957                    (not (looking-at outline-regexp)))                    (not (looking-at allout-regexp)))
2958             (if (> 0 (setq excess (- (current-column)             (if (> 0 (setq excess (- (current-column)
2959                                       old-margin)))                                       old-margin)))
2960                 ;; Text starts left of old margin - don't adjust:                 ;; Text starts left of old margin - don't adjust:
# Line 2963  Note that refill of indented paragraphs Line 2964  Note that refill of indented paragraphs
2964               ;; beyond the old margin:               ;; beyond the old margin:
2965               (delete-region old-indent-begin old-indent-end)               (delete-region old-indent-begin old-indent-end)
2966               (indent-to (+ new-margin excess)))))))))               (indent-to (+ new-margin excess)))))))))
2967  ;;;_    > outline-rebullet-current-heading (arg)  ;;;_    > allout-rebullet-current-heading (arg)
2968  (defun outline-rebullet-current-heading (arg)  (defun allout-rebullet-current-heading (arg)
2969    "Solicit new bullet for current visible heading."    "Solicit new bullet for current visible heading."
2970    (interactive "p")    (interactive "p")
2971    (let ((initial-col (current-column))    (let ((initial-col (current-column))
2972          (on-bullet (eq (point)(outline-current-bullet-pos)))          (on-bullet (eq (point)(allout-current-bullet-pos)))
2973          (backwards (if (< arg 0)          (backwards (if (< arg 0)
2974                         (setq arg (* arg -1)))))                         (setq arg (* arg -1)))))
2975      (while (> arg 0)      (while (> arg 0)
2976        (save-excursion (outline-back-to-current-heading)        (save-excursion (allout-back-to-current-heading)
2977                        (outline-end-of-prefix)                        (allout-end-of-prefix)
2978                        (outline-rebullet-heading t       ;;; solicit                        (allout-rebullet-heading t        ;;; solicit
2979                                                  nil     ;;; depth                                                  nil     ;;; depth
2980                                                  nil     ;;; number-control                                                  nil     ;;; number-control
2981                                                  nil     ;;; index                                                  nil     ;;; index
# Line 2984  Note that refill of indented paragraphs Line 2985  Note that refill of indented paragraphs
2985            nil            nil
2986          (setq initial-col nil)          ; Override positioning back to init col          (setq initial-col nil)          ; Override positioning back to init col
2987          (if (not backwards)          (if (not backwards)
2988              (outline-next-visible-heading 1)              (allout-next-visible-heading 1)
2989            (outline-goto-prefix)            (allout-goto-prefix)
2990            (outline-next-visible-heading -1))))            (allout-next-visible-heading -1))))
2991      (message "Done.")      (message "Done.")
2992      (cond (on-bullet (goto-char (outline-current-bullet-pos)))      (cond (on-bullet (goto-char (allout-current-bullet-pos)))
2993            (initial-col (move-to-column initial-col)))))            (initial-col (move-to-column initial-col)))))
2994  ;;;_    > outline-rebullet-heading (&optional solicit ...)  ;;;_    > allout-rebullet-heading (&optional solicit ...)
2995  (defun outline-rebullet-heading (&optional solicit  (defun allout-rebullet-heading (&optional solicit
2996                                             new-depth                                             new-depth
2997                                             number-control                                             number-control
2998                                             index                                             index
# Line 3011  Second arg DEPTH forces the topic prefix Line 3012  Second arg DEPTH forces the topic prefix
3012  of the topic's current depth.  of the topic's current depth.
3013    
3014  Third arg NUMBER-CONTROL can force the prefix to or away from  Third arg NUMBER-CONTROL can force the prefix to or away from
3015  numbered form.  It has effect only if `outline-numbered-bullet' is  numbered form.  It has effect only if `allout-numbered-bullet' is
3016  non-nil and soliciting was not explicitly invoked (via first arg).  non-nil and soliciting was not explicitly invoked (via first arg).
3017  Its effect, numbering or denumbering, then depends on the setting  Its effect, numbering or denumbering, then depends on the setting
3018  of the forth arg, INDEX.  of the forth arg, INDEX.
# Line 3022  non-nil NUMBER-CONTROL forces denumberin Line 3023  non-nil NUMBER-CONTROL forces denumberin
3023  non-nil NUMBER-CONTROL) forces a numbered-prefix form.  If non-nil  non-nil NUMBER-CONTROL) forces a numbered-prefix form.  If non-nil
3024  INDEX is a number, then that number is used for the numbered  INDEX is a number, then that number is used for the numbered
3025  prefix.  Non-nil and non-number means that the index for the  prefix.  Non-nil and non-number means that the index for the
3026  numbered prefix will be derived by outline-make-topic-prefix.  numbered prefix will be derived by `allout-make-topic-prefix'.
3027    
3028  Fifth arg DO-SUCCESSORS t means re-resolve count on succeeding  Fifth arg DO-SUCCESSORS t means re-resolve count on succeeding
3029  siblings.  siblings.
3030    
3031  Cf vars `outline-stylish-prefixes', `outline-old-style-prefixes',  Cf vars `allout-stylish-prefixes', `allout-old-style-prefixes',
3032  and `outline-numbered-bullet', which all affect the behavior of  and `allout-numbered-bullet', which all affect the behavior of
3033  this function."  this function."
3034    
3035    (let* ((current-depth (outline-depth))    (let* ((current-depth (allout-depth))
3036           (new-depth (or new-depth current-depth))           (new-depth (or new-depth current-depth))
3037           (mb outline-recent-prefix-beginning)           (mb allout-recent-prefix-beginning)
3038           (me outline-recent-prefix-end)           (me allout-recent-prefix-end)
3039           (current-bullet (buffer-substring (- me 1) me))           (current-bullet (buffer-substring (- me 1) me))
3040           (new-prefix (outline-make-topic-prefix current-bullet           (new-prefix (allout-make-topic-prefix current-bullet
3041                                                  nil                                                  nil
3042                                                  new-depth                                                  new-depth
3043                                                  solicit                                                  solicit
# Line 3052  this function." Line 3053  this function."
3053    
3054        ;; New prefix probably different from old:        ;; New prefix probably different from old:
3055                                          ; get rid of old one:                                          ; get rid of old one:
3056        (outline-unprotected (delete-region mb me))        (allout-unprotected (delete-region mb me))
3057        (goto-char mb)        (goto-char mb)
3058                                          ; Dispense with number if                                          ; Dispense with number if
3059                                          ; numbered-bullet prefix:                                          ; numbered-bullet prefix:
3060        (if (and outline-numbered-bullet        (if (and allout-numbered-bullet
3061                 (string= outline-numbered-bullet current-bullet)                 (string= allout-numbered-bullet current-bullet)
3062                 (looking-at "[0-9]+"))                 (looking-at "[0-9]+"))
3063            (outline-unprotected            (allout-unprotected
3064             (delete-region (match-beginning 0)(match-end 0))))             (delete-region (match-beginning 0)(match-end 0))))
3065    
3066                                          ; Put in new prefix:                                          ; Put in new prefix:
3067        (outline-unprotected (insert new-prefix))        (allout-unprotected (insert new-prefix))
3068    
3069        ;; Reindent the body if elected and margin changed:        ;; Reindent the body if elected and margin changed:
3070        (if (and outline-reindent-bodies        (if (and allout-reindent-bodies
3071                 (not (= new-depth current-depth)))                 (not (= new-depth current-depth)))
3072            (outline-reindent-body current-depth new-depth))            (allout-reindent-body current-depth new-depth))
3073    
3074        ;; Recursively rectify successive siblings of orig topic if        ;; Recursively rectify successive siblings of orig topic if
3075        ;; caller elected for it:        ;; caller elected for it:
3076        (if do-successors        (if do-successors
3077            (save-excursion            (save-excursion
3078              (while (outline-next-sibling new-depth nil)              (while (allout-next-sibling new-depth nil)
3079                (setq index                (setq index
3080                      (cond ((numberp index) (1+ index))                      (cond ((numberp index) (1+ index))
3081                            ((not number-control)  (outline-sibling-index))))                            ((not number-control)  (allout-sibling-index))))
3082                (if (outline-numbered-type-prefix)                (if (allout-numbered-type-prefix)
3083                    (outline-rebullet-heading nil         ;;; solicit                    (allout-rebullet-heading nil          ;;; solicit
3084                                              new-depth   ;;; new-depth                                              new-depth   ;;; new-depth
3085                                              number-control;;; number-control                                              number-control;;; number-control
3086                                              index       ;;; index                                              index       ;;; index
3087                                              nil)))))    ;;;(dont!)do-successors                                              nil)))))    ;;;(dont!)do-successors
3088        ) ; (if (and (= current-depth new-depth)...))        ) ; (if (and (= current-depth new-depth)...))
3089      ) ; let* ((current-depth (outline-depth))...)      ) ; let* ((current-depth (allout-depth))...)
3090    ) ; defun    ) ; defun
3091  ;;;_    > outline-rebullet-topic (arg)  ;;;_    > allout-rebullet-topic (arg)
3092  (defun outline-rebullet-topic (arg)  (defun allout-rebullet-topic (arg)
3093    "Like outline-rebullet-topic-grunt, but start from topic visible at point.    "Like `allout-rebullet-topic-grunt', but start from topic visible at point.
3094    
3095  Descends into invisible as well as visible topics, however.  Descends into invisible as well as visible topics, however.
3096    
# Line 3103  With repeat count, shift topic depth by Line 3104  With repeat count, shift topic depth by
3104              ((listp arg) (setq arg (car arg))))              ((listp arg) (setq arg (car arg))))
3105        ;; Fill the user in, in case we're shifting a big topic:        ;; Fill the user in, in case we're shifting a big topic:
3106        (if (not (zerop arg)) (message "Shifting..."))        (if (not (zerop arg)) (message "Shifting..."))
3107        (outline-back-to-current-heading)        (allout-back-to-current-heading)
3108        (if (<= (+ (outline-recent-depth) arg) 0)        (if (<= (+ (allout-recent-depth) arg) 0)
3109            (error "Attempt to shift topic below level 1"))            (error "Attempt to shift topic below level 1"))
3110        (outline-rebullet-topic-grunt arg)        (allout-rebullet-topic-grunt arg)
3111        (if (not (zerop arg)) (message "Shifting... done.")))        (if (not (zerop arg)) (message "Shifting... done.")))
3112      (move-to-column (max 0 (+ start-col arg)))))      (move-to-column (max 0 (+ start-col arg)))))
3113  ;;;_     > outline-rebullet-topic-grunt (&optional relative-depth ...)  ;;;_     > allout-rebullet-topic-grunt (&optional relative-depth ...)
3114  (defun outline-rebullet-topic-grunt (&optional relative-depth  (defun allout-rebullet-topic-grunt (&optional relative-depth
3115                                                 starting-depth                                                 starting-depth
3116                                                 starting-point                                                 starting-point
3117                                                 index                                                 index
3118                                                 do-successors)                                                 do-successors)
3119    
3120    "Rebullet the topic at point, visible or invisible, and all    "Rebullet the topic at point, visible or invisible, and all
3121  contained subtopics.  See outline-rebullet-heading for rebulleting  contained subtopics.  See `allout-rebullet-heading' for rebulleting
3122  behavior.  behavior.
3123    
3124  All arguments are optional.  All arguments are optional.
# Line 3129  The rest of the args are for internal re Line 3130  The rest of the args are for internal re
3130  itself.  The are STARTING-DEPTH, STARTING-POINT, and INDEX."  itself.  The are STARTING-DEPTH, STARTING-POINT, and INDEX."
3131    
3132    (let* ((relative-depth (or relative-depth 0))    (let* ((relative-depth (or relative-depth 0))
3133           (new-depth (outline-depth))           (new-depth (allout-depth))
3134           (starting-depth (or starting-depth new-depth))           (starting-depth (or starting-depth new-depth))
3135           (on-starting-call  (null starting-point))           (on-starting-call  (null starting-point))
3136           (index (or index           (index (or index
# Line 3137  itself.  The are STARTING-DEPTH, STARTIN Line 3138  itself.  The are STARTING-DEPTH, STARTIN
3138                      ;; calculates it at what might be new depth:                      ;; calculates it at what might be new depth:
3139                      (and (or (zerop relative-depth)                      (and (or (zerop relative-depth)
3140                               (not on-starting-call))                               (not on-starting-call))
3141                           (outline-sibling-index))))                           (allout-sibling-index))))
3142           (moving-outwards (< 0 relative-depth))           (moving-outwards (< 0 relative-depth))
3143           (starting-point (or starting-point (point))))           (starting-point (or starting-point (point))))
3144    
# Line 3149  itself.  The are STARTING-DEPTH, STARTIN Line 3150  itself.  The are STARTING-DEPTH, STARTIN
3150    
3151      (cond ((= starting-depth new-depth)      (cond ((= starting-depth new-depth)
3152             ;; We're at depth to work on this one:             ;; We're at depth to work on this one:
3153             (outline-rebullet-heading nil                ;;; solicit             (allout-rebullet-heading nil         ;;; solicit
3154                                       (+ starting-depth  ;;; starting-depth                                       (+ starting-depth  ;;; starting-depth
3155                                          relative-depth)                                          relative-depth)
3156                                       nil                ;;; number                                       nil                ;;; number
# Line 3160  itself.  The are STARTING-DEPTH, STARTIN Line 3161  itself.  The are STARTING-DEPTH, STARTIN
3161                                       nil)               ;;; do-successors                                       nil)               ;;; do-successors
3162             ;; ... and work on subsequent ones which are at greater depth:             ;; ... and work on subsequent ones which are at greater depth:
3163             (setq index 0)             (setq index 0)
3164             (outline-next-heading)             (allout-next-heading)
3165             (while (and (not (eobp))             (while (and (not (eobp))
3166                         (< starting-depth (outline-recent-depth)))                         (< starting-depth (allout-recent-depth)))
3167               (setq index (1+ index))               (setq index (1+ index))
3168               (outline-rebullet-topic-grunt relative-depth   ;;; relative-depth               (allout-rebullet-topic-grunt relative-depth   ;;; relative-depth
3169                                             (1+ starting-depth);;;starting-depth                                             (1+ starting-depth);;;starting-depth
3170                                             starting-point   ;;; starting-point                                             starting-point   ;;; starting-point
3171                                             index)))         ;;; index                                             index)))         ;;; index
# Line 3172  itself.  The are STARTING-DEPTH, STARTIN Line 3173  itself.  The are STARTING-DEPTH, STARTIN
3173            ((< starting-depth new-depth)            ((< starting-depth new-depth)
3174             ;; Rare case - subtopic more than one level deeper than parent.             ;; Rare case - subtopic more than one level deeper than parent.
3175             ;; Treat this one at an even deeper level:             ;; Treat this one at an even deeper level:
3176             (outline-rebullet-topic-grunt relative-depth   ;;; relative-depth             (allout-rebullet-topic-grunt relative-depth   ;;; relative-depth
3177                                           new-depth        ;;; starting-depth                                           new-depth        ;;; starting-depth
3178                                           starting-point   ;;; starting-point                                           starting-point   ;;; starting-point
3179                                           index)))         ;;; index                                           index)))         ;;; index
# Line 3183  itself.  The are STARTING-DEPTH, STARTIN Line 3184  itself.  The are STARTING-DEPTH, STARTIN
3184            ;; if topic has changed depth            ;; if topic has changed depth
3185            (if (or do-successors            (if (or do-successors
3186                    (and (not (zerop relative-depth))                    (and (not (zerop relative-depth))
3187                         (or (= (outline-recent-depth) starting-depth)                         (or (= (allout-recent-depth) starting-depth)
3188                             (= (outline-recent-depth) (+ starting-depth                             (= (allout-recent-depth) (+ starting-depth
3189                                                          relative-depth)))))                                                          relative-depth)))))
3190                (outline-rebullet-heading nil nil nil nil t))                (allout-rebullet-heading nil nil nil nil t))
3191            ;; Now rectify numbering of new siblings of the adjusted topic,            ;; Now rectify numbering of new siblings of the adjusted topic,
3192            ;; if depth has been changed:            ;; if depth has been changed:
3193            (progn (goto-char starting-point)            (progn (goto-char starting-point)
3194                   (if (not (zerop relative-depth))                   (if (not (zerop relative-depth))
3195                       (outline-rebullet-heading nil nil nil nil t)))))                       (allout-rebullet-heading nil nil nil nil t)))))
3196      )      )
3197    )    )
3198  ;;;_    > outline-renumber-to-depth (&optional depth)  ;;;_    > allout-renumber-to-depth (&optional depth)
3199  (defun outline-renumber-to-depth (&optional depth)  (defun allout-renumber-to-depth (&optional depth)
3200    "Renumber siblings at current depth.    "Renumber siblings at current depth.
3201    
3202  Affects superior topics if optional arg DEPTH is less than current depth.  Affects superior topics if optional arg DEPTH is less than current depth.
# Line 3205  Returns final depth." Line 3206  Returns final depth."
3206    ;; Proceed by level, processing subsequent siblings on each,    ;; Proceed by level, processing subsequent siblings on each,
3207    ;; ascending until we get shallower than the start depth:    ;; ascending until we get shallower than the start depth:
3208    
3209    (let ((ascender (outline-depth))    (let ((ascender (allout-depth))
3210          was-eobp)          was-eobp)
3211      (while (and (not (eobp))      (while (and (not (eobp))
3212                  (outline-depth)                  (allout-depth)
3213                  (>= (outline-recent-depth) depth)                  (>= (allout-recent-depth) depth)
3214                  (>= ascender depth))                  (>= ascender depth))
3215                                          ; Skip over all topics at                                          ; Skip over all topics at
3216                                          ; lesser depths, which can not                                          ; lesser depths, which can not
3217                                          ; have been disturbed:                                          ; have been disturbed:
3218        (while (and (not (setq was-eobp (eobp)))        (while (and (not (setq was-eobp (eobp)))
3219                    (> (outline-recent-depth) ascender))                    (> (allout-recent-depth) ascender))
3220          (outline-next-heading))          (allout-next-heading))
3221                                          ; Prime ascender for ascension:                                          ; Prime ascender for ascension:
3222        (setq ascender (1- (outline-recent-depth)))        (setq ascender (1- (allout-recent-depth)))
3223        (if (>= (outline-recent-depth) depth)        (if (>= (allout-recent-depth) depth)
3224            (outline-rebullet-heading nil ;;; solicit            (allout-rebullet-heading nil  ;;; solicit
3225                                      nil ;;; depth                                      nil ;;; depth
3226                                      nil ;;; number-control                                      nil ;;; number-control
3227                                      nil ;;; index                                      nil ;;; index
3228                                      t)) ;;; do-successors                                      t)) ;;; do-successors
3229        (if was-eobp (goto-char (point-max)))))        (if was-eobp (goto-char (point-max)))))
3230    (outline-recent-depth))    (allout-recent-depth))
3231  ;;;_    > outline-number-siblings (&optional denumber)  ;;;_    > allout-number-siblings (&optional denumber)
3232  (defun outline-number-siblings (&optional denumber)  (defun allout-number-siblings (&optional denumber)
3233    "Assign numbered topic prefix to this topic and its siblings.    "Assign numbered topic prefix to this topic and its siblings.
3234    
3235  With universal argument, denumber - assign default bullet to this  With universal argument, denumber - assign default bullet to this
# Line 3240  rebulleting each topic at this level." Line 3241  rebulleting each topic at this level."
3241    (interactive "P")    (interactive "P")
3242    
3243    (save-excursion    (save-excursion
3244      (outline-back-to-current-heading)      (allout-back-to-current-heading)
3245      (outline-beginning-of-level)      (allout-beginning-of-level)
3246      (let ((depth (outline-recent-depth))      (let ((depth (allout-recent-depth))
3247            (index (if (not denumber) 1))            (index (if (not denumber) 1))
3248            (use-bullet (equal '(16) denumber))            (use-bullet (equal '(16) denumber))
3249            (more t))            (more t))
3250        (while more        (while more
3251          (outline-rebullet-heading use-bullet            ;;; solicit          (allout-rebullet-heading use-bullet             ;;; solicit
3252                                    depth                 ;;; depth                                    depth                 ;;; depth
3253                                    t                     ;;; number-control                                    t                     ;;; number-control
3254                                    index                 ;;; index                                    index                 ;;; index
3255                                    nil)                  ;;; do-successors                                    nil)                  ;;; do-successors
3256          (if index (setq index (1+ index)))          (if index (setq index (1+ index)))
3257          (setq more (outline-next-sibling depth nil))))))          (setq more (allout-next-sibling depth nil))))))
3258  ;;;_    > outline-shift-in (arg)  ;;;_    > allout-shift-in (arg)
3259  (defun outline-shift-in (arg)  (defun allout-shift-in (arg)
3260    "Increase depth of current heading and any topics collapsed within it."    "Increase depth of current heading and any topics collapsed within it."
3261    (interactive "p")    (interactive "p")
3262    (outline-rebullet-topic arg))    (allout-rebullet-topic arg))
3263  ;;;_    > outline-shift-out (arg)  ;;;_    > allout-shift-out (arg)
3264  (defun outline-shift-out (arg)  (defun allout-shift-out (arg)
3265    "Decrease depth of current heading and any topics collapsed within it."    "Decrease depth of current heading and any topics collapsed within it."
3266    (interactive "p")    (interactive "p")
3267    (outline-rebullet-topic (* arg -1)))    (allout-rebullet-topic (* arg -1)))
3268  ;;;_   : Surgery (kill-ring) functions with special provisions for outlines:  ;;;_   : Surgery (kill-ring) functions with special provisions for outlines:
3269  ;;;_    > outline-kill-line (&optional arg)  ;;;_    > allout-kill-line (&optional arg)
3270  (defun outline-kill-line (&optional arg)  (defun allout-kill-line (&optional arg)
3271    "Kill line, adjusting subsequent lines suitably for outline mode."    "Kill line, adjusting subsequent lines suitably for outline mode."
3272    
3273    (interactive "*P")    (interactive "*P")
3274    (if (not (and (outline-mode-p)                ; active outline mode,    (if (not (and (allout-mode-p)         ; active outline mode,
3275                  outline-numbered-bullet         ; numbers may need adjustment,                  allout-numbered-bullet          ; numbers may need adjustment,
3276                  (bolp)                          ; may be clipping topic head,                  (bolp)                          ; may be clipping topic head,
3277                  (looking-at outline-regexp)))   ; are clipping topic head.                  (looking-at allout-regexp)))    ; are clipping topic head.
3278        ;; Above conditions do not obtain - just do a regular kill:        ;; Above conditions do not obtain - just do a regular kill:
3279        (kill-line arg)        (kill-line arg)
3280      ;; Ah, have to watch out for adjustments:      ;; Ah, have to watch out for adjustments:
3281      (let* ((depth (outline-depth)))      (let* ((depth (allout-depth)))
3282                                          ; Do the kill:                                          ; Do the kill:
3283        (kill-line arg)        (kill-line arg)
3284                                          ; Provide some feedback:                                          ; Provide some feedback:
# Line 3285  rebulleting each topic at this level." Line 3286  rebulleting each topic at this level."
3286        (save-excursion        (save-excursion
3287                                          ; Start with the topic                                          ; Start with the topic
3288                                          ; following killed line:                                          ; following killed line:
3289          (if (not (looking-at outline-regexp))          (if (not (looking-at allout-regexp))
3290              (outline-next-heading))              (allout-next-heading))
3291          (outline-renumber-to-depth depth)))))          (allout-renumber-to-depth depth)))))
3292  ;;;_    > outline-kill-topic ()  ;;;_    > allout-kill-topic ()
3293  (defun outline-kill-topic ()  (defun allout-kill-topic ()
3294    "Kill topic together with subtopics.    "Kill topic together with subtopics.
3295    
3296  Leaves primary topic's trailing vertical whitespace, if any."  Leaves primary topic's trailing vertical whitespace, if any."
# Line 3301  Leaves primary topic's trailing vertical Line 3302  Leaves primary topic's trailing vertical
3302    ;; a lag *after* the kill has been performed.    ;; a lag *after* the kill has been performed.
3303    
3304    (interactive)    (interactive)
3305    (let* ((beg (prog1 (outline-back-to-current-heading)(beginning-of-line)))    (let* ((beg (prog1 (allout-back-to-current-heading)(beginning-of-line)))
3306           (depth (outline-recent-depth)))           (depth (allout-recent-depth)))
3307      (outline-end-of-current-subtree)      (allout-end-of-current-subtree)
3308      (if (not (eobp))      (if (not (eobp))
3309          (if (or (not (looking-at "^$"))          (if (or (not (looking-at "^$"))
3310                  ;; A blank line - cut it with this topic *unless* this                  ;; A blank line - cut it with this topic *unless* this
# Line 3311  Leaves primary topic's trailing vertical Line 3312  Leaves primary topic's trailing vertical
3312                  ;; we'll leave the blank line as part of the                  ;; we'll leave the blank line as part of the
3313                  ;; containing topic:                  ;; containing topic:
3314                  (save-excursion                  (save-excursion
3315                    (and (outline-next-heading)                    (and (allout-next-heading)
3316                         (>= (outline-recent-depth) depth))))                         (>= (allout-recent-depth) depth))))
3317              (forward-char 1)))              (forward-char 1)))
3318    
3319      (kill-region beg (point))      (kill-region beg (point))
3320      (sit-for 0)      (sit-for 0)
3321      (save-excursion      (save-excursion
3322        (outline-renumber-to-depth depth))))        (allout-renumber-to-depth depth))))
3323  ;;;_    > outline-yank-processing ()  ;;;_    > allout-yank-processing ()
3324  (defun outline-yank-processing (&optional arg)  (defun allout-yank-processing (&optional arg)
3325    
3326    "Incidental outline-specific business to be done just after text yanks.    "Incidental outline specific business to be done just after text yanks.
3327    
3328  Does depth adjustment of yanked topics, when:  Does depth adjustment of yanked topics, when:
3329    
# Line 3338  header into which it's being yanked. Line 3339  header into which it's being yanked.
3339    
3340  The point is left in front of yanked, adjusted topics, rather than  The point is left in front of yanked, adjusted topics, rather than
3341  at the end (and vice-versa with the mark).  Non-adjusted yanks,  at the end (and vice-versa with the mark).  Non-adjusted yanks,
3342  however, are left exactly like normal, non-outline-specific yanks."  however, are left exactly like normal, not outline specific yanks."
3343    
3344    (interactive "*P")    (interactive "*P")
3345                                          ; Get to beginning, leaving                                          ; Get to beginning, leaving
# Line 3348  however, are left exactly like normal, n Line 3349  however, are left exactly like normal, n
3349    (let* ((subj-beg (point))    (let* ((subj-beg (point))
3350           (subj-end (my-mark-marker t))           (subj-end (my-mark-marker t))
3351           ;; 'resituate' if yanking an entire topic into topic header:           ;; 'resituate' if yanking an entire topic into topic header:
3352           (resituate (and (outline-e-o-prefix-p)           (resituate (and (allout-e-o-prefix-p)
3353                           (looking-at (concat "\\(" outline-regexp "\\)"))                           (looking-at (concat "\\(" allout-regexp "\\)"))
3354                           (outline-prefix-data (match-beginning 1)                           (allout-prefix-data (match-beginning 1)
3355                                                (match-end 1))))                                                (match-end 1))))
3356           ;; `rectify-numbering' if resituating (where several topics may           ;; `rectify-numbering' if resituating (where several topics may
3357           ;; be resituating) or yanking a topic into a topic slot (bol):           ;; be resituating) or yanking a topic into a topic slot (bol):
3358           (rectify-numbering (or resituate           (rectify-numbering (or resituate
3359                                  (and (bolp) (looking-at outline-regexp)))))                                  (and (bolp) (looking-at allout-regexp)))))
3360      (if resituate      (if resituate
3361                                          ; The yanked stuff is a topic:                                          ; The yanked stuff is a topic:
3362          (let* ((prefix-len (- (match-end 1) subj-beg))          (let* ((prefix-len (- (match-end 1) subj-beg))
3363                 (subj-depth (outline-recent-depth))                 (subj-depth (allout-recent-depth))
3364                 (prefix-bullet (outline-recent-bullet))                 (prefix-bullet (allout-recent-bullet))
3365                 (adjust-to-depth                 (adjust-to-depth
3366                  ;; Nil if adjustment unnecessary, otherwise depth to which                  ;; Nil if adjustment unnecessary, otherwise depth to which
3367                  ;; adjustment should be made:                  ;; adjustment should be made:
# Line 3368  however, are left exactly like normal, n Line 3369  however, are left exactly like normal, n
3369                    (and (goto-char subj-end)                    (and (goto-char subj-end)
3370                         (eolp)                         (eolp)
3371                         (goto-char subj-beg)                         (goto-char subj-beg)
3372                         (and (looking-at outline-regexp)                         (and (looking-at allout-regexp)
3373                              (progn                              (progn
3374                                (beginning-of-line)                                (beginning-of-line)
3375                                (not (= (point) subj-beg)))                                (not (= (point) subj-beg)))
3376                              (looking-at outline-regexp)                              (looking-at allout-regexp)
3377                              (outline-prefix-data (match-beginning 0)                              (allout-prefix-data (match-beginning 0)
3378                                                   (match-end 0)))                                                   (match-end 0)))
3379                         (outline-recent-depth))))                         (allout-recent-depth))))
3380                 done                 done
3381                 (more t))                 (more t))
3382            (setq rectify-numbering outline-numbered-bullet)            (setq rectify-numbering allout-numbered-bullet)
3383            (if adjust-to-depth            (if adjust-to-depth
3384                                          ; Do the adjustment:                                          ; Do the adjustment:
3385                (progn                (progn
# Line 3389  however, are left exactly like normal, n Line 3390  however, are left exactly like normal, n
3390                                          ; line at end, if any:                                          ; line at end, if any:
3391                    (goto-char (point-max))                    (goto-char (point-max))
3392                    (if (looking-at "^$")                    (if (looking-at "^$")
3393                        (outline-unprotected (delete-char -1)))                        (allout-unprotected (delete-char -1)))
3394                                          ; Work backwards, with each                                          ; Work backwards, with each
3395                                          ; shallowest level,                                          ; shallowest level,
3396                                          ; successively excluding the                                          ; successively excluding the
3397                                          ; last processed topic from                                          ; last processed topic from
3398                                          ; the narrow region:                                          ; the narrow region:
3399                    (while more                    (while more
3400                      (outline-back-to-current-heading)                      (allout-back-to-current-heading)
3401                                          ; go as high as we can in each bunch:                                          ; go as high as we can in each bunch:
3402                      (while (outline-ascend-to-depth (1- (outline-depth))))                      (while (allout-ascend-to-depth (1- (allout-depth))))
3403                      (save-excursion                      (save-excursion
3404                        (outline-rebullet-topic-grunt (- adjust-to-depth                        (allout-rebullet-topic-grunt (- adjust-to-depth
3405                                                         subj-depth))                                                         subj-depth))
3406                        (outline-depth))                        (allout-depth))
3407                      (if (setq more (not (bobp)))                      (if (setq more (not (bobp)))
3408                          (progn (widen)                          (progn (widen)
3409                                 (forward-char -1)                                 (forward-char -1)
# Line 3411  however, are left exactly like normal, n Line 3412  however, are left exactly like normal, n
3412                  ;; Preserve new bullet if it's a distinctive one, otherwise                  ;; Preserve new bullet if it's a distinctive one, otherwise
3413                  ;; use old one:                  ;; use old one:
3414                  (if (string-match (regexp-quote prefix-bullet)                  (if (string-match (regexp-quote prefix-bullet)
3415                                    outline-distinctive-bullets-string)                                    allout-distinctive-bullets-string)
3416                                          ; Delete from bullet of old to                                          ; Delete from bullet of old to
3417                                          ; before bullet of new:                                          ; before bullet of new:
3418                      (progn                      (progn
# Line 3419  however, are left exactly like normal, n Line 3420  however, are left exactly like normal, n
3420                        (delete-region (point) subj-beg)                        (delete-region (point) subj-beg)
3421                        (set-marker (my-mark-marker t) subj-end)                        (set-marker (my-mark-marker t) subj-end)
3422                        (goto-char subj-beg)                        (goto-char subj-beg)
3423                        (outline-end-of-prefix))                        (allout-end-of-prefix))
3424                                          ; Delete base subj prefix,                                          ; Delete base subj prefix,
3425                                          ; leaving old one:                                          ; leaving old one:
3426                    (delete-region (point) (+ (point)                    (delete-region (point) (+ (point)
# Line 3437  however, are left exactly like normal, n Line 3438  however, are left exactly like normal, n
3438              (message "... reconciling numbers") (sit-for 0)              (message "... reconciling numbers") (sit-for 0)
3439                                          ; ... and renumber, in case necessary:                                          ; ... and renumber, in case necessary:
3440              (goto-char subj-beg)              (goto-char subj-beg)
3441              (if (outline-goto-prefix)              (if (allout-goto-prefix)
3442                  (outline-rebullet-heading nil   ;;; solicit                  (allout-rebullet-heading nil    ;;; solicit
3443                                            (outline-depth) ;;; depth                                            (allout-depth) ;;; depth
3444                                            nil   ;;; number-control                                            nil   ;;; number-control
3445                                            nil   ;;; index                                            nil   ;;; index
3446                                            t))                                            t))
3447              (message ""))))              (message ""))))
3448      (if (not resituate)      (if (not resituate)
3449        (exchange-point-and-mark))))        (exchange-point-and-mark))))
3450  ;;;_    > outline-yank (&optional arg)  ;;;_    > allout-yank (&optional arg)
3451  (defun outline-yank (&optional arg)  (defun allout-yank (&optional arg)
3452    "Outline-mode yank, with depth and numbering adjustment of yanked topics.    "`allout-mode' yank, with depth and numbering adjustment of yanked topics.
3453    
3454  Non-topic yanks work no differently than normal yanks.  Non-topic yanks work no differently than normal yanks.
3455    
3456  If a topic is being yanked into a bare topic prefix, the depth of the  If a topic is being yanked into a bare topic prefix, the depth of the
3457  yanked topic is adjusted to the depth of the topic prefix.  yanked topic is adjusted to the depth of the topic prefix.
3458    
3459    1 we're yanking in an outline-mode buffer    1 we're yanking in an `allout-mode' buffer
3460    2 the stuff being yanked starts with a valid outline header prefix, and    2 the stuff being yanked starts with a valid outline header prefix, and
3461    3 it is being yanked at the end of a line which consists of only a valid    3 it is being yanked at the end of a line which consists of only a valid
3462      topic prefix.      topic prefix.
# Line 3472  exactly like normal yanks. Line 3473  exactly like normal yanks.
3473  Numbering of yanked topics, and the successive siblings at the depth  Numbering of yanked topics, and the successive siblings at the depth
3474  into which they're being yanked, is adjusted.  into which they're being yanked, is adjusted.
3475    
3476  Outline-yank-pop works with outline-yank just like normal yank-pop  `allout-yank-pop' works with `allout-yank' just like normal yank-pop
3477  works with normal yank in non-outline buffers."  works with normal yank in non-outline buffers."
3478    
3479    (interactive "*P")    (interactive "*P")
3480    (setq this-command 'yank)    (setq this-command 'yank)
3481    (yank arg)    (yank arg)
3482    (if (outline-mode-p)    (if (allout-mode-p)
3483        (outline-yank-processing)))        (allout-yank-processing)))
3484  ;;;_    > outline-yank-pop (&optional arg)  ;;;_    > allout-yank-pop (&optional arg)
3485  (defun outline-yank-pop (&optional arg)  (defun allout-yank-pop (&optional arg)
3486    "Yank-pop like outline-yank when popping to bare outline prefixes.    "Yank-pop like `allout-yank' when popping to bare outline prefixes.
3487    
3488  Adapts level of popped topics to level of fresh prefix.  Adapts level of popped topics to level of fresh prefix.
3489    
# Line 3492  by pops to non-distinctive yanks.  Bug.. Line 3493  by pops to non-distinctive yanks.  Bug..
3493    (interactive "*p")    (interactive "*p")
3494    (setq this-command 'yank)    (setq this-command 'yank)
3495    (yank-pop arg)    (yank-pop arg)
3496    (if (outline-mode-p)    (if (allout-mode-p)
3497        (outline-yank-processing)))        (allout-yank-processing)))
3498    
3499  ;;;_  - Specialty bullet functions  ;;;_  - Specialty bullet functions
3500  ;;;_   : File Cross references  ;;;_   : File Cross references
3501  ;;;_    > outline-resolve-xref ()  ;;;_    > allout-resolve-xref ()
3502  (defun outline-resolve-xref ()  (defun allout-resolve-xref ()
3503    "Pop to file associated with current heading, if it has an xref bullet.    "Pop to file associated with current heading, if it has an xref bullet.
3504    
3505  \(Works according to setting of `outline-file-xref-bullet')."  \(Works according to setting of `allout-file-xref-bullet')."
3506    (interactive)    (interactive)
3507    (if (not outline-file-xref-bullet)    (if (not allout-file-xref-bullet)
3508        (error        (error
3509         "outline cross references disabled - no `outline-file-xref-bullet'")         "outline cross references disabled - no `allout-file-xref-bullet'")
3510      (if (not (string= (outline-current-bullet) outline-file-xref-bullet))      (if (not (string= (allout-current-bullet) allout-file-xref-bullet))
3511          (error "current heading lacks cross-reference bullet `%s'"          (error "current heading lacks cross-reference bullet `%s'"
3512                 outline-file-xref-bullet)                 allout-file-xref-bullet)
3513        (let (file-name)        (let (file-name)
3514          (save-excursion          (save-excursion
3515            (let* ((text-start outline-recent-prefix-end)            (let* ((text-start allout-recent-prefix-end)
3516                   (heading-end (progn (end-of-line) (point))))                   (heading-end (progn (end-of-line) (point))))
3517              (goto-char text-start)              (goto-char text-start)
3518              (setq file-name              (setq file-name
# Line 3542  by pops to non-distinctive yanks.  Bug.. Line 3543  by pops to non-distinctive yanks.  Bug..
3543  ;;;_ #6 Exposure Control  ;;;_ #6 Exposure Control
3544    
3545  ;;;_  - Fundamental  ;;;_  - Fundamental
3546  ;;;_   > outline-flag-current-subtree (flag)  ;;;_   > allout-flag-current-subtree (flag)
3547  (defun outline-flag-current-subtree (flag)  (defun allout-flag-current-subtree (flag)
3548    "Hide or show subtree of currently-visible topic.    "Hide or show subtree of currently-visible topic.
3549    
3550  See `outline-flag-region' for more details."  See `allout-flag-region' for more details."
3551    
3552    (save-excursion    (save-excursion
3553      (outline-back-to-current-heading)      (allout-back-to-current-heading)
3554      (outline-flag-region (point)      (allout-flag-region (point)
3555                           (progn (outline-end-of-current-subtree) (1- (point)))                           (progn (allout-end-of-current-subtree) (1- (point)))
3556                           flag)))                           flag)))
3557    
3558  ;;;_  - Topic-specific  ;;;_  - Topic-specific
3559  ;;;_   > outline-show-entry ()  ;;;_   > allout-show-entry ()
3560  (defun outline-show-entry ()  (defun allout-show-entry ()
3561    "Like `outline-show-current-entry', reveals entries nested in hidden topics.    "Like `allout-show-current-entry', reveals entries nested in hidden topics.
3562    
3563  This is a way to give restricted peek at a concealed locality without the  This is a way to give restricted peek at a concealed locality without the
3564  expense of exposing its context, but can leave the outline with aberrant  expense of exposing its context, but can leave the outline with aberrant
3565  exposure.  outline-hide-current-entry-completely or outline-show-offshoot  exposure.  `allout-hide-current-entry-completely' or `allout-show-to-offshoot'
3566  should be used after the peek to rectify the exposure."  should be used after the peek to rectify the exposure."
3567    
3568    (interactive)    (interactive)
3569    (save-excursion    (save-excursion
3570      (let ((at (point))      (let ((at (point))
3571            beg end)            beg end)
3572        (outline-goto-prefix)        (allout-goto-prefix)
3573        (setq beg (if (= (preceding-char) ?\r) (1- (point)) (point)))        (setq beg (if (= (preceding-char) ?\r) (1- (point)) (point)))
3574        (re-search-forward "[\n\r]" nil t)        (re-search-forward "[\n\r]" nil t)
3575        (setq end (1- (if (< at (point))        (setq end (1- (if (< at (point))
3576                          ;; We're on topic head line - show only it:                          ;; We're on topic head line - show only it:
3577                          (point)                          (point)
3578                        ;; or we're in body - include it:                        ;; or we're in body - include it:
3579                        (max beg (or (outline-pre-next-preface) (point))))))                        (max beg (or (allout-pre-next-preface) (point))))))
3580        (outline-flag-region beg end ?\n)        (allout-flag-region beg end ?\n)
3581        (list beg end))))        (list beg end))))
3582  ;;;_   > outline-show-children (&optional level strict)  ;;;_   > allout-show-children (&optional level strict)
3583  (defun outline-show-children (&optional level strict)  (defun allout-show-children (&optional level strict)
3584    
3585    "If point is visible, show all direct subheadings of this heading.    "If point is visible, show all direct subheadings of this heading.
3586    
3587  Otherwise, do outline-show-to-offshoot, and then show subheadings.  Otherwise, do `allout-show-to-offshoot', and then show subheadings.
3588    
3589  Optional LEVEL specifies how many levels below the current level  Optional LEVEL specifies how many levels below the current level
3590  should be shown, or all levels if t.  Default is 1.  should be shown, or all levels if t.  Default is 1.
# Line 3599  point of non-opened subtree?)" Line 3600  point of non-opened subtree?)"
3600    (interactive "p")    (interactive "p")
3601    (let (max-pos)    (let (max-pos)
3602      (if (and (not strict)      (if (and (not strict)
3603               (outline-hidden-p))               (allout-hidden-p))
3604    
3605          (progn (outline-show-to-offshoot) ; Point's concealed, open to          (progn (allout-show-to-offshoot) ; Point's concealed, open to
3606                                            ; expose it.                                            ; expose it.
3607                 ;; Then recurse, but with "strict" set so we don't                 ;; Then recurse, but with "strict" set so we don't
3608                 ;; infinite regress:                 ;; infinite regress:
3609                 (setq max-pos (outline-show-children level t)))                 (setq max-pos (allout-show-children level t)))
3610    
3611        (save-excursion        (save-excursion
3612          (save-restriction          (save-restriction
3613            (let* ((start-pt (point))            (let* ((start-pt (point))
3614                   (chart (outline-chart-subtree (or level 1)))                   (chart (allout-chart-subtree (or level 1)))
3615                   (to-reveal (outline-chart-to-reveal chart (or level 1))))                   (to-reveal (allout-chart-to-reveal chart (or level 1))))
3616              (goto-char start-pt)              (goto-char start-pt)
3617              (if (and strict (= (preceding-char) ?\r))              (if (and strict (= (preceding-char) ?\r))
3618                  ;; Concealed root would already have been taken care of,                  ;; Concealed root would already have been taken care of,
3619                  ;; unless strict was set.                  ;; unless strict was set.
3620                  (progn                  (progn
3621                    (outline-flag-region (point) (outline-snug-back) ?\n)                    (allout-flag-region (point) (allout-snug-back) ?\n)
3622                    (if outline-show-bodies                    (if allout-show-bodies
3623                        (progn (goto-char (car to-reveal))                        (progn (goto-char (car to-reveal))
3624                               (outline-show-current-entry)))))                               (allout-show-current-entry)))))
3625              (while to-reveal              (while to-reveal
3626                (goto-char (car to-reveal))                (goto-char (car to-reveal))
3627                (outline-flag-region (point) (outline-snug-back) ?\n)                (allout-flag-region (point) (allout-snug-back) ?\n)
3628                (if outline-show-bodies                (if allout-show-bodies
3629                    (progn (goto-char (car to-reveal))                    (progn (goto-char (car to-reveal))
3630                           (outline-show-current-entry)))                           (allout-show-current-entry)))
3631                (setq to-reveal (cdr to-reveal)))))))))                (setq to-reveal (cdr to-reveal)))))))))
3632  ;;;_   > outline-hide-point-reconcile ()  ;;;_   > allout-hide-point-reconcile ()
3633  (defun outline-hide-reconcile ()  (defun allout-hide-reconcile ()
3634    "Like `outline-hide-current-entry'; hides completely if within hidden region.    "Like `allout-hide-current-entry'; hides completely if within hidden region.
3635    
3636  Specifically intended for aberrant exposure states, like entries that were  Specifically intended for aberrant exposure states, like entries that were
3637  exposed by outline-show-entry but are within otherwise concealed regions."  exposed by `allout-show-entry' but are within otherwise concealed regions."
3638    (interactive)    (interactive)
3639    (save-excursion    (save-excursion
3640      (outline-goto-prefix)      (allout-goto-prefix)
3641      (outline-flag-region (if (not (bobp)) (1- (point)) (point))      (allout-flag-region (if (not (bobp)) (1- (point)) (point))
3642                           (progn (outline-pre-next-preface)                           (progn (allout-pre-next-preface)
3643                                  (if (= ?\r (following-char))                                  (if (= ?\r (following-char))
3644                                      (point)                                      (point)
3645                                    (1- (point))))                                    (1- (point))))
3646                           ?\r)))                           ?\r)))
3647  ;;;_   > outline-show-to-offshoot ()  ;;;_   > allout-show-to-offshoot ()
3648  (defun outline-show-to-offshoot ()  (defun allout-show-to-offshoot ()
3649    "Like outline-show-entry, but reveals all concealed ancestors, as well.    "Like `allout-show-entry', but reveals all concealed ancestors, as well.
3650    
3651  As with outline-hide-current-entry-completely, useful for rectifying  As with `allout-hide-current-entry-completely', useful for rectifying
3652  aberrant exposure states produced by outline-show-entry."  aberrant exposure states produced by `allout-show-entry'."
3653    
3654    (interactive)    (interactive)
3655    (save-excursion    (save-excursion
3656      (let ((orig-pt (point))      (let ((orig-pt (point))
3657            (orig-pref (outline-goto-prefix))            (orig-pref (allout-goto-prefix))
3658            (last-at (point))            (last-at (point))
3659            bag-it)            bag-it)
3660        (while (or bag-it (= (preceding-char) ?\r))        (while (or bag-it (= (preceding-char) ?\r))
# Line 3662  aberrant exposure states produced by out Line 3663  aberrant exposure states produced by out
3663              ;; Oops, we're not making any progress!  Show the current              ;; Oops, we're not making any progress!  Show the current
3664              ;; topic completely, and bag this try.              ;; topic completely, and bag this try.
3665              (progn (beginning-of-line)              (progn (beginning-of-line)
3666                     (outline-show-current-subtree)                     (allout-show-current-subtree)
3667                     (goto-char orig-pt)                     (goto-char orig-pt)
3668                     (setq bag-it t)                     (setq bag-it t)
3669                     (beep)                     (beep)
3670                     (message "%s: %s"                     (message "%s: %s"
3671                              "outline-show-to-offshoot: "                              "allout-show-to-offshoot: "
3672                              "Aberrant nesting encountered.")))                              "Aberrant nesting encountered.")))
3673          (outline-show-children)          (allout-show-children)
3674          (goto-char orig-pref))          (goto-char orig-pref))
3675        (goto-char orig-pt)))        (goto-char orig-pt)))
3676    (if (outline-hidden-p)    (if (allout-hidden-p)
3677        (outline-show-entry)))        (allout-show-entry)))
3678  ;;;_   > outline-hide-current-entry ()  ;;;_   > allout-hide-current-entry ()
3679  (defun outline-hide-current-entry ()  (defun allout-hide-current-entry ()
3680    "Hide the body directly following this heading."    "Hide the body directly following this heading."
3681    (interactive)    (interactive)
3682    (outline-back-to-current-heading)    (allout-back-to-current-heading)
3683    (save-excursion    (save-excursion
3684     (outline-flag-region (point)     (allout-flag-region (point)
3685                          (progn (outline-end-of-current-entry) (point))                          (progn (allout-end-of-current-entry) (point))
3686                          ?\r)))                          ?\r)))
3687  ;;;_   > outline-show-current-entry (&optional arg)  ;;;_   > allout-show-current-entry (&optional arg)
3688  (defun outline-show-current-entry (&optional arg)  (defun allout-show-current-entry (&optional arg)
3689    
3690    "Show body following current heading, or hide the entry if repeat count."    "Show body following current heading, or hide the entry if repeat count."
3691    
3692    (interactive "P")    (interactive "P")
3693    (if arg    (if arg
3694        (outline-hide-current-entry)        (allout-hide-current-entry)
3695      (save-excursion      (save-excursion
3696        (outline-flag-region (point)        (allout-flag-region (point)
3697                             (progn (outline-end-of-current-entry) (point))                             (progn (allout-end-of-current-entry) (point))
3698                             ?\n))))                             ?\n))))
3699  ;;;_   > outline-hide-current-entry-completely ()  ;;;_   > allout-hide-current-entry-completely ()
3700  ; ... outline-hide-current-entry-completely also for isearch dynamic exposure:  ; ... allout-hide-current-entry-completely also for isearch dynamic exposure:
3701  (defun outline-hide-current-entry-completely ()  (defun allout-hide-current-entry-completely ()
3702    "Like outline-hide-current-entry, but conceal topic completely.    "Like `allout-hide-current-entry', but conceal topic completely.
3703    
3704  Specifically intended for aberrant exposure states, like entries that were  Specifically intended for aberrant exposure states, like entries that were
3705  exposed by outline-show-entry but are within otherwise concealed regions."  exposed by `allout-show-entry' but are within otherwise concealed regions."
3706    (interactive)    (interactive)
3707    (save-excursion    (save-excursion
3708      (outline-goto-prefix)      (allout-goto-prefix)
3709      (outline-flag-region (if (not (bobp)) (1- (point)) (point))      (allout-flag-region (if (not (bobp)) (1- (point)) (point))
3710                           (progn (outline-pre-next-preface)                           (progn (allout-pre-next-preface)
3711                                  (if (= ?\r (following-char))                                  (if (= ?\r (following-char))
3712                                      (point)                                      (point)
3713                                    (1- (point))))                                    (1- (point))))
3714                           ?\r)))                           ?\r)))
3715  ;;;_   > outline-show-current-subtree (&optional arg)  ;;;_   > allout-show-current-subtree (&optional arg)
3716  (defun outline-show-current-subtree (&optional arg)  (defun allout-show-current-subtree (&optional arg)
3717    "Show everything within the current topic.  With a repeat-count,    "Show everything within the current topic.  With a repeat-count,
3718  expose this topic and its siblings."  expose this topic and its siblings."
3719    (interactive "P")    (interactive "P")
3720    (save-excursion    (save-excursion
3721      (if (<= (outline-current-depth) 0)      (if (<= (allout-current-depth) 0)
3722          ;; Outside any topics - try to get to the first:          ;; Outside any topics - try to get to the first:
3723          (if (not (outline-next-heading))          (if (not (allout-next-heading))
3724              (error "No topics")              (error "No topics")
3725            ;; got to first, outermost topic - set to expose it and siblings:            ;; got to first, outermost topic - set to expose it and siblings:
3726            (message "Above outermost topic - exposing all.")            (message "Above outermost topic - exposing all.")
3727            (outline-flag-region (point-min)(point-max) ?\n))            (allout-flag-region (point-min)(point-max) ?\n))
3728        (if (not arg)        (if (not arg)
3729            (outline-flag-current-subtree ?\n)            (allout-flag-current-subtree ?\n)
3730          (outline-beginning-of-level)          (allout-beginning-of-level)
3731          (outline-expose-topic '(* :))))))          (allout-expose-topic '(* :))))))
3732  ;;;_   > outline-hide-current-subtree (&optional just-close)  ;;;_   > allout-hide-current-subtree (&optional just-close)
3733  (defun outline-hide-current-subtree (&optional just-close)  (defun allout-hide-current-subtree (&optional just-close)
3734    "Close the current topic, or containing topic if this one is already closed.    "Close the current topic, or containing topic if this one is already closed.
3735    
3736  If this topic is closed and it's a top level topic, close this topic  If this topic is closed and it's a top level topic, close this topic
# Line 3741  siblings, even if the target topic is al Line 3742  siblings, even if the target topic is al
3742    (interactive)    (interactive)
3743    (let ((from (point))    (let ((from (point))
3744          (orig-eol (progn (end-of-line)          (orig-eol (progn (end-of-line)
3745                           (if (not (outline-goto-prefix))                           (if (not (allout-goto-prefix))
3746                               (error "No topics found")                               (error "No topics found")
3747                             (end-of-line)(point)))))                             (end-of-line)(point)))))
3748      (outline-flag-current-subtree ?\r)      (allout-flag-current-subtree ?\r)
3749      (goto-char from)      (goto-char from)
3750      (if (and (= orig-eol (progn (goto-char orig-eol)      (if (and (= orig-eol (progn (goto-char orig-eol)
3751                                  (end-of-line)                                  (end-of-line)
# Line 3752  siblings, even if the target topic is al Line 3753  siblings, even if the target topic is al
3753               (not just-close)               (not just-close)
3754               ;; Structure didn't change - try hiding current level:               ;; Structure didn't change - try hiding current level:
3755               (goto-char from)               (goto-char from)
3756               (if (outline-up-current-level 1 t)               (if (allout-up-current-level 1 t)
3757                   t                   t
3758                 (goto-char 0)                 (goto-char 0)
3759                 (let ((msg                 (let ((msg
3760                        "Top-level topic already closed - closing siblings..."))                        "Top-level topic already closed - closing siblings..."))
3761                   (message msg)                   (message msg)
3762                   (outline-expose-topic '(0 :))                   (allout-expose-topic '(0 :))
3763                   (message (concat msg "  Done.")))                   (message (concat msg "  Done.")))
3764                 nil)                 nil)
3765               (/= (outline-recent-depth) 0))               (/= (allout-recent-depth) 0))
3766          (outline-hide-current-subtree))          (allout-hide-current-subtree))
3767        (goto-char from)))        (goto-char from)))
3768  ;;;_   > outline-show-current-branches ()  ;;;_   > allout-show-current-branches ()
3769  (defun outline-show-current-branches ()  (defun allout-show-current-branches ()
3770    "Show all subheadings of this heading, but not their bodies."    "Show all subheadings of this heading, but not their bodies."
3771    (interactive)    (interactive)
3772    (beginning-of-line)    (beginning-of-line)
3773    (outline-show-children t))    (allout-show-children t))
3774  ;;;_   > outline-hide-current-leaves ()  ;;;_   > allout-hide-current-leaves ()
3775  (defun outline-hide-current-leaves ()  (defun allout-hide-current-leaves ()
3776    "Hide the bodies of the current topic and all its offspring."    "Hide the bodies of the current topic and all its offspring."
3777    (interactive)    (interactive)
3778    (outline-back-to-current-heading)    (allout-back-to-current-heading)
3779    (outline-hide-region-body (point) (progn (outline-end-of-current-subtree)    (allout-hide-region-body (point) (progn (allout-end-of-current-subtree)
3780                                             (point))))                                             (point))))
3781    
3782  ;;;_  - Region and beyond  ;;;_  - Region and beyond
3783  ;;;_   > outline-show-all ()  ;;;_   > allout-show-all ()
3784  (defun outline-show-all ()  (defun allout-show-all ()
3785    "Show all of the text in the buffer."    "Show all of the text in the buffer."
3786    (interactive)    (interactive)
3787    (message "Exposing entire buffer...")    (message "Exposing entire buffer...")
3788    (outline-flag-region (point-min) (point-max) ?\n)    (allout-flag-region (point-min) (point-max) ?\n)
3789    (message "Exposing entire buffer...  Done."))    (message "Exposing entire buffer...  Done."))
3790  ;;;_   > outline-hide-bodies ()  ;;;_   > allout-hide-bodies ()
3791  (defun outline-hide-bodies ()  (defun allout-hide-bodies ()
3792    "Hide all of buffer except headings."    "Hide all of buffer except headings."
3793    (interactive)    (interactive)
3794    (outline-hide-region-body (point-min) (point-max)))    (allout-hide-region-body (point-min) (point-max)))
3795  ;;;_   > outline-hide-region-body (start end)  ;;;_   > allout-hide-region-body (start end)
3796  (defun outline-hide-region-body (start end)  (defun allout-hide-region-body (start end)
3797    "Hide all body lines in the region, but not headings."    "Hide all body lines in the region, but not headings."
3798    (save-excursion    (save-excursion
3799      (save-restriction      (save-restriction
3800        (narrow-to-region start end)        (narrow-to-region start end)
3801        (goto-char (point-min))        (goto-char (point-min))
3802        (while (not (eobp))        (while (not (eobp))
3803          (outline-flag-region (point)          (allout-flag-region (point)
3804                               (progn (outline-pre-next-preface) (point)) ?\r)                               (progn (allout-pre-next-preface) (point)) ?\r)
3805          (if (not (eobp))          (if (not (eobp))
3806              (forward-char              (forward-char
3807               (if (looking-at "[\n\r][\n\r]")               (if (looking-at "[\n\r][\n\r]")
3808                   2 1)))))))                   2 1)))))))
3809    
3810  ;;;_   > outline-expose-topic (spec)  ;;;_   > allout-expose-topic (spec)
3811  (defun outline-expose-topic (spec)  (defun allout-expose-topic (spec)
3812    "Apply exposure specs to successive outline topic items.    "Apply exposure specs to successive outline topic items.
3813    
3814  Use the more convenient frontend, `outline-new-exposure', if you don't  Use the more convenient frontend, `allout-new-exposure', if you don't
3815  need evaluation of the arguments, or even better, the `outline-layout'  need evaluation of the arguments, or even better, the `allout-layout'
3816  variable-keyed mode-activation/auto-exposure feature of allout outline  variable-keyed mode-activation/auto-exposure feature of allout outline
3817  mode.  See the respective documentation strings for more details.  mode.  See the respective documentation strings for more details.
3818    
# Line 3851  Simple (numeric and null-list) specs are Line 3852  Simple (numeric and null-list) specs are
3852    -  - exposes the body of the corresponding topic.    -  - exposes the body of the corresponding topic.
3853    
3854  Examples:  Examples:
3855  \(outline-expose-topic '(-1 : 0))  \(allout-expose-topic '(-1 : 0))
3856          Close this and all following topics at current level, exposing          Close this and all following topics at current level, exposing
3857          only their immediate children, but close down the last topic          only their immediate children, but close down the last topic
3858          at this current level completely.          at this current level completely.
3859  \(outline-expose-topic '(-1 () : 1 0))  \(allout-expose-topic '(-1 () : 1 0))
3860          Close current topic so only the immediate subtopics are shown;          Close current topic so only the immediate subtopics are shown;
3861          show the children in the second to last topic, and completely          show the children in the second to last topic, and completely
3862          close the last one.          close the last one.
3863  \(outline-expose-topic '(-2 : -1 *))  \(allout-expose-topic '(-2 : -1 *))
3864          Expose children and grandchildren of all topics at current          Expose children and grandchildren of all topics at current
3865          level except the last two; expose children of the second to          level except the last two; expose children of the second to
3866          last and completely open the last one."          last and completely open the last one."
# Line 3867  Examples: Line 3868  Examples:
3868    (interactive "xExposure spec: ")    (interactive "xExposure spec: ")
3869    (if (not (listp spec))    (if (not (listp spec))
3870        nil        nil
3871      (let ((depth (outline-depth))      (let ((depth (allout-depth))
3872            (max-pos 0)            (max-pos 0)
3873            prev-elem curr-elem            prev-elem curr-elem
3874            stay done            stay done
# Line 3880  Examples: Line 3881  Examples:
3881          (cond                           ; Do current element:          (cond                           ; Do current element:
3882           ((null curr-elem) nil)           ((null curr-elem) nil)
3883           ((symbolp curr-elem)           ((symbolp curr-elem)
3884            (cond ((eq curr-elem '*) (outline-show-current-subtree)            (cond ((eq curr-elem '*) (allout-show-current-subtree)
3885                   (if (> outline-recent-end-of-subtree max-pos)                   (if (> allout-recent-end-of-subtree max-pos)
3886                       (setq max-pos outline-recent-end-of-subtree)))                       (setq max-pos allout-recent-end-of-subtree)))
3887                  ((eq curr-elem '+) (outline-show-current-branches)                  ((eq curr-elem '+) (allout-show-current-branches)
3888                   (if (> outline-recent-end-of-subtree max-pos)                   (if (> allout-recent-end-of-subtree max-pos)
3889                       (setq max-pos outline-recent-end-of-subtree)))                       (setq max-pos allout-recent-end-of-subtree)))
3890                  ((eq curr-elem '-) (outline-show-current-entry))                  ((eq curr-elem '-) (allout-show-current-entry))
3891                  ((eq curr-elem ':)                  ((eq curr-elem ':)
3892                   (setq stay t)                   (setq stay t)
3893                   ;; Expand the `repeat' spec to an explicit version,                   ;; Expand the `repeat' spec to an explicit version,
3894                   ;; w.r.t. remaining siblings:                   ;; w.r.t. remaining siblings:
3895                   (let ((residue    ; = # of sibs not covered by remaining spec                   (let ((residue    ; = # of sibs not covered by remaining spec
3896                          ;; Dang - could be nice to make use of the chart, sigh:                          ;; Dang - could be nice to make use of the chart, sigh:
3897                          (- (length (outline-chart-siblings))                          (- (length (allout-chart-siblings))
3898                             (length spec))))                             (length spec))))
3899                     (if (< 0 residue)                     (if (< 0 residue)
3900                         ;; Some residue - cover it with prev-elem:                         ;; Some residue - cover it with prev-elem:
3901                         (setq spec (append (make-list residue prev-elem)                         (setq spec (append (make-list residue prev-elem)
3902                                            spec)))))))                                            spec)))))))
3903           ((numberp curr-elem)           ((numberp curr-elem)
3904            (if (and (>= 0 curr-elem) (outline-visible-p))            (if (and (>= 0 curr-elem) (allout-visible-p))
3905                (save-excursion (outline-hide-current-subtree t)                (save-excursion (allout-hide-current-subtree t)
3906                                (if (> 0 curr-elem)                                (if (> 0 curr-elem)
3907                                    nil                                    nil
3908                                  (if (> outline-recent-end-of-subtree max-pos)                                  (if (> allout-recent-end-of-subtree max-pos)
3909                                      (setq max-pos                                      (setq max-pos
3910                                            outline-recent-end-of-subtree)))))                                            allout-recent-end-of-subtree)))))
3911            (if (> (abs curr-elem) 0)            (if (> (abs curr-elem) 0)
3912                (progn (outline-show-children (abs curr-elem))                (progn (allout-show-children (abs curr-elem))
3913                       (if (> outline-recent-end-of-subtree max-pos)                       (if (> allout-recent-end-of-subtree max-pos)
3914                           (setq max-pos outline-recent-end-of-subtree)))))                           (setq max-pos allout-recent-end-of-subtree)))))
3915            ((listp curr-elem)            ((listp curr-elem)
3916             (if (outline-descend-to-depth (1+ depth))             (if (allout-descend-to-depth (1+ depth))
3917                 (let ((got (outline-expose-topic curr-elem)))                 (let ((got (allout-expose-topic curr-elem)))
3918                   (if (and got (> got max-pos)) (setq max-pos got))))))                   (if (and got (> got max-pos)) (setq max-pos got))))))
3919          (cond (stay (setq stay nil))          (cond (stay (setq stay nil))
3920                ((listp (car spec)) nil)                ((listp (car spec)) nil)
3921                ((> max-pos (point))                ((> max-pos (point))
3922                 ;; Capitalize on max-pos state to get us nearer next sibling:                 ;; Capitalize on max-pos state to get us nearer next sibling:
3923                 (progn (goto-char (min (point-max) max-pos))                 (progn (goto-char (min (point-max) max-pos))
3924                        (outline-next-heading)))                        (allout-next-heading)))
3925                ((outline-next-sibling depth))))                ((allout-next-sibling depth))))
3926        max-pos)))        max-pos)))
3927  ;;;_   > outline-old-expose-topic (spec &rest followers)  ;;;_   > allout-old-expose-topic (spec &rest followers)
3928  (defun outline-old-expose-topic (spec &rest followers)  (defun allout-old-expose-topic (spec &rest followers)
3929    
3930    "Deprecated.  Use outline-expose-topic \(with different schema    "Deprecated.  Use `allout-expose-topic' \(with different schema
3931  format) instead.  format) instead.
3932    
3933  Dictate wholesale exposure scheme for current topic, according to SPEC.  Dictate wholesale exposure scheme for current topic, according to SPEC.
# Line 3959  for the corresponding offspring of the t Line 3960  for the corresponding offspring of the t
3960  Optional FOLLOWER arguments dictate exposure for succeeding siblings."  Optional FOLLOWER arguments dictate exposure for succeeding siblings."
3961    
3962    (interactive "xExposure spec: ")    (interactive "xExposure spec: ")
3963    (let ((depth (outline-current-depth))    (let ((depth (allout-current-depth))
3964          done          done
3965          max-pos)          max-pos)
3966      (cond ((null spec) nil)      (cond ((null spec) nil)
3967            ((symbolp spec)            ((symbolp spec)
3968             (if (eq spec '*) (outline-show-current-subtree))             (if (eq spec '*) (allout-show-current-subtree))
3969             (if (eq spec '+) (outline-show-current-branches))             (if (eq spec '+) (allout-show-current-branches))
3970             (if (eq spec '-) (outline-show-current-entry)))             (if (eq spec '-) (allout-show-current-entry)))
3971            ((numberp spec)            ((numberp spec)
3972             (if (>= 0 spec)             (if (>= 0 spec)
3973                 (save-excursion (outline-hide-current-subtree t)                 (save-excursion (allout-hide-current-subtree t)
3974                                 (end-of-line)                                 (end-of-line)
3975                                 (if (or (not max-pos)                                 (if (or (not max-pos)
3976                                         (> (point) max-pos))                                         (> (point) max-pos))
# Line 3977  Optional FOLLOWER arguments dictate expo Line 3978  Optional FOLLOWER arguments dictate expo
3978                                 (if (> 0 spec)                                 (if (> 0 spec)
3979                                     (setq spec (* -1 spec)))))                                     (setq spec (* -1 spec)))))
3980             (if (> spec 0)             (if (> spec 0)
3981               (outline-show-children spec)))               (allout-show-children spec)))
3982            ((listp spec)            ((listp spec)
3983             ;(let ((got (outline-old-expose-topic (car spec))))             ;(let ((got (allout-old-expose-topic (car spec))))
3984             ;  (if (and got (or (not max-pos) (> got max-pos)))             ;  (if (and got (or (not max-pos) (> got max-pos)))
3985             ;     (setq max-pos got)))             ;     (setq max-pos got)))
3986             (let ((new-depth  (+ (outline-current-depth) 1))             (let ((new-depth  (+ (allout-current-depth) 1))
3987                   got)                   got)
3988               (setq max-pos (outline-old-expose-topic (car spec)))               (setq max-pos (allout-old-expose-topic (car spec)))
3989               (setq spec (cdr spec))               (setq spec (cdr spec))
3990               (if (and spec               (if (and spec
3991                        (outline-descend-to-depth new-depth)                        (allout-descend-to-depth new-depth)
3992                        (not (outline-hidden-p)))                        (not (allout-hidden-p)))
3993                   (progn (setq got (apply 'outline-old-expose-topic spec))                   (progn (setq got (apply 'allout-old-expose-topic spec))
3994                          (if (and got (or (not max-pos) (> got max-pos)))                          (if (and got (or (not max-pos) (> got max-pos)))
3995                              (setq max-pos got)))))))                              (setq max-pos got)))))))
3996      (while (and followers      (while (and followers
# Line 3997  Optional FOLLOWER arguments dictate expo Line 3998  Optional FOLLOWER arguments dictate expo
3998                             (progn (goto-char max-pos)                             (progn (goto-char max-pos)
3999                                    (setq max-pos nil)))                                    (setq max-pos nil)))
4000                         (end-of-line)                         (end-of-line)
4001                         (outline-next-sibling depth)))                         (allout-next-sibling depth)))
4002        (outline-old-expose-topic (car followers))        (allout-old-expose-topic (car followers))
4003        (setq followers (cdr followers)))        (setq followers (cdr followers)))
4004      max-pos))      max-pos))
4005  ;;;_   > outline-new-exposure '()  ;;;_   > allout-new-exposure '()
4006  (defmacro outline-new-exposure (&rest spec)  (defmacro allout-new-exposure (&rest spec)
4007    "Literal frontend for `outline-expose-topic', doesn't evaluate arguments.    "Literal frontend for `allout-expose-topic', doesn't evaluate arguments.
4008  Some arguments that would need to be quoted in outline-expose-topic  Some arguments that would need to be quoted in `allout-expose-topic'
4009  need not be quoted in outline-new-exposure.  need not be quoted in `allout-new-exposure'.
4010    
4011  Cursor is left at start position.  Cursor is left at start position.
4012    
4013  Use this instead of obsolete `outline-exposure'.  Use this instead of obsolete `allout-exposure'.
4014    
4015  Examples:  Examples:
4016  \(outline-exposure (-1 () () () 1) 0)  \(allout-exposure (-1 () () () 1) 0)
4017          Close current topic at current level so only the immediate          Close current topic at current level so only the immediate
4018          subtopics are shown, except also show the children of the          subtopics are shown, except also show the children of the
4019          third subtopic; and close the next topic at the current level.          third subtopic; and close the next topic at the current level.
4020  \(outline-exposure : -1 0)  \(allout-exposure : -1 0)
4021          Close all topics at current level to expose only their          Close all topics at current level to expose only their
4022          immediate children, except for the last topic at the current          immediate children, except for the last topic at the current
4023          level, in which even its immediate children are hidden.          level, in which even its immediate children are hidden.
4024  \(outline-exposure -2 : -1 *)  \(allout-exposure -2 : -1 *)
4025          Expose children and grandchildren of first topic at current          Expose children and grandchildren of first topic at current
4026          level, and expose children of subsequent topics at current          level, and expose children of subsequent topics at current
4027          level *except* for the last, which should be opened completely."          level *except* for the last, which should be opened completely."
4028    (list 'save-excursion    (list 'save-excursion
4029          '(if (not (or (outline-goto-prefix)          '(if (not (or (allout-goto-prefix)
4030                        (outline-next-heading)))                        (allout-next-heading)))
4031               (error "outline-new-exposure: Can't find any outline topics"))               (error "allout-new-exposure: Can't find any outline topics"))
4032          (list 'outline-expose-topic (list 'quote spec))))          (list 'allout-expose-topic (list 'quote spec))))
4033  ;;;_   > outline-exposure '()  ;;;_   > allout-exposure '()
4034  (defmacro outline-exposure (&rest spec)  (defmacro allout-exposure (&rest spec)
4035    "Being deprecated - use more recent `outline-new-exposure' instead.    "Being deprecated - use more recent `allout-new-exposure' instead.
4036    
4037  Literal frontend for `outline-old-expose-topic', doesn't evaluate arguments  Literal frontend for `allout-old-expose-topic', doesn't evaluate arguments
4038  and retains start position."  and retains start position."
4039    (list 'save-excursion    (list 'save-excursion
4040          '(if (not (or (outline-goto-prefix)          '(if (not (or (allout-goto-prefix)
4041                        (outline-next-heading)))                        (allout-next-heading)))
4042               (error "Can't find any outline topics"))               (error "Can't find any outline topics"))
4043          (cons 'outline-old-expose-topic          (cons 'allout-old-expose-topic
4044                (mapcar (function (lambda (x) (list 'quote x))) spec))))                (mapcar (function (lambda (x) (list 'quote x))) spec))))
4045    
4046  ;;;_ #7 Systematic outline presentation - copying, printing, flattening  ;;;_ #7 Systematic outline presentation - copying, printing, flattening
4047    
4048  ;;;_  - Mapping and processing of topics  ;;;_  - Mapping and processing of topics
4049  ;;;_   ( See also Subtree Charting, in Navigation code.)  ;;;_   ( See also Subtree Charting, in Navigation code.)
4050  ;;;_   > outline-stringify-flat-index (flat-index)  ;;;_   > allout-stringify-flat-index (flat-index)
4051  (defun outline-stringify-flat-index (flat-index &optional context)  (defun allout-stringify-flat-index (flat-index &optional context)
4052    "Convert list representing section/subsection/... to document string.    "Convert list representing section/subsection/... to document string.
4053    
4054  Optional arg CONTEXT indicates interior levels to include."  Optional arg CONTEXT indicates interior levels to include."
4055    (let ((delim ".")    (let ((delim ".")
4056          result          result
4057          numstr          numstr
4058          (context-depth (or (and context 2) 1)))          (context-depth (or (and context 2) 1)))
4059      ;; Take care of the explicit context:      ;; Take care of the explicit context:
# Line 4080  Optional arg CONTEXT indicates interior Line 4081  Optional arg CONTEXT indicates interior
4081            ;; Dispose of single extra delim:            ;; Dispose of single extra delim:
4082            (setq result (cdr result))))            (setq result (cdr result))))
4083      (apply 'concat result)))      (apply 'concat result)))
4084  ;;;_   > outline-stringify-flat-index-plain (flat-index)  ;;;_   > allout-stringify-flat-index-plain (flat-index)
4085  (defun outline-stringify-flat-index-plain (flat-index)  (defun allout-stringify-flat-index-plain (flat-index)
4086    "Convert list representing section/subsection/... to document string."    "Convert list representing section/subsection/... to document string."
4087    (let ((delim ".")    (let ((delim ".")
4088          result)          result)
# Line 4091  Optional arg CONTEXT indicates interior Line 4092  Optional arg CONTEXT indicates interior
4092                                   (cons delim result))))                                   (cons delim result))))
4093            (setq flat-index (cdr flat-index)))            (setq flat-index (cdr flat-index)))
4094      (apply 'concat result)))      (apply 'concat result)))
4095  ;;;_   > outline-stringify-flat-index-indented (flat-index)  ;;;_   > allout-stringify-flat-index-indented (flat-index)
4096  (defun outline-stringify-flat-index-indented (flat-index)  (defun allout-stringify-flat-index-indented (flat-index)
4097    "Convert list representing section/subsection/... to document string."    "Convert list representing section/subsection/... to document string."
4098    (let ((delim ".")    (let ((delim ".")
4099          result          result
4100          numstr)          numstr)
4101      ;; Take care of the explicit context:      ;; Take care of the explicit context:
4102      (setq numstr (int-to-string (car flat-index))      (setq numstr (int-to-string (car flat-index))
# Line 4120  Optional arg CONTEXT indicates interior Line 4121  Optional arg CONTEXT indicates interior
4121            ;; Dispose of single extra delim:            ;; Dispose of single extra delim:
4122            (setq result (cdr result))))            (setq result (cdr result))))
4123      (apply 'concat result)))      (apply 'concat result)))
4124  ;;;_   > outline-listify-exposed (&optional start end format)  ;;;_   > allout-listify-exposed (&optional start end format)
4125  (defun outline-listify-exposed (&optional start end format)  (defun allout-listify-exposed (&optional start end format)
4126    
4127    "Produce a list representing exposed topics in current region.    "Produce a list representing exposed topics in current region.
4128    
4129  This list can then be used by `outline-process-exposed' to manipulate  This list can then be used by `allout-process-exposed' to manipulate
4130  the subject region.  the subject region.
4131    
4132  Optional START and END indicate bounds of region.  Optional START and END indicate bounds of region.
# Line 4158  header and body.  The elements of that l Line 4159  header and body.  The elements of that l
4159        (goto-char start)        (goto-char start)
4160        (beginning-of-line)        (beginning-of-line)
4161        ;; Goto initial topic, and register preceeding stuff, if any:        ;; Goto initial topic, and register preceeding stuff, if any:
4162        (if (> (outline-goto-prefix) start)        (if (> (allout-goto-prefix) start)
4163            ;; First topic follows beginning point - register preliminary stuff:            ;; First topic follows beginning point - register preliminary stuff:
4164            (setq result (list (list 0 "" nil            (setq result (list (list 0 "" nil
4165                                     (buffer-substring start (1- (point)))))))                                     (buffer-substring start (1- (point)))))))
4166        (while (and (not done)        (while (and (not done)
4167                    (not (eobp))          ; Loop until we've covered the region.                    (not (eobp))          ; Loop until we've covered the region.
4168                    (not (> (point) end)))                    (not (> (point) end)))
4169          (setq depth (outline-recent-depth)      ; Current topics depth,          (setq depth (allout-recent-depth)       ; Current topics depth,
4170                bullet (outline-recent-bullet)    ; ... bullet,                bullet (allout-recent-bullet)     ; ... bullet,
4171                prefix (outline-recent-prefix)                prefix (allout-recent-prefix)
4172                beg (progn (outline-end-of-prefix t) (point))) ; and beginning.                beg (progn (allout-end-of-prefix t) (point))) ; and beginning.
4173          (setq done                      ; The boundary for the current topic:          (setq done                      ; The boundary for the current topic:
4174                (not (outline-next-visible-heading 1)))                (not (allout-next-visible-heading 1)))
4175          (setq new-depth (outline-recent-depth))          (setq new-depth (allout-recent-depth))
4176          (setq gone-out out          (setq gone-out out
4177                out (< new-depth depth))                out (< new-depth depth))
4178          (beginning-of-line)          (beginning-of-line)
# Line 4202  header and body.  The elements of that l Line 4203  header and body.  The elements of that l
4203                 (if format                 (if format
4204                     (let ((special (if (string-match                     (let ((special (if (string-match
4205                                         (regexp-quote bullet)                                         (regexp-quote bullet)
4206                                         outline-distinctive-bullets-string)                                         allout-distinctive-bullets-string)
4207                                        bullet)))                                        bullet)))
4208                       (cond ((listp format)                       (cond ((listp format)
4209                              (list depth                              (list depth
4210                                    (if outline-abbreviate-flattened-numbering                                    (if allout-abbreviate-flattened-numbering
4211                                        (outline-stringify-flat-index format                                        (allout-stringify-flat-index format
4212                                                                      gone-out)                                                                      gone-out)
4213                                        (outline-stringify-flat-index-plain                                        (allout-stringify-flat-index-plain
4214                                         format))                                         format))
4215                                    strings                                    strings
4216                                    special))                                    special))
# Line 4222  header and body.  The elements of that l Line 4223  header and body.  The elements of that l
4223                                (list depth                                (list depth
4224                                      (make-string depth ? )                                      (make-string depth ? )
4225                                      strings)))                                      strings)))
4226                             (t (error "outline-listify-exposed: %s %s"                             (t (error "allout-listify-exposed: %s %s"
4227                                       "invalid format" format))))                                       "invalid format" format))))
4228                   (list depth prefix strings))                   (list depth prefix strings))
4229                      result))                      result))
# Line 4245  header and body.  The elements of that l Line 4246  header and body.  The elements of that l
4246                                   (cdr format)))))))                                   (cdr format)))))))
4247        ;; Put the list with first at front, to last at back:        ;; Put the list with first at front, to last at back:
4248        (nreverse result))))        (nreverse result))))
4249  ;;;_   > outline-process-exposed (&optional func from to frombuf  ;;;_   > allout-process-exposed (&optional func from to frombuf
4250  ;;;                                         tobuf format)  ;;;                                         tobuf format)
4251  (defun outline-process-exposed (&optional func from to frombuf tobuf  (defun allout-process-exposed (&optional func from to frombuf tobuf
4252                                            format &optional start-num)                                            format &optional start-num)
4253    "Map function on exposed parts of current topic; results to another buffer.    "Map function on exposed parts of current topic; results to another buffer.
4254    
# Line 4266  alternate presentation form: Line 4267  alternate presentation form:
4267                         except for distinctive bullets.                         except for distinctive bullets.
4268    
4269  Defaults:  Defaults:
4270    FUNCTION:     `outline-insert-listified'    FUNCTION:     `allout-insert-listified'
4271    FROM:         region start, if region active, else start of buffer    FROM:         region start, if region active, else start of buffer
4272    TO:           region end, if region active, else end of buffer    TO:           region end, if region active, else end of buffer
4273    FROMBUF:      current buffer    FROMBUF:      current buffer
# Line 4275  Defaults: Line 4276  Defaults:
4276    
4277                                          ; Resolve arguments,                                          ; Resolve arguments,
4278                                          ; defaulting if necessary:                                          ; defaulting if necessary:
4279    (if (not func) (setq func 'outline-insert-listified))    (if (not func) (setq func 'allout-insert-listified))
4280    (if (not (and from to))    (if (not (and from to))
4281        (if (my-region-active-p)        (if (my-region-active-p)
4282            (setq from (region-beginning) to (region-end))            (setq from (region-beginning) to (region-end))
# Line 4285  Defaults: Line 4286  Defaults:
4286            ;; Specified but not a buffer - get it:            ;; Specified but not a buffer - get it:
4287            (let ((got (get-buffer frombuf)))            (let ((got (get-buffer frombuf)))
4288              (if (not got)              (if (not got)
4289                  (error (concat "outline-process-exposed: source buffer "                  (error (concat "allout-process-exposed: source buffer "
4290                                 frombuf                                 frombuf
4291                                 " not found."))                                 " not found."))
4292                (setq frombuf got))))                (setq frombuf got))))
# Line 4301  Defaults: Line 4302  Defaults:
4302    
4303    (let* ((listified    (let* ((listified
4304            (progn (set-buffer frombuf)            (progn (set-buffer frombuf)
4305                   (outline-listify-exposed from to format))))                   (allout-listify-exposed from to format))))
4306      (set-buffer tobuf)      (set-buffer tobuf)
4307      (mapcar func listified)      (mapcar func listified)
4308      (pop-to-buffer tobuf)))      (pop-to-buffer tobuf)))
4309    
4310  ;;;_  - Copy exposed  ;;;_  - Copy exposed
4311  ;;;_   > outline-insert-listified (listified)  ;;;_   > allout-insert-listified (listified)
4312  (defun outline-insert-listified (listified)  (defun allout-insert-listified (listified)
4313    "Insert contents of listified outline portion in current buffer.    "Insert contents of listified outline portion in current buffer.
4314    
4315  Listified is a list representing each topic header and body:  Listified is a list representing each topic header and body:
# Line 4333  If `bullet-plus' is specified, it is ins Line 4334  If `bullet-plus' is specified, it is ins
4334        (if (setq text (cdr text))        (if (setq text (cdr text))
4335            (insert "\n")))            (insert "\n")))
4336      (insert "\n")))      (insert "\n")))
4337  ;;;_   > outline-copy-exposed-to-buffer (&optional arg tobuf format)  ;;;_   > allout-copy-exposed-to-buffer (&optional arg tobuf format)
4338  (defun outline-copy-exposed-to-buffer (&optional arg tobuf format)  (defun allout-copy-exposed-to-buffer (&optional arg tobuf format)
4339    "Duplicate exposed portions of current outline to another buffer.    "Duplicate exposed portions of current outline to another buffer.
4340    
4341  Other buffer has current buffers name with \" exposed\" appended to it.  Other buffer has current buffers name with \" exposed\" appended to it.
# Line 4358  alternate presentation format for the ou Line 4359  alternate presentation format for the ou
4359    (if (not tobuf)    (if (not tobuf)
4360        (setq tobuf (get-buffer-create (concat "*" (buffer-name) " exposed*"))))        (setq tobuf (get-buffer-create (concat "*" (buffer-name) " exposed*"))))
4361    (let* ((start-pt (point))    (let* ((start-pt (point))
4362           (beg (if arg (outline-back-to-current-heading) (point-min)))           (beg (if arg (allout-back-to-current-heading) (point-min)))
4363           (end (if arg (outline-end-of-current-subtree) (point-max)))           (end (if arg (allout-end-of-current-subtree) (point-max)))
4364           (buf (current-buffer))           (buf (current-buffer))
4365           (start-list ()))           (start-list ()))
4366      (if (eq format 'flat)      (if (eq format 'flat)
4367          (setq format (if arg (save-excursion          (setq format (if arg (save-excursion
4368                                     (goto-char beg)                                     (goto-char beg)
4369                                     (outline-topic-flat-index))                                     (allout-topic-flat-index))
4370                             '(1))))                             '(1))))
4371      (save-excursion (set-buffer tobuf)(erase-buffer))      (save-excursion (set-buffer tobuf)(erase-buffer))
4372      (outline-process-exposed 'outline-insert-listified      (allout-process-exposed 'allout-insert-listified
4373                               beg                               beg
4374                               end                               end
4375                               (current-buffer)                               (current-buffer)
# Line 4377  alternate presentation format for the ou Line 4378  alternate presentation format for the ou
4378      (goto-char (point-min))      (goto-char (point-min))
4379      (pop-to-buffer buf)      (pop-to-buffer buf)
4380      (goto-char start-pt)))      (goto-char start-pt)))
4381  ;;;_   > outline-flatten-exposed-to-buffer (&optional arg tobuf)  ;;;_   > allout-flatten-exposed-to-buffer (&optional arg tobuf)
4382  (defun outline-flatten-exposed-to-buffer (&optional arg tobuf)  (defun allout-flatten-exposed-to-buffer (&optional arg tobuf)
4383    "Present numeric outline of outline's exposed portions in another buffer.    "Present numeric outline of outline's exposed portions in another buffer.
4384    
4385  The resulting outline is not compatable with outline mode - use  The resulting outline is not compatable with outline mode - use
4386  `outline-copy-exposed-to-buffer' if you want that.  `allout-copy-exposed-to-buffer' if you want that.
4387    
4388  Use `outline-indented-exposed-to-buffer' for indented presentation.  Use `allout-indented-exposed-to-buffer' for indented presentation.
4389    
4390  With repeat count, copy the exposed portions of only current topic.  With repeat count, copy the exposed portions of only current topic.
4391    
# Line 4392  Other buffer has current buffers name wi Line 4393  Other buffer has current buffers name wi
4393  it, unless optional second arg TOBUF is specified, in which case it is  it, unless optional second arg TOBUF is specified, in which case it is
4394  used verbatim."  used verbatim."
4395    (interactive "P")    (interactive "P")
4396    (outline-copy-exposed-to-buffer arg tobuf 'flat))    (allout-copy-exposed-to-buffer arg tobuf 'flat))
4397  ;;;_   > outline-indented-exposed-to-buffer (&optional arg tobuf)  ;;;_   > allout-indented-exposed-to-buffer (&optional arg tobuf)
4398  (defun outline-indented-exposed-to-buffer (&optional arg tobuf)  (defun allout-indented-exposed-to-buffer (&optional arg tobuf)
4399    "Present indented outline of outline's exposed portions in another buffer.    "Present indented outline of outline's exposed portions in another buffer.
4400    
4401  The resulting outline is not compatable with outline mode - use  The resulting outline is not compatable with outline mode - use
4402  `outline-copy-exposed-to-buffer' if you want that.  `allout-copy-exposed-to-buffer' if you want that.
4403    
4404  Use `outline-flatten-exposed-to-buffer' for numeric sectional presentation.  Use `allout-flatten-exposed-to-buffer' for numeric sectional presentation.
4405    
4406  With repeat count, copy the exposed portions of only current topic.  With repeat count, copy the exposed portions of only current topic.
4407    
# Line 4408  Other buffer has current buffers name wi Line 4409  Other buffer has current buffers name wi
4409  it, unless optional second arg TOBUF is specified, in which case it is  it, unless optional second arg TOBUF is specified, in which case it is
4410  used verbatim."  used verbatim."
4411    (interactive "P")    (interactive "P")
4412    (outline-copy-exposed-to-buffer arg tobuf 'indent))    (allout-copy-exposed-to-buffer arg tobuf 'indent))
4413    
4414  ;;;_  - LaTeX formatting  ;;;_  - LaTeX formatting
4415  ;;;_   > outline-latex-verb-quote (str &optional flow)  ;;;_   > allout-latex-verb-quote (str &optional flow)
4416  (defun outline-latex-verb-quote (str &optional flow)  (defun allout-latex-verb-quote (str &optional flow)
4417    "Return copy of STRING for literal reproduction across latex processing.    "Return copy of STRING for literal reproduction across latex processing.
4418  Expresses the original characters \(including carriage returns) of the  Expresses the original characters \(including carriage returns) of the
4419  string across latex processing."  string across latex processing."
# Line 4424  string across latex processing." Line 4425  string across latex processing."
4425                        (t (char-to-string char)))))                        (t (char-to-string char)))))
4426               str               str
4427               ""))               ""))
4428  ;;;_   > outline-latex-verbatim-quote-curr-line ()  ;;;_   > allout-latex-verbatim-quote-curr-line ()
4429  (defun outline-latex-verbatim-quote-curr-line ()  (defun allout-latex-verbatim-quote-curr-line ()
4430    "Express line for exact \(literal) representation across latex processing.    "Express line for exact \(literal) representation across latex processing.
4431    
4432  Adjust line contents so it is unaltered \(from the original line)  Adjust line contents so it is unaltered \(from the original line)
# Line 4443  environment.  Leaves point at the end of Line 4444  environment.  Leaves point at the end of
4444        (insert "\\")        (insert "\\")
4445        (setq end (1+ end))        (setq end (1+ end))
4446        (goto-char (1+ (match-end 0))))))        (goto-char (1+ (match-end 0))))))
4447  ;;;_   > outline-insert-latex-header (buf)  ;;;_   > allout-insert-latex-header (buf)
4448  (defun outline-insert-latex-header (buf)  (defun allout-insert-latex-header (buf)
4449    "Insert initial latex commands at point in BUFFER."    "Insert initial latex commands at point in BUFFER."
4450    ;; Much of this is being derived from the stuff in appendix of E in    ;; Much of this is being derived from the stuff in appendix of E in
4451    ;; the TeXBook, pg 421.    ;; the TeXBook, pg 421.
4452    (set-buffer buf)    (set-buffer buf)
4453    (let ((doc-style (format "\n\\documentstyle{%s}\n"    (let ((doc-style (format "\n\\documentstyle{%s}\n"
4454                             "report"))                             "report"))
4455          (page-numbering (if outline-number-pages          (page-numbering (if allout-number-pages
4456                              "\\pagestyle{empty}\n"                              "\\pagestyle{empty}\n"
4457                            ""))                            ""))
4458          (linesdef (concat "\\def\\beginlines{"          (linesdef (concat "\\def\\beginlines{"
# Line 4462  environment.  Leaves point at the end of Line 4463  environment.  Leaves point at the end of
4463                            "\\def\\endlines{"                            "\\def\\endlines{"
4464                            "\\kern1pt\\endgroup\\medbreak\\noindent}\n"))                            "\\kern1pt\\endgroup\\medbreak\\noindent}\n"))
4465          (titlecmd (format "\\newcommand{\\titlecmd}[1]{{%s #1}}\n"          (titlecmd (format "\\newcommand{\\titlecmd}[1]{{%s #1}}\n"
4466                            outline-title-style))                            allout-title-style))
4467          (labelcmd (format "\\newcommand{\\labelcmd}[1]{{%s #1}}\n"          (labelcmd (format "\\newcommand{\\labelcmd}[1]{{%s #1}}\n"
4468                            outline-label-style))                            allout-label-style))
4469          (headlinecmd (format "\\newcommand{\\headlinecmd}[1]{{%s #1}}\n"          (headlinecmd (format "\\newcommand{\\headlinecmd}[1]{{%s #1}}\n"
4470                               outline-head-line-style))                               allout-head-line-style))
4471          (bodylinecmd (format "\\newcommand{\\bodylinecmd}[1]{{%s #1}}\n"          (bodylinecmd (format "\\newcommand{\\bodylinecmd}[1]{{%s #1}}\n"
4472                               outline-body-line-style))                               allout-body-line-style))
4473          (setlength (format "%s%s%s%s"          (setlength (format "%s%s%s%s"
4474                             "\\newlength{\\stepsize}\n"                             "\\newlength{\\stepsize}\n"
4475                             "\\setlength{\\stepsize}{"                             "\\setlength{\\stepsize}{"
4476                             outline-indent                             allout-indent
4477                             "}\n"))                             "}\n"))
4478          (oneheadline (format "%s%s%s%s%s%s%s"          (oneheadline (format "%s%s%s%s%s%s%s"
4479                               "\\newcommand{\\OneHeadLine}[3]{%\n"                               "\\newcommand{\\OneHeadLine}[3]{%\n"
# Line 4480  environment.  Leaves point at the end of Line 4481  environment.  Leaves point at the end of
4481                               "\\hspace*{#2\\stepsize}%\n"                               "\\hspace*{#2\\stepsize}%\n"
4482                               "\\labelcmd{#1}\\hspace*{.2cm}"                               "\\labelcmd{#1}\\hspace*{.2cm}"
4483                               "\\headlinecmd{#3}\\\\["                               "\\headlinecmd{#3}\\\\["
4484                               outline-line-skip                               allout-line-skip
4485                               "]\n}\n"))                               "]\n}\n"))
4486          (onebodyline (format "%s%s%s%s%s%s"          (onebodyline (format "%s%s%s%s%s%s"
4487                                 "\\newcommand{\\OneBodyLine}[2]{%\n"                                 "\\newcommand{\\OneBodyLine}[2]{%\n"
4488                                 "\\noindent%\n"                                 "\\noindent%\n"
4489                                 "\\hspace*{#1\\stepsize}%\n"                                 "\\hspace*{#1\\stepsize}%\n"
4490                                 "\\bodylinecmd{#2}\\\\["                                 "\\bodylinecmd{#2}\\\\["
4491                                 outline-line-skip                                 allout-line-skip
4492                                 "]\n}\n"))                                 "]\n}\n"))
4493          (begindoc "\\begin{document}\n\\begin{center}\n")          (begindoc "\\begin{document}\n\\begin{center}\n")
4494          (title (format "%s%s%s%s"          (title (format "%s%s%s%s"
4495                         "\\titlecmd{"                         "\\titlecmd{"
4496                         (outline-latex-verb-quote (if outline-title                         (allout-latex-verb-quote (if allout-title
4497                                                  (condition-case err                                                  (condition-case err
4498                                                      (eval outline-title)                                                      (eval allout-title)
4499                                                    ('error "<unnamed buffer>"))                                                    ('error "<unnamed buffer>"))
4500                                                "Unnamed Outline"))                                                "Unnamed Outline"))
4501                         "}\n"                         "}\n"
# Line 4517  environment.  Leaves point at the end of Line 4518  environment.  Leaves point at the end of
4518                      hoffset                      hoffset
4519                      vspace)                      vspace)
4520              )))              )))
4521  ;;;_   > outline-insert-latex-trailer (buf)  ;;;_   > allout-insert-latex-trailer (buf)
4522  (defun outline-insert-latex-trailer (buf)  (defun allout-insert-latex-trailer (buf)
4523    "Insert concluding latex commands at point in BUFFER."    "Insert concluding latex commands at point in BUFFER."
4524    (set-buffer buf)    (set-buffer buf)
4525    (insert "\n\\end{document}\n"))    (insert "\n\\end{document}\n"))
4526  ;;;_   > outline-latexify-one-item (depth prefix bullet text)  ;;;_   > allout-latexify-one-item (depth prefix bullet text)
4527  (defun outline-latexify-one-item (depth prefix bullet text)  (defun allout-latexify-one-item (depth prefix bullet text)
4528    "Insert LaTeX commands for formatting one outline item.    "Insert LaTeX commands for formatting one outline item.
4529    
4530  Args are the topics numeric DEPTH, the header PREFIX lead string, the  Args are the topics numeric DEPTH, the header PREFIX lead string, the
# Line 4533  BULLET string, and a list of TEXT string Line 4534  BULLET string, and a list of TEXT string
4534           (curr-line)           (curr-line)
4535           body-content bop)           body-content bop)
4536                                          ; Do the head line:                                          ; Do the head line:
4537      (insert (concat "\\OneHeadLine{\\verb\1 "      (insert (concat "\\OneHeadLine{\\verb\1 "
4538                      (outline-latex-verb-quote bullet)                      (allout-latex-verb-quote bullet)
4539                      "\1}{"                      "\1}{"
4540                      depth                      depth
4541                      "}{\\verb\1 "                      "}{\\verb\1 "
4542                      (if head-line                      (if head-line
4543                          (outline-latex-verb-quote head-line)                          (allout-latex-verb-quote head-line)
4544                        "")                        "")
4545                      "\1}\n"))                      "\1}\n"))
4546      (if (not body-lines)      (if (not body-lines)
# Line 4561  BULLET string, and a list of TEXT string Line 4562  BULLET string, and a list of TEXT string
4562                                      (substring curr-line bop))))                                      (substring curr-line bop))))
4563          ;;(insert "|" (car body-lines) "|")          ;;(insert "|" (car body-lines) "|")
4564          (insert curr-line)          (insert curr-line)
4565          (outline-latex-verbatim-quote-curr-line)          (allout-latex-verbatim-quote-curr-line)
4566          (insert "\n")          (insert "\n")
4567          (setq body-lines (cdr body-lines)))          (setq body-lines (cdr body-lines)))
4568        (if body-content        (if body-content
# Line 4572  BULLET string, and a list of TEXT string Line 4573  BULLET string, and a list of TEXT string
4573        ;;(insert "\\endlines\n")        ;;(insert "\\endlines\n")
4574        (insert "\\end{verbatim}\n")        (insert "\\end{verbatim}\n")
4575        )))        )))
4576  ;;;_   > outline-latexify-exposed (arg &optional tobuf)  ;;;_   > allout-latexify-exposed (arg &optional tobuf)
4577  (defun outline-latexify-exposed (arg &optional tobuf)  (defun allout-latexify-exposed (arg &optional tobuf)
4578    "Format current topics exposed portions to TOBUF for latex processing.    "Format current topics exposed portions to TOBUF for latex processing.
4579  TOBUF defaults to a buffer named the same as the current buffer, but  TOBUF defaults to a buffer named the same as the current buffer, but
4580  with \"*\" prepended and \" latex-formed*\" appended.  with \"*\" prepended and \" latex-formed*\" appended.
# Line 4585  With repeat count, copy the exposed port Line 4586  With repeat count, copy the exposed port
4586        (setq tobuf        (setq tobuf
4587              (get-buffer-create (concat "*" (buffer-name) " latexified*"))))              (get-buffer-create (concat "*" (buffer-name) " latexified*"))))
4588    (let* ((start-pt (point))    (let* ((start-pt (point))
4589           (beg (if arg (point-min) (outline-back-to-current-heading)))           (beg (if arg (point-min) (allout-back-to-current-heading)))
4590           (end (if arg (point-max) (outline-end-of-current-subtree)))           (end (if arg (point-max) (allout-end-of-current-subtree)))
4591           (buf (current-buffer)))           (buf (current-buffer)))
4592      (set-buffer tobuf)      (set-buffer tobuf)
4593      (erase-buffer)      (erase-buffer)
4594      (outline-insert-latex-header tobuf)      (allout-insert-latex-header tobuf)
4595      (goto-char (point-max))      (goto-char (point-max))
4596      (outline-process-exposed 'outline-latexify-one-item      (allout-process-exposed 'allout-latexify-one-item
4597                               beg                               beg
4598                               end                               end
4599                               buf                               buf
4600                               tobuf)                               tobuf)
4601      (goto-char (point-max))      (goto-char (point-max))
4602      (outline-insert-latex-trailer tobuf)      (allout-insert-latex-trailer tobuf)
4603      (goto-char (point-min))      (goto-char (point-min))
4604      (pop-to-buffer buf)      (pop-to-buffer buf)
4605      (goto-char start-pt)))      (goto-char start-pt)))
4606    
4607  ;;;_ #8 miscellaneous  ;;;_ #8 miscellaneous
4608  ;;;_  > outline-mark-topic ()  ;;;_  > allout-mark-topic ()
4609  (defun outline-mark-topic ()  (defun allout-mark-topic ()
4610    "Put the region around topic currently containing point."    "Put the region around topic currently containing point."
4611    (interactive)    (interactive)
4612    (beginning-of-line)    (beginning-of-line)
4613    (outline-goto-prefix)    (allout-goto-prefix)
4614    (push-mark (point))    (push-mark (point))
4615    (outline-end-of-current-subtree)    (allout-end-of-current-subtree)
4616    (exchange-point-and-mark))    (exchange-point-and-mark))
4617  ;;;_  > outlineify-sticky ()  ;;;_  > outlineify-sticky ()
4618  ;; outlinify-sticky is correct spelling; provide this alias for sticklers:  ;; outlinify-sticky is correct spelling; provide this alias for sticklers:
# Line 4619  With repeat count, copy the exposed port Line 4620  With repeat count, copy the exposed port
4620  (defun outlineify-sticky (&optional arg)  (defun outlineify-sticky (&optional arg)
4621    "Activate outline mode and establish file var so it is started subsequently.    "Activate outline mode and establish file var so it is started subsequently.
4622    
4623  See doc-string for `outline-layout' and `outline-init' for details on  See doc-string for `allout-layout' and `allout-init' for details on
4624  setup for auto-startup."  setup for auto-startup."
4625    
4626    (interactive "P")    (interactive "P")
4627    
4628    (outline-mode t)    (allout-mode t)
4629    
4630    (save-excursion    (save-excursion
4631      (goto-char (point-min))      (goto-char (point-min))
4632      (if (looking-at outline-regexp)      (if (looking-at allout-regexp)
4633          t          t
4634        (outline-open-topic 2)        (allout-open-topic 2)
4635        (insert (concat "Dummy outline topic header - see"        (insert (concat "Dummy outline topic header - see"
4636                        "`outline-mode' docstring: `^Hm'."))                        "`allout-mode' docstring: `^Hm'."))
4637        (forward-line 1)        (forward-line 1)
4638        (goto-char (point-max))        (goto-char (point-max))
4639        (open-line 1)        (open-line 1)
4640        (outline-open-topic 0)        (allout-open-topic 0)
4641        (insert "Local emacs vars.\n")        (insert "Local emacs vars.\n")
4642        (outline-open-topic 1)        (allout-open-topic 1)
4643        (insert "(`outline-layout' is for allout.el outline-mode)\n")        (insert "(`allout-layout' is for allout.el allout-mode)\n")
4644        (outline-open-topic 0)        (allout-open-topic 0)
4645        (insert "Local variables:\n")        (insert "Local variables:\n")
4646        (outline-open-topic 0)        (allout-open-topic 0)
4647        (insert (format "outline-layout: %s\n"        (insert (format "allout-layout: %s\n"
4648                               (or outline-layout                               (or allout-layout
4649                                   '(-1 : 0))))                                   '(-1 : 0))))
4650        (outline-open-topic 0)        (allout-open-topic 0)
4651        (insert "End:\n"))))        (insert "End:\n"))))
4652  ;;;_  > solicit-char-in-string (prompt string &optional do-defaulting)  ;;;_  > solicit-char-in-string (prompt string &optional do-defaulting)
4653  (defun solicit-char-in-string (prompt string &optional do-defaulting)  (defun solicit-char-in-string (prompt string &optional do-defaulting)
# Line 4729  function.  If HOOK is void, it is first Line 4730  function.  If HOOK is void, it is first
4730                 (if append                 (if append
4731                     (nconc (symbol-value hook) (list function))                     (nconc (symbol-value hook) (list function))
4732                   (cons function (symbol-value hook)))))))                   (cons function (symbol-value hook)))))))
4733  ;;;_  : my-mark-marker to accomodate divergent emacsen:  ;;;_  : my-mark-marker to accommodate divergent emacsen:
4734  (defun my-mark-marker (&optional force buffer)  (defun my-mark-marker (&optional force buffer)
4735    "Accomodate the different signature for mark-marker across emacsen.    "Accommodate the different signature for mark-marker across emacsen.
4736    
4737  GNU XEmacs takes two optional args, while mainline GNU Emacs does not,  GNU XEmacs takes two optional args, while mainline GNU Emacs does not,
4738  so pass them along when appropriate."  so pass them along when appropriate."
4739    (if (string-match " XEmacs " emacs-version)    (if (featurep 'xemacs)
4740        (mark-marker force buffer)        (mark-marker force buffer)
4741      (mark-marker)))      (mark-marker)))
4742    
4743  ;;;_ #9 Under development  ;;;_ #9 Under development
4744  ;;;_  > outline-bullet-isearch (&optional bullet)  ;;;_  > allout-bullet-isearch (&optional bullet)
4745  (defun outline-bullet-isearch (&optional bullet)  (defun allout-bullet-isearch (&optional bullet)
4746    "Isearch \(regexp) for topic with bullet BULLET."    "Isearch \(regexp) for topic with bullet BULLET."
4747    (interactive)    (interactive)
4748    (if (not bullet)    (if (not bullet)
4749        (setq bullet (solicit-char-in-string        (setq bullet (solicit-char-in-string
4750                      "ISearch for topic with bullet: "                      "ISearch for topic with bullet: "
4751                      (regexp-sans-escapes outline-bullets-string))))                      (regexp-sans-escapes allout-bullets-string))))
4752    
4753    (let ((isearch-regexp t)    (let ((isearch-regexp t)
4754          (isearch-string (concat "^"          (isearch-string (concat "^"
4755                                  outline-header-prefix                                  allout-header-prefix
4756                                  "[ \t]*"                                  "[ \t]*"
4757                                  bullet)))                                  bullet)))
4758      (isearch-repeat 'forward)      (isearch-repeat 'forward)
# Line 4760  so pass them along when appropriate." Line 4761  so pass them along when appropriate."
4761  ;;;     wrapping the isearch functions.  ;;;     wrapping the isearch functions.
4762    
4763  ;;;_* Local emacs vars.  ;;;_* Local emacs vars.
4764  ;;; The following `outline-layout' local variable setting:  ;;; The following `allout-layout' local variable setting:
4765  ;;;  - closes all topics from the first topic to just before the third-to-last,  ;;;  - closes all topics from the first topic to just before the third-to-last,
4766  ;;;  - shows the children of the third to last (config vars)  ;;;  - shows the children of the third to last (config vars)
4767  ;;;  - and the second to last (code section),  ;;;  - and the second to last (code section),
4768  ;;;  - and closes the last topic (this local-variables section).  ;;;  - and closes the last topic (this local-variables section).
4769  ;;;Local variables:  ;;;Local variables:
4770  ;;;outline-layout: (0 : -1 -1 0)  ;;;allout-layout: (0 : -1 -1 0)
4771  ;;;End:  ;;;End:
4772    
4773  ;;; allout.el ends here  ;;; allout.el ends here

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.32.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26