diff options
| author | Dave Love | 2000-06-07 13:25:06 +0000 |
|---|---|---|
| committer | Dave Love | 2000-06-07 13:25:06 +0000 |
| commit | 9179616f477a70328d232b5e6978023e6db17352 (patch) | |
| tree | 7f5f0b158f3dfefb0469e2b37d8114150c5dd61e | |
| parent | 3091c2a6523ee0ba7c017b081997e22480ef9419 (diff) | |
| download | emacs-9179616f477a70328d232b5e6978023e6db17352.tar.gz emacs-9179616f477a70328d232b5e6978023e6db17352.zip | |
New version from Manheimer.
| -rw-r--r-- | lisp/allout.el | 1629 |
1 files changed, 1004 insertions, 625 deletions
diff --git a/lisp/allout.el b/lisp/allout.el index c096c8be9fe..40a6b76bb1a 100644 --- a/lisp/allout.el +++ b/lisp/allout.el | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | ;;; allout.el --- Extensive outline mode for use alone and with other modes. | 1 | ;;;_* allout.el --- Extensive outline mode for use alone and with other modes. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Ken Manheimer <klm@python.org> | 5 | ;; Author: Ken Manheimer <klm@python.org> |
| 6 | ;; Maintainer: Ken Manheimer <klm@python.org> | 6 | ;; Maintainer: Ken Manheimer <klm@python.org> |
| 7 | ;; Created: Dec 1991 - first release to usenet | 7 | ;; Created: Dec 1991 - first release to usenet |
| 8 | ;; Version: Id: allout.el,v 4.3 1994/05/12 17:43:08 klm Exp || | 8 | ;; Version: $Id: allout.el,v 4.35 2000/02/01 15:58:14 klm Exp klm $|| |
| 9 | ;; Keywords: outlines | 9 | ;; Keywords: outline mode wp languages |
| 10 | 10 | ||
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | 12 | ||
| @@ -28,17 +28,28 @@ | |||
| 28 | ;;;_* Commentary: | 28 | ;;;_* Commentary: |
| 29 | 29 | ||
| 30 | ;; Allout outline mode provides extensive outline formatting and | 30 | ;; Allout outline mode provides extensive outline formatting and |
| 31 | ;; manipulation capabilities, subsuming and well beyond that of | 31 | ;; and manipulation beyond standard emacs outline mode. It provides |
| 32 | ;; standard emacs outline mode. It is specifically aimed at | 32 | ;; for structured editing of outlines, as well as navigation and |
| 33 | ;; supporting outline structuring and manipulation of syntax- | 33 | ;; exposure. It also provides for syntax-sensitive text like |
| 34 | ;; sensitive text, eg programming languages. (For an example, see the | 34 | ;; programming languages. (For an example, see the allout code |
| 35 | ;; allout code itself, which is organized in outline structure.) | 35 | ;; itself, which is organized in ;; an outline framework.) |
| 36 | ;; | 36 | ;; |
| 37 | ;; It also includes such things as topic-oriented repositioning, cut, and | 37 | ;; In addition to outline navigation and exposure, allout includes: |
| 38 | ;; paste; integral outline exposure-layout; incremental search with | 38 | ;; |
| 39 | ;; dynamic exposure/concealment of concealed text; automatic topic-number | 39 | ;; - topic-oriented repositioning, cut, and paste |
| 40 | ;; maintenance; and many other features. | 40 | ;; - integral outline exposure-layout |
| 41 | ;; | 41 | ;; - incremental search with dynamic exposure and reconcealment of hidden text |
| 42 | ;; - automatic topic-number maintenance | ||
| 43 | ;; - "Hot-spot" operation, for single-keystroke maneuvering and | ||
| 44 | ;; exposure control. (See the outline-mode docstring.) | ||
| 45 | ;; | ||
| 46 | ;; and many other features. | ||
| 47 | ;; | ||
| 48 | ;; The outline menubar additions provide quick reference to many of | ||
| 49 | ;; the features, and see the docstring of the variable `outline-init' | ||
| 50 | ;; for instructions on priming your emacs session for automatic | ||
| 51 | ;; activation of outline-mode. | ||
| 52 | ;; | ||
| 42 | ;; See the docstring of the variables `outline-layout' and | 53 | ;; See the docstring of the variables `outline-layout' and |
| 43 | ;; `outline-auto-activation' for details on automatic activation of | 54 | ;; `outline-auto-activation' for details on automatic activation of |
| 44 | ;; allout outline-mode as a minor mode. (It has changed since allout | 55 | ;; allout outline-mode as a minor mode. (It has changed since allout |
| @@ -47,14 +58,7 @@ | |||
| 47 | ;; Note - the lines beginning with `;;;_' are outline topic headers. | 58 | ;; Note - the lines beginning with `;;;_' are outline topic headers. |
| 48 | ;; Just `ESC-x eval-current-buffer' to give it a whirl. | 59 | ;; Just `ESC-x eval-current-buffer' to give it a whirl. |
| 49 | 60 | ||
| 50 | ;;Ken Manheimer 301 975-3539 | 61 | ;; Ken Manheimer klm@python.org |
| 51 | ;;ken.manheimer@nist.gov FAX: 301 963-9137 | ||
| 52 | ;; | ||
| 53 | ;;Computer Systems and Communications Division | ||
| 54 | ;; | ||
| 55 | ;; Nat'l Institute of Standards and Technology | ||
| 56 | ;; Technology A151 | ||
| 57 | ;; Gaithersburg, MD 20899 | ||
| 58 | 62 | ||
| 59 | ;;;_* Provide | 63 | ;;;_* Provide |
| 60 | (provide 'outline) | 64 | (provide 'outline) |
| @@ -69,7 +73,7 @@ | |||
| 69 | ;;;_ + Layout, Mode, and Topic Header Configuration | 73 | ;;;_ + Layout, Mode, and Topic Header Configuration |
| 70 | 74 | ||
| 71 | ;;;_ = outline-auto-activation | 75 | ;;;_ = outline-auto-activation |
| 72 | (defvar outline-auto-activation nil | 76 | (defcustom outline-auto-activation nil |
| 73 | "*Regulates auto-activation modality of allout outlines - see `outline-init'. | 77 | "*Regulates auto-activation modality of allout outlines - see `outline-init'. |
| 74 | 78 | ||
| 75 | Setq-default by `outline-init' to regulate whether or not allout | 79 | Setq-default by `outline-init' to regulate whether or not allout |
| @@ -84,14 +88,19 @@ With value `t', auto-mode-activation and auto-layout are enabled. | |||
| 84 | With value `ask', auto-mode-activation is enabled, and endorsement for | 88 | With value `ask', auto-mode-activation is enabled, and endorsement for |
| 85 | performing auto-layout is asked of the user each time. | 89 | performing auto-layout is asked of the user each time. |
| 86 | 90 | ||
| 87 | With value `activate', only auto-mode-activation is enabled, | 91 | With value `activate', only auto-mode-activation is enabled, |
| 88 | auto-layout is not. | 92 | auto-layout is not. |
| 89 | 93 | ||
| 90 | With value `nil', neither auto-mode-activation nor auto-layout are | 94 | With value `nil', neither auto-mode-activation nor auto-layout are |
| 91 | enabled. | 95 | enabled. |
| 92 | 96 | ||
| 93 | See the docstring for `outline-init' for the proper interface to | 97 | See the docstring for `outline-init' for the proper interface to |
| 94 | this variable.") | 98 | this variable." |
| 99 | :type '(choice (const :tag "On" t) | ||
| 100 | (const :tag "Ask about layout" "ask") | ||
| 101 | (const :tag "Mode only" "activate") | ||
| 102 | (const :tag "Off" nil)) | ||
| 103 | :group 'allout) | ||
| 95 | ;;;_ = outline-layout | 104 | ;;;_ = outline-layout |
| 96 | (defvar outline-layout nil | 105 | (defvar outline-layout nil |
| 97 | "*Layout specification and provisional mode trigger for allout outlines. | 106 | "*Layout specification and provisional mode trigger for allout outlines. |
| @@ -112,18 +121,25 @@ this var via the file's local variables. For example, the following | |||
| 112 | lines at the bottom of an Emacs Lisp file: | 121 | lines at the bottom of an Emacs Lisp file: |
| 113 | 122 | ||
| 114 | ;;;Local variables: | 123 | ;;;Local variables: |
| 115 | ;;;outline-layout: \(0 : -1 -1 0\) | 124 | ;;;outline-layout: \(0 : -1 -1 0) |
| 116 | ;;;End: | 125 | ;;;End: |
| 117 | 126 | ||
| 118 | will, modulo the above-mentioned conditions, cause the mode to be | 127 | will, modulo the above-mentioned conditions, cause the mode to be |
| 119 | activated when the file is visited, followed by the equivalent of | 128 | activated when the file is visited, followed by the equivalent of |
| 120 | `\(outline-expose-topic 0 : -1 -1 0\)'. \(This is the layout used for | 129 | `\(outline-expose-topic 0 : -1 -1 0)'. \(This is the layout used for |
| 121 | the allout.el, itself.) | 130 | the allout.el, itself.) |
| 122 | 131 | ||
| 123 | Also, allout's mode-specific provisions will make topic prefixes default | 132 | Also, allout's mode-specific provisions will make topic prefixes default |
| 124 | to the comment-start string, if any, of the language of the file. This | 133 | to the comment-start string, if any, of the language of the file. This |
| 125 | is modulo the setting of `outline-use-mode-specific-leader', which see.") | 134 | is modulo the setting of `outline-use-mode-specific-leader', which see.") |
| 126 | (make-variable-buffer-local 'outline-layout) | 135 | (make-variable-buffer-local 'outline-layout) |
| 136 | ;;;_ = outline-show-bodies | ||
| 137 | (defcustom outline-show-bodies nil | ||
| 138 | "*If non-nil, show entire body when exposing a topic, rather than | ||
| 139 | just the header." | ||
| 140 | :type 'boolean | ||
| 141 | :group 'allout) | ||
| 142 | (make-variable-buffer-local 'outline-show-bodies) | ||
| 127 | 143 | ||
| 128 | ;;;_ = outline-header-prefix | 144 | ;;;_ = outline-header-prefix |
| 129 | (defcustom outline-header-prefix "." | 145 | (defcustom outline-header-prefix "." |
| @@ -153,8 +169,7 @@ bullets." | |||
| 153 | :group 'allout) | 169 | :group 'allout) |
| 154 | (make-variable-buffer-local 'outline-primary-bullet) | 170 | (make-variable-buffer-local 'outline-primary-bullet) |
| 155 | ;;;_ = outline-plain-bullets-string | 171 | ;;;_ = outline-plain-bullets-string |
| 156 | (defcustom outline-plain-bullets-string (concat outline-primary-bullet | 172 | (defcustom outline-plain-bullets-string ".:,;" |
| 157 | "+-:.;,") | ||
| 158 | "*The bullets normally used in outline topic prefixes. | 173 | "*The bullets normally used in outline topic prefixes. |
| 159 | 174 | ||
| 160 | See `outline-distinctive-bullets-string' for the other kind of | 175 | See `outline-distinctive-bullets-string' for the other kind of |
| @@ -168,16 +183,31 @@ of this var to take effect." | |||
| 168 | :group 'allout) | 183 | :group 'allout) |
| 169 | (make-variable-buffer-local 'outline-plain-bullets-string) | 184 | (make-variable-buffer-local 'outline-plain-bullets-string) |
| 170 | ;;;_ = outline-distinctive-bullets-string | 185 | ;;;_ = outline-distinctive-bullets-string |
| 171 | (defcustom outline-distinctive-bullets-string "=>([{}&!?#%\"X@$~\\" | 186 | (defcustom outline-distinctive-bullets-string "*+-=>([{}&!?#%\"X@$~_\\" |
| 172 | "*Persistent outline header bullets used to distinguish special topics. | 187 | "*Persistent outline header bullets used to distinguish special topics. |
| 173 | 188 | ||
| 174 | These bullets are not offered among the regular, level-specific | 189 | These bullets are used to distinguish topics from the run-of-the-mill |
| 175 | rotation, and are not altered by automatic rebulleting, as when | 190 | ones. They are not used in the standard topic headers created by |
| 176 | shifting the level of a topic. See `outline-plain-bullets-string' for | 191 | the topic-opening, shifting, and rebulleting \(eg, on topic shift, |
| 177 | the selection of alternating bullets. | 192 | topic paste, blanket rebulleting) routines, but are offered among the |
| 193 | choices for rebulleting. They are not altered by the above automatic | ||
| 194 | rebulleting, so they can be used to characterize topics, eg: | ||
| 195 | |||
| 196 | `?' question topics | ||
| 197 | `\(' parenthetic comment \(with a matching close paren inside) | ||
| 198 | `[' meta-note \(with a matching close ] inside) | ||
| 199 | `\"' a quote | ||
| 200 | `=' value settings | ||
| 201 | `~' \"more or less\" | ||
| 202 | |||
| 203 | ... just for example. (`#' typically has a special meaning to the | ||
| 204 | software, according to the value of `outline-numbered-bullet'.) | ||
| 205 | |||
| 206 | See `outline-plain-bullets-string' for the selection of | ||
| 207 | alternating bullets. | ||
| 178 | 208 | ||
| 179 | You must run `set-outline-regexp' in order for changes | 209 | You must run `set-outline-regexp' in order for outline mode to |
| 180 | to the value of this var to effect outline-mode operation. | 210 | reconcile to changes of this value. |
| 181 | 211 | ||
| 182 | DO NOT include the close-square-bracket, `]', on either of the bullet | 212 | DO NOT include the close-square-bracket, `]', on either of the bullet |
| 183 | strings." | 213 | strings." |
| @@ -197,17 +227,17 @@ String values are used as they stand. | |||
| 197 | 227 | ||
| 198 | Value `t' means to first check for assoc value in `outline-mode-leaders' | 228 | Value `t' means to first check for assoc value in `outline-mode-leaders' |
| 199 | alist, then use comment-start string, if any, then use default \(`.'). | 229 | alist, then use comment-start string, if any, then use default \(`.'). |
| 200 | \(See note about use of comment-start strings, below.\) | 230 | \(See note about use of comment-start strings, below.) |
| 201 | 231 | ||
| 202 | Set to the symbol for either of `outline-mode-leaders' or | 232 | Set to the symbol for either of `outline-mode-leaders' or |
| 203 | `comment-start' to use only one of them, respectively. | 233 | `comment-start' to use only one of them, respectively. |
| 204 | 234 | ||
| 205 | Value `nil' means to always use the default \(`.'\). | 235 | Value `nil' means to always use the default \(`.'). |
| 206 | 236 | ||
| 207 | comment-start strings that do not end in spaces are tripled, and an | 237 | comment-start strings that do not end in spaces are tripled, and an |
| 208 | `_' underscore is tacked on the end, to distinguish them from regular | 238 | `_' underscore is tacked on the end, to distinguish them from regular |
| 209 | comment strings. comment-start strings that do end in spaces are not | 239 | comment strings. comment-start strings that do end in spaces are not |
| 210 | tripled, but an underscore is substituted for the space. [This | 240 | tripled, but an underscore is substituted for the space. [This |
| 211 | presumes that the space is for appearance, not comment syntax. You | 241 | presumes that the space is for appearance, not comment syntax. You |
| 212 | can use `outline-mode-leaders' to override this behavior, when | 242 | can use `outline-mode-leaders' to override this behavior, when |
| 213 | incorrect.]" | 243 | incorrect.]" |
| @@ -219,7 +249,7 @@ incorrect.]" | |||
| 219 | (defvar outline-mode-leaders '() | 249 | (defvar outline-mode-leaders '() |
| 220 | "Specific outline-prefix leading strings per major modes. | 250 | "Specific outline-prefix leading strings per major modes. |
| 221 | 251 | ||
| 222 | Entries will be used in the stead (or lieu) of mode-specific | 252 | Entries will be used instead or in lieu of mode-specific |
| 223 | comment-start strings. See also `outline-use-mode-specific-leader'. | 253 | comment-start strings. See also `outline-use-mode-specific-leader'. |
| 224 | 254 | ||
| 225 | If you're constructing a string that will comment-out outline | 255 | If you're constructing a string that will comment-out outline |
| @@ -302,11 +332,26 @@ disables numbering maintenance." | |||
| 302 | (defcustom outline-file-xref-bullet "@" | 332 | (defcustom outline-file-xref-bullet "@" |
| 303 | "*Bullet signifying file cross-references, for `outline-resolve-xref'. | 333 | "*Bullet signifying file cross-references, for `outline-resolve-xref'. |
| 304 | 334 | ||
| 305 | Set this var to the bullet you want to use for file cross-references. | 335 | Set this var to the bullet you want to use for file cross-references." |
| 306 | Set it to nil if you want to inhibit this capability." | ||
| 307 | :type '(choice (const nil) string) | 336 | :type '(choice (const nil) string) |
| 308 | :group 'allout) | 337 | :group 'allout) |
| 309 | 338 | ||
| 339 | ;;;_ = outline-presentation-padding | ||
| 340 | (defcustom outline-presentation-padding 2 | ||
| 341 | "*Presentation-format white-space padding factor, for greater indent." | ||
| 342 | :type 'integer | ||
| 343 | :group 'allout) | ||
| 344 | |||
| 345 | (make-variable-buffer-local 'outline-presentation-padding) | ||
| 346 | |||
| 347 | ;;;_ = outline-abbreviate-flattened-numbering | ||
| 348 | (defcustom outline-abbreviate-flattened-numbering nil | ||
| 349 | "*If non-nil, `outline-flatten-exposed-to-buffer' abbreviates topic | ||
| 350 | numbers to minimal amount with some context. Otherwise, entire | ||
| 351 | numbers are always used." | ||
| 352 | :type 'boolean | ||
| 353 | :group 'allout) | ||
| 354 | |||
| 310 | ;;;_ + LaTeX formatting | 355 | ;;;_ + LaTeX formatting |
| 311 | ;;;_ - outline-number-pages | 356 | ;;;_ - outline-number-pages |
| 312 | (defcustom outline-number-pages nil | 357 | (defcustom outline-number-pages nil |
| @@ -352,20 +397,23 @@ formatted copy." | |||
| 352 | 397 | ||
| 353 | ;;;_ + Miscellaneous customization | 398 | ;;;_ + Miscellaneous customization |
| 354 | 399 | ||
| 400 | ;;;_ = outline-command-prefix | ||
| 401 | (defcustom outline-command-prefix "\C-c" | ||
| 402 | "*Key sequence to be used as prefix for outline mode command key bindings." | ||
| 403 | :type 'string | ||
| 404 | :group 'allout) | ||
| 405 | |||
| 355 | ;;;_ = outline-keybindings-list | 406 | ;;;_ = outline-keybindings-list |
| 356 | ;;; You have to reactivate outline-mode - `(outline-mode t)' - to | 407 | ;;; You have to reactivate outline-mode - `(outline-mode t)' - to |
| 357 | ;;; institute changes to this var. | 408 | ;;; institute changes to this var. |
| 358 | (defvar outline-keybindings-list () | 409 | (defvar outline-keybindings-list () |
| 359 | "*List of outline-mode key / function bindings. | 410 | "*List of outline-mode key / function bindings, for outline-mode-map. |
| 360 | 411 | ||
| 361 | These bindings will be locally bound on the outline-mode-map. The | 412 | String or vector key will be prefaced with outline-command-prefix, |
| 362 | keys will be prefixed by outline-command-prefix, unless the cell | 413 | unless optional third, non-nil element is present.") |
| 363 | contains a third, no-nil element, in which case the initial string | ||
| 364 | will be used as is.") | ||
| 365 | (setq outline-keybindings-list | 414 | (setq outline-keybindings-list |
| 366 | '( | 415 | '( |
| 367 | ; Motion commands: | 416 | ; Motion commands: |
| 368 | ("?t" outline-latexify-exposed) | ||
| 369 | ("\C-n" outline-next-visible-heading) | 417 | ("\C-n" outline-next-visible-heading) |
| 370 | ("\C-p" outline-previous-visible-heading) | 418 | ("\C-p" outline-previous-visible-heading) |
| 371 | ("\C-u" outline-up-current-level) | 419 | ("\C-u" outline-up-current-level) |
| @@ -373,8 +421,6 @@ will be used as is.") | |||
| 373 | ("\C-b" outline-backward-current-level) | 421 | ("\C-b" outline-backward-current-level) |
| 374 | ("\C-a" outline-beginning-of-current-entry) | 422 | ("\C-a" outline-beginning-of-current-entry) |
| 375 | ("\C-e" outline-end-of-current-entry) | 423 | ("\C-e" outline-end-of-current-entry) |
| 376 | ;;("\C-n" outline-next-line-or-topic) | ||
| 377 | ;;("\C-p" outline-previous-line-or-topic) | ||
| 378 | ; Exposure commands: | 424 | ; Exposure commands: |
| 379 | ("\C-i" outline-show-children) | 425 | ("\C-i" outline-show-children) |
| 380 | ("\C-s" outline-show-current-subtree) | 426 | ("\C-s" outline-show-current-subtree) |
| @@ -396,24 +442,20 @@ will be used as is.") | |||
| 396 | ("\M-y" outline-yank-pop t) | 442 | ("\M-y" outline-yank-pop t) |
| 397 | ("\C-k" outline-kill-topic) | 443 | ("\C-k" outline-kill-topic) |
| 398 | ; Miscellaneous commands: | 444 | ; Miscellaneous commands: |
| 399 | ("\C-@" outline-mark-topic) | 445 | ;([?\C-\ ] outline-mark-topic) |
| 400 | ("@" outline-resolve-xref) | 446 | ("@" outline-resolve-xref) |
| 401 | ("?c" outline-copy-exposed))) | 447 | ("=c" outline-copy-exposed-to-buffer) |
| 402 | 448 | ("=i" outline-indented-exposed-to-buffer) | |
| 403 | ;;;_ = outline-command-prefix | 449 | ("=t" outline-latexify-exposed) |
| 404 | (defcustom outline-command-prefix "\C-c" | 450 | ("=p" outline-flatten-exposed-to-buffer))) |
| 405 | "*Key sequence to be used as prefix for outline mode command key bindings." | 451 | |
| 406 | :type 'string | 452 | ;;;_ = outline-isearch-dynamic-expose |
| 407 | :group 'allout) | 453 | (defcustom outline-isearch-dynamic-expose t |
| 408 | 454 | "*Non-nil enable dynamic exposure of hidden incremental-search | |
| 409 | ;;;_ = outline-enwrap-isearch-mode | 455 | targets as they're encountered." |
| 410 | (defcustom outline-enwrap-isearch-mode t | ||
| 411 | "*Set non-nil to enable automatic exposure of concealed isearch targets. | ||
| 412 | |||
| 413 | If non-nil, isearch will expose hidden text encountered in the course | ||
| 414 | of a search, and to reconceal it if the search is continued past it." | ||
| 415 | :type 'boolean | 456 | :type 'boolean |
| 416 | :group 'allout) | 457 | :group 'allout) |
| 458 | (make-variable-buffer-local 'outline-isearch-dynamic-expose) | ||
| 417 | 459 | ||
| 418 | ;;;_ = outline-use-hanging-indents | 460 | ;;;_ = outline-use-hanging-indents |
| 419 | (defcustom outline-use-hanging-indents t | 461 | (defcustom outline-use-hanging-indents t |
| @@ -461,16 +503,16 @@ behavior." | |||
| 461 | 503 | ||
| 462 | ;;;_* CODE - no user customizations below. | 504 | ;;;_* CODE - no user customizations below. |
| 463 | 505 | ||
| 464 | ;;;_ #1 Internal Outline Formatting and Configuration | 506 | ;;;_ #1 Internal Outline Formatting and Configuration |
| 465 | ;;;_ - Version | 507 | ;;;_ : Version |
| 466 | ;;;_ = outline-version | 508 | ;;;_ = outline-version |
| 467 | (defvar outline-version | 509 | (defvar outline-version |
| 468 | (let ((rcs-rev "Revision: 4.3")) | 510 | (let ((rcs-rev "$Revision: 4.35 $")) |
| 469 | (condition-case err | 511 | (condition-case err |
| 470 | (save-match-data | 512 | (save-match-data |
| 471 | (string-match "Revision: \\([0-9]+\\.[0-9]+\\)" rcs-rev) | 513 | (string-match "Revision: \\([0-9]+\\.[0-9]+\\)" rcs-rev) |
| 472 | (substring rcs-rev (match-beginning 1) (match-end 1))) | 514 | (substring rcs-rev (match-beginning 1) (match-end 1))) |
| 473 | (error rcs-rev))) | 515 | ('error rcs-rev))) |
| 474 | "Revision number of currently loaded outline package. \(allout.el)") | 516 | "Revision number of currently loaded outline package. \(allout.el)") |
| 475 | ;;;_ > outline-version | 517 | ;;;_ > outline-version |
| 476 | (defun outline-version (&optional here) | 518 | (defun outline-version (&optional here) |
| @@ -480,7 +522,7 @@ behavior." | |||
| 480 | (if here (insert-string msg)) | 522 | (if here (insert-string msg)) |
| 481 | (message "%s" msg) | 523 | (message "%s" msg) |
| 482 | msg)) | 524 | msg)) |
| 483 | ;;;_ - Topic header format | 525 | ;;;_ : Topic header format |
| 484 | ;;;_ = outline-regexp | 526 | ;;;_ = outline-regexp |
| 485 | (defvar outline-regexp "" | 527 | (defvar outline-regexp "" |
| 486 | "*Regular expression to match the beginning of a heading line. | 528 | "*Regular expression to match the beginning of a heading line. |
| @@ -512,7 +554,7 @@ that (match-beginning 2) and (match-end 2) delimit the prefix.") | |||
| 512 | ;;;_ = outline-bob-regexp | 554 | ;;;_ = outline-bob-regexp |
| 513 | (defvar outline-bob-regexp () | 555 | (defvar outline-bob-regexp () |
| 514 | "Like outline-line-boundary-regexp, for headers at beginning of buffer. | 556 | "Like outline-line-boundary-regexp, for headers at beginning of buffer. |
| 515 | \(match-beginning 2) and (match-end 2) delimit the prefix.") | 557 | \(match-beginning 2) and \(match-end 2) delimit the prefix.") |
| 516 | (make-variable-buffer-local 'outline-bob-regexp) | 558 | (make-variable-buffer-local 'outline-bob-regexp) |
| 517 | ;;;_ = outline-header-subtraction | 559 | ;;;_ = outline-header-subtraction |
| 518 | (defvar outline-header-subtraction (1- (length outline-header-prefix)) | 560 | (defvar outline-header-subtraction (1- (length outline-header-prefix)) |
| @@ -556,7 +598,7 @@ Works according to settings of: | |||
| 556 | `outline-use-mode-specific-leader' | 598 | `outline-use-mode-specific-leader' |
| 557 | and `outline-mode-leaders'. | 599 | and `outline-mode-leaders'. |
| 558 | 600 | ||
| 559 | Apply this via \(re\)activation of `outline-mode', rather than | 601 | Apply this via \(re)activation of `outline-mode', rather than |
| 560 | invoking it directly." | 602 | invoking it directly." |
| 561 | (let* ((use-leader (and (boundp 'outline-use-mode-specific-leader) | 603 | (let* ((use-leader (and (boundp 'outline-use-mode-specific-leader) |
| 562 | (if (or (stringp outline-use-mode-specific-leader) | 604 | (if (or (stringp outline-use-mode-specific-leader) |
| @@ -617,7 +659,8 @@ Works with respect to `outline-plain-bullets-string' and | |||
| 617 | ;; Derive outline-bullets-string from user configured components: | 659 | ;; Derive outline-bullets-string from user configured components: |
| 618 | (setq outline-bullets-string "") | 660 | (setq outline-bullets-string "") |
| 619 | (let ((strings (list 'outline-plain-bullets-string | 661 | (let ((strings (list 'outline-plain-bullets-string |
| 620 | 'outline-distinctive-bullets-string)) | 662 | 'outline-distinctive-bullets-string |
| 663 | 'outline-primary-bullet)) | ||
| 621 | cur-string | 664 | cur-string |
| 622 | cur-len | 665 | cur-len |
| 623 | cur-char | 666 | cur-char |
| @@ -660,7 +703,7 @@ Works with respect to `outline-plain-bullets-string' and | |||
| 660 | (setq outline-bob-regexp | 703 | (setq outline-bob-regexp |
| 661 | (concat "\\(\\`\\)\\(" outline-regexp "\\)")) | 704 | (concat "\\(\\`\\)\\(" outline-regexp "\\)")) |
| 662 | ) | 705 | ) |
| 663 | ;;;_ - Key bindings | 706 | ;;;_ : Key bindings |
| 664 | ;;;_ = outline-mode-map | 707 | ;;;_ = outline-mode-map |
| 665 | (defvar outline-mode-map nil "Keybindings for (allout) outline minor mode.") | 708 | (defvar outline-mode-map nil "Keybindings for (allout) outline minor mode.") |
| 666 | ;;;_ > produce-outline-mode-map (keymap-alist &optional base-map) | 709 | ;;;_ > produce-outline-mode-map (keymap-alist &optional base-map) |
| @@ -669,13 +712,18 @@ Works with respect to `outline-plain-bullets-string' and | |||
| 669 | 712 | ||
| 670 | Built on top of optional BASE-MAP, or empty sparse map if none specified. | 713 | Built on top of optional BASE-MAP, or empty sparse map if none specified. |
| 671 | See doc string for outline-keybindings-list for format of binding list." | 714 | See doc string for outline-keybindings-list for format of binding list." |
| 672 | (let ((map (or base-map (make-sparse-keymap)))) | 715 | (let ((map (or base-map (make-sparse-keymap))) |
| 673 | (mapcar (lambda (cell) | 716 | (pref (list outline-command-prefix))) |
| 674 | (apply 'define-key map (if (null (cdr (cdr cell))) | 717 | (mapcar (function |
| 675 | (cons (concat outline-command-prefix | 718 | (lambda (cell) |
| 676 | (car cell)) | 719 | (let ((add-pref (null (cdr (cdr cell)))) |
| 677 | (cdr cell)) | 720 | (key-suff (list (car cell)))) |
| 678 | (list (car cell) (car (cdr cell)))))) | 721 | (apply 'define-key |
| 722 | (list map | ||
| 723 | (apply 'concat (if add-pref | ||
| 724 | (append pref key-suff) | ||
| 725 | key-suff)) | ||
| 726 | (car (cdr cell))))))) | ||
| 679 | keymap-list) | 727 | keymap-list) |
| 680 | map)) | 728 | map)) |
| 681 | ;;;_ = outline-prior-bindings - being deprecated. | 729 | ;;;_ = outline-prior-bindings - being deprecated. |
| @@ -688,7 +736,65 @@ activation. Being deprecated.") | |||
| 688 | "Variable for use in V18, with outline-prior-bindings, for | 736 | "Variable for use in V18, with outline-prior-bindings, for |
| 689 | resurrecting, on mode deactivation, bindings that existed before | 737 | resurrecting, on mode deactivation, bindings that existed before |
| 690 | activation. Being deprecated.") | 738 | activation. Being deprecated.") |
| 691 | ;;;_ - Mode-Specific Variable Maintenance Utilities | 739 | ;;;_ : Menu bar |
| 740 | (defun produce-outline-mode-menubar-entries () | ||
| 741 | (require 'easymenu) | ||
| 742 | (easy-menu-define outline-mode-exposure-menu | ||
| 743 | outline-mode-map | ||
| 744 | "Allout outline exposure menu." | ||
| 745 | '("Exposure" | ||
| 746 | ["Show Entry" outline-show-current-entry t] | ||
| 747 | ["Show Children" outline-show-children t] | ||
| 748 | ["Show Subtree" outline-show-current-subtree t] | ||
| 749 | ["Hide Subtree" outline-hide-current-subtree t] | ||
| 750 | ["Hide Leaves" outline-hide-current-leaves t] | ||
| 751 | "----" | ||
| 752 | ["Show All" outline-show-all t])) | ||
| 753 | (easy-menu-define outline-mode-editing-menu | ||
| 754 | outline-mode-map | ||
| 755 | "Allout outline editing menu." | ||
| 756 | '("Headings" | ||
| 757 | ["Open Sibling" outline-open-sibtopic t] | ||
| 758 | ["Open Subtopic" outline-open-subtopic t] | ||
| 759 | ["Open Supertopic" outline-open-supertopic t] | ||
| 760 | "----" | ||
| 761 | ["Shift Topic In" outline-shift-in t] | ||
| 762 | ["Shift Topic Out" outline-shift-out t] | ||
| 763 | ["Rebullet Topic" outline-rebullet-topic t] | ||
| 764 | ["Rebullet Heading" outline-rebullet-current-heading t] | ||
| 765 | ["Number Siblings" outline-number-siblings t])) | ||
| 766 | (easy-menu-define outline-mode-navigation-menu | ||
| 767 | outline-mode-map | ||
| 768 | "Allout outline navigation menu." | ||
| 769 | '("Navigation" | ||
| 770 | ["Next Visible Heading" outline-next-visible-heading t] | ||
| 771 | ["Previous Visible Heading" | ||
| 772 | outline-previous-visible-heading t] | ||
| 773 | "----" | ||
| 774 | ["Up Level" outline-up-current-level t] | ||
| 775 | ["Forward Current Level" outline-forward-current-level t] | ||
| 776 | ["Backward Current Level" | ||
| 777 | outline-backward-current-level t] | ||
| 778 | "----" | ||
| 779 | ["Beginning of Entry" | ||
| 780 | outline-beginning-of-current-entry t] | ||
| 781 | ["End of Entry" outline-end-of-current-entry t] | ||
| 782 | ["End of Subtree" outline-end-of-current-subtree t])) | ||
| 783 | (easy-menu-define outline-mode-misc-menu | ||
| 784 | outline-mode-map | ||
| 785 | "Allout outlines miscellaneous bindings." | ||
| 786 | '("Misc" | ||
| 787 | ["Version" outline-version t] | ||
| 788 | "----" | ||
| 789 | ["Duplicate Exposed" outline-copy-exposed-to-buffer t] | ||
| 790 | ["Duplicate Exposed, numbered" | ||
| 791 | outline-flatten-exposed-to-buffer t] | ||
| 792 | ["Duplicate Exposed, indented" | ||
| 793 | outline-indented-exposed-to-buffer t] | ||
| 794 | "----" | ||
| 795 | ["Set Header Lead" outline-reset-header-lead t] | ||
| 796 | ["Set New Exposure" outline-expose-topic t]))) | ||
| 797 | ;;;_ : Mode-Specific Variable Maintenance Utilities | ||
| 692 | ;;;_ = outline-mode-prior-settings | 798 | ;;;_ = outline-mode-prior-settings |
| 693 | (defvar outline-mode-prior-settings nil | 799 | (defvar outline-mode-prior-settings nil |
| 694 | "Internal outline mode use; settings to be resumed on mode deactivation.") | 800 | "Internal outline mode use; settings to be resumed on mode deactivation.") |
| @@ -751,7 +857,7 @@ from the list." | |||
| 751 | (cdr outline-mode-prior-settings))) | 857 | (cdr outline-mode-prior-settings))) |
| 752 | (setq outline-mode-prior-settings rebuild))))) | 858 | (setq outline-mode-prior-settings rebuild))))) |
| 753 | ) | 859 | ) |
| 754 | ;;;_ - Mode-specific incidentals | 860 | ;;;_ : Mode-specific incidentals |
| 755 | ;;;_ = outline-during-write-cue nil | 861 | ;;;_ = outline-during-write-cue nil |
| 756 | (defvar outline-during-write-cue nil | 862 | (defvar outline-during-write-cue nil |
| 757 | "Used to inhibit outline change-protection during file write. | 863 | "Used to inhibit outline change-protection during file write. |
| @@ -759,6 +865,22 @@ from the list." | |||
| 759 | See also `outline-post-command-business', `outline-write-file-hook', | 865 | See also `outline-post-command-business', `outline-write-file-hook', |
| 760 | `outline-before-change-protect', and `outline-post-command-business' | 866 | `outline-before-change-protect', and `outline-post-command-business' |
| 761 | functions.") | 867 | functions.") |
| 868 | ;;;_ = outline-pre-was-isearching nil | ||
| 869 | (defvar outline-pre-was-isearching nil | ||
| 870 | "Cue for isearch-dynamic-exposure mechanism, implemented in | ||
| 871 | outline-pre- and -post-command-hooks.") | ||
| 872 | (make-variable-buffer-local 'outline-pre-was-isearching) | ||
| 873 | ;;;_ = outline-isearch-prior-pos nil | ||
| 874 | (defvar outline-isearch-prior-pos nil | ||
| 875 | "Cue for isearch-dynamic-exposure tracking, used by outline-isearch-expose.") | ||
| 876 | (make-variable-buffer-local 'outline-isearch-prior-pos) | ||
| 877 | ;;;_ = outline-isearch-did-quit | ||
| 878 | (defvar outline-isearch-did-quit nil | ||
| 879 | "Distinguishes isearch conclusion and cancellation. | ||
| 880 | |||
| 881 | Maintained by outline-isearch-abort \(which is wrapped around the real | ||
| 882 | isearch-abort), and monitored by outline-isearch-expose for action.") | ||
| 883 | (make-variable-buffer-local 'outline-isearch-did-quit) | ||
| 762 | ;;;_ = outline-override-protect nil | 884 | ;;;_ = outline-override-protect nil |
| 763 | (defvar outline-override-protect nil | 885 | (defvar outline-override-protect nil |
| 764 | "Used in outline-mode for regulate of concealed-text protection mechanism. | 886 | "Used in outline-mode for regulate of concealed-text protection mechanism. |
| @@ -770,18 +892,18 @@ It's automatically reset to nil after every buffer modification.") | |||
| 770 | (make-variable-buffer-local 'outline-override-protect) | 892 | (make-variable-buffer-local 'outline-override-protect) |
| 771 | ;;;_ > outline-unprotected (expr) | 893 | ;;;_ > outline-unprotected (expr) |
| 772 | (defmacro outline-unprotected (expr) | 894 | (defmacro outline-unprotected (expr) |
| 773 | "Evaluate EXPRESSION with `outline-override-protect' let-bound to t." | 895 | "Evaluate EXPRESSION with `outline-override-protect' let-bound `t'." |
| 774 | (` (let ((outline-override-protect t)) | 896 | `(let ((outline-override-protect t)) |
| 775 | (, expr)))) | 897 | ,expr)) |
| 776 | ;;;_ = outline-undo-aggregation | 898 | ;;;_ = outline-undo-aggregation |
| 777 | (defvar outline-undo-aggregation 30 | 899 | (defvar outline-undo-aggregation 30 |
| 778 | "Amount of successive self-insert actions to bunch together per undo. | 900 | "Amount of successive self-insert actions to bunch together per undo. |
| 779 | 901 | ||
| 780 | This is purely a kludge variable, regulating the compensation for a bug in | 902 | This is purely a kludge variable, regulating the compensation for a bug in |
| 781 | the way that before-change-function and undo interact.") | 903 | the way that before-change-functions and undo interact.") |
| 782 | (make-variable-buffer-local 'outline-undo-aggregation) | 904 | (make-variable-buffer-local 'outline-undo-aggregation) |
| 783 | ;;;_ = file-var-bug hack | 905 | ;;;_ = file-var-bug hack |
| 784 | (defvar outline-v18/9-file-var-hack nil | 906 | (defvar outline-v18/19-file-var-hack nil |
| 785 | "Horrible hack used to prevent invalid multiple triggering of outline | 907 | "Horrible hack used to prevent invalid multiple triggering of outline |
| 786 | mode from prop-line file-var activation. Used by outline-mode function | 908 | mode from prop-line file-var activation. Used by outline-mode function |
| 787 | to track repeats.") | 909 | to track repeats.") |
| @@ -881,37 +1003,55 @@ the following two lines in your emacs init file: | |||
| 881 | ((message | 1003 | ((message |
| 882 | "Outline mode auto-activation and -layout enabled.") | 1004 | "Outline mode auto-activation and -layout enabled.") |
| 883 | 'full))))))) | 1005 | 'full))))))) |
| 884 | 1006 | ||
| 1007 | ;;;_ > outline-setup-menubar () | ||
| 1008 | (defun outline-setup-menubar () | ||
| 1009 | "Populate the current buffer's menubar with allout outline-mode stuff." | ||
| 1010 | (let ((menus (list outline-mode-exposure-menu | ||
| 1011 | outline-mode-editing-menu | ||
| 1012 | outline-mode-navigation-menu | ||
| 1013 | outline-mode-misc-menu)) | ||
| 1014 | cur) | ||
| 1015 | (while menus | ||
| 1016 | (setq cur (car menus) | ||
| 1017 | menus (cdr menus)) | ||
| 1018 | (easy-menu-add cur)))) | ||
| 885 | ;;;_ > outline-mode (&optional toggle) | 1019 | ;;;_ > outline-mode (&optional toggle) |
| 886 | ;;;_ : Defun: | 1020 | ;;;_ : Defun: |
| 887 | (defun outline-mode (&optional toggle) | 1021 | (defun outline-mode (&optional toggle) |
| 888 | ;;;_ . Doc string: | 1022 | ;;;_ . Doc string: |
| 889 | "Toggle minor mode for controlling exposure and editing of text outlines. | 1023 | "Toggle minor mode for controlling exposure and editing of text outlines. |
| 890 | 1024 | ||
| 891 | Optional arg forces mode reactivation iff arg is positive num or symbol. | 1025 | Optional arg forces mode to re-initialize iff arg is positive num or |
| 1026 | symbol. Allout outline mode always runs as a minor mode. | ||
| 892 | 1027 | ||
| 893 | Allout outline mode provides extensive outline formatting and | 1028 | Allout outline mode provides extensive outline-oriented formatting and |
| 894 | manipulation capabilities. It is specifically aimed at supporting | 1029 | manipulation. It enables structural editing of outlines, as well as |
| 895 | outline structuring and manipulation of syntax-sensitive text, eg | 1030 | navigation and exposure. It also is specifically aimed at |
| 896 | programming languages. \(For an example, see the allout code itself, | 1031 | accommodating syntax-sensitive text like programming languages. \(For |
| 897 | which is organized in outline structure.\) | 1032 | an example, see the allout code itself, which is organized as an allout |
| 1033 | outline.) | ||
| 898 | 1034 | ||
| 899 | It also includes such things as topic-oriented repositioning, cut, and | 1035 | In addition to outline navigation and exposure, allout includes: |
| 900 | paste; integral outline exposure-layout; incremental search with | ||
| 901 | dynamic exposure/concealment of concealed text; automatic topic-number | ||
| 902 | maintenance; and many other features. | ||
| 903 | 1036 | ||
| 904 | See the docstring of the variable `outline-init' for instructions on | 1037 | - topic-oriented repositioning, cut, and paste |
| 905 | priming your emacs session for automatic activation of outline-mode, | 1038 | - integral outline exposure-layout |
| 906 | according to file-var settings of the `outline-layout' variable. | 1039 | - incremental search with dynamic exposure and reconcealment of hidden text |
| 1040 | - automatic topic-number maintenance | ||
| 1041 | - \"Hot-spot\" operation, for single-keystroke maneuvering and | ||
| 1042 | exposure control. \(See the outline-mode docstring.) | ||
| 1043 | |||
| 1044 | and many other features. | ||
| 907 | 1045 | ||
| 908 | Below is a description of the bindings, and then explanation of | 1046 | Below is a description of the bindings, and then explanation of |
| 909 | special outline-mode features and terminology. | 1047 | special outline-mode features and terminology. See also the outline |
| 1048 | menubar additions for quick reference to many of the features, and see | ||
| 1049 | the docstring of the variable `outline-init' for instructions on | ||
| 1050 | priming your emacs session for automatic activation of outline-mode. | ||
| 1051 | |||
| 910 | 1052 | ||
| 911 | The bindings themselves are established according to the values of | 1053 | The bindings are dictated by the `outline-keybindings-list' and |
| 912 | variables `outline-keybindings-list' and `outline-command-prefix', | 1054 | `outline-command-prefix' variables. |
| 913 | each time the mode is invoked. Prior bindings are resurrected when | ||
| 914 | the mode is revoked. | ||
| 915 | 1055 | ||
| 916 | Navigation: Exposure Control: | 1056 | Navigation: Exposure Control: |
| 917 | ---------- ---------------- | 1057 | ---------- ---------------- |
| @@ -936,7 +1076,7 @@ C-c < outline-shift-out ... less deep. | |||
| 936 | C-c<CR> outline-rebullet-topic Reconcile bullets of topic and its offspring | 1076 | C-c<CR> outline-rebullet-topic Reconcile bullets of topic and its offspring |
| 937 | - distinctive bullets are not changed, others | 1077 | - distinctive bullets are not changed, others |
| 938 | alternated according to nesting depth. | 1078 | alternated according to nesting depth. |
| 939 | C-c * outline-rebullet-current-heading Prompt for alternate bullet for | 1079 | C-c b outline-rebullet-current-heading Prompt for alternate bullet for |
| 940 | current topic. | 1080 | current topic. |
| 941 | C-c # outline-number-siblings Number bullets of topic and siblings - the | 1081 | C-c # outline-number-siblings Number bullets of topic and siblings - the |
| 942 | offspring are not affected. With repeat | 1082 | offspring are not affected. With repeat |
| @@ -953,14 +1093,18 @@ M-y outline-yank-pop Is to outline-yank as yank-pop is to yank | |||
| 953 | 1093 | ||
| 954 | Misc commands: | 1094 | Misc commands: |
| 955 | ------------- | 1095 | ------------- |
| 956 | C-c @ outline-resolve-xref pop-to-buffer named by xref (cf | ||
| 957 | outline-file-xref-bullet) | ||
| 958 | C-c c outline-copy-exposed Copy current topic outline sans concealed | ||
| 959 | text, to buffer with name derived from | ||
| 960 | current buffer - \"XXX exposed\" | ||
| 961 | M-x outlineify-sticky Activate outline mode for current buffer, | 1096 | M-x outlineify-sticky Activate outline mode for current buffer, |
| 962 | and establish a default file-var setting | 1097 | and establish a default file-var setting |
| 963 | for `outline-layout'. | 1098 | for `outline-layout'. |
| 1099 | C-c C-SPC outline-mark-topic | ||
| 1100 | C-c = c outline-copy-exposed-to-buffer | ||
| 1101 | Duplicate outline, sans concealed text, to | ||
| 1102 | buffer with name derived from derived from | ||
| 1103 | that of current buffer - \"*XXX exposed*\". | ||
| 1104 | C-c = p outline-flatten-exposed-to-buffer | ||
| 1105 | Like above 'copy-exposed', but convert topic | ||
| 1106 | prefixes to section.subsection... numeric | ||
| 1107 | format. | ||
| 964 | ESC ESC (outline-init t) Setup emacs session for outline mode | 1108 | ESC ESC (outline-init t) Setup emacs session for outline mode |
| 965 | auto-activation. | 1109 | auto-activation. |
| 966 | 1110 | ||
| @@ -1075,13 +1219,13 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1075 | (and (natnump toggle) | 1219 | (and (natnump toggle) |
| 1076 | (not (zerop toggle))))))) | 1220 | (not (zerop toggle))))))) |
| 1077 | ;; outline-mode already called once during this complex command? | 1221 | ;; outline-mode already called once during this complex command? |
| 1078 | (same-complex-command (eq outline-v18/9-file-var-hack | 1222 | (same-complex-command (eq outline-v18/19-file-var-hack |
| 1079 | (car command-history))) | 1223 | (car command-history))) |
| 1080 | do-layout | 1224 | do-layout |
| 1081 | ) | 1225 | ) |
| 1082 | 1226 | ||
| 1083 | ; See comments below re v19.18,.19 bug. | 1227 | ; See comments below re v19.18,.19 bug. |
| 1084 | (setq outline-v18/9-file-var-hack (car command-history)) | 1228 | (setq outline-v18/19-file-var-hack (car command-history)) |
| 1085 | 1229 | ||
| 1086 | (cond | 1230 | (cond |
| 1087 | 1231 | ||
| @@ -1110,11 +1254,12 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1110 | ; Revoke those keys that remain | 1254 | ; Revoke those keys that remain |
| 1111 | ; as we set them: | 1255 | ; as we set them: |
| 1112 | (let ((curr-loc (current-local-map))) | 1256 | (let ((curr-loc (current-local-map))) |
| 1113 | (mapcar '(lambda (cell) | 1257 | (mapcar (function |
| 1258 | (lambda (cell) | ||
| 1114 | (if (eq (lookup-key curr-loc (car cell)) | 1259 | (if (eq (lookup-key curr-loc (car cell)) |
| 1115 | (car (cdr cell))) | 1260 | (car (cdr cell))) |
| 1116 | (define-key curr-loc (car cell) | 1261 | (define-key curr-loc (car cell) |
| 1117 | (assq (car cell) outline-prior-bindings)))) | 1262 | (assq (car cell) outline-prior-bindings))))) |
| 1118 | outline-added-bindings) | 1263 | outline-added-bindings) |
| 1119 | (outline-resumptions 'outline-added-bindings) | 1264 | (outline-resumptions 'outline-added-bindings) |
| 1120 | (outline-resumptions 'outline-prior-bindings))) | 1265 | (outline-resumptions 'outline-prior-bindings))) |
| @@ -1124,10 +1269,8 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1124 | (outline-resumptions 'outline-primary-bullet) | 1269 | (outline-resumptions 'outline-primary-bullet) |
| 1125 | (outline-resumptions 'outline-old-style-prefixes))) | 1270 | (outline-resumptions 'outline-old-style-prefixes))) |
| 1126 | (outline-resumptions 'selective-display) | 1271 | (outline-resumptions 'selective-display) |
| 1127 | (if (and (boundp 'before-change-function) before-change-function) | 1272 | (if (and (boundp 'before-change-functions) before-change-functions) |
| 1128 | (outline-resumptions 'before-change-function)) | 1273 | (outline-resumptions 'before-change-functions)) |
| 1129 | (setq pre-command-hook (delq 'outline-pre-command-business | ||
| 1130 | pre-command-hook)) | ||
| 1131 | (setq local-write-file-hooks | 1274 | (setq local-write-file-hooks |
| 1132 | (delq 'outline-write-file-hook | 1275 | (delq 'outline-write-file-hook |
| 1133 | local-write-file-hooks)) | 1276 | local-write-file-hooks)) |
| @@ -1160,6 +1303,7 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1160 | ; epoch, minor-mode key bindings: | 1303 | ; epoch, minor-mode key bindings: |
| 1161 | (setq outline-mode-map | 1304 | (setq outline-mode-map |
| 1162 | (produce-outline-mode-map outline-keybindings-list)) | 1305 | (produce-outline-mode-map outline-keybindings-list)) |
| 1306 | (produce-outline-mode-menubar-entries) | ||
| 1163 | (fset 'outline-mode-map outline-mode-map) | 1307 | (fset 'outline-mode-map outline-mode-map) |
| 1164 | ; Include on minor-mode-map-alist, | 1308 | ; Include on minor-mode-map-alist, |
| 1165 | ; if not already there: | 1309 | ; if not already there: |
| @@ -1187,8 +1331,10 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1187 | (outline-resumptions 'selective-display '(t)) | 1331 | (outline-resumptions 'selective-display '(t)) |
| 1188 | (if outline-inhibit-protection | 1332 | (if outline-inhibit-protection |
| 1189 | t | 1333 | t |
| 1190 | (outline-resumptions 'before-change-function | 1334 | (outline-resumptions 'before-change-functions |
| 1191 | '(outline-before-change-protect))) | 1335 | '(outline-before-change-protect))) |
| 1336 | (add-hook 'pre-command-hook 'outline-pre-command-business) | ||
| 1337 | (add-hook 'post-command-hook 'outline-post-command-business) | ||
| 1192 | ; Temporarily set by any outline | 1338 | ; Temporarily set by any outline |
| 1193 | ; functions that can be trusted to | 1339 | ; functions that can be trusted to |
| 1194 | ; deal properly with concealed text. | 1340 | ; deal properly with concealed text. |
| @@ -1207,21 +1353,24 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1207 | ;; Paragraphs are broken by topic headlines. | 1353 | ;; Paragraphs are broken by topic headlines. |
| 1208 | (make-local-variable 'paragraph-start) | 1354 | (make-local-variable 'paragraph-start) |
| 1209 | (outline-resumptions 'paragraph-start | 1355 | (outline-resumptions 'paragraph-start |
| 1210 | (list (concat paragraph-start "\\|\\(" | 1356 | (list (concat paragraph-start "\\|^\\(" |
| 1211 | outline-regexp "\\)"))) | 1357 | outline-regexp "\\)"))) |
| 1212 | (make-local-variable 'paragraph-separate) | 1358 | (make-local-variable 'paragraph-separate) |
| 1213 | (outline-resumptions 'paragraph-separate | 1359 | (outline-resumptions 'paragraph-separate |
| 1214 | (list (concat paragraph-separate "\\|\\(" | 1360 | (list (concat paragraph-separate "\\|^\\(" |
| 1215 | outline-regexp "\\)"))) | 1361 | outline-regexp "\\)"))) |
| 1216 | 1362 | ||
| 1217 | (or (assq 'outline-mode minor-mode-alist) | 1363 | (or (assq 'outline-mode minor-mode-alist) |
| 1218 | (setq minor-mode-alist | 1364 | (setq minor-mode-alist |
| 1219 | (cons '(outline-mode " Outl") minor-mode-alist))) | 1365 | (cons '(outline-mode " Outl") minor-mode-alist))) |
| 1220 | 1366 | ||
| 1367 | (outline-setup-menubar) | ||
| 1368 | |||
| 1221 | (if outline-layout | 1369 | (if outline-layout |
| 1222 | (setq do-layout t)) | 1370 | (setq do-layout t)) |
| 1223 | 1371 | ||
| 1224 | (if outline-enwrap-isearch-mode | 1372 | (if (and outline-isearch-dynamic-expose |
| 1373 | (not (fboundp 'outline-real-isearch-abort))) | ||
| 1225 | (outline-enwrap-isearch)) | 1374 | (outline-enwrap-isearch)) |
| 1226 | 1375 | ||
| 1227 | (run-hooks 'outline-mode-hook) | 1376 | (run-hooks 'outline-mode-hook) |
| @@ -1259,6 +1408,9 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1259 | outline-mode | 1408 | outline-mode |
| 1260 | ) ; let* | 1409 | ) ; let* |
| 1261 | ) ; defun | 1410 | ) ; defun |
| 1411 | ;;;_ > outline-minor-mode | ||
| 1412 | ;;; XXX released verion doesn't do this? | ||
| 1413 | (defalias 'outline-minor-mode 'outline-mode) | ||
| 1262 | 1414 | ||
| 1263 | ;;;_ #3 Internal Position State-Tracking - "outline-recent-*" funcs | 1415 | ;;;_ #3 Internal Position State-Tracking - "outline-recent-*" funcs |
| 1264 | ;;; All the basic outline functions that directly do string matches to | 1416 | ;;; All the basic outline functions that directly do string matches to |
| @@ -1285,8 +1437,8 @@ OPEN: A topic that is not closed, though its offspring or body may be." | |||
| 1285 | "Register outline-prefix state data - BEGINNING and END of prefix. | 1437 | "Register outline-prefix state data - BEGINNING and END of prefix. |
| 1286 | 1438 | ||
| 1287 | For reference by `outline-recent' funcs. Returns BEGINNING." | 1439 | For reference by `outline-recent' funcs. Returns BEGINNING." |
| 1288 | (` (setq outline-recent-prefix-end (, end) | 1440 | `(setq outline-recent-prefix-end ,end |
| 1289 | outline-recent-prefix-beginning (, beg)))) | 1441 | outline-recent-prefix-beginning ,beg)) |
| 1290 | ;;;_ > outline-recent-depth () | 1442 | ;;;_ > outline-recent-depth () |
| 1291 | (defmacro outline-recent-depth () | 1443 | (defmacro outline-recent-depth () |
| 1292 | "Return depth of last heading encountered by an outline maneuvering function. | 1444 | "Return depth of last heading encountered by an outline maneuvering function. |
| @@ -1333,6 +1485,8 @@ Actually, returns prefix beginning point." | |||
| 1333 | (beginning-of-line) | 1485 | (beginning-of-line) |
| 1334 | (and (looking-at outline-regexp) | 1486 | (and (looking-at outline-regexp) |
| 1335 | (outline-prefix-data (match-beginning 0) (match-end 0))))) | 1487 | (outline-prefix-data (match-beginning 0) (match-end 0))))) |
| 1488 | ;;;_ > outline-on-heading-p () | ||
| 1489 | (defalias 'outline-on-heading-p 'outline-on-current-heading-p) | ||
| 1336 | ;;;_ > outline-e-o-prefix-p () | 1490 | ;;;_ > outline-e-o-prefix-p () |
| 1337 | (defun outline-e-o-prefix-p () | 1491 | (defun outline-e-o-prefix-p () |
| 1338 | "True if point is located where current topic prefix ends, heading begins." | 1492 | "True if point is located where current topic prefix ends, heading begins." |
| @@ -1352,16 +1506,16 @@ Actually, returns prefix beginning point." | |||
| 1352 | '(not (outline-hidden-p))) | 1506 | '(not (outline-hidden-p))) |
| 1353 | ;;;_ : Location attributes | 1507 | ;;;_ : Location attributes |
| 1354 | ;;;_ > outline-depth () | 1508 | ;;;_ > outline-depth () |
| 1355 | (defmacro outline-depth () | 1509 | (defsubst outline-depth () |
| 1356 | "Like outline-current-depth, but respects hidden as well as visible topics." | 1510 | "Like outline-current-depth, but respects hidden as well as visible topics." |
| 1357 | '(save-excursion | 1511 | (save-excursion |
| 1358 | (if (outline-goto-prefix) | 1512 | (if (outline-goto-prefix) |
| 1359 | (outline-recent-depth) | 1513 | (outline-recent-depth) |
| 1360 | (progn | 1514 | (progn |
| 1361 | ;; Oops, no prefix, zero prefix data: | 1515 | ;; Oops, no prefix, zero prefix data: |
| 1362 | (outline-prefix-data (point)(point)) | 1516 | (outline-prefix-data (point)(point)) |
| 1363 | ;; ... and return 0: | 1517 | ;; ... and return 0: |
| 1364 | 0)))) | 1518 | 0)))) |
| 1365 | ;;;_ > outline-current-depth () | 1519 | ;;;_ > outline-current-depth () |
| 1366 | (defmacro outline-current-depth () | 1520 | (defmacro outline-current-depth () |
| 1367 | "Return nesting depth of visible topic most immediately containing point." | 1521 | "Return nesting depth of visible topic most immediately containing point." |
| @@ -1393,7 +1547,7 @@ Actually, returns prefix beginning point." | |||
| 1393 | (buffer-substring (- outline-recent-prefix-end 1) | 1547 | (buffer-substring (- outline-recent-prefix-end 1) |
| 1394 | outline-recent-prefix-end)) | 1548 | outline-recent-prefix-end)) |
| 1395 | ;; Quick and dirty provision, ostensibly for missing bullet: | 1549 | ;; Quick and dirty provision, ostensibly for missing bullet: |
| 1396 | (args-out-of-range nil)) | 1550 | ('args-out-of-range nil)) |
| 1397 | ) | 1551 | ) |
| 1398 | ;;;_ > outline-get-prefix-bullet (prefix) | 1552 | ;;;_ > outline-get-prefix-bullet (prefix) |
| 1399 | (defun outline-get-prefix-bullet (prefix) | 1553 | (defun outline-get-prefix-bullet (prefix) |
| @@ -1402,23 +1556,55 @@ Actually, returns prefix beginning point." | |||
| 1402 | ;; oughtn't be called then, so forget about it... | 1556 | ;; oughtn't be called then, so forget about it... |
| 1403 | (if (string-match outline-regexp prefix) | 1557 | (if (string-match outline-regexp prefix) |
| 1404 | (substring prefix (1- (match-end 0)) (match-end 0)))) | 1558 | (substring prefix (1- (match-end 0)) (match-end 0)))) |
| 1559 | ;;;_ > outline-sibling-index (&optional depth) | ||
| 1560 | (defun outline-sibling-index (&optional depth) | ||
| 1561 | "Item number of this prospective topic among its siblings. | ||
| 1562 | |||
| 1563 | If optional arg depth is greater than current depth, then we're | ||
| 1564 | opening a new level, and return 0. | ||
| 1565 | |||
| 1566 | If less than this depth, ascend to that depth and count..." | ||
| 1567 | |||
| 1568 | (save-excursion | ||
| 1569 | (cond ((and depth (<= depth 0) 0)) | ||
| 1570 | ((or (not depth) (= depth (outline-depth))) | ||
| 1571 | (let ((index 1)) | ||
| 1572 | (while (outline-previous-sibling (outline-recent-depth) nil) | ||
| 1573 | (setq index (1+ index))) | ||
| 1574 | index)) | ||
| 1575 | ((< depth (outline-recent-depth)) | ||
| 1576 | (outline-ascend-to-depth depth) | ||
| 1577 | (outline-sibling-index)) | ||
| 1578 | (0)))) | ||
| 1579 | ;;;_ > outline-topic-flat-index () | ||
| 1580 | (defun outline-topic-flat-index () | ||
| 1581 | "Return a list indicating point's numeric section.subsect.subsubsect... | ||
| 1582 | Outermost is first." | ||
| 1583 | (let* ((depth (outline-depth)) | ||
| 1584 | (next-index (outline-sibling-index depth)) | ||
| 1585 | (rev-sibls nil)) | ||
| 1586 | (while (> next-index 0) | ||
| 1587 | (setq rev-sibls (cons next-index rev-sibls)) | ||
| 1588 | (setq depth (1- depth)) | ||
| 1589 | (setq next-index (outline-sibling-index depth))) | ||
| 1590 | rev-sibls) | ||
| 1591 | ) | ||
| 1405 | 1592 | ||
| 1406 | ;;;_ - Navigation macros | 1593 | ;;;_ - Navigation macros |
| 1407 | ;;;_ > outline-next-heading () | 1594 | ;;;_ > outline-next-heading () |
| 1408 | (defmacro outline-next-heading () | 1595 | (defsubst outline-next-heading () |
| 1409 | "Move to the heading for the topic \(possibly invisible) before this one. | 1596 | "Move to the heading for the topic \(possibly invisible) before this one. |
| 1410 | 1597 | ||
| 1411 | Returns the location of the heading, or nil if none found." | 1598 | Returns the location of the heading, or nil if none found." |
| 1412 | 1599 | ||
| 1413 | '(if (and (bobp) (not (eobp))) | 1600 | (if (and (bobp) (not (eobp))) |
| 1414 | (forward-char 1)) | 1601 | (forward-char 1)) |
| 1415 | 1602 | ||
| 1416 | '(if (re-search-forward outline-line-boundary-regexp nil 0) | 1603 | (if (re-search-forward outline-line-boundary-regexp nil 0) |
| 1417 | (progn ; Got valid location state - set vars: | 1604 | (outline-prefix-data ; Got valid location state - set vars: |
| 1418 | (outline-prefix-data | 1605 | (goto-char (or (match-beginning 2) |
| 1419 | (goto-char (or (match-beginning 2) | 1606 | outline-recent-prefix-beginning)) |
| 1420 | outline-recent-prefix-beginning)) | 1607 | (or (match-end 2) outline-recent-prefix-end)))) |
| 1421 | (or (match-end 2) outline-recent-prefix-end))))) | ||
| 1422 | ;;;_ : outline-this-or-next-heading | 1608 | ;;;_ : outline-this-or-next-heading |
| 1423 | (defun outline-this-or-next-heading () | 1609 | (defun outline-this-or-next-heading () |
| 1424 | "Position cursor on current or next heading." | 1610 | "Position cursor on current or next heading." |
| @@ -1451,15 +1637,15 @@ Return the location of the beginning of the heading, or nil if not found." | |||
| 1451 | ;;; Use of charts enables efficient navigation of subtrees, by | 1637 | ;;; Use of charts enables efficient navigation of subtrees, by |
| 1452 | ;;; requiring only a single regexp-search based traversal, to scope | 1638 | ;;; requiring only a single regexp-search based traversal, to scope |
| 1453 | ;;; out the subtopic locations. The chart then serves as the basis | 1639 | ;;; out the subtopic locations. The chart then serves as the basis |
| 1454 | ;;; for whatever assessment or adjustment of the subtree that is | 1640 | ;;; for assessment or adjustment of the subtree, without redundant |
| 1455 | ;;; required, without requiring redundant topic-traversal procedures. | 1641 | ;;; traversal of the structure. |
| 1456 | 1642 | ||
| 1457 | ;;;_ > outline-chart-subtree (&optional levels orig-depth prev-depth) | 1643 | ;;;_ > outline-chart-subtree (&optional levels orig-depth prev-depth) |
| 1458 | (defun outline-chart-subtree (&optional levels orig-depth prev-depth) | 1644 | (defun outline-chart-subtree (&optional levels orig-depth prev-depth) |
| 1459 | "Produce a location \"chart\" of subtopics of the containing topic. | 1645 | "Produce a location \"chart\" of subtopics of the containing topic. |
| 1460 | 1646 | ||
| 1461 | Optional argument LEVELS specifies the depth \(relative to start | 1647 | Optional argument LEVELS specifies the depth \(relative to start |
| 1462 | depth\) for the chart. Subsequent optional args are not for public | 1648 | depth) for the chart. Subsequent optional args are not for public |
| 1463 | use. | 1649 | use. |
| 1464 | 1650 | ||
| 1465 | Charts are used to capture outline structure, so that outline-altering | 1651 | Charts are used to capture outline structure, so that outline-altering |
| @@ -1490,8 +1676,10 @@ starting point, and PREV-DEPTH is depth of prior topic." | |||
| 1490 | ;; Loop over the current levels' siblings. Besides being more | 1676 | ;; Loop over the current levels' siblings. Besides being more |
| 1491 | ;; efficient than tail-recursing over a level, it avoids exceeding | 1677 | ;; efficient than tail-recursing over a level, it avoids exceeding |
| 1492 | ;; the typically quite constrained emacs max-lisp-eval-depth. | 1678 | ;; the typically quite constrained emacs max-lisp-eval-depth. |
| 1679 | ;; | ||
| 1493 | ;; Probably would speed things up to implement loop-based stack | 1680 | ;; Probably would speed things up to implement loop-based stack |
| 1494 | ;; operation rather than recursing for lower levels. Bah. | 1681 | ;; operation rather than recursing for lower levels. Bah. |
| 1682 | |||
| 1495 | (while (and (not (eobp)) | 1683 | (while (and (not (eobp)) |
| 1496 | ; Still within original topic? | 1684 | ; Still within original topic? |
| 1497 | (< orig-depth (setq curr-depth (outline-recent-depth))) | 1685 | (< orig-depth (setq curr-depth (outline-recent-depth))) |
| @@ -1529,11 +1717,11 @@ starting point, and PREV-DEPTH is depth of prior topic." | |||
| 1529 | ; the original level. Position | 1717 | ; the original level. Position |
| 1530 | ; to the end of it: | 1718 | ; to the end of it: |
| 1531 | (progn (and (not (eobp)) (forward-char -1)) | 1719 | (progn (and (not (eobp)) (forward-char -1)) |
| 1532 | (and (memq (preceding-char) '(?\n ?\^M)) | 1720 | (and (memq (preceding-char) '(?\n ?\r)) |
| 1533 | (memq (aref (buffer-substring (max 1 (- (point) 3)) | 1721 | (memq (aref (buffer-substring (max 1 (- (point) 3)) |
| 1534 | (point)) | 1722 | (point)) |
| 1535 | 1) | 1723 | 1) |
| 1536 | '(?\n ?\^M)) | 1724 | '(?\n ?\r)) |
| 1537 | (forward-char -1)) | 1725 | (forward-char -1)) |
| 1538 | (setq outline-recent-end-of-subtree (point)))) | 1726 | (setq outline-recent-end-of-subtree (point)))) |
| 1539 | 1727 | ||
| @@ -1577,7 +1765,7 @@ start point." | |||
| 1577 | result)) | 1765 | result)) |
| 1578 | ;;;_ X outline-chart-spec (chart spec &optional exposing) | 1766 | ;;;_ X outline-chart-spec (chart spec &optional exposing) |
| 1579 | (defun outline-chart-spec (chart spec &optional exposing) | 1767 | (defun outline-chart-spec (chart spec &optional exposing) |
| 1580 | "Not yet \(if ever\) implemented. | 1768 | "Not yet \(if ever) implemented. |
| 1581 | 1769 | ||
| 1582 | Produce exposure directives given topic/subtree CHART and an exposure SPEC. | 1770 | Produce exposure directives given topic/subtree CHART and an exposure SPEC. |
| 1583 | 1771 | ||
| @@ -1610,9 +1798,9 @@ exposed reside. | |||
| 1610 | ;;;_ - Within Topic | 1798 | ;;;_ - Within Topic |
| 1611 | ;;;_ > outline-goto-prefix () | 1799 | ;;;_ > outline-goto-prefix () |
| 1612 | (defun outline-goto-prefix () | 1800 | (defun outline-goto-prefix () |
| 1613 | "Put point at beginning of outline prefix for immediately containing topic. | 1801 | "Put point at beginning of immediately containing outline topic. |
| 1614 | 1802 | ||
| 1615 | Goes to first subsequent topic if none immediately containing. | 1803 | Goes to most immediate subsequent topic if none immediately containing. |
| 1616 | 1804 | ||
| 1617 | Not sensitive to topic visibility. | 1805 | Not sensitive to topic visibility. |
| 1618 | 1806 | ||
| @@ -1629,8 +1817,7 @@ Returns a the point at the beginning of the prefix, or nil if none." | |||
| 1629 | (if (bobp) | 1817 | (if (bobp) |
| 1630 | (cond ((looking-at outline-regexp) | 1818 | (cond ((looking-at outline-regexp) |
| 1631 | (outline-prefix-data (match-beginning 0)(match-end 0))) | 1819 | (outline-prefix-data (match-beginning 0)(match-end 0))) |
| 1632 | ((outline-next-heading) | 1820 | ((outline-next-heading)) |
| 1633 | (outline-prefix-data (match-beginning 0)(match-end 0))) | ||
| 1634 | (done)) | 1821 | (done)) |
| 1635 | done))) | 1822 | done))) |
| 1636 | ;;;_ > outline-end-of-prefix () | 1823 | ;;;_ > outline-end-of-prefix () |
| @@ -1648,7 +1835,7 @@ otherwise skip white space between bullet and ensuing text." | |||
| 1648 | t | 1835 | t |
| 1649 | (while (looking-at "[0-9]") (forward-char 1)) | 1836 | (while (looking-at "[0-9]") (forward-char 1)) |
| 1650 | (if (and (not (eolp)) (looking-at "\\s-")) (forward-char 1))) | 1837 | (if (and (not (eolp)) (looking-at "\\s-")) (forward-char 1))) |
| 1651 | (set-match-data match-data)) | 1838 | (store-match-data match-data)) |
| 1652 | ;; Reestablish where we are: | 1839 | ;; Reestablish where we are: |
| 1653 | (outline-current-depth))) | 1840 | (outline-current-depth))) |
| 1654 | ;;;_ > outline-current-bullet-pos () | 1841 | ;;;_ > outline-current-bullet-pos () |
| @@ -1669,6 +1856,8 @@ otherwise skip white space between bullet and ensuing text." | |||
| 1669 | 'move) | 1856 | 'move) |
| 1670 | (outline-prefix-data (match-beginning 1)(match-end 1)))) | 1857 | (outline-prefix-data (match-beginning 1)(match-end 1)))) |
| 1671 | (if (interactive-p) (outline-end-of-prefix)))) | 1858 | (if (interactive-p) (outline-end-of-prefix)))) |
| 1859 | ;;;_ > outline-back-to-heading () | ||
| 1860 | (defalias 'outline-back-to-heading 'outline-back-to-current-heading) | ||
| 1672 | ;;;_ > outline-pre-next-preface () | 1861 | ;;;_ > outline-pre-next-preface () |
| 1673 | (defun outline-pre-next-preface () | 1862 | (defun outline-pre-next-preface () |
| 1674 | "Skip forward to just before the next heading line. | 1863 | "Skip forward to just before the next heading line. |
| @@ -1689,9 +1878,9 @@ Returns that character position." | |||
| 1689 | (> (outline-recent-depth) level)) | 1878 | (> (outline-recent-depth) level)) |
| 1690 | (outline-next-heading)) | 1879 | (outline-next-heading)) |
| 1691 | (and (not (eobp)) (forward-char -1)) | 1880 | (and (not (eobp)) (forward-char -1)) |
| 1692 | (and (memq (preceding-char) '(?\n ?\^M)) | 1881 | (and (memq (preceding-char) '(?\n ?\r)) |
| 1693 | (memq (aref (buffer-substring (max 1 (- (point) 3)) (point)) 1) | 1882 | (memq (aref (buffer-substring (max 1 (- (point) 3)) (point)) 1) |
| 1694 | '(?\n ?\^M)) | 1883 | '(?\n ?\r)) |
| 1695 | (forward-char -1)) | 1884 | (forward-char -1)) |
| 1696 | (setq outline-recent-end-of-subtree (point)))) | 1885 | (setq outline-recent-end-of-subtree (point)))) |
| 1697 | ;;;_ > outline-beginning-of-current-entry () | 1886 | ;;;_ > outline-beginning-of-current-entry () |
| @@ -1714,6 +1903,13 @@ If already there, move cursor to bullet for hot-spot operation. | |||
| 1714 | (prog1 (outline-pre-next-preface) | 1903 | (prog1 (outline-pre-next-preface) |
| 1715 | (if (and (not (bobp))(looking-at "^$")) | 1904 | (if (and (not (bobp))(looking-at "^$")) |
| 1716 | (forward-char -1)))) | 1905 | (forward-char -1)))) |
| 1906 | ;;;_ > outline-end-of-current-heading () | ||
| 1907 | (defun outline-end-of-current-heading () | ||
| 1908 | (interactive) | ||
| 1909 | (outline-beginning-of-current-entry) | ||
| 1910 | (forward-line -1) | ||
| 1911 | (end-of-line)) | ||
| 1912 | (defalias 'outline-end-of-heading 'outline-end-of-current-heading) | ||
| 1717 | 1913 | ||
| 1718 | ;;;_ - Depth-wise | 1914 | ;;;_ - Depth-wise |
| 1719 | ;;;_ > outline-ascend-to-depth (depth) | 1915 | ;;;_ > outline-ascend-to-depth (depth) |
| @@ -1731,6 +1927,13 @@ If already there, move cursor to bullet for hot-spot operation. | |||
| 1731 | (goto-char last-good) | 1927 | (goto-char last-good) |
| 1732 | nil)) | 1928 | nil)) |
| 1733 | (if (interactive-p) (outline-end-of-prefix)))) | 1929 | (if (interactive-p) (outline-end-of-prefix)))) |
| 1930 | ;;;_ > outline-ascend () | ||
| 1931 | (defun outline-ascend () | ||
| 1932 | "Ascend one level, returning t if successful, nil if not." | ||
| 1933 | (prog1 | ||
| 1934 | (if (outline-beginning-of-level) | ||
| 1935 | (outline-previous-heading)) | ||
| 1936 | (if (interactive-p) (outline-end-of-prefix)))) | ||
| 1734 | ;;;_ > outline-descend-to-depth (depth) | 1937 | ;;;_ > outline-descend-to-depth (depth) |
| 1735 | (defun outline-descend-to-depth (depth) | 1938 | (defun outline-descend-to-depth (depth) |
| 1736 | "Descend to depth DEPTH within current topic. | 1939 | "Descend to depth DEPTH within current topic. |
| @@ -1831,10 +2034,10 @@ Presumes point is at the start of a topic prefix." | |||
| 1831 | (if (or (bobp) (eobp)) | 2034 | (if (or (bobp) (eobp)) |
| 1832 | nil | 2035 | nil |
| 1833 | (forward-char -1)) | 2036 | (forward-char -1)) |
| 1834 | (if (or (bobp) (not (memq (preceding-char) '(?\n ?\^M)))) | 2037 | (if (or (bobp) (not (memq (preceding-char) '(?\n ?\r)))) |
| 1835 | nil | 2038 | nil |
| 1836 | (forward-char -1) | 2039 | (forward-char -1) |
| 1837 | (if (or (bobp) (not (memq (preceding-char) '(?\n ?\^M)))) | 2040 | (if (or (bobp) (not (memq (preceding-char) '(?\n ?\r)))) |
| 1838 | (forward-char -1))) | 2041 | (forward-char -1))) |
| 1839 | (point)) | 2042 | (point)) |
| 1840 | ;;;_ > outline-beginning-of-level () | 2043 | ;;;_ > outline-beginning-of-level () |
| @@ -1854,7 +2057,7 @@ Presumes point is at the start of a topic prefix." | |||
| 1854 | "Move to the next ARG'th visible heading line, backward if arg is negative. | 2057 | "Move to the next ARG'th visible heading line, backward if arg is negative. |
| 1855 | 2058 | ||
| 1856 | Move as far as possible in indicated direction \(beginning or end of | 2059 | Move as far as possible in indicated direction \(beginning or end of |
| 1857 | buffer\) if headings are exhausted." | 2060 | buffer) if headings are exhausted." |
| 1858 | 2061 | ||
| 1859 | (interactive "p") | 2062 | (interactive "p") |
| 1860 | (let* ((backward (if (< arg 0) (setq arg (* -1 arg)))) | 2063 | (let* ((backward (if (< arg 0) (setq arg (* -1 arg)))) |
| @@ -1957,9 +2160,8 @@ Changes to concealed regions are ignored while file is being written. | |||
| 1957 | \(This is for the sake of functions that do change the file during | 2160 | \(This is for the sake of functions that do change the file during |
| 1958 | writes, like crypt and zip modes.) | 2161 | writes, like crypt and zip modes.) |
| 1959 | 2162 | ||
| 1960 | Locally bound in outline buffers to `before-change-function', which | 2163 | Locally bound in outline buffers to `before-change-functions', which |
| 1961 | in emacs 19 is run before any change to the buffer. (Has no effect | 2164 | in emacs 19 is run before any change to the buffer. |
| 1962 | in Emacs 18, which doesn't support before-change-function.) | ||
| 1963 | 2165 | ||
| 1964 | Any functions which set [`this-command' to `undo', or which set] | 2166 | Any functions which set [`this-command' to `undo', or which set] |
| 1965 | `outline-override-protect' non-nil (as does, eg, outline-flag-chars) | 2167 | `outline-override-protect' non-nil (as does, eg, outline-flag-chars) |
| @@ -2036,7 +2238,7 @@ are exempt from this restriction." | |||
| 2036 | (sit-for 1) | 2238 | (sit-for 1) |
| 2037 | nil))))) | 2239 | nil))))) |
| 2038 | response) | 2240 | response) |
| 2039 | (quit nil)) | 2241 | ('quit nil)) |
| 2040 | ; Continue: | 2242 | ; Continue: |
| 2041 | (if (eq response 'reclose) | 2243 | (if (eq response 'reclose) |
| 2042 | (save-excursion | 2244 | (save-excursion |
| @@ -2078,12 +2280,14 @@ outline-mode-map.") | |||
| 2078 | 2280 | ||
| 2079 | - Massages buffer-undo-list so successive, standard character self-inserts are | 2281 | - Massages buffer-undo-list so successive, standard character self-inserts are |
| 2080 | aggregated. This kludge compensates for lack of undo bunching when | 2282 | aggregated. This kludge compensates for lack of undo bunching when |
| 2081 | before-change-function is used." | 2283 | before-change-functions is used." |
| 2082 | 2284 | ||
| 2083 | ; Apply any external change func: | 2285 | ; Apply any external change func: |
| 2084 | (if (not (outline-mode-p)) ; In outline-mode. | 2286 | (if (not (outline-mode-p)) ; In outline-mode. |
| 2085 | nil | 2287 | nil |
| 2086 | (setq outline-override-protect nil) | 2288 | (setq outline-override-protect nil) |
| 2289 | (if outline-isearch-dynamic-expose | ||
| 2290 | (outline-isearch-rectification)) | ||
| 2087 | (if outline-during-write-cue | 2291 | (if outline-during-write-cue |
| 2088 | ;; Was used by outline-before-change-protect, done with it now: | 2292 | ;; Was used by outline-before-change-protect, done with it now: |
| 2089 | (setq outline-during-write-cue nil)) | 2293 | (setq outline-during-write-cue nil)) |
| @@ -2124,7 +2328,6 @@ outline-mode-map.") | |||
| 2124 | ;;;_ > outline-pre-command-business () | 2328 | ;;;_ > outline-pre-command-business () |
| 2125 | (defun outline-pre-command-business () | 2329 | (defun outline-pre-command-business () |
| 2126 | "Outline pre-command-hook function for outline buffers. | 2330 | "Outline pre-command-hook function for outline buffers. |
| 2127 | |||
| 2128 | Implements special behavior when cursor is on bullet char. | 2331 | Implements special behavior when cursor is on bullet char. |
| 2129 | 2332 | ||
| 2130 | Self-insert characters are reinterpreted control-character references | 2333 | Self-insert characters are reinterpreted control-character references |
| @@ -2132,34 +2335,48 @@ into the outline-mode-map. The outline-mode post-command hook will | |||
| 2132 | position a cursor that has moved as a result of such reinterpretation, | 2335 | position a cursor that has moved as a result of such reinterpretation, |
| 2133 | on the destination topic's bullet, when the cursor wound up in the | 2336 | on the destination topic's bullet, when the cursor wound up in the |
| 2134 | 2337 | ||
| 2135 | The upshot is that you can get easy, single (unmodified) key outline | 2338 | The upshot is that you can get easy, single (ie, unmodified) key |
| 2136 | maneuvering and general operations by positioning the cursor on the | 2339 | outline maneuvering operations by positioning the cursor on the bullet |
| 2137 | bullet char, and it continues until you deliberately some non-outline | 2340 | char. You stay in this mode until you use some regular |
| 2138 | motion command to relocate the cursor off of a bullet char." | 2341 | cursor-positioning command to relocate the cursor off of a bullet |
| 2139 | 2342 | char." | |
| 2140 | (if (and (boundp 'outline-mode) | ||
| 2141 | outline-mode | ||
| 2142 | (eq this-command 'self-insert-command) | ||
| 2143 | (eq (point)(outline-current-bullet-pos))) | ||
| 2144 | |||
| 2145 | (let* ((this-key-num (if (numberp last-command-event) | ||
| 2146 | last-command-event)) | ||
| 2147 | mapped-binding) | ||
| 2148 | 2343 | ||
| 2344 | (if (not (outline-mode-p)) | ||
| 2345 | ;; Shouldn't be invoked if not in allout outline-mode, but just in case: | ||
| 2346 | nil | ||
| 2347 | ;; Register isearch status: | ||
| 2348 | (if (and (boundp 'isearch-mode) isearch-mode) | ||
| 2349 | (setq outline-pre-was-isearching t) | ||
| 2350 | (setq outline-pre-was-isearching nil)) | ||
| 2351 | ;; Hot-spot navigation provisions: | ||
| 2352 | (if (and (eq this-command 'self-insert-command) | ||
| 2353 | (eq (point)(outline-current-bullet-pos))) | ||
| 2354 | (let* ((this-key-num (cond | ||
| 2355 | ((numberp last-command-char) | ||
| 2356 | last-command-char) | ||
| 2357 | ;; XXX Only xemacs has characterp. | ||
| 2358 | ((and (fboundp 'characterp) | ||
| 2359 | (characterp last-command-char)) | ||
| 2360 | (char-to-int last-command-char)) | ||
| 2361 | (t 0))) | ||
| 2362 | mapped-binding) | ||
| 2363 | (if (zerop this-key-num) | ||
| 2364 | nil | ||
| 2149 | ; Map upper-register literals | 2365 | ; Map upper-register literals |
| 2150 | ; to lower register: | 2366 | ; to lower register: |
| 2151 | (if (<= 96 this-key-num) | 2367 | (if (<= 96 this-key-num) |
| 2152 | (setq this-key-num (- this-key-num 32))) | 2368 | (setq this-key-num (- this-key-num 32))) |
| 2153 | ; Check if we have a literal: | 2369 | ; Check if we have a literal: |
| 2154 | (if (and (<= 64 this-key-num) | 2370 | (if (and (<= 64 this-key-num) |
| 2155 | (>= 96 this-key-num)) | 2371 | (>= 96 this-key-num)) |
| 2156 | (setq mapped-binding | 2372 | (setq mapped-binding |
| 2157 | (lookup-key 'outline-mode-map | 2373 | (lookup-key 'outline-mode-map |
| 2158 | (concat outline-command-prefix | 2374 | (concat outline-command-prefix |
| 2159 | (char-to-string (- this-key-num 64)))))) | 2375 | (char-to-string (- this-key-num |
| 2160 | (if mapped-binding | 2376 | 64)))))) |
| 2161 | (setq outline-post-goto-bullet t | 2377 | (if mapped-binding |
| 2162 | this-command mapped-binding))))) | 2378 | (setq outline-post-goto-bullet t |
| 2379 | this-command mapped-binding))))))) | ||
| 2163 | ;;;_ > outline-find-file-hook () | 2380 | ;;;_ > outline-find-file-hook () |
| 2164 | (defun outline-find-file-hook () | 2381 | (defun outline-find-file-hook () |
| 2165 | "Activate outline-mode when `outline-auto-activation' & `outline-layout' are non-nil. | 2382 | "Activate outline-mode when `outline-auto-activation' & `outline-layout' are non-nil. |
| @@ -2169,9 +2386,110 @@ See `outline-init' for setup instructions." | |||
| 2169 | (not (outline-mode-p)) | 2386 | (not (outline-mode-p)) |
| 2170 | outline-layout) | 2387 | outline-layout) |
| 2171 | (outline-mode t))) | 2388 | (outline-mode t))) |
| 2172 | ;;;_ : Establish the hooks | 2389 | ;;;_ > outline-isearch-rectification |
| 2173 | (add-hook 'post-command-hook 'outline-post-command-business) | 2390 | (defun outline-isearch-rectification () |
| 2174 | (add-hook 'pre-command-hook 'outline-pre-command-business) | 2391 | "Rectify outline exposure before, during, or after isearch. |
| 2392 | |||
| 2393 | Called as part of outline-post-command-business." | ||
| 2394 | |||
| 2395 | (let ((isearching (and (boundp 'isearch-mode) isearch-mode))) | ||
| 2396 | (cond ((and isearching (not outline-pre-was-isearching)) | ||
| 2397 | (outline-isearch-expose 'start)) | ||
| 2398 | ((and isearching outline-pre-was-isearching) | ||
| 2399 | (outline-isearch-expose 'continue)) | ||
| 2400 | ((and (not isearching) outline-pre-was-isearching) | ||
| 2401 | (outline-isearch-expose 'final)) | ||
| 2402 | ;; Not and wasn't isearching: | ||
| 2403 | (t (setq outline-isearch-prior-pos nil) | ||
| 2404 | (setq outline-isearch-did-quit nil))))) | ||
| 2405 | ;;;_ = outline-isearch-was-font-lock | ||
| 2406 | (defvar outline-isearch-was-font-lock | ||
| 2407 | (and (boundp 'font-lock-mode) font-lock-mode)) | ||
| 2408 | ;;;_ > outline-isearch-expose (mode) | ||
| 2409 | (defun outline-isearch-expose (mode) | ||
| 2410 | "Mode is either 'clear, 'start, 'continue, or 'final." | ||
| 2411 | ;; outline-isearch-prior-pos encodes exposure status of prior pos: | ||
| 2412 | ;; (pos was-vis header-pos end-pos) | ||
| 2413 | ;; pos - point of concern | ||
| 2414 | ;; was-vis - t, else 'topic if entire topic was exposed, 'entry otherwise | ||
| 2415 | ;; Do reclosure or prior pos, as necessary: | ||
| 2416 | (if (eq mode 'start) | ||
| 2417 | (setq outline-isearch-was-font-lock (and (boundp 'font-lock-mode) | ||
| 2418 | font-lock-mode) | ||
| 2419 | font-lock-mode nil) | ||
| 2420 | (if (eq mode 'final) | ||
| 2421 | (setq font-lock-mode outline-isearch-was-font-lock)) | ||
| 2422 | (if (and outline-isearch-prior-pos | ||
| 2423 | (listp outline-isearch-prior-pos)) | ||
| 2424 | ;; Conceal prior peek: | ||
| 2425 | (outline-flag-region (car (cdr outline-isearch-prior-pos)) | ||
| 2426 | (car (cdr (cdr outline-isearch-prior-pos))) | ||
| 2427 | ?\r))) | ||
| 2428 | (if (outline-visible-p) | ||
| 2429 | (setq outline-isearch-prior-pos nil) | ||
| 2430 | (if (not (eq mode 'final)) | ||
| 2431 | (setq outline-isearch-prior-pos (cons (point) (outline-show-entry))) | ||
| 2432 | (if outline-isearch-did-quit | ||
| 2433 | nil | ||
| 2434 | (setq outline-isearch-prior-pos nil) | ||
| 2435 | (outline-show-children)))) | ||
| 2436 | (setq outline-isearch-did-quit nil)) | ||
| 2437 | ;;;_ > outline-enwrap-isearch () | ||
| 2438 | (defun outline-enwrap-isearch () | ||
| 2439 | "Impose outline-mode isearch-abort wrapper for dynamic exposure in isearch. | ||
| 2440 | |||
| 2441 | The function checks to ensure that the rebinding is done only once." | ||
| 2442 | |||
| 2443 | (add-hook 'isearch-mode-end-hook 'outline-isearch-rectification) | ||
| 2444 | (if (fboundp 'outline-real-isearch-abort) | ||
| 2445 | ;; | ||
| 2446 | nil | ||
| 2447 | ; Ensure load of isearch-mode: | ||
| 2448 | (if (or (and (fboundp 'isearch-mode) | ||
| 2449 | (fboundp 'isearch-abort)) | ||
| 2450 | (condition-case error | ||
| 2451 | (load-library "isearch-mode") | ||
| 2452 | ('file-error (message | ||
| 2453 | "Skipping isearch-mode provisions - %s '%s'" | ||
| 2454 | (car (cdr error)) | ||
| 2455 | (car (cdr (cdr error)))) | ||
| 2456 | (sit-for 1) | ||
| 2457 | ;; Inhibit subsequent tries and return nil: | ||
| 2458 | (setq outline-isearch-dynamic-expose nil)))) | ||
| 2459 | ;; Isearch-mode loaded, encapsulate specific entry points for | ||
| 2460 | ;; outline dynamic-exposure business: | ||
| 2461 | (progn | ||
| 2462 | ;; stash crucial isearch-mode funcs under known, private | ||
| 2463 | ;; names, then register wrapper functions under the old | ||
| 2464 | ;; names, in their stead: | ||
| 2465 | (fset 'outline-real-isearch-abort (symbol-function 'isearch-abort)) | ||
| 2466 | (fset 'isearch-abort 'outline-isearch-abort))))) | ||
| 2467 | ;;;_ > outline-isearch-abort () | ||
| 2468 | (defun outline-isearch-abort () | ||
| 2469 | "Wrapper for outline-real-isearch-abort \(which see), to register | ||
| 2470 | actual quits." | ||
| 2471 | (interactive) | ||
| 2472 | (setq outline-isearch-did-quit nil) | ||
| 2473 | (condition-case what | ||
| 2474 | (outline-real-isearch-abort) | ||
| 2475 | ('quit (setq outline-isearch-did-quit t) | ||
| 2476 | (signal 'quit nil)))) | ||
| 2477 | |||
| 2478 | ;;; Prevent unnecessary font-lock while isearching! | ||
| 2479 | (defvar isearch-was-font-locking nil) | ||
| 2480 | (defun isearch-inhibit-font-lock () | ||
| 2481 | "Inhibit font-lock while isearching - for use on isearch-mode-hook." | ||
| 2482 | (if (and (outline-mode-p) (boundp 'font-lock-mode) font-lock-mode) | ||
| 2483 | (setq isearch-was-font-locking t | ||
| 2484 | font-lock-mode nil))) | ||
| 2485 | (add-hook 'isearch-mode-hook 'isearch-inhibit-font-lock) | ||
| 2486 | (defun isearch-reenable-font-lock () | ||
| 2487 | "Reenable font-lock after isearching - for use on isearch-mode-end-hook." | ||
| 2488 | (if (and (boundp 'font-lock-mode) font-lock-mode) | ||
| 2489 | (if (and (outline-mode-p) isearch-was-font-locking) | ||
| 2490 | (setq isearch-was-font-locking nil | ||
| 2491 | font-lock-mode t)))) | ||
| 2492 | (add-hook 'isearch-mode-end-hook 'isearch-reenable-font-lock) | ||
| 2175 | 2493 | ||
| 2176 | ;;;_ - Topic Format Assessment | 2494 | ;;;_ - Topic Format Assessment |
| 2177 | ;;;_ > outline-solicit-alternate-bullet (depth &optional current-bullet) | 2495 | ;;;_ > outline-solicit-alternate-bullet (depth &optional current-bullet) |
| @@ -2181,37 +2499,21 @@ See `outline-init' for setup instructions." | |||
| 2181 | 2499 | ||
| 2182 | Offer one suitable for current depth DEPTH as default." | 2500 | Offer one suitable for current depth DEPTH as default." |
| 2183 | 2501 | ||
| 2184 | (let* ((default-bullet (or current-bullet | 2502 | (let* ((default-bullet (or (and (stringp current-bullet) current-bullet) |
| 2185 | (outline-bullet-for-depth depth))) | 2503 | (outline-bullet-for-depth depth))) |
| 2186 | (sans-escapes (regexp-sans-escapes outline-bullets-string)) | 2504 | (sans-escapes (regexp-sans-escapes outline-bullets-string)) |
| 2187 | (choice (solicit-char-in-string | 2505 | choice) |
| 2188 | (format "Select bullet: %s ('%s' default): " | 2506 | (save-excursion |
| 2189 | sans-escapes | 2507 | (goto-char (outline-current-bullet-pos)) |
| 2190 | default-bullet) | 2508 | (setq choice (solicit-char-in-string |
| 2191 | sans-escapes | 2509 | (format "Select bullet: %s ('%s' default): " |
| 2192 | t))) | 2510 | sans-escapes |
| 2511 | default-bullet) | ||
| 2512 | sans-escapes | ||
| 2513 | t))) | ||
| 2514 | (message "") | ||
| 2193 | (if (string= choice "") default-bullet choice)) | 2515 | (if (string= choice "") default-bullet choice)) |
| 2194 | ) | 2516 | ) |
| 2195 | ;;;_ > outline-sibling-index (&optional depth) | ||
| 2196 | (defun outline-sibling-index (&optional depth) | ||
| 2197 | "Item number of this prospective topic among its siblings. | ||
| 2198 | |||
| 2199 | If optional arg depth is greater than current depth, then we're | ||
| 2200 | opening a new level, and return 0. | ||
| 2201 | |||
| 2202 | If less than this depth, ascend to that depth and count..." | ||
| 2203 | |||
| 2204 | (save-excursion | ||
| 2205 | (cond ((and depth (<= depth 0) 0)) | ||
| 2206 | ((or (not depth) (= depth (outline-depth))) | ||
| 2207 | (let ((index 1)) | ||
| 2208 | (while (outline-previous-sibling (outline-recent-depth) nil) | ||
| 2209 | (setq index (1+ index))) | ||
| 2210 | index)) | ||
| 2211 | ((< depth (outline-recent-depth)) | ||
| 2212 | (outline-ascend-to-depth depth) | ||
| 2213 | (outline-sibling-index)) | ||
| 2214 | (0)))) | ||
| 2215 | ;;;_ > outline-distinctive-bullet (bullet) | 2517 | ;;;_ > outline-distinctive-bullet (bullet) |
| 2216 | (defun outline-distinctive-bullet (bullet) | 2518 | (defun outline-distinctive-bullet (bullet) |
| 2217 | "True if bullet is one of those on outline-distinctive-bullets-string." | 2519 | "True if bullet is one of those on outline-distinctive-bullets-string." |
| @@ -2267,9 +2569,12 @@ bullet or previous sibling. | |||
| 2267 | Third arg DEPTH forces the topic prefix to that depth, regardless of | 2569 | Third arg DEPTH forces the topic prefix to that depth, regardless of |
| 2268 | the current topics' depth. | 2570 | the current topics' depth. |
| 2269 | 2571 | ||
| 2270 | Fourth arg SOLICIT non-nil provokes solicitation from the user of a | 2572 | If SOLICIT is non-nil, then the choice of bullet is solicited from |
| 2271 | choice among the valid bullets. (This overrides other all the | 2573 | user. If it's a character, then that character is offered as the |
| 2272 | options, including, eg, a distinctive PRIOR-BULLET.) | 2574 | default, otherwise the one suited to the context \(according to |
| 2575 | distinction or depth) is offered. \(This overrides other options, | ||
| 2576 | including, eg, a distinctive PRIOR-BULLET.) If non-nil, then the | ||
| 2577 | context-specific bullet is used. | ||
| 2273 | 2578 | ||
| 2274 | Fifth arg, NUMBER-CONTROL, matters only if `outline-numbered-bullet' | 2579 | Fifth arg, NUMBER-CONTROL, matters only if `outline-numbered-bullet' |
| 2275 | is non-nil *and* soliciting was not explicitly invoked. Then | 2580 | is non-nil *and* soliciting was not explicitly invoked. Then |
| @@ -2322,7 +2627,7 @@ index for each successive sibling)." | |||
| 2322 | ((progn (setq body (make-string (- depth 2) ?\ )) | 2627 | ((progn (setq body (make-string (- depth 2) ?\ )) |
| 2323 | ;; The actual condition: | 2628 | ;; The actual condition: |
| 2324 | solicit) | 2629 | solicit) |
| 2325 | (let* ((got (outline-solicit-alternate-bullet depth))) | 2630 | (let* ((got (outline-solicit-alternate-bullet depth solicit))) |
| 2326 | ;; Gotta check whether we're numbering and got a numbered bullet: | 2631 | ;; Gotta check whether we're numbering and got a numbered bullet: |
| 2327 | (setq numbering (and outline-numbered-bullet | 2632 | (setq numbering (and outline-numbered-bullet |
| 2328 | (not (and number-control (not index))) | 2633 | (not (and number-control (not index))) |
| @@ -2381,14 +2686,16 @@ index for each successive sibling)." | |||
| 2381 | ((outline-sibling-index)))))) | 2686 | ((outline-sibling-index)))))) |
| 2382 | ) | 2687 | ) |
| 2383 | ) | 2688 | ) |
| 2384 | ;;;_ > outline-open-topic (relative-depth &optional before) | 2689 | ;;;_ > outline-open-topic (relative-depth &optional before use_sib_bullet) |
| 2385 | (defun outline-open-topic (relative-depth &optional before) | 2690 | (defun outline-open-topic (relative-depth &optional before use_sib_bullet) |
| 2386 | "Open a new topic at depth DEPTH. | 2691 | "Open a new topic at depth DEPTH. |
| 2387 | 2692 | ||
| 2388 | New topic is situated after current one, unless optional flag BEFORE | 2693 | New topic is situated after current one, unless optional flag BEFORE |
| 2389 | is non-nil, or unless current line is complete empty (not even | 2694 | is non-nil, or unless current line is complete empty (not even |
| 2390 | whitespace), in which case open is done on current line. | 2695 | whitespace), in which case open is done on current line. |
| 2391 | 2696 | ||
| 2697 | If USE_SIB_BULLET is true, use the bullet of the prior sibling. | ||
| 2698 | |||
| 2392 | Nuances: | 2699 | Nuances: |
| 2393 | 2700 | ||
| 2394 | - Creation of new topics is with respect to the visible topic | 2701 | - Creation of new topics is with respect to the visible topic |
| @@ -2415,13 +2722,18 @@ Nuances: | |||
| 2415 | (opening-on-blank (if (looking-at "^\$") | 2722 | (opening-on-blank (if (looking-at "^\$") |
| 2416 | (not (setq before nil)))) | 2723 | (not (setq before nil)))) |
| 2417 | opening-numbered ; Will get while computing ref-topic, below | 2724 | opening-numbered ; Will get while computing ref-topic, below |
| 2418 | ref-depth ; Will get while computing ref-topic, next | 2725 | ref-depth ; Will get while computing ref-topic, below |
| 2726 | ref-bullet ; Will get while computing ref-topic, next | ||
| 2419 | (ref-topic (save-excursion | 2727 | (ref-topic (save-excursion |
| 2420 | (cond ((< relative-depth 0) | 2728 | (cond ((< relative-depth 0) |
| 2421 | (outline-ascend-to-depth depth)) | 2729 | (outline-ascend-to-depth depth)) |
| 2422 | ((>= relative-depth 1) nil) | 2730 | ((>= relative-depth 1) nil) |
| 2423 | (t (outline-back-to-current-heading))) | 2731 | (t (outline-back-to-current-heading))) |
| 2424 | (setq ref-depth (outline-recent-depth)) | 2732 | (setq ref-depth (outline-recent-depth)) |
| 2733 | (setq ref-bullet | ||
| 2734 | (if (> outline-recent-prefix-end 1) | ||
| 2735 | (outline-recent-bullet) | ||
| 2736 | "")) | ||
| 2425 | (setq opening-numbered | 2737 | (setq opening-numbered |
| 2426 | (save-excursion | 2738 | (save-excursion |
| 2427 | (and outline-numbered-bullet | 2739 | (and outline-numbered-bullet |
| @@ -2524,10 +2836,10 @@ Nuances: | |||
| 2524 | ;;(if doing-beginning (save-excursion (newline (if dbl-space 2 1)))) | 2836 | ;;(if doing-beginning (save-excursion (newline (if dbl-space 2 1)))) |
| 2525 | 2837 | ||
| 2526 | 2838 | ||
| 2527 | (outline-rebullet-heading nil ;;; solicit | 2839 | (outline-rebullet-heading (and use_sib_bullet ref-bullet);;; solicit |
| 2528 | depth ;;; depth | 2840 | depth ;;; depth |
| 2529 | nil ;;; number-control | 2841 | nil ;;; number-control |
| 2530 | nil ;;; index | 2842 | nil ;;; index |
| 2531 | t) (end-of-line) | 2843 | t) (end-of-line) |
| 2532 | ) | 2844 | ) |
| 2533 | ) | 2845 | ) |
| @@ -2544,7 +2856,6 @@ Nuances: | |||
| 2544 | ;;;_ ; buffer boundaries - special provisions for beginning and end ob | 2856 | ;;;_ ; buffer boundaries - special provisions for beginning and end ob |
| 2545 | ;;;_ ; level 1 topics have special provisions also - double space. | 2857 | ;;;_ ; level 1 topics have special provisions also - double space. |
| 2546 | ;;;_ ; location of new topic | 2858 | ;;;_ ; location of new topic |
| 2547 | ;;;_ . | ||
| 2548 | ;;;_ > outline-open-subtopic (arg) | 2859 | ;;;_ > outline-open-subtopic (arg) |
| 2549 | (defun outline-open-subtopic (arg) | 2860 | (defun outline-open-subtopic (arg) |
| 2550 | "Open new topic header at deeper level than the current one. | 2861 | "Open new topic header at deeper level than the current one. |
| @@ -2557,10 +2868,12 @@ prior to the current one." | |||
| 2557 | (defun outline-open-sibtopic (arg) | 2868 | (defun outline-open-sibtopic (arg) |
| 2558 | "Open new topic header at same level as the current one. | 2869 | "Open new topic header at same level as the current one. |
| 2559 | 2870 | ||
| 2871 | Positive universal arg means to use the bullet of the prior sibling. | ||
| 2872 | |||
| 2560 | Negative universal arg means to place the new topic prior to the current | 2873 | Negative universal arg means to place the new topic prior to the current |
| 2561 | one." | 2874 | one." |
| 2562 | (interactive "p") | 2875 | (interactive "p") |
| 2563 | (outline-open-topic 0 (> 0 arg))) | 2876 | (outline-open-topic 0 (> 0 arg) (< 1 arg))) |
| 2564 | ;;;_ > outline-open-supertopic (arg) | 2877 | ;;;_ > outline-open-supertopic (arg) |
| 2565 | (defun outline-open-supertopic (arg) | 2878 | (defun outline-open-supertopic (arg) |
| 2566 | "Open new topic header at shallower level than the current one. | 2879 | "Open new topic header at shallower level than the current one. |
| @@ -2636,21 +2949,31 @@ Note that refill of indented paragraphs is not done." | |||
| 2636 | (indent-to (+ new-margin excess))))))))) | 2949 | (indent-to (+ new-margin excess))))))))) |
| 2637 | ;;;_ > outline-rebullet-current-heading (arg) | 2950 | ;;;_ > outline-rebullet-current-heading (arg) |
| 2638 | (defun outline-rebullet-current-heading (arg) | 2951 | (defun outline-rebullet-current-heading (arg) |
| 2639 | "Like non-interactive version `outline-rebullet-heading'. | 2952 | "Solicit new bullet for current visible heading." |
| 2640 | 2953 | (interactive "p") | |
| 2641 | But \(only\) affects visible heading containing point. | 2954 | (let ((initial-col (current-column)) |
| 2642 | 2955 | (on-bullet (eq (point)(outline-current-bullet-pos))) | |
| 2643 | With repeat count, solicit for bullet." | 2956 | (backwards (if (< arg 0) |
| 2644 | (interactive "P") | 2957 | (setq arg (* arg -1))))) |
| 2645 | (save-excursion (outline-back-to-current-heading) | 2958 | (while (> arg 0) |
| 2646 | (outline-end-of-prefix) | 2959 | (save-excursion (outline-back-to-current-heading) |
| 2647 | (outline-rebullet-heading (not arg) ;;; solicit | 2960 | (outline-end-of-prefix) |
| 2648 | nil ;;; depth | 2961 | (outline-rebullet-heading t ;;; solicit |
| 2649 | nil ;;; number-control | 2962 | nil ;;; depth |
| 2650 | nil ;;; index | 2963 | nil ;;; number-control |
| 2651 | t) ;;; do-successors | 2964 | nil ;;; index |
| 2652 | ) | 2965 | t)) ;;; do-successors |
| 2653 | ) | 2966 | (setq arg (1- arg)) |
| 2967 | (if (<= arg 0) | ||
| 2968 | nil | ||
| 2969 | (setq initial-col nil) ; Override positioning back to init col | ||
| 2970 | (if (not backwards) | ||
| 2971 | (outline-next-visible-heading 1) | ||
| 2972 | (outline-goto-prefix) | ||
| 2973 | (outline-next-visible-heading -1)))) | ||
| 2974 | (message "Done.") | ||
| 2975 | (cond (on-bullet (goto-char (outline-current-bullet-pos))) | ||
| 2976 | (initial-col (move-to-column initial-col))))) | ||
| 2654 | ;;;_ > outline-rebullet-heading (&optional solicit ...) | 2977 | ;;;_ > outline-rebullet-heading (&optional solicit ...) |
| 2655 | (defun outline-rebullet-heading (&optional solicit | 2978 | (defun outline-rebullet-heading (&optional solicit |
| 2656 | new-depth | 2979 | new-depth |
| @@ -2662,12 +2985,14 @@ With repeat count, solicit for bullet." | |||
| 2662 | 2985 | ||
| 2663 | All args are optional. | 2986 | All args are optional. |
| 2664 | 2987 | ||
| 2665 | If SOLICIT is non-nil then the choice of bullet is solicited from | 2988 | If SOLICIT is non-nil, then the choice of bullet is solicited from |
| 2666 | user. Otherwise the distinctiveness of the bullet or the topic | 2989 | user. If it's a character, then that character is offered as the |
| 2667 | depth determines it. | 2990 | default, otherwise the one suited to the context \(according to |
| 2991 | distinction or depth) is offered. If non-nil, then the | ||
| 2992 | context-specific bullet is just used. | ||
| 2668 | 2993 | ||
| 2669 | Second arg DEPTH forces the topic prefix to that depth, regardless | 2994 | Second arg DEPTH forces the topic prefix to that depth, regardless |
| 2670 | of the topics current depth. | 2995 | of the topic's current depth. |
| 2671 | 2996 | ||
| 2672 | Third arg NUMBER-CONTROL can force the prefix to or away from | 2997 | Third arg NUMBER-CONTROL can force the prefix to or away from |
| 2673 | numbered form. It has effect only if `outline-numbered-bullet' is | 2998 | numbered form. It has effect only if `outline-numbered-bullet' is |
| @@ -2864,7 +3189,8 @@ Returns final depth." | |||
| 2864 | ;; Proceed by level, processing subsequent siblings on each, | 3189 | ;; Proceed by level, processing subsequent siblings on each, |
| 2865 | ;; ascending until we get shallower than the start depth: | 3190 | ;; ascending until we get shallower than the start depth: |
| 2866 | 3191 | ||
| 2867 | (let ((ascender (outline-depth))) | 3192 | (let ((ascender (outline-depth)) |
| 3193 | was-eobp) | ||
| 2868 | (while (and (not (eobp)) | 3194 | (while (and (not (eobp)) |
| 2869 | (outline-depth) | 3195 | (outline-depth) |
| 2870 | (>= (outline-recent-depth) depth) | 3196 | (>= (outline-recent-depth) depth) |
| @@ -2872,7 +3198,7 @@ Returns final depth." | |||
| 2872 | ; Skip over all topics at | 3198 | ; Skip over all topics at |
| 2873 | ; lesser depths, which can not | 3199 | ; lesser depths, which can not |
| 2874 | ; have been disturbed: | 3200 | ; have been disturbed: |
| 2875 | (while (and (not (eobp)) | 3201 | (while (and (not (setq was-eobp (eobp))) |
| 2876 | (> (outline-recent-depth) ascender)) | 3202 | (> (outline-recent-depth) ascender)) |
| 2877 | (outline-next-heading)) | 3203 | (outline-next-heading)) |
| 2878 | ; Prime ascender for ascension: | 3204 | ; Prime ascender for ascension: |
| @@ -2882,7 +3208,8 @@ Returns final depth." | |||
| 2882 | nil ;;; depth | 3208 | nil ;;; depth |
| 2883 | nil ;;; number-control | 3209 | nil ;;; number-control |
| 2884 | nil ;;; index | 3210 | nil ;;; index |
| 2885 | t))));;; do-successors | 3211 | t)) ;;; do-successors |
| 3212 | (if was-eobp (goto-char (point-max))))) | ||
| 2886 | (outline-recent-depth)) | 3213 | (outline-recent-depth)) |
| 2887 | ;;;_ > outline-number-siblings (&optional denumber) | 3214 | ;;;_ > outline-number-siblings (&optional denumber) |
| 2888 | (defun outline-number-siblings (&optional denumber) | 3215 | (defun outline-number-siblings (&optional denumber) |
| @@ -3000,11 +3327,11 @@ however, are left exactly like normal, non-outline-specific yanks." | |||
| 3000 | (interactive "*P") | 3327 | (interactive "*P") |
| 3001 | ; Get to beginning, leaving | 3328 | ; Get to beginning, leaving |
| 3002 | ; region around subject: | 3329 | ; region around subject: |
| 3003 | (if (< (mark-marker) (point)) | 3330 | (if (< (my-mark-marker t) (point)) |
| 3004 | (exchange-point-and-mark)) | 3331 | (exchange-point-and-mark)) |
| 3005 | (let* ((subj-beg (point)) | 3332 | (let* ((subj-beg (point)) |
| 3006 | (subj-end (mark-marker)) | 3333 | (subj-end (my-mark-marker t)) |
| 3007 | ;; `resituate' if yanking an entire topic into topic header: | 3334 | ;; 'resituate' if yanking an entire topic into topic header: |
| 3008 | (resituate (and (outline-e-o-prefix-p) | 3335 | (resituate (and (outline-e-o-prefix-p) |
| 3009 | (looking-at (concat "\\(" outline-regexp "\\)")) | 3336 | (looking-at (concat "\\(" outline-regexp "\\)")) |
| 3010 | (outline-prefix-data (match-beginning 1) | 3337 | (outline-prefix-data (match-beginning 1) |
| @@ -3074,7 +3401,7 @@ however, are left exactly like normal, non-outline-specific yanks." | |||
| 3074 | (progn | 3401 | (progn |
| 3075 | (beginning-of-line) | 3402 | (beginning-of-line) |
| 3076 | (delete-region (point) subj-beg) | 3403 | (delete-region (point) subj-beg) |
| 3077 | (set-marker (mark-marker) subj-end) | 3404 | (set-marker (my-mark-marker t) subj-end) |
| 3078 | (goto-char subj-beg) | 3405 | (goto-char subj-beg) |
| 3079 | (outline-end-of-prefix)) | 3406 | (outline-end-of-prefix)) |
| 3080 | ; Delete base subj prefix, | 3407 | ; Delete base subj prefix, |
| @@ -3189,14 +3516,14 @@ by pops to non-distinctive yanks. Bug..." | |||
| 3189 | (error "%s not found and can't be created" file-name))) | 3516 | (error "%s not found and can't be created" file-name))) |
| 3190 | (condition-case failure | 3517 | (condition-case failure |
| 3191 | (find-file-other-window file-name) | 3518 | (find-file-other-window file-name) |
| 3192 | (error failure)) | 3519 | ('error failure)) |
| 3193 | (error "%s not found" file-name)) | 3520 | (error "%s not found" file-name)) |
| 3194 | ) | 3521 | ) |
| 3195 | ) | 3522 | ) |
| 3196 | ) | 3523 | ) |
| 3197 | ) | 3524 | ) |
| 3198 | 3525 | ||
| 3199 | ;;;_ #6 Exposure Control and Processing | 3526 | ;;;_ #6 Exposure Control |
| 3200 | 3527 | ||
| 3201 | ;;;_ - Fundamental | 3528 | ;;;_ - Fundamental |
| 3202 | ;;;_ > outline-flag-region (from to flag) | 3529 | ;;;_ > outline-flag-region (from to flag) |
| @@ -3206,11 +3533,11 @@ Ie, text following flag C-m \(carriage-return) is hidden until the | |||
| 3206 | next C-j (newline) char. | 3533 | next C-j (newline) char. |
| 3207 | 3534 | ||
| 3208 | Returns the endpoint of the region." | 3535 | Returns the endpoint of the region." |
| 3209 | (` (let ((buffer-read-only nil) | 3536 | `(let ((buffer-read-only nil) |
| 3210 | (outline-override-protect t)) | 3537 | (outline-override-protect t)) |
| 3211 | (subst-char-in-region (, from) (, to) | 3538 | (subst-char-in-region ,from ,to |
| 3212 | (if (= (, flag) ?\n) ?\r ?\n) | 3539 | (if (= ,flag ?\n) ?\r ?\n) |
| 3213 | (, flag) t)))) | 3540 | ,flag t))) |
| 3214 | ;;;_ > outline-flag-current-subtree (flag) | 3541 | ;;;_ > outline-flag-current-subtree (flag) |
| 3215 | (defun outline-flag-current-subtree (flag) | 3542 | (defun outline-flag-current-subtree (flag) |
| 3216 | "Hide or show subtree of currently-visible topic. | 3543 | "Hide or show subtree of currently-visible topic. |
| @@ -3223,124 +3550,8 @@ See `outline-flag-region' for more details." | |||
| 3223 | (progn (outline-end-of-current-subtree) (1- (point))) | 3550 | (progn (outline-end-of-current-subtree) (1- (point))) |
| 3224 | flag))) | 3551 | flag))) |
| 3225 | 3552 | ||
| 3226 | ;;;_ - Mapping and processing of topics | ||
| 3227 | ;;;_ " See also chart functions, in navigation | ||
| 3228 | ;;;_ > outline-listify-exposed (&optional start end) | ||
| 3229 | (defun outline-listify-exposed (&optional start end) | ||
| 3230 | |||
| 3231 | "Produce a list representing exposed topics in current region. | ||
| 3232 | |||
| 3233 | This list can then be used by `outline-process-exposed' to manipulate | ||
| 3234 | the subject region. | ||
| 3235 | |||
| 3236 | List is composed of elements that may themselves be lists representing | ||
| 3237 | exposed components in subtopic. | ||
| 3238 | |||
| 3239 | Each component list contains: | ||
| 3240 | - a number representing the depth of the topic, | ||
| 3241 | - a string representing the header-prefix (ref. `outline-header-prefix'), | ||
| 3242 | - a string representing the bullet character, | ||
| 3243 | - and a series of strings, each containing one line of the exposed | ||
| 3244 | portion of the topic entry." | ||
| 3245 | |||
| 3246 | (interactive "r") | ||
| 3247 | (save-excursion | ||
| 3248 | (let* (strings pad result depth bullet beg next done) ; State vars. | ||
| 3249 | (goto-char start) | ||
| 3250 | (beginning-of-line) | ||
| 3251 | (if (not (outline-goto-prefix)) ; Get initial position within a topic: | ||
| 3252 | (outline-next-visible-heading 1)) | ||
| 3253 | (while (and (not done) | ||
| 3254 | (not (eobp)) ; Loop until we've covered the region. | ||
| 3255 | (not (> (point) end))) | ||
| 3256 | (setq depth (outline-recent-depth) ; Current topics' depth, | ||
| 3257 | bullet (outline-recent-bullet) ; ... bullet, | ||
| 3258 | beg (progn (outline-end-of-prefix t) (point))) ; and beginning. | ||
| 3259 | (setq done ; The boundary for the current topic: | ||
| 3260 | (not (outline-next-visible-heading 1))) | ||
| 3261 | (beginning-of-line) | ||
| 3262 | (setq next (point)) | ||
| 3263 | (goto-char beg) | ||
| 3264 | (setq strings nil) | ||
| 3265 | (while (> next (point)) ; Get all the exposed text in | ||
| 3266 | (setq strings | ||
| 3267 | (cons (buffer-substring | ||
| 3268 | beg | ||
| 3269 | ;To hidden text or end of line: | ||
| 3270 | (progn | ||
| 3271 | (search-forward "\r" | ||
| 3272 | (save-excursion (end-of-line) | ||
| 3273 | (point)) | ||
| 3274 | 1) | ||
| 3275 | (if (= (preceding-char) ?\r) | ||
| 3276 | (1- (point)) | ||
| 3277 | (point)))) | ||
| 3278 | strings)) | ||
| 3279 | (if (< (point) next) ; Resume from after hid text, if any. | ||
| 3280 | (forward-line 1)) | ||
| 3281 | (setq beg (point))) | ||
| 3282 | ;; Accumulate list for this topic: | ||
| 3283 | (setq result | ||
| 3284 | (cons (append (list depth | ||
| 3285 | outline-header-prefix | ||
| 3286 | bullet) | ||
| 3287 | (nreverse strings)) | ||
| 3288 | result))) | ||
| 3289 | ;; Put the list with first at front, to last at back: | ||
| 3290 | (nreverse result)))) | ||
| 3291 | ;;;_ > outline-process-exposed (arg &optional tobuf) | ||
| 3292 | (defun outline-process-exposed (&optional func from to frombuf tobuf) | ||
| 3293 | "Map function on exposed parts of current topic; results to another buffer. | ||
| 3294 | |||
| 3295 | Apply FUNCTION \(default 'outline-insert-listified) to exposed | ||
| 3296 | portions FROM position TO position \(default region, or the entire | ||
| 3297 | buffer if no region active) in buffer FROMBUF \(default current | ||
| 3298 | buffer) to buffer TOBUF \(default is buffer named like frombuf but | ||
| 3299 | with \"*\" prepended and \" exposed*\" appended). | ||
| 3300 | |||
| 3301 | The function must as its arguments the elements of the list | ||
| 3302 | representations of topic entries produced by outline-listify-exposed." | ||
| 3303 | |||
| 3304 | ; Resolve arguments, | ||
| 3305 | ; defaulting if necessary: | ||
| 3306 | (if (not func) (setq func 'outline-insert-listified)) | ||
| 3307 | (if (not (and from to)) | ||
| 3308 | (if mark-active | ||
| 3309 | (setq from (region-beginning) to (region-end)) | ||
| 3310 | (setq from (point-min) to (point-max)))) | ||
| 3311 | (if frombuf | ||
| 3312 | (if (not (bufferp frombuf)) | ||
| 3313 | ;; Specified but not a buffer - get it: | ||
| 3314 | (let ((got (get-buffer frombuf))) | ||
| 3315 | (if (not got) | ||
| 3316 | (error "outline-process-exposed: source buffer %s not found." | ||
| 3317 | frombuf) | ||
| 3318 | (setq frombuf got)))) | ||
| 3319 | ;; not specified - default it: | ||
| 3320 | (setq frombuf (current-buffer))) | ||
| 3321 | (if tobuf | ||
| 3322 | (if (not (bufferp tobuf)) | ||
| 3323 | (setq tobuf (get-buffer-create tobuf))) | ||
| 3324 | ;; not specified - default it: | ||
| 3325 | (setq tobuf (concat "*" (buffer-name frombuf) " exposed*"))) | ||
| 3326 | |||
| 3327 | (let* ((listified (progn (set-buffer frombuf) | ||
| 3328 | (outline-listify-exposed from to))) | ||
| 3329 | (prefix outline-header-prefix) ; ... as set in frombuf. | ||
| 3330 | curr) | ||
| 3331 | (set-buffer tobuf) | ||
| 3332 | (while listified | ||
| 3333 | (setq curr (car listified)) | ||
| 3334 | (setq listified (cdr listified)) | ||
| 3335 | (apply func (list (car curr) ; depth | ||
| 3336 | (car (cdr curr)) ; header-prefix | ||
| 3337 | (car (cdr (cdr curr))) ; bullet | ||
| 3338 | (cdr (cdr (cdr curr)))))) ; list of text lines | ||
| 3339 | (pop-to-buffer tobuf))) | ||
| 3340 | |||
| 3341 | ;;;_ - Topic-specific | 3553 | ;;;_ - Topic-specific |
| 3342 | ;;;_ > outline-show-entry () | 3554 | ;;;_ > outline-show-entry () |
| 3343 | ; outline-show-entry basically for isearch dynamic exposure, as is... | ||
| 3344 | (defun outline-show-entry () | 3555 | (defun outline-show-entry () |
| 3345 | "Like `outline-show-current-entry', reveals entries nested in hidden topics. | 3556 | "Like `outline-show-current-entry', reveals entries nested in hidden topics. |
| 3346 | 3557 | ||
| @@ -3351,10 +3562,18 @@ should be used after the peek to rectify the exposure." | |||
| 3351 | 3562 | ||
| 3352 | (interactive) | 3563 | (interactive) |
| 3353 | (save-excursion | 3564 | (save-excursion |
| 3354 | (outline-goto-prefix) | 3565 | (let ((at (point)) |
| 3355 | (outline-flag-region (if (bobp) (point) (1- (point))) | 3566 | beg end) |
| 3356 | (or (outline-pre-next-preface) (point)) | 3567 | (outline-goto-prefix) |
| 3357 | ?\n))) | 3568 | (setq beg (if (= (preceding-char) ?\r) (1- (point)) (point))) |
| 3569 | (re-search-forward "[\n\r]" nil t) | ||
| 3570 | (setq end (1- (if (< at (point)) | ||
| 3571 | ;; We're on topic head line - show only it: | ||
| 3572 | (point) | ||
| 3573 | ;; or we're in body - include it: | ||
| 3574 | (max beg (or (outline-pre-next-preface) (point)))))) | ||
| 3575 | (outline-flag-region beg end ?\n) | ||
| 3576 | (list beg end)))) | ||
| 3358 | ;;;_ > outline-show-children (&optional level strict) | 3577 | ;;;_ > outline-show-children (&optional level strict) |
| 3359 | (defun outline-show-children (&optional level strict) | 3578 | (defun outline-show-children (&optional level strict) |
| 3360 | 3579 | ||
| @@ -3393,28 +3612,18 @@ point of non-opened subtree?)" | |||
| 3393 | (if (and strict (= (preceding-char) ?\r)) | 3612 | (if (and strict (= (preceding-char) ?\r)) |
| 3394 | ;; Concealed root would already have been taken care of, | 3613 | ;; Concealed root would already have been taken care of, |
| 3395 | ;; unless strict was set. | 3614 | ;; unless strict was set. |
| 3396 | (outline-flag-region (point) (outline-snug-back) ?\n)) | 3615 | (progn |
| 3616 | (outline-flag-region (point) (outline-snug-back) ?\n) | ||
| 3617 | (if outline-show-bodies | ||
| 3618 | (progn (goto-char (car to-reveal)) | ||
| 3619 | (outline-show-current-entry))))) | ||
| 3397 | (while to-reveal | 3620 | (while to-reveal |
| 3398 | (goto-char (car to-reveal)) | 3621 | (goto-char (car to-reveal)) |
| 3399 | (outline-flag-region (point) (outline-snug-back) ?\n) | 3622 | (outline-flag-region (point) (outline-snug-back) ?\n) |
| 3623 | (if outline-show-bodies | ||
| 3624 | (progn (goto-char (car to-reveal)) | ||
| 3625 | (outline-show-current-entry))) | ||
| 3400 | (setq to-reveal (cdr to-reveal))))))))) | 3626 | (setq to-reveal (cdr to-reveal))))))))) |
| 3401 | ;;;_ x outline-show-current-children (&optional level strict) | ||
| 3402 | (defun outline-show-current-children (&optional level strict) | ||
| 3403 | "This command was misnamed, use `outline-show-children' instead. | ||
| 3404 | |||
| 3405 | \(The \"current\" in the name is supposed to imply that it works on | ||
| 3406 | the visible topic containing point, while it really works with respect | ||
| 3407 | to the most immediate topic, concealed or not. I'll leave this old | ||
| 3408 | name around for a bit, but i'll soon activate an annoying message to | ||
| 3409 | warn people about the change, and then deprecate this alias." | ||
| 3410 | |||
| 3411 | (interactive "p") | ||
| 3412 | ;;(beep) | ||
| 3413 | ;;(message (format "Use `%s' instead of `%s' (%s)." | ||
| 3414 | ;; "outline-show-children" | ||
| 3415 | ;; "outline-show-current-children" | ||
| 3416 | ;; (buffer-name (current-buffer)))) | ||
| 3417 | (outline-show-children level strict)) | ||
| 3418 | ;;;_ > outline-hide-point-reconcile () | 3627 | ;;;_ > outline-hide-point-reconcile () |
| 3419 | (defun outline-hide-reconcile () | 3628 | (defun outline-hide-reconcile () |
| 3420 | "Like `outline-hide-current-entry'; hides completely if within hidden region. | 3629 | "Like `outline-hide-current-entry'; hides completely if within hidden region. |
| @@ -3432,7 +3641,7 @@ exposed by outline-show-entry but are within otherwise concealed regions." | |||
| 3432 | ?\r))) | 3641 | ?\r))) |
| 3433 | ;;;_ > outline-show-to-offshoot () | 3642 | ;;;_ > outline-show-to-offshoot () |
| 3434 | (defun outline-show-to-offshoot () | 3643 | (defun outline-show-to-offshoot () |
| 3435 | "Like outline-show-entry, but reveals opens all concealed ancestors, as well. | 3644 | "Like outline-show-entry, but reveals all concealed ancestors, as well. |
| 3436 | 3645 | ||
| 3437 | As with outline-hide-current-entry-completely, useful for rectifying | 3646 | As with outline-hide-current-entry-completely, useful for rectifying |
| 3438 | aberrant exposure states produced by outline-show-entry." | 3647 | aberrant exposure states produced by outline-show-entry." |
| @@ -3469,7 +3678,7 @@ aberrant exposure states produced by outline-show-entry." | |||
| 3469 | (save-excursion | 3678 | (save-excursion |
| 3470 | (outline-flag-region (point) | 3679 | (outline-flag-region (point) |
| 3471 | (progn (outline-end-of-current-entry) (point)) | 3680 | (progn (outline-end-of-current-entry) (point)) |
| 3472 | ?\^M))) | 3681 | ?\r))) |
| 3473 | ;;;_ > outline-show-current-entry (&optional arg) | 3682 | ;;;_ > outline-show-current-entry (&optional arg) |
| 3474 | (defun outline-show-current-entry (&optional arg) | 3683 | (defun outline-show-current-entry (&optional arg) |
| 3475 | 3684 | ||
| @@ -3531,7 +3740,7 @@ siblings, even if the target topic is already closed." | |||
| 3531 | (if (not (outline-goto-prefix)) | 3740 | (if (not (outline-goto-prefix)) |
| 3532 | (error "No topics found.") | 3741 | (error "No topics found.") |
| 3533 | (end-of-line)(point))))) | 3742 | (end-of-line)(point))))) |
| 3534 | (outline-flag-current-subtree ?\^M) | 3743 | (outline-flag-current-subtree ?\r) |
| 3535 | (goto-char from) | 3744 | (goto-char from) |
| 3536 | (if (and (= orig-eol (progn (goto-char orig-eol) | 3745 | (if (and (= orig-eol (progn (goto-char orig-eol) |
| 3537 | (end-of-line) | 3746 | (end-of-line) |
| @@ -3587,7 +3796,7 @@ siblings, even if the target topic is already closed." | |||
| 3587 | (goto-char (point-min)) | 3796 | (goto-char (point-min)) |
| 3588 | (while (not (eobp)) | 3797 | (while (not (eobp)) |
| 3589 | (outline-flag-region (point) | 3798 | (outline-flag-region (point) |
| 3590 | (progn (outline-pre-next-preface) (point)) ?\^M) | 3799 | (progn (outline-pre-next-preface) (point)) ?\r) |
| 3591 | (if (not (eobp)) | 3800 | (if (not (eobp)) |
| 3592 | (forward-char | 3801 | (forward-char |
| 3593 | (if (looking-at "[\n\r][\n\r]") | 3802 | (if (looking-at "[\n\r][\n\r]") |
| @@ -3714,7 +3923,7 @@ Examples: | |||
| 3714 | (defun outline-old-expose-topic (spec &rest followers) | 3923 | (defun outline-old-expose-topic (spec &rest followers) |
| 3715 | 3924 | ||
| 3716 | "Deprecated. Use outline-expose-topic \(with different schema | 3925 | "Deprecated. Use outline-expose-topic \(with different schema |
| 3717 | format\) instead. | 3926 | format) instead. |
| 3718 | 3927 | ||
| 3719 | Dictate wholesale exposure scheme for current topic, according to SPEC. | 3928 | Dictate wholesale exposure scheme for current topic, according to SPEC. |
| 3720 | 3929 | ||
| @@ -3827,216 +4036,375 @@ and retains start position." | |||
| 3827 | (outline-next-heading))) | 4036 | (outline-next-heading))) |
| 3828 | (error "Can't find any outline topics.")) | 4037 | (error "Can't find any outline topics.")) |
| 3829 | (cons 'outline-old-expose-topic | 4038 | (cons 'outline-old-expose-topic |
| 3830 | (mapcar '(lambda (x) (list 'quote x)) spec)))) | 4039 | (mapcar (function (lambda (x) (list 'quote x))) spec)))) |
| 3831 | 4040 | ||
| 3832 | ;;;_ #7 ISearch with Dynamic Exposure | 4041 | ;;;_ #7 Systematic outline presentation - copying, printing, flattening |
| 3833 | ;;;_ = outline-search-reconceal | ||
| 3834 | (defvar outline-search-reconceal nil | ||
| 3835 | "Track whether current search match was concealed outside of search. | ||
| 3836 | 4042 | ||
| 3837 | The value is the location of the match, if it was concealed, regular | 4043 | ;;;_ - Mapping and processing of topics |
| 3838 | if the entire topic was concealed, in a list if the entry was concealed.") | 4044 | ;;;_ ( See also Subtree Charting, in Navigation code.) |
| 3839 | ;;;_ = outline-search-quitting | 4045 | ;;;_ > outline-stringify-flat-index (flat-index) |
| 3840 | (defconst outline-search-quitting nil | 4046 | (defun outline-stringify-flat-index (flat-index &optional context) |
| 3841 | "Distinguishes isearch conclusion and cancellation. | 4047 | "Convert list representing section/subsection/... to document string. |
| 4048 | |||
| 4049 | Optional arg CONTEXT indicates interior levels to include." | ||
| 4050 | (let ((delim ".") | ||
| 4051 | result | ||
| 4052 | numstr | ||
| 4053 | (context-depth (or (and context 2) 1))) | ||
| 4054 | ;; Take care of the explicit context: | ||
| 4055 | (while (> context-depth 0) | ||
| 4056 | (setq numstr (int-to-string (car flat-index)) | ||
| 4057 | flat-index (cdr flat-index) | ||
| 4058 | result (if flat-index | ||
| 4059 | (cons delim (cons numstr result)) | ||
| 4060 | (cons numstr result)) | ||
| 4061 | context-depth (if flat-index (1- context-depth) 0))) | ||
| 4062 | (setq delim " ") | ||
| 4063 | ;; Take care of the indentation: | ||
| 4064 | (if flat-index | ||
| 4065 | (progn | ||
| 4066 | (while flat-index | ||
| 4067 | (setq result | ||
| 4068 | (cons delim | ||
| 4069 | (cons (make-string | ||
| 4070 | (1+ (truncate (if (zerop (car flat-index)) | ||
| 4071 | 1 | ||
| 4072 | (log10 (car flat-index))))) | ||
| 4073 | ? ) | ||
| 4074 | result))) | ||
| 4075 | (setq flat-index (cdr flat-index))) | ||
| 4076 | ;; Dispose of single extra delim: | ||
| 4077 | (setq result (cdr result)))) | ||
| 4078 | (apply 'concat result))) | ||
| 4079 | ;;;_ > outline-stringify-flat-index-plain (flat-index) | ||
| 4080 | (defun outline-stringify-flat-index-plain (flat-index) | ||
| 4081 | "Convert list representing section/subsection/... to document string." | ||
| 4082 | (let ((delim ".") | ||
| 4083 | result) | ||
| 4084 | (while flat-index | ||
| 4085 | (setq result (cons (int-to-string (car flat-index)) | ||
| 4086 | (if result | ||
| 4087 | (cons delim result)))) | ||
| 4088 | (setq flat-index (cdr flat-index))) | ||
| 4089 | (apply 'concat result))) | ||
| 4090 | ;;;_ > outline-stringify-flat-index-indented (flat-index) | ||
| 4091 | (defun outline-stringify-flat-index-indented (flat-index) | ||
| 4092 | "Convert list representing section/subsection/... to document string." | ||
| 4093 | (let ((delim ".") | ||
| 4094 | result | ||
| 4095 | numstr) | ||
| 4096 | ;; Take care of the explicit context: | ||
| 4097 | (setq numstr (int-to-string (car flat-index)) | ||
| 4098 | flat-index (cdr flat-index) | ||
| 4099 | result (if flat-index | ||
| 4100 | (cons delim (cons numstr result)) | ||
| 4101 | (cons numstr result))) | ||
| 4102 | (setq delim " ") | ||
| 4103 | ;; Take care of the indentation: | ||
| 4104 | (if flat-index | ||
| 4105 | (progn | ||
| 4106 | (while flat-index | ||
| 4107 | (setq result | ||
| 4108 | (cons delim | ||
| 4109 | (cons (make-string | ||
| 4110 | (1+ (truncate (if (zerop (car flat-index)) | ||
| 4111 | 1 | ||
| 4112 | (log10 (car flat-index))))) | ||
| 4113 | ? ) | ||
| 4114 | result))) | ||
| 4115 | (setq flat-index (cdr flat-index))) | ||
| 4116 | ;; Dispose of single extra delim: | ||
| 4117 | (setq result (cdr result)))) | ||
| 4118 | (apply 'concat result))) | ||
| 4119 | ;;;_ > outline-listify-exposed (&optional start end format) | ||
| 4120 | (defun outline-listify-exposed (&optional start end format) | ||
| 3842 | 4121 | ||
| 3843 | Used by isearch-terminate/outline-provisions and | 4122 | "Produce a list representing exposed topics in current region. |
| 3844 | isearch-done/outline-provisions") | ||
| 3845 | 4123 | ||
| 4124 | This list can then be used by `outline-process-exposed' to manipulate | ||
| 4125 | the subject region. | ||
| 3846 | 4126 | ||
| 3847 | ;;;_ > outline-enwrap-isearch () | 4127 | Optional START and END indicate bounds of region. |
| 3848 | (defun outline-enwrap-isearch () | ||
| 3849 | "Impose outline-mode isearch-mode wrappers for dynamic exposure in isearch. | ||
| 3850 | 4128 | ||
| 3851 | Isearch progressively exposes and reconceals hidden topics when | 4129 | optional arg, FORMAT, designates an alternate presentation form for |
| 3852 | working in outline mode, but works normally elsewhere. | 4130 | the prefix: |
| 3853 | 4131 | ||
| 3854 | The function checks to ensure that the rebindings are done only once." | 4132 | list - Present prefix as numeric section.subsection..., starting with |
| 4133 | section indicated by the list, innermost nesting first. | ||
| 4134 | `indent' \(symbol) - Convert header prefixes to all white space, | ||
| 4135 | except for distinctive bullets. | ||
| 3855 | 4136 | ||
| 3856 | ; Should isearch-mode be employed, | 4137 | The elements of the list produced are lists that represents a topic |
| 3857 | (if (or (not outline-enwrap-isearch-mode) | 4138 | header and body. The elements of that list are: |
| 3858 | ; or are preparations already done? | ||
| 3859 | (fboundp 'real-isearch-terminate)) | ||
| 3860 | 4139 | ||
| 3861 | ;; ... no - skip this all: | 4140 | - a number representing the depth of the topic, |
| 3862 | nil | 4141 | - a string representing the header-prefix, including trailing whitespace and |
| 4142 | bullet. | ||
| 4143 | - a string representing the bullet character, | ||
| 4144 | - and a series of strings, each containing one line of the exposed | ||
| 4145 | portion of the topic entry." | ||
| 3863 | 4146 | ||
| 3864 | ;; ... yes: | 4147 | (interactive "r") |
| 4148 | (save-excursion | ||
| 4149 | (let* | ||
| 4150 | ;; state vars: | ||
| 4151 | (strings prefix pad result depth new-depth out gone-out bullet beg | ||
| 4152 | next done) | ||
| 3865 | 4153 | ||
| 3866 | ; Ensure load of isearch-mode: | 4154 | (goto-char start) |
| 3867 | (if (or (and (fboundp 'isearch-mode) | 4155 | (beginning-of-line) |
| 3868 | (fboundp 'isearch-quote-char)) | 4156 | ;; Goto initial topic, and register preceeding stuff, if any: |
| 3869 | (condition-case error | 4157 | (if (> (outline-goto-prefix) start) |
| 3870 | (load-library outline-enwrap-isearch-mode) | 4158 | ;; First topic follows beginning point - register preliminary stuff: |
| 3871 | (file-error (message "Skipping isearch-mode provisions - %s '%s'" | 4159 | (setq result (list (list 0 "" nil |
| 3872 | (car (cdr error)) | 4160 | (buffer-substring start (1- (point))))))) |
| 3873 | (car (cdr (cdr error)))) | 4161 | (while (and (not done) |
| 3874 | (sit-for 1) | 4162 | (not (eobp)) ; Loop until we've covered the region. |
| 3875 | ;; Inhibit subsequent tries and return nil: | 4163 | (not (> (point) end))) |
| 3876 | (setq outline-enwrap-isearch-mode nil)))) | 4164 | (setq depth (outline-recent-depth) ; Current topics depth, |
| 3877 | ;; Isearch-mode loaded, encapsulate specific entry points for | 4165 | bullet (outline-recent-bullet) ; ... bullet, |
| 3878 | ;; outline dynamic-exposure business: | 4166 | prefix (outline-recent-prefix) |
| 3879 | (progn | 4167 | beg (progn (outline-end-of-prefix t) (point))) ; and beginning. |
| 4168 | (setq done ; The boundary for the current topic: | ||
| 4169 | (not (outline-next-visible-heading 1))) | ||
| 4170 | (setq new-depth (outline-recent-depth)) | ||
| 4171 | (setq gone-out out | ||
| 4172 | out (< new-depth depth)) | ||
| 4173 | (beginning-of-line) | ||
| 4174 | (setq next (point)) | ||
| 4175 | (goto-char beg) | ||
| 4176 | (setq strings nil) | ||
| 4177 | (while (> next (point)) ; Get all the exposed text in | ||
| 4178 | (setq strings | ||
| 4179 | (cons (buffer-substring | ||
| 4180 | beg | ||
| 4181 | ;To hidden text or end of line: | ||
| 4182 | (progn | ||
| 4183 | (search-forward "\r" | ||
| 4184 | (save-excursion (end-of-line) | ||
| 4185 | (point)) | ||
| 4186 | 1) | ||
| 4187 | (if (= (preceding-char) ?\r) | ||
| 4188 | (1- (point)) | ||
| 4189 | (point)))) | ||
| 4190 | strings)) | ||
| 4191 | (if (< (point) next) ; Resume from after hid text, if any. | ||
| 4192 | (forward-line 1)) | ||
| 4193 | (setq beg (point))) | ||
| 4194 | ;; Accumulate list for this topic: | ||
| 4195 | (setq strings (nreverse strings)) | ||
| 4196 | (setq result | ||
| 4197 | (cons | ||
| 4198 | (if format | ||
| 4199 | (let ((special (if (string-match | ||
| 4200 | (regexp-quote bullet) | ||
| 4201 | outline-distinctive-bullets-string) | ||
| 4202 | bullet))) | ||
| 4203 | (cond ((listp format) | ||
| 4204 | (list depth | ||
| 4205 | (if outline-abbreviate-flattened-numbering | ||
| 4206 | (outline-stringify-flat-index format | ||
| 4207 | gone-out) | ||
| 4208 | (outline-stringify-flat-index-plain | ||
| 4209 | format)) | ||
| 4210 | strings | ||
| 4211 | special)) | ||
| 4212 | ((eq format 'indent) | ||
| 4213 | (if special | ||
| 4214 | (list depth | ||
| 4215 | (concat (make-string (1+ depth) ? ) | ||
| 4216 | (substring prefix -1)) | ||
| 4217 | strings) | ||
| 4218 | (list depth | ||
| 4219 | (make-string depth ? ) | ||
| 4220 | strings))) | ||
| 4221 | (t (error "outline-listify-exposed: %s %s" | ||
| 4222 | "invalid format" format)))) | ||
| 4223 | (list depth prefix strings)) | ||
| 4224 | result)) | ||
| 4225 | ;; Reasses format, if any: | ||
| 4226 | (if (and format (listp format)) | ||
| 4227 | (cond ((= new-depth depth) | ||
| 4228 | (setq format (cons (1+ (car format)) | ||
| 4229 | (cdr format)))) | ||
| 4230 | ((> new-depth depth) ; descending - assume by 1: | ||
| 4231 | (setq format (cons 1 format))) | ||
| 4232 | (t | ||
| 4233 | ; Pop the residue: | ||
| 4234 | (while (< new-depth depth) | ||
| 4235 | (setq format (cdr format)) | ||
| 4236 | (setq depth (1- depth))) | ||
| 4237 | ; And increment the current one: | ||
| 4238 | (setq format | ||
| 4239 | (cons (1+ (or (car format) | ||
| 4240 | -1)) | ||
| 4241 | (cdr format))))))) | ||
| 4242 | ;; Put the list with first at front, to last at back: | ||
| 4243 | (nreverse result)))) | ||
| 4244 | ;;;_ > outline-process-exposed (&optional func from to frombuf | ||
| 4245 | ;;; tobuf format) | ||
| 4246 | (defun outline-process-exposed (&optional func from to frombuf tobuf | ||
| 4247 | format &optional start-num) | ||
| 4248 | "Map function on exposed parts of current topic; results to another buffer. | ||
| 3880 | 4249 | ||
| 3881 | ;; stash crucial isearch-mode funcs under known, private | 4250 | All args are options; default values itemized below. |
| 3882 | ;; names, then register wrapper functions under the old | ||
| 3883 | ;; names, in their stead: `isearch-quit' is pre isearch v 1.2. | ||
| 3884 | (fset 'real-isearch-terminate | ||
| 3885 | ; `isearch-quit' is pre v 1.2: | ||
| 3886 | (or (if (fboundp 'isearch-quit) | ||
| 3887 | (symbol-function 'isearch-quit)) | ||
| 3888 | (if (fboundp 'isearch-abort) | ||
| 3889 | ; `isearch-abort' is v 1.2 and on: | ||
| 3890 | (symbol-function 'isearch-abort)))) | ||
| 3891 | (fset 'isearch-quit 'isearch-terminate/outline-provisions) | ||
| 3892 | (fset 'isearch-abort 'isearch-terminate/outline-provisions) | ||
| 3893 | (fset 'real-isearch-done (symbol-function 'isearch-done)) | ||
| 3894 | (fset 'isearch-done 'isearch-done/outline-provisions) | ||
| 3895 | (fset 'real-isearch-update (symbol-function 'isearch-update)) | ||
| 3896 | (fset 'isearch-update 'isearch-update/outline-provisions) | ||
| 3897 | (make-variable-buffer-local 'outline-search-reconceal))))) | ||
| 3898 | ;;;_ > outline-isearch-arrival-business () | ||
| 3899 | (defun outline-isearch-arrival-business () | ||
| 3900 | "Do outline business like exposing current point, if necessary. | ||
| 3901 | |||
| 3902 | Registers reconcealment requirements in outline-search-reconceal | ||
| 3903 | accordingly. | ||
| 3904 | |||
| 3905 | Set outline-search-reconceal to nil if current point is not | ||
| 3906 | concealed, to value of point if entire topic is concealed, and a | ||
| 3907 | list containing point if only the topic body is concealed. | ||
| 3908 | |||
| 3909 | This will be used to determine whether outline-hide-current-entry | ||
| 3910 | or outline-hide-current-entry-completely will be necessary to | ||
| 3911 | restore the prior concealment state." | ||
| 3912 | 4251 | ||
| 3913 | (if (outline-mode-p) | 4252 | Apply FUNCTION to exposed portions FROM position TO position in buffer |
| 3914 | (setq outline-search-reconceal | 4253 | FROMBUF to buffer TOBUF. Sixth optional arg, FORMAT, designates an |
| 3915 | (if (outline-hidden-p) | 4254 | alternate presentation form: |
| 3916 | (save-excursion | ||
| 3917 | (if (re-search-backward outline-line-boundary-regexp nil 1) | ||
| 3918 | ;; Nil value means we got to b-o-b - wouldn't need | ||
| 3919 | ;; to advance. | ||
| 3920 | (forward-char 1)) | ||
| 3921 | ; We'll return point or list | ||
| 3922 | ; containing point, depending | ||
| 3923 | ; on concealment state of | ||
| 3924 | ; topic prefix. | ||
| 3925 | (prog1 (if (outline-hidden-p) (point) (list (point))) | ||
| 3926 | ; And reveal the current | ||
| 3927 | ; search target: | ||
| 3928 | (outline-show-entry))))))) | ||
| 3929 | ;;;_ > outline-isearch-advancing-business () | ||
| 3930 | (defun outline-isearch-advancing-business () | ||
| 3931 | "Do outline business like deexposing current point, if necessary. | ||
| 3932 | |||
| 3933 | Works according to reconceal state registration." | ||
| 3934 | (if (and (outline-mode-p) outline-search-reconceal) | ||
| 3935 | (save-excursion | ||
| 3936 | (if (listp outline-search-reconceal) | ||
| 3937 | ;; Leave the topic visible: | ||
| 3938 | (progn (goto-char (car outline-search-reconceal)) | ||
| 3939 | (outline-hide-current-entry)) | ||
| 3940 | ;; Rehide the entire topic: | ||
| 3941 | (goto-char outline-search-reconceal) | ||
| 3942 | (outline-hide-current-entry-completely))))) | ||
| 3943 | ;;;_ > isearch-terminate/outline-provisions () | ||
| 3944 | (defun isearch-terminate/outline-provisions () | ||
| 3945 | (interactive) | ||
| 3946 | (if (and (outline-mode-p) outline-enwrap-isearch-mode) | ||
| 3947 | (outline-isearch-advancing-business)) | ||
| 3948 | (let ((outline-search-quitting t) | ||
| 3949 | (outline-search-reconceal nil)) | ||
| 3950 | (real-isearch-terminate))) | ||
| 3951 | ;;;_ > isearch-done/outline-provisions () | ||
| 3952 | (defun isearch-done/outline-provisions (&optional nopush edit) | ||
| 3953 | (interactive) | ||
| 3954 | (if (and (outline-mode-p) outline-enwrap-isearch-mode) | ||
| 3955 | (progn (if (and outline-search-reconceal | ||
| 3956 | (not (listp outline-search-reconceal))) | ||
| 3957 | ;; The topic was concealed - reveal it, its siblings, | ||
| 3958 | ;; and any ancestors that are still concealed: | ||
| 3959 | (save-excursion | ||
| 3960 | (message "(exposing destination)")(sit-for 0) | ||
| 3961 | (outline-goto-prefix) | ||
| 3962 | ; There may be a closed blank | ||
| 3963 | ; line between prior and | ||
| 3964 | ; current topic that would be | ||
| 3965 | ; missed - provide for it: | ||
| 3966 | (if (not (bobp)) | ||
| 3967 | (progn (forward-char -1) ; newline | ||
| 3968 | (if (eq ?\r (preceding-char)) | ||
| 3969 | (outline-flag-region (1- (point)) | ||
| 3970 | (point) | ||
| 3971 | ?\n)) | ||
| 3972 | (forward-char 1))) | ||
| 3973 | ; Goto parent | ||
| 3974 | (outline-ascend-to-depth (1- (outline-recent-depth))) | ||
| 3975 | (outline-show-children))) | ||
| 3976 | (if (and (boundp 'outline-search-quitting) | ||
| 3977 | outline-search-quitting) | ||
| 3978 | nil | ||
| 3979 | ; We're concluding abort: | ||
| 3980 | (outline-isearch-arrival-business) | ||
| 3981 | (outline-show-children)))) | ||
| 3982 | (if nopush | ||
| 3983 | ;; isearch-done in newer version of isearch mode takes arg: | ||
| 3984 | (real-isearch-done nopush) | ||
| 3985 | (real-isearch-done))) | ||
| 3986 | ;;;_ > isearch-update/outline-provisions () | ||
| 3987 | (defun isearch-update/outline-provisions () | ||
| 3988 | "Wrapper dynamically adjusts isearch target exposure. | ||
| 3989 | |||
| 3990 | Appropriately exposes and reconceals hidden outline portions, as | ||
| 3991 | necessary, in the course of searching." | ||
| 3992 | (if (not (and (outline-mode-p) outline-enwrap-isearch-mode)) | ||
| 3993 | ;; Just do the plain business: | ||
| 3994 | (real-isearch-update) | ||
| 3995 | |||
| 3996 | ;; Ah - provide for outline conditions: | ||
| 3997 | (outline-isearch-advancing-business) | ||
| 3998 | (real-isearch-update) | ||
| 3999 | (cond (isearch-success (outline-isearch-arrival-business)) | ||
| 4000 | ((not isearch-success) (outline-isearch-advancing-business))))) | ||
| 4001 | |||
| 4002 | ;;;_ #8 Copying and printing | ||
| 4003 | 4255 | ||
| 4004 | ;;;_ - Copy exposed | 4256 | `flat' - Present prefix as numeric section.subsection..., starting with |
| 4005 | ;;;_ > outline-insert-listified (depth prefix bullet text) | 4257 | section indicated by the start-num, innermost nesting first. |
| 4006 | (defun outline-insert-listified (depth prefix bullet text) | 4258 | X`flat-indented' - Prefix is like `flat' for first topic at each |
| 4007 | "Insert contents of listified outline portion in current buffer." | 4259 | X level, but subsequent topics have only leaf topic |
| 4008 | (insert-string (concat (if (> depth 1) prefix "") | 4260 | X number, padded with blanks to line up with first. |
| 4009 | (make-string (1- depth) ?\ ) | 4261 | `indent' \(symbol) - Convert header prefixes to all white space, |
| 4010 | bullet)) | 4262 | except for distinctive bullets. |
| 4011 | (while text | ||
| 4012 | (insert-string (car text)) | ||
| 4013 | (if (setq text (cdr text)) | ||
| 4014 | (insert-string "\n"))) | ||
| 4015 | (insert-string "\n")) | ||
| 4016 | ;;;_ > outline-copy-exposed (arg &optional tobuf) | ||
| 4017 | (defun outline-copy-exposed (arg &optional tobuf) | ||
| 4018 | "Duplicate exposed portions of current topic to another buffer. | ||
| 4019 | |||
| 4020 | Other buffer has current buffers' name with \" exposed\" appended to it. | ||
| 4021 | 4263 | ||
| 4022 | With repeat count, copy the exposed portions of entire buffer." | 4264 | Defaults: |
| 4265 | FUNCTION: `outline-insert-listified' | ||
| 4266 | FROM: region start, if region active, else start of buffer | ||
| 4267 | TO: region end, if region active, else end of buffer | ||
| 4268 | FROMBUF: current buffer | ||
| 4269 | TOBUF: buffer name derived: \"*current-buffer-name exposed*\" | ||
| 4270 | FORMAT: nil" | ||
| 4271 | |||
| 4272 | ; Resolve arguments, | ||
| 4273 | ; defaulting if necessary: | ||
| 4274 | (if (not func) (setq func 'outline-insert-listified)) | ||
| 4275 | (if (not (and from to)) | ||
| 4276 | (if (my-region-active-p) | ||
| 4277 | (setq from (region-beginning) to (region-end)) | ||
| 4278 | (setq from (point-min) to (point-max)))) | ||
| 4279 | (if frombuf | ||
| 4280 | (if (not (bufferp frombuf)) | ||
| 4281 | ;; Specified but not a buffer - get it: | ||
| 4282 | (let ((got (get-buffer frombuf))) | ||
| 4283 | (if (not got) | ||
| 4284 | (error (concat "outline-process-exposed: source buffer " | ||
| 4285 | frombuf | ||
| 4286 | " not found.")) | ||
| 4287 | (setq frombuf got)))) | ||
| 4288 | ;; not specified - default it: | ||
| 4289 | (setq frombuf (current-buffer))) | ||
| 4290 | (if tobuf | ||
| 4291 | (if (not (bufferp tobuf)) | ||
| 4292 | (setq tobuf (get-buffer-create tobuf))) | ||
| 4293 | ;; not specified - default it: | ||
| 4294 | (setq tobuf (concat "*" (buffer-name frombuf) " exposed*"))) | ||
| 4295 | (if (listp format) | ||
| 4296 | (nreverse format)) | ||
| 4297 | |||
| 4298 | (let* ((listified | ||
| 4299 | (progn (set-buffer frombuf) | ||
| 4300 | (outline-listify-exposed from to format)))) | ||
| 4301 | (set-buffer tobuf) | ||
| 4302 | (mapcar func listified) | ||
| 4303 | (pop-to-buffer tobuf))) | ||
| 4304 | |||
| 4305 | ;;;_ - Copy exposed | ||
| 4306 | ;;;_ > outline-insert-listified (listified) | ||
| 4307 | (defun outline-insert-listified (listified) | ||
| 4308 | "Insert contents of listified outline portion in current buffer. | ||
| 4309 | |||
| 4310 | Listified is a list representing each topic header and body: | ||
| 4311 | |||
| 4312 | \`(depth prefix text)' | ||
| 4313 | |||
| 4314 | or \`(depth prefix text bullet-plus)' | ||
| 4315 | |||
| 4316 | If `bullet-plus' is specified, it is inserted just after the entire prefix." | ||
| 4317 | (setq listified (cdr listified)) | ||
| 4318 | (let ((prefix (prog1 | ||
| 4319 | (car listified) | ||
| 4320 | (setq listified (cdr listified)))) | ||
| 4321 | (text (prog1 | ||
| 4322 | (car listified) | ||
| 4323 | (setq listified (cdr listified)))) | ||
| 4324 | (bullet-plus (car listified))) | ||
| 4325 | (insert-string prefix) | ||
| 4326 | (if bullet-plus (insert-string (concat " " bullet-plus))) | ||
| 4327 | (while text | ||
| 4328 | (insert-string (car text)) | ||
| 4329 | (if (setq text (cdr text)) | ||
| 4330 | (insert-string "\n"))) | ||
| 4331 | (insert-string "\n"))) | ||
| 4332 | ;;;_ > outline-copy-exposed-to-buffer (&optional arg tobuf format) | ||
| 4333 | (defun outline-copy-exposed-to-buffer (&optional arg tobuf format) | ||
| 4334 | "Duplicate exposed portions of current outline to another buffer. | ||
| 4335 | |||
| 4336 | Other buffer has current buffers name with \" exposed\" appended to it. | ||
| 4337 | |||
| 4338 | With repeat count, copy the exposed parts of only the current topic. | ||
| 4339 | |||
| 4340 | Optional second arg TOBUF is target buffer name. | ||
| 4341 | |||
| 4342 | Optional third arg FORMAT, if non-nil, symbolically designates an | ||
| 4343 | alternate presentation format for the outline: | ||
| 4344 | |||
| 4345 | `flat' - Convert topic header prefixes to numeric | ||
| 4346 | section.subsection... identifiers. | ||
| 4347 | `indent' - Convert header prefixes to all white space, except for | ||
| 4348 | distinctive bullets. | ||
| 4349 | `indent-flat' - The best of both - only the first of each level has | ||
| 4350 | the full path, the rest have only the section number | ||
| 4351 | of the leaf, preceded by the right amount of indentation." | ||
| 4023 | 4352 | ||
| 4024 | (interactive "P") | 4353 | (interactive "P") |
| 4025 | (if (not tobuf) | 4354 | (if (not tobuf) |
| 4026 | (setq tobuf (get-buffer-create (concat "*" (buffer-name) " exposed*")))) | 4355 | (setq tobuf (get-buffer-create (concat "*" (buffer-name) " exposed*")))) |
| 4027 | (let* ((start-pt (point)) | 4356 | (let* ((start-pt (point)) |
| 4028 | (beg (if arg (point-min) (outline-back-to-current-heading))) | 4357 | (beg (if arg (outline-back-to-current-heading) (point-min))) |
| 4029 | (end (if arg (point-max) (outline-end-of-current-subtree))) | 4358 | (end (if arg (outline-end-of-current-subtree) (point-max))) |
| 4030 | (buf (current-buffer))) | 4359 | (buf (current-buffer)) |
| 4360 | (start-list ())) | ||
| 4361 | (if (eq format 'flat) | ||
| 4362 | (setq format (if arg (save-excursion | ||
| 4363 | (goto-char beg) | ||
| 4364 | (outline-topic-flat-index)) | ||
| 4365 | '(1)))) | ||
| 4031 | (save-excursion (set-buffer tobuf)(erase-buffer)) | 4366 | (save-excursion (set-buffer tobuf)(erase-buffer)) |
| 4032 | (outline-process-exposed 'outline-insert-listified | 4367 | (outline-process-exposed 'outline-insert-listified |
| 4033 | beg | 4368 | beg |
| 4034 | end | 4369 | end |
| 4035 | (current-buffer) | 4370 | (current-buffer) |
| 4036 | tobuf) | 4371 | tobuf |
| 4372 | format start-list) | ||
| 4037 | (goto-char (point-min)) | 4373 | (goto-char (point-min)) |
| 4038 | (pop-to-buffer buf) | 4374 | (pop-to-buffer buf) |
| 4039 | (goto-char start-pt))) | 4375 | (goto-char start-pt))) |
| 4376 | ;;;_ > outline-flatten-exposed-to-buffer (&optional arg tobuf) | ||
| 4377 | (defun outline-flatten-exposed-to-buffer (&optional arg tobuf) | ||
| 4378 | "Present numeric outline of outline's exposed portions in another buffer. | ||
| 4379 | |||
| 4380 | The resulting outline is not compatable with outline mode - use | ||
| 4381 | `outline-copy-exposed-to-buffer' if you want that. | ||
| 4382 | |||
| 4383 | Use `outline-indented-exposed-to-buffer' for indented presentation. | ||
| 4384 | |||
| 4385 | With repeat count, copy the exposed portions of only current topic. | ||
| 4386 | |||
| 4387 | Other buffer has current buffers name with \" exposed\" appended to | ||
| 4388 | it, unless optional second arg TOBUF is specified, in which case it is | ||
| 4389 | used verbatim." | ||
| 4390 | (interactive "P") | ||
| 4391 | (outline-copy-exposed-to-buffer arg tobuf 'flat)) | ||
| 4392 | ;;;_ > outline-indented-exposed-to-buffer (&optional arg tobuf) | ||
| 4393 | (defun outline-indented-exposed-to-buffer (&optional arg tobuf) | ||
| 4394 | "Present indented outline of outline's exposed portions in another buffer. | ||
| 4395 | |||
| 4396 | The resulting outline is not compatable with outline mode - use | ||
| 4397 | `outline-copy-exposed-to-buffer' if you want that. | ||
| 4398 | |||
| 4399 | Use `outline-flatten-exposed-to-buffer' for numeric sectional presentation. | ||
| 4400 | |||
| 4401 | With repeat count, copy the exposed portions of only current topic. | ||
| 4402 | |||
| 4403 | Other buffer has current buffers name with \" exposed\" appended to | ||
| 4404 | it, unless optional second arg TOBUF is specified, in which case it is | ||
| 4405 | used verbatim." | ||
| 4406 | (interactive "P") | ||
| 4407 | (outline-copy-exposed-to-buffer arg tobuf 'indent)) | ||
| 4040 | 4408 | ||
| 4041 | ;;;_ - LaTeX formatting | 4409 | ;;;_ - LaTeX formatting |
| 4042 | ;;;_ > outline-latex-verb-quote (str &optional flow) | 4410 | ;;;_ > outline-latex-verb-quote (str &optional flow) |
| @@ -4044,17 +4412,17 @@ With repeat count, copy the exposed portions of entire buffer." | |||
| 4044 | "Return copy of STRING for literal reproduction across latex processing. | 4412 | "Return copy of STRING for literal reproduction across latex processing. |
| 4045 | Expresses the original characters \(including carriage returns) of the | 4413 | Expresses the original characters \(including carriage returns) of the |
| 4046 | string across latex processing." | 4414 | string across latex processing." |
| 4047 | (mapconcat '(lambda (char) | 4415 | (mapconcat (function |
| 4048 | ;;;mess: (cond ((memq char '(?"" ?$ ?% ?# ?& ?- ?" ?` ?^ ?- ?*));;;")))) | 4416 | (lambda (char) |
| 4049 | (cond ((memq char '(?\\ ?$ ?% ?# ?& ?{ ?} ?_ ?^ ?- ?*)) | 4417 | (cond ((memq char '(?\\ ?$ ?% ?# ?& ?{ ?} ?_ ?^ ?- ?*)) |
| 4050 | (concat "\\char" (number-to-string char) "{}")) | 4418 | (concat "\\char" (number-to-string char) "{}")) |
| 4051 | ((= char ?\n) "\\\\") | 4419 | ((= char ?\n) "\\\\") |
| 4052 | (t (char-to-string char)))) | 4420 | (t (char-to-string char))))) |
| 4053 | str | 4421 | str |
| 4054 | "")) | 4422 | "")) |
| 4055 | ;;;_ > outline-latex-verbatim-quote-curr-line () | 4423 | ;;;_ > outline-latex-verbatim-quote-curr-line () |
| 4056 | (defun outline-latex-verbatim-quote-curr-line () | 4424 | (defun outline-latex-verbatim-quote-curr-line () |
| 4057 | "Express line for exact \(literal\) representation across latex processing. | 4425 | "Express line for exact \(literal) representation across latex processing. |
| 4058 | 4426 | ||
| 4059 | Adjust line contents so it is unaltered \(from the original line) | 4427 | Adjust line contents so it is unaltered \(from the original line) |
| 4060 | across latex processing, within the context of a `verbatim' | 4428 | across latex processing, within the context of a `verbatim' |
| @@ -4123,7 +4491,7 @@ environment. Leaves point at the end of the line." | |||
| 4123 | (outline-latex-verb-quote (if outline-title | 4491 | (outline-latex-verb-quote (if outline-title |
| 4124 | (condition-case err | 4492 | (condition-case err |
| 4125 | (eval outline-title) | 4493 | (eval outline-title) |
| 4126 | (error "<unnamed buffer>")) | 4494 | ('error "<unnamed buffer>")) |
| 4127 | "Unnamed Outline")) | 4495 | "Unnamed Outline")) |
| 4128 | "}\n" | 4496 | "}\n" |
| 4129 | "\\end{center}\n\n")) | 4497 | "\\end{center}\n\n")) |
| @@ -4154,14 +4522,14 @@ environment. Leaves point at the end of the line." | |||
| 4154 | (defun outline-latexify-one-item (depth prefix bullet text) | 4522 | (defun outline-latexify-one-item (depth prefix bullet text) |
| 4155 | "Insert LaTeX commands for formatting one outline item. | 4523 | "Insert LaTeX commands for formatting one outline item. |
| 4156 | 4524 | ||
| 4157 | Args are the topics' numeric DEPTH, the header PREFIX lead string, the | 4525 | Args are the topics numeric DEPTH, the header PREFIX lead string, the |
| 4158 | BULLET string, and a list of TEXT strings for the body." | 4526 | BULLET string, and a list of TEXT strings for the body." |
| 4159 | (let* ((head-line (if text (car text))) | 4527 | (let* ((head-line (if text (car text))) |
| 4160 | (body-lines (cdr text)) | 4528 | (body-lines (cdr text)) |
| 4161 | (curr-line) | 4529 | (curr-line) |
| 4162 | body-content bop) | 4530 | body-content bop) |
| 4163 | ; Do the head line: | 4531 | ; Do the head line: |
| 4164 | (insert-string (concat "\\OneHeadLine{\\verb\1 " | 4532 | (insert-string (concat "\\OneHeadLine{\\verb\1 " |
| 4165 | (outline-latex-verb-quote bullet) | 4533 | (outline-latex-verb-quote bullet) |
| 4166 | "\1}{" | 4534 | "\1}{" |
| 4167 | depth | 4535 | depth |
| @@ -4202,7 +4570,7 @@ BULLET string, and a list of TEXT strings for the body." | |||
| 4202 | ))) | 4570 | ))) |
| 4203 | ;;;_ > outline-latexify-exposed (arg &optional tobuf) | 4571 | ;;;_ > outline-latexify-exposed (arg &optional tobuf) |
| 4204 | (defun outline-latexify-exposed (arg &optional tobuf) | 4572 | (defun outline-latexify-exposed (arg &optional tobuf) |
| 4205 | "Format current topic's exposed portions to TOBUF for latex processing. | 4573 | "Format current topics exposed portions to TOBUF for latex processing. |
| 4206 | TOBUF defaults to a buffer named the same as the current buffer, but | 4574 | TOBUF defaults to a buffer named the same as the current buffer, but |
| 4207 | with \"*\" prepended and \" latex-formed*\" appended. | 4575 | with \"*\" prepended and \" latex-formed*\" appended. |
| 4208 | 4576 | ||
| @@ -4231,7 +4599,7 @@ With repeat count, copy the exposed portions of entire buffer." | |||
| 4231 | (pop-to-buffer buf) | 4599 | (pop-to-buffer buf) |
| 4232 | (goto-char start-pt))) | 4600 | (goto-char start-pt))) |
| 4233 | 4601 | ||
| 4234 | ;;;_ #9 miscellaneous | 4602 | ;;;_ #8 miscellaneous |
| 4235 | ;;;_ > outline-mark-topic () | 4603 | ;;;_ > outline-mark-topic () |
| 4236 | (defun outline-mark-topic () | 4604 | (defun outline-mark-topic () |
| 4237 | "Put the region around topic currently containing point." | 4605 | "Put the region around topic currently containing point." |
| @@ -4260,10 +4628,10 @@ setup for auto-startup." | |||
| 4260 | t | 4628 | t |
| 4261 | (outline-open-topic 2) | 4629 | (outline-open-topic 2) |
| 4262 | (insert-string (concat "Dummy outline topic header - see" | 4630 | (insert-string (concat "Dummy outline topic header - see" |
| 4263 | "`outline-mode' docstring for info.")) | 4631 | "`outline-mode' docstring: `^Hm'.")) |
| 4264 | (next-line 1) | 4632 | (forward-line 1) |
| 4265 | (goto-char (point-max)) | 4633 | (goto-char (point-max)) |
| 4266 | (next-line 1) | 4634 | (open-line 1) |
| 4267 | (outline-open-topic 0) | 4635 | (outline-open-topic 0) |
| 4268 | (insert-string "Local emacs vars.\n") | 4636 | (insert-string "Local emacs vars.\n") |
| 4269 | (outline-open-topic 1) | 4637 | (outline-open-topic 1) |
| @@ -4273,7 +4641,7 @@ setup for auto-startup." | |||
| 4273 | (outline-open-topic 0) | 4641 | (outline-open-topic 0) |
| 4274 | (insert-string (format "outline-layout: %s\n" | 4642 | (insert-string (format "outline-layout: %s\n" |
| 4275 | (or outline-layout | 4643 | (or outline-layout |
| 4276 | '(1 : 0)))) | 4644 | '(-1 : 0)))) |
| 4277 | (outline-open-topic 0) | 4645 | (outline-open-topic 0) |
| 4278 | (insert-string "End:\n")))) | 4646 | (insert-string "End:\n")))) |
| 4279 | ;;;_ > solicit-char-in-string (prompt string &optional do-defaulting) | 4647 | ;;;_ > solicit-char-in-string (prompt string &optional do-defaulting) |
| @@ -4289,28 +4657,25 @@ Optional arg DO-DEFAULTING indicates to accept empty input (CR)." | |||
| 4289 | (message "%s" new-prompt) | 4657 | (message "%s" new-prompt) |
| 4290 | 4658 | ||
| 4291 | ;; We do our own reading here, so we can circumvent, eg, special | 4659 | ;; We do our own reading here, so we can circumvent, eg, special |
| 4292 | ;; treatment for `?' character. (Might oughta change minibuffer | 4660 | ;; treatment for `?' character. (Oughta use minibuffer keymap instead.) |
| 4293 | ;; keymap instead, oh well.) | ||
| 4294 | (setq got | 4661 | (setq got |
| 4295 | (char-to-string (let ((cursor-in-echo-area nil)) (read-char)))) | 4662 | (char-to-string (let ((cursor-in-echo-area nil)) (read-char)))) |
| 4296 | 4663 | ||
| 4297 | (if (null (string-match (regexp-quote got) string)) | 4664 | (setq got |
| 4298 | (if (and do-defaulting (string= got "\^M")) | 4665 | (cond ((string-match (regexp-quote got) string) got) |
| 4299 | ;; We're defaulting, return null string to indicate that: | 4666 | ((and do-defaulting (string= got "\r")) |
| 4300 | (setq got "") | 4667 | ;; Return empty string to default: |
| 4301 | ;; Failed match and not defaulting, | 4668 | "") |
| 4302 | ;; set the prompt to give feedback, | 4669 | ((string= got "\C-g") (signal 'quit nil)) |
| 4303 | (setq new-prompt (concat prompt | 4670 | (t |
| 4304 | got | 4671 | (setq new-prompt (concat prompt |
| 4305 | " ...pick from: " | 4672 | got |
| 4306 | string | 4673 | " ...pick from: " |
| 4307 | "")) | 4674 | string |
| 4308 | ;; and set loop to try again: | 4675 | "")) |
| 4309 | (setq got nil)) | 4676 | nil)))) |
| 4310 | ;; Got a match - give feedback: | 4677 | ;; got something out of loop - return it: |
| 4311 | (message ""))) | 4678 | got) |
| 4312 | ;; got something out of loop - return it: | ||
| 4313 | got) | ||
| 4314 | ) | 4679 | ) |
| 4315 | ;;;_ > regexp-sans-escapes (string) | 4680 | ;;;_ > regexp-sans-escapes (string) |
| 4316 | (defun regexp-sans-escapes (regexp &optional successive-backslashes) | 4681 | (defun regexp-sans-escapes (regexp &optional successive-backslashes) |
| @@ -4335,6 +4700,11 @@ Optional arg SUCCESSIVE-BACKSLASHES is used internally for recursion." | |||
| 4335 | (regexp-sans-escapes (substring regexp 1))) | 4700 | (regexp-sans-escapes (substring regexp 1))) |
| 4336 | ;; Exclude first char, but maintain count: | 4701 | ;; Exclude first char, but maintain count: |
| 4337 | (regexp-sans-escapes (substring regexp 1) successive-backslashes)))) | 4702 | (regexp-sans-escapes (substring regexp 1) successive-backslashes)))) |
| 4703 | ;;;_ > my-region-active-p () | ||
| 4704 | (defmacro my-region-active-p () | ||
| 4705 | (if (fboundp 'region-active-p) | ||
| 4706 | '(region-active-p) | ||
| 4707 | 'mark-active)) | ||
| 4338 | ;;;_ - add-hook definition for divergent emacsen | 4708 | ;;;_ - add-hook definition for divergent emacsen |
| 4339 | ;;;_ > add-hook (hook function &optional append) | 4709 | ;;;_ > add-hook (hook function &optional append) |
| 4340 | (if (not (fboundp 'add-hook)) | 4710 | (if (not (fboundp 'add-hook)) |
| @@ -4355,11 +4725,20 @@ function. If HOOK is void, it is first set to nil." | |||
| 4355 | (if append | 4725 | (if append |
| 4356 | (nconc (symbol-value hook) (list function)) | 4726 | (nconc (symbol-value hook) (list function)) |
| 4357 | (cons function (symbol-value hook))))))) | 4727 | (cons function (symbol-value hook))))))) |
| 4728 | ;;;_ : my-mark-marker to accomodate divergent emacsen: | ||
| 4729 | (defun my-mark-marker (&optional force buffer) | ||
| 4730 | "Accomodate the different signature for mark-marker across emacsen. | ||
| 4731 | |||
| 4732 | GNU XEmacs takes two optional args, while mainline GNU Emacs does not, | ||
| 4733 | so pass them along when appropriate." | ||
| 4734 | (if (string-match " XEmacs " emacs-version) | ||
| 4735 | (mark-marker force buffer) | ||
| 4736 | (mark-marker))) | ||
| 4358 | 4737 | ||
| 4359 | ;;;_ #10 Under development | 4738 | ;;;_ #9 Under development |
| 4360 | ;;;_ > outline-bullet-isearch (&optional bullet) | 4739 | ;;;_ > outline-bullet-isearch (&optional bullet) |
| 4361 | (defun outline-bullet-isearch (&optional bullet) | 4740 | (defun outline-bullet-isearch (&optional bullet) |
| 4362 | "Isearch \(regexp\) for topic with bullet BULLET." | 4741 | "Isearch \(regexp) for topic with bullet BULLET." |
| 4363 | (interactive) | 4742 | (interactive) |
| 4364 | (if (not bullet) | 4743 | (if (not bullet) |
| 4365 | (setq bullet (solicit-char-in-string | 4744 | (setq bullet (solicit-char-in-string |