Mercurial > emacs
comparison lisp/allout.el @ 79939:f87999df3305
Many doc fixes.
(allout-encrypt-string): Fix error message.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 27 Jan 2008 01:04:56 +0000 |
parents | 5096ade2d1f5 |
children | b113c474ec50 |
comparison
equal
deleted
inserted
replaced
79938:ad7fd6c7e3ff | 79939:f87999df3305 |
---|---|
3 ;; Copyright (C) 1992, 1993, 1994, 2001, 2002, 2003, 2004, | 3 ;; Copyright (C) 1992, 1993, 1994, 2001, 2002, 2003, 2004, |
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Ken Manheimer <ken dot manheimer at gmail dot com> | 6 ;; Author: Ken Manheimer <ken dot manheimer at gmail dot com> |
7 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com> | 7 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com> |
8 ;; Created: Dec 1991 - first release to usenet | 8 ;; Created: Dec 1991 -- first release to usenet |
9 ;; Version: 2.2.1 | 9 ;; Version: 2.2.1 |
10 ;; Keywords: outlines wp languages | 10 ;; Keywords: outlines wp languages |
11 ;; Website: http://myriadicity.net/Sundry/EmacsAllout | 11 ;; Website: http://myriadicity.net/Sundry/EmacsAllout |
12 | 12 |
13 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
34 ;; | 34 ;; |
35 ;; - Classic outline-mode topic-oriented navigation and exposure adjustment | 35 ;; - Classic outline-mode topic-oriented navigation and exposure adjustment |
36 ;; - Topic-oriented editing including coherent topic and subtopic | 36 ;; - Topic-oriented editing including coherent topic and subtopic |
37 ;; creation, promotion, demotion, cut/paste across depths, etc. | 37 ;; creation, promotion, demotion, cut/paste across depths, etc. |
38 ;; - Incremental search with dynamic exposure and reconcealment of text | 38 ;; - Incremental search with dynamic exposure and reconcealment of text |
39 ;; - Customizable bullet format - enables programming-language specific | 39 ;; - Customizable bullet format -- enables programming-language specific |
40 ;; outlining, for code-folding editing. (Allout code itself is to try it; | 40 ;; outlining, for code-folding editing. (Allout code itself is to try it; |
41 ;; formatted as an outline - do ESC-x eval-buffer in allout.el; but | 41 ;; formatted as an outline -- do ESC-x eval-buffer in allout.el; but |
42 ;; emacs local file variables need to be enabled when the | 42 ;; emacs local file variables need to be enabled when the |
43 ;; file was visited - see `enable-local-variables'.) | 43 ;; file was visited -- see `enable-local-variables'.) |
44 ;; - Configurable per-file initial exposure settings | 44 ;; - Configurable per-file initial exposure settings |
45 ;; - Symmetric-key and key-pair topic encryption, plus symmetric passphrase | 45 ;; - Symmetric-key and key-pair topic encryption, plus symmetric passphrase |
46 ;; mnemonic support, with verification against an established passphrase | 46 ;; mnemonic support, with verification against an established passphrase |
47 ;; (using a stashed encrypted dummy string) and user-supplied hint | 47 ;; (using a stashed encrypted dummy string) and user-supplied hint |
48 ;; maintenance. (See allout-toggle-current-subtree-encryption docstring. | 48 ;; maintenance. (See allout-toggle-current-subtree-encryption docstring. |
51 ;; - Automatic topic-number maintenance | 51 ;; - Automatic topic-number maintenance |
52 ;; - "Hot-spot" operation, for single-keystroke maneuvering and | 52 ;; - "Hot-spot" operation, for single-keystroke maneuvering and |
53 ;; exposure control (see the allout-mode docstring) | 53 ;; exposure control (see the allout-mode docstring) |
54 ;; - Easy rendering of exposed portions into numbered, latex, indented, etc | 54 ;; - Easy rendering of exposed portions into numbered, latex, indented, etc |
55 ;; outline styles | 55 ;; outline styles |
56 ;; - Careful attention to whitespace - enabling blank lines between items | 56 ;; - Careful attention to whitespace -- enabling blank lines between items |
57 ;; and maintenance of hanging indentation (in paragraph auto-fill and | 57 ;; and maintenance of hanging indentation (in paragraph auto-fill and |
58 ;; across topic promotion and demotion) of topic bodies consistent with | 58 ;; across topic promotion and demotion) of topic bodies consistent with |
59 ;; indentation of their topic header. | 59 ;; indentation of their topic header. |
60 ;; | 60 ;; |
61 ;; and more. | 61 ;; and more. |
74 ;; See the docstring of the variables `allout-layout' and | 74 ;; See the docstring of the variables `allout-layout' and |
75 ;; `allout-auto-activation' for details on automatic activation of | 75 ;; `allout-auto-activation' for details on automatic activation of |
76 ;; `allout-mode' as a minor mode. (It has changed since allout | 76 ;; `allout-mode' as a minor mode. (It has changed since allout |
77 ;; 3.x, for those of you that depend on the old method.) | 77 ;; 3.x, for those of you that depend on the old method.) |
78 ;; | 78 ;; |
79 ;; Note - the lines beginning with `;;;_' are outline topic headers. | 79 ;; Note -- the lines beginning with `;;;_' are outline topic headers. |
80 ;; Just `ESC-x eval-buffer' to give it a whirl. | 80 ;; Just `ESC-x eval-buffer' to give it a whirl. |
81 | 81 |
82 ;; ken manheimer (ken dot manheimer at gmail dot com) | 82 ;; ken manheimer (ken dot manheimer at gmail dot com) |
83 | 83 |
84 ;;; Code: | 84 ;;; Code: |
109 | 109 |
110 ;;;_ + Layout, Mode, and Topic Header Configuration | 110 ;;;_ + Layout, Mode, and Topic Header Configuration |
111 | 111 |
112 ;;;_ = allout-auto-activation | 112 ;;;_ = allout-auto-activation |
113 (defcustom allout-auto-activation nil | 113 (defcustom allout-auto-activation nil |
114 "*Regulates auto-activation modality of allout outlines - see `allout-init'. | 114 "*Regulates auto-activation modality of allout outlines -- see `allout-init'. |
115 | 115 |
116 Setq-default by `allout-init' to regulate whether or not allout | 116 Setq-default by `allout-init' to regulate whether or not allout |
117 outline mode is automatically activated when the buffer-specific | 117 outline mode is automatically activated when the buffer-specific |
118 variable `allout-layout' is non-nil, and whether or not the layout | 118 variable `allout-layout' is non-nil, and whether or not the layout |
119 dictated by `allout-layout' should be imposed on mode activation. | 119 dictated by `allout-layout' should be imposed on mode activation. |
151 value will automatically trigger `allout-mode', provided | 151 value will automatically trigger `allout-mode', provided |
152 `allout-init' has been called to enable this behavior. | 152 `allout-init' has been called to enable this behavior. |
153 | 153 |
154 The types of elements in the layout specification are: | 154 The types of elements in the layout specification are: |
155 | 155 |
156 integer - dictate the relative depth to open the corresponding topic(s), | 156 INTEGER -- dictate the relative depth to open the corresponding topic(s), |
157 where: | 157 where: |
158 - negative numbers force the topic to be closed before opening | 158 -- negative numbers force the topic to be closed before opening |
159 to the absolute value of the number, so all siblings are open | 159 to the absolute value of the number, so all siblings are open |
160 only to that level. | 160 only to that level. |
161 - positive numbers open to the relative depth indicated by the | 161 -- positive numbers open to the relative depth indicated by the |
162 number, but do not force already opened subtopics to be closed. | 162 number, but do not force already opened subtopics to be closed. |
163 - 0 means to close topic - hide all subitems. | 163 -- 0 means to close topic -- hide all subitems. |
164 : - repeat spec - apply the preceeding element to all siblings at | 164 : -- repeat spec -- apply the preceeding element to all siblings at |
165 current level, *up to* those siblings that would be covered by specs | 165 current level, *up to* those siblings that would be covered by specs |
166 following the `:' on the list. Ie, apply to all topics at level but | 166 following the `:' on the list. Ie, apply to all topics at level but |
167 trailing ones accounted for by trailing specs. (Only the first of | 167 trailing ones accounted for by trailing specs. (Only the first of |
168 multiple colons at the same level is honored - later ones are ignored.) | 168 multiple colons at the same level is honored -- later ones are ignored.) |
169 * - completely exposes the topic, including bodies | 169 * -- completely exposes the topic, including bodies |
170 + - exposes all subtopics, but not the bodies | 170 + -- exposes all subtopics, but not the bodies |
171 - - exposes the body of the corresponding topic, but not subtopics | 171 - -- exposes the body of the corresponding topic, but not subtopics |
172 list - a nested layout spec, to be applied intricately to its | 172 LIST -- a nested layout spec, to be applied intricately to its |
173 corresponding item(s) | 173 corresponding item(s) |
174 | 174 |
175 Examples: | 175 Examples: |
176 '(-2 : 0) | 176 (-2 : 0) |
177 Collapse the top-level topics to show their children and | 177 Collapse the top-level topics to show their children and |
178 grandchildren, but completely collapse the final top-level topic. | 178 grandchildren, but completely collapse the final top-level topic. |
179 '(-1 () : 1 0) | 179 (-1 () : 1 0) |
180 Close the first topic so only the immediate subtopics are shown, | 180 Close the first topic so only the immediate subtopics are shown, |
181 leave the subsequent topics exposed as they are until the second | 181 leave the subsequent topics exposed as they are until the second |
182 second to last topic, which is exposed at least one level, and | 182 second to last topic, which is exposed at least one level, and |
183 completely close the last topic. | 183 completely close the last topic. |
184 '(-2 : -1 *) | 184 (-2 : -1 *) |
185 Expose children and grandchildren of all topics at current | 185 Expose children and grandchildren of all topics at current |
186 level except the last two; expose children of the second to | 186 level except the last two; expose children of the second to |
187 last and completely expose the last one, including its subtopics. | 187 last and completely expose the last one, including its subtopics. |
188 | 188 |
189 See `allout-expose-topic' for more about the exposure process. | 189 See `allout-expose-topic' for more about the exposure process. |
251 "*If non-nil, \\[allout-end-of-line] will cycle through smart-placement options. | 251 "*If non-nil, \\[allout-end-of-line] will cycle through smart-placement options. |
252 | 252 |
253 Cycling only happens on when the command is repeated, not when it | 253 Cycling only happens on when the command is repeated, not when it |
254 follows a different command. | 254 follows a different command. |
255 | 255 |
256 Smart-placement means that repeated calls to this function will | 256 Smart placement means that repeated calls to this function will |
257 advance as follows: | 257 advance as follows: |
258 | 258 |
259 - if the cursor is not on the end-of-line, | 259 - if the cursor is not on the end-of-line, |
260 then it goes to the end-of-line | 260 then it goes to the end-of-line |
261 - if the cursor is on the end-of-line but not the end-of-entry, | 261 - if the cursor is on the end-of-line but not the end-of-entry, |
333 otherwise automatically rebulleted, so their marking is | 333 otherwise automatically rebulleted, so their marking is |
334 persistent until deliberately changed. Their significance is | 334 persistent until deliberately changed. Their significance is |
335 purely by convention, however. Some conventions suggest | 335 purely by convention, however. Some conventions suggest |
336 themselves: | 336 themselves: |
337 | 337 |
338 `(' - open paren - an aside or incidental point | 338 `(' - open paren -- an aside or incidental point |
339 `?' - question mark - uncertain or outright question | 339 `?' - question mark -- uncertain or outright question |
340 `!' - exclamation point/bang - emphatic | 340 `!' - exclamation point/bang -- emphatic |
341 `[' - open square bracket - meta-note, about item instead of item's subject | 341 `[' - open square bracket -- meta-note, about item instead of item's subject |
342 `\"' - double quote - a quotation or other citation | 342 `\"' - double quote -- a quotation or other citation |
343 `=' - equal sign - an assignement, equating a name with some connotation | 343 `=' - equal sign -- an assignement, equating a name with some connotation |
344 `^' - carat - relates to something above | 344 `^' - carat -- relates to something above |
345 | 345 |
346 Some are more elusive, but their rationale may be recognizable: | 346 Some are more elusive, but their rationale may be recognizable: |
347 | 347 |
348 `+' - plus - pending consideration, completion | 348 `+' - plus -- pending consideration, completion |
349 `_' - underscore - done, completed | 349 `_' - underscore -- done, completed |
350 `&' - ampersand - addendum, furthermore | 350 `&' - ampersand -- addendum, furthermore |
351 | 351 |
352 \(Some other non-plain bullets have special meaning to the | 352 \(Some other non-plain bullets have special meaning to the |
353 software. By default: | 353 software. By default: |
354 | 354 |
355 `~' marks encryptable topics - see `allout-topic-encryption-bullet' | 355 `~' marks encryptable topics -- see `allout-topic-encryption-bullet' |
356 `#' marks auto-numbered bullets - see `allout-numbered-bullet'.) | 356 `#' marks auto-numbered bullets -- see `allout-numbered-bullet'.) |
357 | 357 |
358 See `allout-plain-bullets-string' for the standard, alternating | 358 See `allout-plain-bullets-string' for the standard, alternating |
359 bullets. | 359 bullets. |
360 | 360 |
361 You must run `set-allout-regexp' in order for outline mode to | 361 You must run `set-allout-regexp' in order for outline mode to |
434 :group 'allout) | 434 :group 'allout) |
435 (make-variable-buffer-local 'allout-old-style-prefixes) | 435 (make-variable-buffer-local 'allout-old-style-prefixes) |
436 ;;;###autoload | 436 ;;;###autoload |
437 (put 'allout-old-style-prefixes 'safe-local-variable | 437 (put 'allout-old-style-prefixes 'safe-local-variable |
438 (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil))))) | 438 (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil))))) |
439 ;;;_ = allout-stylish-prefixes - alternating bullets | 439 ;;;_ = allout-stylish-prefixes -- alternating bullets |
440 (defcustom allout-stylish-prefixes t | 440 (defcustom allout-stylish-prefixes t |
441 "*Do fancy stuff with topic prefix bullets according to level, etc. | 441 "*Do fancy stuff with topic prefix bullets according to level, etc. |
442 | 442 |
443 Non-nil enables topic creation, modification, and repositioning | 443 Non-nil enables topic creation, modification, and repositioning |
444 functions to vary the topic bullet char (the char that marks the topic | 444 functions to vary the topic bullet char (the char that marks the topic |
598 (make-variable-buffer-local 'allout-passphrase-verifier-handling) | 598 (make-variable-buffer-local 'allout-passphrase-verifier-handling) |
599 ;;;_ = allout-passphrase-hint-handling | 599 ;;;_ = allout-passphrase-hint-handling |
600 (defcustom allout-passphrase-hint-handling 'always | 600 (defcustom allout-passphrase-hint-handling 'always |
601 "*Dictate outline encryption passphrase reminder handling: | 601 "*Dictate outline encryption passphrase reminder handling: |
602 | 602 |
603 always - always show reminder when prompting | 603 always -- always show reminder when prompting |
604 needed - show reminder on passphrase entry failure | 604 needed -- show reminder on passphrase entry failure |
605 disabled - never present or adjust reminder | 605 disabled -- never present or adjust reminder |
606 | 606 |
607 See the docstring for the `allout-enable-file-variable-adjustment' | 607 See the docstring for the `allout-enable-file-variable-adjustment' |
608 variable for details about allout ajustment of file variables." | 608 variable for details about allout ajustment of file variables." |
609 :type '(choice (const always) | 609 :type '(choice (const always) |
610 (const needed) | 610 (const needed) |
623 currently being edited. (In that case, the currently edited topic | 623 currently being edited. (In that case, the currently edited topic |
624 will be automatically decrypted before any user interaction, so they | 624 will be automatically decrypted before any user interaction, so they |
625 can continue editing but the copy on the file system will be | 625 can continue editing but the copy on the file system will be |
626 encrypted.) | 626 encrypted.) |
627 Auto-saves will use the \"All except current topic\" mode if this | 627 Auto-saves will use the \"All except current topic\" mode if this |
628 one is selected, to avoid practical difficulties - see below. | 628 one is selected, to avoid practical difficulties -- see below. |
629 - All except current topic: skip the topic currently being edited, even if | 629 - All except current topic: skip the topic currently being edited, even if |
630 it's pending encryption. This may expose the current topic on the | 630 it's pending encryption. This may expose the current topic on the |
631 file sytem, but avoids the nuisance of prompts for the encryption | 631 file sytem, but avoids the nuisance of prompts for the encryption |
632 passphrase in the middle of editing for, eg, autosaves. | 632 passphrase in the middle of editing for, eg, autosaves. |
633 This mode is used for auto-saves for both this option and \"Yes\". | 633 This mode is used for auto-saves for both this option and \"Yes\". |
675 willing to let allout use a bunch of \C-c keybindings." | 675 willing to let allout use a bunch of \C-c keybindings." |
676 :type 'string | 676 :type 'string |
677 :group 'allout) | 677 :group 'allout) |
678 | 678 |
679 ;;;_ = allout-keybindings-list | 679 ;;;_ = allout-keybindings-list |
680 ;;; You have to reactivate allout-mode - `(allout-mode t)' - to | 680 ;;; You have to reactivate allout-mode -- `(allout-mode t)' -- to |
681 ;;; institute changes to this var. | 681 ;;; institute changes to this var. |
682 (defvar allout-keybindings-list () | 682 (defvar allout-keybindings-list () |
683 "*List of `allout-mode' key / function bindings, for `allout-mode-map'. | 683 "*List of `allout-mode' key / function bindings, for `allout-mode-map'. |
684 | 684 |
685 String or vector key will be prefaced with `allout-command-prefix', | 685 String or vector key will be prefaced with `allout-command-prefix', |
790 For details, see `allout-toggle-current-subtree-encryption's docstring." | 790 For details, see `allout-toggle-current-subtree-encryption's docstring." |
791 :type 'boolean | 791 :type 'boolean |
792 :group 'allout) | 792 :group 'allout) |
793 (make-variable-buffer-local 'allout-enable-file-variable-adjustment) | 793 (make-variable-buffer-local 'allout-enable-file-variable-adjustment) |
794 | 794 |
795 ;;;_* CODE - no user customizations below. | 795 ;;;_* CODE -- no user customizations below. |
796 | 796 |
797 ;;;_ #1 Internal Outline Formatting and Configuration | 797 ;;;_ #1 Internal Outline Formatting and Configuration |
798 ;;;_ : Version | 798 ;;;_ : Version |
799 ;;;_ = allout-version | 799 ;;;_ = allout-version |
800 (defvar allout-version "2.2.1" | 800 (defvar allout-version "2.2.1" |
810 ;;;_ : Mode activation (defined here because it's referenced early) | 810 ;;;_ : Mode activation (defined here because it's referenced early) |
811 ;;;_ = allout-mode | 811 ;;;_ = allout-mode |
812 (defvar allout-mode nil "Allout outline mode minor-mode flag.") | 812 (defvar allout-mode nil "Allout outline mode minor-mode flag.") |
813 (make-variable-buffer-local 'allout-mode) | 813 (make-variable-buffer-local 'allout-mode) |
814 ;;;_ = allout-layout nil | 814 ;;;_ = allout-layout nil |
815 (defvar allout-layout nil ; LEAVE GLOBAL VALUE NIL - see docstring. | 815 (defvar allout-layout nil ; LEAVE GLOBAL VALUE NIL -- see docstring. |
816 "Buffer-specific setting for allout layout. | 816 "Buffer-specific setting for allout layout. |
817 | 817 |
818 In buffers where this is non-nil (and if `allout-init' has been run, to | 818 In buffers where this is non-nil (and if `allout-init' has been run, to |
819 enable this behavior), `allout-mode' will be automatically activated. The | 819 enable this behavior), `allout-mode' will be automatically activated. The |
820 layout dictated by the value will be used to set the initial exposure when | 820 layout dictated by the value will be used to set the initial exposure when |
854 (make-variable-buffer-local 'allout-regexp) | 854 (make-variable-buffer-local 'allout-regexp) |
855 ;;;_ = allout-bullets-string | 855 ;;;_ = allout-bullets-string |
856 (defvar allout-bullets-string "" | 856 (defvar allout-bullets-string "" |
857 "A string dictating the valid set of outline topic bullets. | 857 "A string dictating the valid set of outline topic bullets. |
858 | 858 |
859 This var should *not* be set by the user - it is set by `set-allout-regexp', | 859 This var should *not* be set by the user -- it is set by `set-allout-regexp', |
860 and is produced from the elements of `allout-plain-bullets-string' | 860 and is produced from the elements of `allout-plain-bullets-string' |
861 and `allout-distinctive-bullets-string'.") | 861 and `allout-distinctive-bullets-string'.") |
862 (make-variable-buffer-local 'allout-bullets-string) | 862 (make-variable-buffer-local 'allout-bullets-string) |
863 ;;;_ = allout-bullets-string-len | 863 ;;;_ = allout-bullets-string-len |
864 (defvar allout-bullets-string-len 0 | 864 (defvar allout-bullets-string-len 0 |
952 (memq allout-use-mode-specific-leader | 952 (memq allout-use-mode-specific-leader |
953 '(allout-mode-leaders | 953 '(allout-mode-leaders |
954 comment-start | 954 comment-start |
955 t))) | 955 t))) |
956 allout-use-mode-specific-leader | 956 allout-use-mode-specific-leader |
957 ;; Oops - garbled value, equate with effect of 't: | 957 ;; Oops -- garbled value, equate with effect of t: |
958 t))) | 958 t))) |
959 (leader | 959 (leader |
960 (cond | 960 (cond |
961 ((not use-leader) nil) | 961 ((not use-leader) nil) |
962 ;; Use the explicitly designated leader: | 962 ;; Use the explicitly designated leader: |
981 (if (not leader) | 981 (if (not leader) |
982 nil | 982 nil |
983 (setq allout-header-prefix leader) | 983 (setq allout-header-prefix leader) |
984 (if (not allout-old-style-prefixes) | 984 (if (not allout-old-style-prefixes) |
985 ;; setting allout-primary-bullet makes the top level topics use - | 985 ;; setting allout-primary-bullet makes the top level topics use - |
986 ;; actually, be - the special prefix: | 986 ;; actually, be -- the special prefix: |
987 (setq allout-primary-bullet leader)) | 987 (setq allout-primary-bullet leader)) |
988 allout-header-prefix))) | 988 allout-header-prefix))) |
989 (defalias 'allout-infer-header-lead | 989 (defalias 'allout-infer-header-lead |
990 'allout-infer-header-lead-and-primary-bullet) | 990 'allout-infer-header-lead-and-primary-bullet) |
991 ;;;_ > allout-infer-body-reindent () | 991 ;;;_ > allout-infer-body-reindent () |
1237 If the optional third element is the symbol 'append, then the new value is | 1237 If the optional third element is the symbol 'append, then the new value is |
1238 extended from the existing one by `append'ing a list containing the second | 1238 extended from the existing one by `append'ing a list containing the second |
1239 element of the pair onto the end of the existing value. | 1239 element of the pair onto the end of the existing value. |
1240 | 1240 |
1241 Extension, and resumptions in general, should not be used for hook | 1241 Extension, and resumptions in general, should not be used for hook |
1242 functions - use the 'local mode of `add-hook' for that, instead. | 1242 functions -- use the 'local mode of `add-hook' for that, instead. |
1243 | 1243 |
1244 The settings are stored on `allout-mode-prior-settings'." | 1244 The settings are stored on `allout-mode-prior-settings'." |
1245 (while pairs | 1245 (while pairs |
1246 (let* ((pair (pop pairs)) | 1246 (let* ((pair (pop pairs)) |
1247 (name (car pair)) | 1247 (name (car pair)) |
1256 (symbol-value name) | 1256 (symbol-value name) |
1257 (void-variable nil))) | 1257 (void-variable nil))) |
1258 (when (not (assoc name allout-mode-prior-settings)) | 1258 (when (not (assoc name allout-mode-prior-settings)) |
1259 ;; Not already added as a resumption, create the prior setting entry. | 1259 ;; Not already added as a resumption, create the prior setting entry. |
1260 (if (local-variable-p name) | 1260 (if (local-variable-p name) |
1261 ;; is already local variable - preserve the prior value: | 1261 ;; is already local variable -- preserve the prior value: |
1262 (push (list name prior-value) allout-mode-prior-settings) | 1262 (push (list name prior-value) allout-mode-prior-settings) |
1263 ;; wasn't local variable, indicate so for resumption by killing | 1263 ;; wasn't local variable, indicate so for resumption by killing |
1264 ;; local value, and make it local: | 1264 ;; local value, and make it local: |
1265 (push (list name) allout-mode-prior-settings) | 1265 (push (list name) allout-mode-prior-settings) |
1266 (make-local-variable name))) | 1266 (make-local-variable name))) |
1322 | 1322 |
1323 It is run at the conclusion of `allout-flag-region'. | 1323 It is run at the conclusion of `allout-flag-region'. |
1324 | 1324 |
1325 Functions on the hook must take three arguments: | 1325 Functions on the hook must take three arguments: |
1326 | 1326 |
1327 - from - integer indicating the point at the start of the change. | 1327 - FROM -- integer indicating the point at the start of the change. |
1328 - to - integer indicating the point of the end of the change. | 1328 - TO -- integer indicating the point of the end of the change. |
1329 - flag - change mode: nil for exposure, otherwise concealment. | 1329 - FLAG -- change mode: nil for exposure, otherwise concealment. |
1330 | 1330 |
1331 This hook might be invoked multiple times by a single command. | 1331 This hook might be invoked multiple times by a single command. |
1332 | 1332 |
1333 This hook is replacing `allout-view-change-hook', which is being deprecated | 1333 This hook is replacing `allout-view-change-hook', which is being deprecated |
1334 and eventually will not be invoked.") | 1334 and eventually will not be invoked.") |
1336 (defvar allout-structure-added-hook nil | 1336 (defvar allout-structure-added-hook nil |
1337 "*Hook that's run after addition of items to the outline. | 1337 "*Hook that's run after addition of items to the outline. |
1338 | 1338 |
1339 Functions on the hook should take two arguments: | 1339 Functions on the hook should take two arguments: |
1340 | 1340 |
1341 - new-start - integer indicating the point at the start of the first new item. | 1341 - NEW-START -- integer indicating position of start of the first new item. |
1342 - new-end - integer indicating the point of the end of the last new item. | 1342 - NEW-END -- integer indicating position of end of the last new item. |
1343 | 1343 |
1344 Some edits that introduce new items may missed by this hook - | 1344 Some edits that introduce new items may missed by this hook: |
1345 specifically edits that native allout routines do not control. | 1345 specifically edits that native allout routines do not control. |
1346 | 1346 |
1347 This hook might be invoked multiple times by a single command.") | 1347 This hook might be invoked multiple times by a single command.") |
1348 ;;;_ = allout-structure-deleted-hook | 1348 ;;;_ = allout-structure-deleted-hook |
1349 (defvar allout-structure-deleted-hook nil | 1349 (defvar allout-structure-deleted-hook nil |
1350 "*Hook that's run after disciplined deletion of subtrees from the outline. | 1350 "*Hook that's run after disciplined deletion of subtrees from the outline. |
1351 | 1351 |
1352 Functions on the hook must take two arguments: | 1352 Functions on the hook must take two arguments: |
1353 | 1353 |
1354 - depth - integer indicating the depth of the subtree that was deleted. | 1354 - DEPTH -- integer indicating the depth of the subtree that was deleted. |
1355 - removed-from - integer indicating the point where the subtree was removed. | 1355 - REMOVED-FROM -- integer indicating the point where the subtree was removed. |
1356 | 1356 |
1357 Some edits that remove or invalidate items may missed by this hook - | 1357 Some edits that remove or invalidate items may missed by this hook: |
1358 specifically edits that native allout routines do not control. | 1358 specifically edits that native allout routines do not control. |
1359 | 1359 |
1360 This hook might be invoked multiple times by a single command.") | 1360 This hook might be invoked multiple times by a single command.") |
1361 ;;;_ = allout-structure-shifted-hook | 1361 ;;;_ = allout-structure-shifted-hook |
1362 (defvar allout-structure-shifted-hook nil | 1362 (defvar allout-structure-shifted-hook nil |
1363 "*Hook that's run after shifting of items in the outline. | 1363 "*Hook that's run after shifting of items in the outline. |
1364 | 1364 |
1365 Functions on the hook should take two arguments: | 1365 Functions on the hook should take two arguments: |
1366 | 1366 |
1367 - depth-change - integer indicating depth increase, negative for decrease | 1367 - DEPTH-CHANGE -- integer indicating depth increase, negative for decrease |
1368 - start - integer indicating the start point of the shifted parent item. | 1368 - START -- integer indicating the start point of the shifted parent item. |
1369 | 1369 |
1370 Some edits that shift items can be missed by this hook - specifically edits | 1370 Some edits that shift items can be missed by this hook: specifically edits |
1371 that native allout routines do not control. | 1371 that native allout routines do not control. |
1372 | 1372 |
1373 This hook might be invoked multiple times by a single command.") | 1373 This hook might be invoked multiple times by a single command.") |
1374 ;;;_ = allout-outside-normal-auto-fill-function | 1374 ;;;_ = allout-outside-normal-auto-fill-function |
1375 (defvar allout-outside-normal-auto-fill-function nil | 1375 (defvar allout-outside-normal-auto-fill-function nil |
1460 | 1460 |
1461 See `allout-encryption-ciphertext-rejection-regexps' for rejection reasons.") | 1461 See `allout-encryption-ciphertext-rejection-regexps' for rejection reasons.") |
1462 (make-variable-buffer-local 'allout-encryption-ciphertext-rejection-ceiling) | 1462 (make-variable-buffer-local 'allout-encryption-ciphertext-rejection-ceiling) |
1463 ;;;_ > allout-mode-p () | 1463 ;;;_ > allout-mode-p () |
1464 ;; Must define this macro above any uses, or byte compilation will lack | 1464 ;; Must define this macro above any uses, or byte compilation will lack |
1465 ;; proper def, if file isn't loaded - eg, during emacs build! | 1465 ;; proper def, if file isn't loaded -- eg, during emacs build! |
1466 (defmacro allout-mode-p () | 1466 (defmacro allout-mode-p () |
1467 "Return t if `allout-mode' is active in current buffer." | 1467 "Return t if `allout-mode' is active in current buffer." |
1468 'allout-mode) | 1468 'allout-mode) |
1469 ;;;_ > allout-write-file-hook-handler () | 1469 ;;;_ > allout-write-file-hook-handler () |
1470 (defun allout-write-file-hook-handler () | 1470 (defun allout-write-file-hook-handler () |
1636 (setplist 'allout-exposure-category nil) | 1636 (setplist 'allout-exposure-category nil) |
1637 (put 'allout-exposure-category 'invisible 'allout) | 1637 (put 'allout-exposure-category 'invisible 'allout) |
1638 (put 'allout-exposure-category 'evaporate t) | 1638 (put 'allout-exposure-category 'evaporate t) |
1639 ;; XXX We use isearch-open-invisible *and* isearch-mode-end-hook. The | 1639 ;; XXX We use isearch-open-invisible *and* isearch-mode-end-hook. The |
1640 ;; latter would be sufficient, but it seems that a separate behavior - | 1640 ;; latter would be sufficient, but it seems that a separate behavior - |
1641 ;; the _transient_ opening of invisible text during isearch - is keyed to | 1641 ;; the _transient_ opening of invisible text during isearch -- is keyed to |
1642 ;; presence of the isearch-open-invisible property - even though this | 1642 ;; presence of the isearch-open-invisible property -- even though this |
1643 ;; property controls the isearch _arrival_ behavior. This is the case at | 1643 ;; property controls the isearch _arrival_ behavior. This is the case at |
1644 ;; least in emacs 21, 22.0, and xemacs 21.4. | 1644 ;; least in emacs 21, 22.0, and xemacs 21.4. |
1645 (put 'allout-exposure-category 'isearch-open-invisible | 1645 (put 'allout-exposure-category 'isearch-open-invisible |
1646 'allout-isearch-end-handler) | 1646 'allout-isearch-end-handler) |
1647 (if (featurep 'xemacs) | 1647 (if (featurep 'xemacs) |
1691 The bindings are dictated by the customizable `allout-keybindings-list' | 1691 The bindings are dictated by the customizable `allout-keybindings-list' |
1692 variable. We recommend customizing `allout-command-prefix' to use just | 1692 variable. We recommend customizing `allout-command-prefix' to use just |
1693 `\\C-c' as the command prefix, if the allout bindings don't conflict with | 1693 `\\C-c' as the command prefix, if the allout bindings don't conflict with |
1694 any personal bindings you have on \\C-c. In any case, outline structure | 1694 any personal bindings you have on \\C-c. In any case, outline structure |
1695 navigation and authoring is simplified by positioning the cursor on an | 1695 navigation and authoring is simplified by positioning the cursor on an |
1696 item's bullet character, the \"hot-spot\" - then you can invoke allout | 1696 item's bullet character, the \"hot-spot\" -- then you can invoke allout |
1697 commands with just the un-prefixed, un-control-shifted command letters. | 1697 commands with just the un-prefixed, un-control-shifted command letters. |
1698 This is described further in the HOT-SPOT Operation section. | 1698 This is described further in the HOT-SPOT Operation section. |
1699 | 1699 |
1700 Exposure Control: | 1700 Exposure Control: |
1701 ---------------- | 1701 ---------------- |
1712 \\[allout-up-current-level] `allout-up-current-level' | 1712 \\[allout-up-current-level] `allout-up-current-level' |
1713 \\[allout-forward-current-level] `allout-forward-current-level' | 1713 \\[allout-forward-current-level] `allout-forward-current-level' |
1714 \\[allout-backward-current-level] `allout-backward-current-level' | 1714 \\[allout-backward-current-level] `allout-backward-current-level' |
1715 \\[allout-end-of-entry] `allout-end-of-entry' | 1715 \\[allout-end-of-entry] `allout-end-of-entry' |
1716 \\[allout-beginning-of-current-entry] `allout-beginning-of-current-entry' (alternately, goes to hot-spot) | 1716 \\[allout-beginning-of-current-entry] `allout-beginning-of-current-entry' (alternately, goes to hot-spot) |
1717 \\[allout-beginning-of-line] `allout-beginning-of-line' - like regular beginning-of-line, but | 1717 \\[allout-beginning-of-line] `allout-beginning-of-line' -- like regular beginning-of-line, but |
1718 if immediately repeated cycles to the beginning of the current item | 1718 if immediately repeated cycles to the beginning of the current item |
1719 and then to the hot-spot (if `allout-beginning-of-line-cycles' is set). | 1719 and then to the hot-spot (if `allout-beginning-of-line-cycles' is set). |
1720 | 1720 |
1721 | 1721 |
1722 Topic Header Production: | 1722 Topic Header Production: |
1730 \\[allout-shift-in] `allout-shift-in' Shift current topic and all offspring deeper | 1730 \\[allout-shift-in] `allout-shift-in' Shift current topic and all offspring deeper |
1731 \\[allout-shift-out] `allout-shift-out' ... less deep | 1731 \\[allout-shift-out] `allout-shift-out' ... less deep |
1732 \\[allout-rebullet-current-heading] `allout-rebullet-current-heading' Prompt for alternate bullet for | 1732 \\[allout-rebullet-current-heading] `allout-rebullet-current-heading' Prompt for alternate bullet for |
1733 current topic | 1733 current topic |
1734 \\[allout-rebullet-topic] `allout-rebullet-topic' Reconcile bullets of topic and | 1734 \\[allout-rebullet-topic] `allout-rebullet-topic' Reconcile bullets of topic and |
1735 its' offspring - distinctive bullets are not changed, others | 1735 its' offspring -- distinctive bullets are not changed, others |
1736 are alternated according to nesting depth. | 1736 are alternated according to nesting depth. |
1737 \\[allout-number-siblings] `allout-number-siblings' Number bullets of topic and siblings - | 1737 \\[allout-number-siblings] `allout-number-siblings' Number bullets of topic and siblings - |
1738 the offspring are not affected. | 1738 the offspring are not affected. |
1739 With repeat count, revoke numbering. | 1739 With repeat count, revoke numbering. |
1740 | 1740 |
1761 for `allout-layout'. | 1761 for `allout-layout'. |
1762 \\[allout-mark-topic] `allout-mark-topic' | 1762 \\[allout-mark-topic] `allout-mark-topic' |
1763 \\[allout-copy-exposed-to-buffer] `allout-copy-exposed-to-buffer' | 1763 \\[allout-copy-exposed-to-buffer] `allout-copy-exposed-to-buffer' |
1764 Duplicate outline, sans concealed text, to | 1764 Duplicate outline, sans concealed text, to |
1765 buffer with name derived from derived from that | 1765 buffer with name derived from derived from that |
1766 of current buffer - \"*BUFFERNAME exposed*\". | 1766 of current buffer -- \"*BUFFERNAME exposed*\". |
1767 \\[allout-flatten-exposed-to-buffer] `allout-flatten-exposed-to-buffer' | 1767 \\[allout-flatten-exposed-to-buffer] `allout-flatten-exposed-to-buffer' |
1768 Like above 'copy-exposed', but convert topic | 1768 Like above 'copy-exposed', but convert topic |
1769 prefixes to section.subsection... numeric | 1769 prefixes to section.subsection... numeric |
1770 format. | 1770 format. |
1771 \\[eval-expression] (allout-init t) Setup Emacs session for outline mode | 1771 \\[eval-expression] (allout-init t) Setup Emacs session for outline mode |
1830 `allout-structure-deleted-hook' | 1830 `allout-structure-deleted-hook' |
1831 `allout-structure-shifted-hook' | 1831 `allout-structure-shifted-hook' |
1832 | 1832 |
1833 Terminology | 1833 Terminology |
1834 | 1834 |
1835 Topic hierarchy constituents - TOPICS and SUBTOPICS: | 1835 Topic hierarchy constituents -- TOPICS and SUBTOPICS: |
1836 | 1836 |
1837 ITEM: A unitary outline element, including the HEADER and ENTRY text. | 1837 ITEM: A unitary outline element, including the HEADER and ENTRY text. |
1838 TOPIC: An ITEM and any ITEMs contained within it, ie having greater DEPTH | 1838 TOPIC: An ITEM and any ITEMs contained within it, ie having greater DEPTH |
1839 and with no intervening items of lower DEPTH than the container. | 1839 and with no intervening items of lower DEPTH than the container. |
1840 CURRENT ITEM: | 1840 CURRENT ITEM: |
2083 (allout-this-or-next-heading) | 2083 (allout-this-or-next-heading) |
2084 (condition-case err | 2084 (condition-case err |
2085 (progn | 2085 (progn |
2086 (apply 'allout-expose-topic (list use-layout)) | 2086 (apply 'allout-expose-topic (list use-layout)) |
2087 (message "Adjusting '%s' exposure... done." (buffer-name))) | 2087 (message "Adjusting '%s' exposure... done." (buffer-name))) |
2088 ;; Problem applying exposure - notify user, but don't | 2088 ;; Problem applying exposure -- notify user, but don't |
2089 ;; interrupt, eg, file visit: | 2089 ;; interrupt, eg, file visit: |
2090 (error (message "%s" (car (cdr err))) | 2090 (error (message "%s" (car (cdr err))) |
2091 (sit-for 1)))))) | 2091 (sit-for 1)))))) |
2092 allout-mode | 2092 allout-mode |
2093 ) ; let* | 2093 ) ; let* |
2151 | 2151 |
2152 We expose the invisible text and ask for confirmation. Refusal or | 2152 We expose the invisible text and ask for confirmation. Refusal or |
2153 `keyboard-quit' abandons the changes, with keyboard-quit additionally | 2153 `keyboard-quit' abandons the changes, with keyboard-quit additionally |
2154 reclosing the opened text. | 2154 reclosing the opened text. |
2155 | 2155 |
2156 No confirmation is necessary when `inhibit-read-only' is set - eg, allout | 2156 No confirmation is necessary when `inhibit-read-only' is set -- eg, allout |
2157 internal functions use this feature cohesively bunch changes." | 2157 internal functions use this feature cohesively bunch changes." |
2158 | 2158 |
2159 (when (and (not inhibit-read-only) (not after)) | 2159 (when (and (not inhibit-read-only) (not after)) |
2160 (let ((start (point)) | 2160 (let ((start (point)) |
2161 (ol-start (overlay-start ol)) | 2161 (ol-start (overlay-start ol)) |
2189 (goto-char start)))) | 2189 (goto-char start)))) |
2190 ;;;_ > allout-before-change-handler (beg end) | 2190 ;;;_ > allout-before-change-handler (beg end) |
2191 (defun allout-before-change-handler (beg end) | 2191 (defun allout-before-change-handler (beg end) |
2192 "Protect against changes to invisible text. | 2192 "Protect against changes to invisible text. |
2193 | 2193 |
2194 See allout-overlay-interior-modification-handler for details." | 2194 See `allout-overlay-interior-modification-handler' for details." |
2195 | 2195 |
2196 (if (and (allout-mode-p) undo-in-progress (allout-hidden-p)) | 2196 (if (and (allout-mode-p) undo-in-progress (allout-hidden-p)) |
2197 (allout-show-to-offshoot)) | 2197 (allout-show-to-offshoot)) |
2198 | 2198 |
2199 ;; allout-overlay-interior-modification-handler on an overlay handles | 2199 ;; allout-overlay-interior-modification-handler on an overlay handles |
2214 function can also be used as an `isearch-mode-end-hook'." | 2214 function can also be used as an `isearch-mode-end-hook'." |
2215 | 2215 |
2216 (if (and (allout-mode-p) (allout-hidden-p)) | 2216 (if (and (allout-mode-p) (allout-hidden-p)) |
2217 (allout-show-to-offshoot))) | 2217 (allout-show-to-offshoot))) |
2218 | 2218 |
2219 ;;;_ #3 Internal Position State-Tracking - "allout-recent-*" funcs | 2219 ;;;_ #3 Internal Position State-Tracking -- "allout-recent-*" funcs |
2220 ;;; All the basic outline functions that directly do string matches to | 2220 ;;; All the basic outline functions that directly do string matches to |
2221 ;;; evaluate heading prefix location set the variables | 2221 ;;; evaluate heading prefix location set the variables |
2222 ;;; `allout-recent-prefix-beginning' and `allout-recent-prefix-end' | 2222 ;;; `allout-recent-prefix-beginning' and `allout-recent-prefix-end' |
2223 ;;; when successful. Functions starting with `allout-recent-' all | 2223 ;;; when successful. Functions starting with `allout-recent-' all |
2224 ;;; use this state, providing the means to avoid redundant searches | 2224 ;;; use this state, providing the means to avoid redundant searches |
2297 ;;;_ : Location Predicates | 2297 ;;;_ : Location Predicates |
2298 ;;;_ > allout-do-doublecheck () | 2298 ;;;_ > allout-do-doublecheck () |
2299 (defsubst allout-do-doublecheck () | 2299 (defsubst allout-do-doublecheck () |
2300 "True if current item conditions qualify for checking on topic aberrance." | 2300 "True if current item conditions qualify for checking on topic aberrance." |
2301 (and | 2301 (and |
2302 ;; presume integrity of outline and yanked content during yank - necessary, | 2302 ;; presume integrity of outline and yanked content during yank -- necessary |
2303 ;; to allow for level disparity of yank location and yanked text: | 2303 ;; to allow for level disparity of yank location and yanked text: |
2304 (not allout-inhibit-aberrance-doublecheck) | 2304 (not allout-inhibit-aberrance-doublecheck) |
2305 ;; allout-doublecheck-at-and-shallower is ceiling for doublecheck: | 2305 ;; allout-doublecheck-at-and-shallower is ceiling for doublecheck: |
2306 (<= allout-recent-depth allout-doublecheck-at-and-shallower))) | 2306 (<= allout-recent-depth allout-doublecheck-at-and-shallower))) |
2307 ;;;_ > allout-aberrant-container-p () | 2307 ;;;_ > allout-aberrant-container-p () |
2334 (while (and (not done) | 2334 (while (and (not done) |
2335 (re-search-forward allout-line-boundary-regexp nil 0)) | 2335 (re-search-forward allout-line-boundary-regexp nil 0)) |
2336 (allout-prefix-data) | 2336 (allout-prefix-data) |
2337 (goto-char allout-recent-prefix-beginning) | 2337 (goto-char allout-recent-prefix-beginning) |
2338 (cond | 2338 (cond |
2339 ;; sibling - continue: | 2339 ;; sibling -- continue: |
2340 ((eq allout-recent-depth depth)) | 2340 ((eq allout-recent-depth depth)) |
2341 ;; first offspring is excessive - aberrant: | 2341 ;; first offspring is excessive -- aberrant: |
2342 ((> allout-recent-depth (1+ depth)) | 2342 ((> allout-recent-depth (1+ depth)) |
2343 (setq done t aberrant t)) | 2343 (setq done t aberrant t)) |
2344 ;; next non-sibling is lower-depth - not aberrant: | 2344 ;; next non-sibling is lower-depth -- not aberrant: |
2345 (t (setq done t))))) | 2345 (t (setq done t))))) |
2346 (if aberrant | 2346 (if aberrant |
2347 aberrant | 2347 aberrant |
2348 (goto-char start-point) | 2348 (goto-char start-point) |
2349 ;; recalibrate allout-recent-* | 2349 ;; recalibrate allout-recent-* |
2664 (< orig-depth (setq curr-depth allout-recent-depth)) | 2664 (< orig-depth (setq curr-depth allout-recent-depth)) |
2665 (cond ((= prev-depth curr-depth) | 2665 (cond ((= prev-depth curr-depth) |
2666 ;; Register this one and move on: | 2666 ;; Register this one and move on: |
2667 (setq chart (cons allout-recent-prefix-beginning chart)) | 2667 (setq chart (cons allout-recent-prefix-beginning chart)) |
2668 (if (and levels (<= levels 1)) | 2668 (if (and levels (<= levels 1)) |
2669 ;; At depth limit - skip sublevels: | 2669 ;; At depth limit -- skip sublevels: |
2670 (or (allout-next-sibling curr-depth) | 2670 (or (allout-next-sibling curr-depth) |
2671 ;; or no more siblings - proceed to | 2671 ;; or no more siblings -- proceed to |
2672 ;; next heading at lesser depth: | 2672 ;; next heading at lesser depth: |
2673 (while (and (<= curr-depth | 2673 (while (and (<= curr-depth |
2674 allout-recent-depth) | 2674 allout-recent-depth) |
2675 (if visible | 2675 (if visible |
2676 (allout-next-visible-heading 1) | 2676 (allout-next-visible-heading 1) |
2739 (setq here (car chart)) | 2739 (setq here (car chart)) |
2740 (if (listp here) | 2740 (if (listp here) |
2741 (let ((further (allout-chart-to-reveal here (if (null depth) | 2741 (let ((further (allout-chart-to-reveal here (if (null depth) |
2742 depth | 2742 depth |
2743 (1- depth))))) | 2743 (1- depth))))) |
2744 ;; We're on the start of a subtree - recurse with it, if there's | 2744 ;; We're on the start of a subtree -- recurse with it, if there's |
2745 ;; more depth to go: | 2745 ;; more depth to go: |
2746 (if further (setq result (append further result))) | 2746 (if further (setq result (append further result))) |
2747 (setq chart (cdr chart))) | 2747 (setq chart (cdr chart))) |
2748 (goto-char here) | 2748 (goto-char here) |
2749 (if (allout-hidden-p) | 2749 (if (allout-hidden-p) |
3124 (setq done (or found (if backward (bobp) (eobp))))) | 3124 (setq done (or found (if backward (bobp) (eobp))))) |
3125 (if (not found) | 3125 (if (not found) |
3126 (progn (goto-char start-point) | 3126 (progn (goto-char start-point) |
3127 nil) | 3127 nil) |
3128 ;; rationale: if any intervening items were at a lower depth, we | 3128 ;; rationale: if any intervening items were at a lower depth, we |
3129 ;; would now be on the first offspring at the target depth - ie, | 3129 ;; would now be on the first offspring at the target depth -- ie, |
3130 ;; the preceeding item (per the search direction) must be at a | 3130 ;; the preceeding item (per the search direction) must be at a |
3131 ;; lesser depth. that's all we need to check. | 3131 ;; lesser depth. that's all we need to check. |
3132 (if backward (allout-next-heading) (allout-previous-heading)) | 3132 (if backward (allout-next-heading) (allout-previous-heading)) |
3133 (if (< allout-recent-depth target-depth) | 3133 (if (< allout-recent-depth target-depth) |
3134 ;; return to start and reestablish allout-recent-*: | 3134 ;; return to start and reestablish allout-recent-*: |
3201 (allout-prefix-data) | 3201 (allout-prefix-data) |
3202 (if (and (allout-do-doublecheck) | 3202 (if (and (allout-do-doublecheck) |
3203 (allout-aberrant-container-p)) | 3203 (allout-aberrant-container-p)) |
3204 ;; skip this aberrant prospective header line: | 3204 ;; skip this aberrant prospective header line: |
3205 t | 3205 t |
3206 ;; this prospective headerline qualifies - register: | 3206 ;; this prospective headerline qualifies -- register: |
3207 (setq got allout-recent-prefix-beginning) | 3207 (setq got allout-recent-prefix-beginning) |
3208 ;; and break the loop: | 3208 ;; and break the loop: |
3209 nil)))) | 3209 nil)))) |
3210 ;; Register this got, it may be the last: | 3210 ;; Register this got, it may be the last: |
3211 (if got (setq prev got)) | 3211 (if got (setq prev got)) |
3369 (char-to-string | 3369 (char-to-string |
3370 (if (and (<= 97 key-num) ; "a" | 3370 (if (and (<= 97 key-num) ; "a" |
3371 (>= 122 key-num)) ; "z" | 3371 (>= 122 key-num)) ; "z" |
3372 (- key-num 96) key-num))) | 3372 (- key-num 96) key-num))) |
3373 t)))) | 3373 t)))) |
3374 ;; Qualified as an allout command - do hot-spot operation. | 3374 ;; Qualified as an allout command -- do hot-spot operation. |
3375 (setq allout-post-goto-bullet t) | 3375 (setq allout-post-goto-bullet t) |
3376 ;; accept-defaults nil, or else we'll get allout-item-icon-key-handler. | 3376 ;; accept-defaults nil, or else we'll get allout-item-icon-key-handler. |
3377 (setq mapped-binding (key-binding (char-to-string key-num)))) | 3377 (setq mapped-binding (key-binding (char-to-string key-num)))) |
3378 | 3378 |
3379 (while (keymapp mapped-binding) | 3379 (while (keymapp mapped-binding) |
3471 | 3471 |
3472 Second arg NEW indicates that a new topic is being opened after the | 3472 Second arg NEW indicates that a new topic is being opened after the |
3473 topic at point, if non-nil. Default bullet for new topics, eg, may | 3473 topic at point, if non-nil. Default bullet for new topics, eg, may |
3474 be set (contingent to other args) to numbered bullets if previous | 3474 be set (contingent to other args) to numbered bullets if previous |
3475 sibling is one. The implication otherwise is that the current topic | 3475 sibling is one. The implication otherwise is that the current topic |
3476 is being adjusted - shifted or rebulleted - and we don't consider | 3476 is being adjusted -- shifted or rebulleted -- and we don't consider |
3477 bullet or previous sibling. | 3477 bullet or previous sibling. |
3478 | 3478 |
3479 Third arg DEPTH forces the topic prefix to that depth, regardless of | 3479 Third arg DEPTH forces the topic prefix to that depth, regardless of |
3480 the current topics' depth. | 3480 the current topics' depth. |
3481 | 3481 |
3517 (bullet-char | 3517 (bullet-char |
3518 | 3518 |
3519 ;; Getting value for bullet char is practically the whole job: | 3519 ;; Getting value for bullet char is practically the whole job: |
3520 | 3520 |
3521 (cond | 3521 (cond |
3522 ; Simplest situation - level 1: | 3522 ; Simplest situation -- level 1: |
3523 ((<= depth 1) (setq header-lead "") allout-primary-bullet) | 3523 ((<= depth 1) (setq header-lead "") allout-primary-bullet) |
3524 ; Simple, too: all asterisks: | 3524 ; Simple, too: all asterisks: |
3525 (allout-old-style-prefixes | 3525 (allout-old-style-prefixes |
3526 ;; Cheat - make body the whole thing, null out header-lead and | 3526 ;; Cheat -- make body the whole thing, null out header-lead and |
3527 ;; bullet-char: | 3527 ;; bullet-char: |
3528 (setq body (make-string depth | 3528 (setq body (make-string depth |
3529 (string-to-char allout-primary-bullet))) | 3529 (string-to-char allout-primary-bullet))) |
3530 (setq header-lead "") | 3530 (setq header-lead "") |
3531 "") | 3531 "") |
3599 ;;;_ > allout-open-topic (relative-depth &optional before offer-recent-bullet) | 3599 ;;;_ > allout-open-topic (relative-depth &optional before offer-recent-bullet) |
3600 (defun allout-open-topic (relative-depth &optional before offer-recent-bullet) | 3600 (defun allout-open-topic (relative-depth &optional before offer-recent-bullet) |
3601 "Open a new topic at depth DEPTH. | 3601 "Open a new topic at depth DEPTH. |
3602 | 3602 |
3603 New topic is situated after current one, unless optional flag BEFORE | 3603 New topic is situated after current one, unless optional flag BEFORE |
3604 is non-nil, or unless current line is completely empty - lacking even | 3604 is non-nil, or unless current line is completely empty -- lacking even |
3605 whitespace - in which case open is done on the current line. | 3605 whitespace -- in which case open is done on the current line. |
3606 | 3606 |
3607 When adding an offspring, it will be added immediately after the parent if | 3607 When adding an offspring, it will be added immediately after the parent if |
3608 the other offspring are exposed, or after the last child if the offspring | 3608 the other offspring are exposed, or after the last child if the offspring |
3609 are hidden. (The intervening offspring will be exposed in the latter | 3609 are hidden. (The intervening offspring will be exposed in the latter |
3610 case.) | 3610 case.) |
3664 doing-beginning | 3664 doing-beginning |
3665 start end) | 3665 start end) |
3666 | 3666 |
3667 (if (not opening-on-blank) | 3667 (if (not opening-on-blank) |
3668 ; Positioning and vertical | 3668 ; Positioning and vertical |
3669 ; padding - only if not | 3669 ; padding -- only if not |
3670 ; opening-on-blank: | 3670 ; opening-on-blank: |
3671 (progn | 3671 (progn |
3672 (goto-char ref-topic) | 3672 (goto-char ref-topic) |
3673 (setq dbl-space ; Determine double space action: | 3673 (setq dbl-space ; Determine double space action: |
3674 (or (and (<= relative-depth 0) ; not descending; | 3674 (or (and (<= relative-depth 0) ; not descending; |
3715 (forward-char 1)) | 3715 (forward-char 1)) |
3716 (if (not (looking-at "^$")) | 3716 (if (not (looking-at "^$")) |
3717 (open-line 1))) | 3717 (open-line 1))) |
3718 (allout-end-of-current-subtree) | 3718 (allout-end-of-current-subtree) |
3719 (if (looking-at "\n\n") (forward-char 1)))) | 3719 (if (looking-at "\n\n") (forward-char 1)))) |
3720 ;; Going inwards - double-space if first offspring is | 3720 ;; Going inwards -- double-space if first offspring is |
3721 ;; double-spaced, otherwise snug up. | 3721 ;; double-spaced, otherwise snug up. |
3722 (allout-end-of-entry) | 3722 (allout-end-of-entry) |
3723 (if (eobp) | 3723 (if (eobp) |
3724 (newline 1) | 3724 (newline 1) |
3725 (line-move 1)) | 3725 (line-move 1)) |
3726 (allout-beginning-of-current-line) | 3726 (allout-beginning-of-current-line) |
3727 (backward-char 1) | 3727 (backward-char 1) |
3728 (if (bolp) | 3728 (if (bolp) |
3729 ;; Blank lines between current header body and next | 3729 ;; Blank lines between current header body and next |
3730 ;; header - get to last substantive (non-white-space) | 3730 ;; header -- get to last substantive (non-white-space) |
3731 ;; line in body: | 3731 ;; line in body: |
3732 (progn (setq dbl-space t) | 3732 (progn (setq dbl-space t) |
3733 (re-search-backward "[^ \t\n]" nil t))) | 3733 (re-search-backward "[^ \t\n]" nil t))) |
3734 (if (looking-at "\n\n") | 3734 (if (looking-at "\n\n") |
3735 (setq dbl-space t)) | 3735 (setq dbl-space t)) |
3870 (setq old-indent-begin (match-beginning 1) | 3870 (setq old-indent-begin (match-beginning 1) |
3871 old-indent-end (match-end 1)) | 3871 old-indent-end (match-end 1)) |
3872 (not (looking-at allout-regexp))) | 3872 (not (looking-at allout-regexp))) |
3873 (if (> 0 (setq excess (- (- old-indent-end old-indent-begin) | 3873 (if (> 0 (setq excess (- (- old-indent-end old-indent-begin) |
3874 old-margin))) | 3874 old-margin))) |
3875 ;; Text starts left of old margin - don't adjust: | 3875 ;; Text starts left of old margin -- don't adjust: |
3876 nil | 3876 nil |
3877 ;; Text was hanging at or right of old left margin - | 3877 ;; Text was hanging at or right of old left margin - |
3878 ;; reindent it, preserving its existing indentation | 3878 ;; reindent it, preserving its existing indentation |
3879 ;; beyond the old margin: | 3879 ;; beyond the old margin: |
3880 (delete-region old-indent-begin old-indent-end) | 3880 (delete-region old-indent-begin old-indent-end) |
4129 nil ;;; number | 4129 nil ;;; number |
4130 starting-index | 4130 starting-index |
4131 nil)))) ;;; do-successors | 4131 nil)))) ;;; do-successors |
4132 | 4132 |
4133 ((< starting-depth new-depth) | 4133 ((< starting-depth new-depth) |
4134 ;; Rare case - subtopic more than one level deeper than parent. | 4134 ;; Rare case -- subtopic more than one level deeper than parent. |
4135 ;; Treat this one at an even deeper level: | 4135 ;; Treat this one at an even deeper level: |
4136 (allout-rebullet-topic-grunt relative-depth | 4136 (allout-rebullet-topic-grunt relative-depth |
4137 new-depth | 4137 new-depth |
4138 starting-point | 4138 starting-point |
4139 index | 4139 index |
4191 allout-recent-depth) | 4191 allout-recent-depth) |
4192 ;;;_ > allout-number-siblings (&optional denumber) | 4192 ;;;_ > allout-number-siblings (&optional denumber) |
4193 (defun allout-number-siblings (&optional denumber) | 4193 (defun allout-number-siblings (&optional denumber) |
4194 "Assign numbered topic prefix to this topic and its siblings. | 4194 "Assign numbered topic prefix to this topic and its siblings. |
4195 | 4195 |
4196 With universal argument, denumber - assign default bullet to this | 4196 With universal argument, denumber -- assign default bullet to this |
4197 topic and its siblings. | 4197 topic and its siblings. |
4198 | 4198 |
4199 With repeated universal argument (`^U^U'), solicit bullet for each | 4199 With repeated universal argument (`^U^U'), solicit bullet for each |
4200 rebulleting each topic at this level." | 4200 rebulleting each topic at this level." |
4201 | 4201 |
4406 (max (1+ (point)) | 4406 (max (1+ (point)) |
4407 (next-single-char-property-change (point) | 4407 (next-single-char-property-change (point) |
4408 'invisible | 4408 'invisible |
4409 nil end)))) | 4409 nil end)))) |
4410 (if (or (not next) (eq prev next)) | 4410 (if (or (not next) (eq prev next)) |
4411 ;; still not at start of hidden area - must not be any left. | 4411 ;; still not at start of hidden area -- must not be any left. |
4412 (setq done t) | 4412 (setq done t) |
4413 (goto-char next) | 4413 (goto-char next) |
4414 (setq prev next) | 4414 (setq prev next) |
4415 (if (not (allout-hidden-p)) | 4415 (if (not (allout-hidden-p)) |
4416 ;; still not at start of hidden area. | 4416 ;; still not at start of hidden area. |
4447 (if (not (get-text-property (point) 'allout-was-hidden)) | 4447 (if (not (get-text-property (point) 'allout-was-hidden)) |
4448 (setq next (next-single-char-property-change (point) | 4448 (setq next (next-single-char-property-change (point) |
4449 'allout-was-hidden | 4449 'allout-was-hidden |
4450 nil end))) | 4450 nil end))) |
4451 (if (or (not next) (eq prev next)) | 4451 (if (or (not next) (eq prev next)) |
4452 ;; no more or not advancing - must not be any left. | 4452 ;; no more or not advancing -- must not be any left. |
4453 (setq done t) | 4453 (setq done t) |
4454 (goto-char next) | 4454 (goto-char next) |
4455 (setq prev next) | 4455 (setq prev next) |
4456 (if (not (get-text-property (point) 'allout-was-hidden)) | 4456 (if (not (get-text-property (point) 'allout-was-hidden)) |
4457 ;; still not at start of annotation. | 4457 ;; still not at start of annotation. |
4503 ;; `rectify-numbering' if resituating (where several topics may | 4503 ;; `rectify-numbering' if resituating (where several topics may |
4504 ;; be resituating) or yanking a topic into a topic slot (bol): | 4504 ;; be resituating) or yanking a topic into a topic slot (bol): |
4505 (rectify-numbering (or resituate | 4505 (rectify-numbering (or resituate |
4506 (and into-bol (looking-at allout-regexp))))) | 4506 (and into-bol (looking-at allout-regexp))))) |
4507 (if resituate | 4507 (if resituate |
4508 ;; Yanking a topic into the start of a topic - reconcile to fit: | 4508 ;; Yanking a topic into the start of a topic -- reconcile to fit: |
4509 (let* ((inhibit-field-text-motion t) | 4509 (let* ((inhibit-field-text-motion t) |
4510 (prefix-len (if (not (match-end 1)) | 4510 (prefix-len (if (not (match-end 1)) |
4511 1 | 4511 1 |
4512 (- (match-end 1) subj-beg))) | 4512 (- (match-end 1) subj-beg))) |
4513 (subj-depth allout-recent-depth) | 4513 (subj-depth allout-recent-depth) |
4642 (defun allout-yank-pop (&optional arg) | 4642 (defun allout-yank-pop (&optional arg) |
4643 "Yank-pop like `allout-yank' when popping to bare outline prefixes. | 4643 "Yank-pop like `allout-yank' when popping to bare outline prefixes. |
4644 | 4644 |
4645 Adapts level of popped topics to level of fresh prefix. | 4645 Adapts level of popped topics to level of fresh prefix. |
4646 | 4646 |
4647 Note - prefix changes to distinctive bullets will stick, if followed | 4647 Note -- prefix changes to distinctive bullets will stick, if followed |
4648 by pops to non-distinctive yanks. Bug..." | 4648 by pops to non-distinctive yanks. Bug..." |
4649 | 4649 |
4650 (interactive "*p") | 4650 (interactive "*p") |
4651 (setq this-command 'yank) | 4651 (setq this-command 'yank) |
4652 (yank-pop arg) | 4652 (yank-pop arg) |
4661 | 4661 |
4662 \(Works according to setting of `allout-file-xref-bullet')." | 4662 \(Works according to setting of `allout-file-xref-bullet')." |
4663 (interactive) | 4663 (interactive) |
4664 (if (not allout-file-xref-bullet) | 4664 (if (not allout-file-xref-bullet) |
4665 (error | 4665 (error |
4666 "Outline cross references disabled - no `allout-file-xref-bullet'") | 4666 "Outline cross references disabled -- no `allout-file-xref-bullet'") |
4667 (if (not (string= (allout-current-bullet) allout-file-xref-bullet)) | 4667 (if (not (string= (allout-current-bullet) allout-file-xref-bullet)) |
4668 (error "Current heading lacks cross-reference bullet `%s'" | 4668 (error "Current heading lacks cross-reference bullet `%s'" |
4669 allout-file-xref-bullet) | 4669 allout-file-xref-bullet) |
4670 (let ((inhibit-field-text-motion t) | 4670 (let ((inhibit-field-text-motion t) |
4671 file-name) | 4671 file-name) |
4888 "Show everything within the current topic. | 4888 "Show everything within the current topic. |
4889 With a repeat-count, expose this topic and its siblings." | 4889 With a repeat-count, expose this topic and its siblings." |
4890 (interactive "P") | 4890 (interactive "P") |
4891 (save-excursion | 4891 (save-excursion |
4892 (if (<= (allout-current-depth) 0) | 4892 (if (<= (allout-current-depth) 0) |
4893 ;; Outside any topics - try to get to the first: | 4893 ;; Outside any topics -- try to get to the first: |
4894 (if (not (allout-next-heading)) | 4894 (if (not (allout-next-heading)) |
4895 (error "No topics") | 4895 (error "No topics") |
4896 ;; got to first, outermost topic - set to expose it and siblings: | 4896 ;; got to first, outermost topic -- set to expose it and siblings: |
4897 (message "Above outermost topic - exposing all.") | 4897 (message "Above outermost topic -- exposing all.") |
4898 (allout-flag-region (point-min)(point-max) nil)) | 4898 (allout-flag-region (point-min)(point-max) nil)) |
4899 (allout-beginning-of-current-line) | 4899 (allout-beginning-of-current-line) |
4900 (if (not arg) | 4900 (if (not arg) |
4901 (allout-flag-current-subtree nil) | 4901 (allout-flag-current-subtree nil) |
4902 (allout-beginning-of-level) | 4902 (allout-beginning-of-level) |
4929 If optional arg JUST-CLOSE is non-nil, do not close the parent or | 4929 If optional arg JUST-CLOSE is non-nil, do not close the parent or |
4930 siblings, even if the target topic is already closed." | 4930 siblings, even if the target topic is already closed." |
4931 | 4931 |
4932 (interactive) | 4932 (interactive) |
4933 (let* ((from (point)) | 4933 (let* ((from (point)) |
4934 (sibs-msg "Top-level topic already closed - closing siblings...") | 4934 (sibs-msg "Top-level topic already closed -- closing siblings...") |
4935 (current-exposed (not (allout-current-topic-collapsed-p t)))) | 4935 (current-exposed (not (allout-current-topic-collapsed-p t)))) |
4936 (cond (current-exposed (allout-flag-current-subtree t)) | 4936 (cond (current-exposed (allout-flag-current-subtree t)) |
4937 (just-close nil) | 4937 (just-close nil) |
4938 ((allout-ascend) (allout-hide-current-subtree)) | 4938 ((allout-ascend) (allout-hide-current-subtree)) |
4939 (t (goto-char 0) | 4939 (t (goto-char 0) |
5017 - negative numbers force the topic to be closed before opening to the | 5017 - negative numbers force the topic to be closed before opening to the |
5018 absolute value of the number, so all siblings are open only to | 5018 absolute value of the number, so all siblings are open only to |
5019 that level. | 5019 that level. |
5020 - positive numbers open to the relative depth indicated by the | 5020 - positive numbers open to the relative depth indicated by the |
5021 number, but do not force already opened subtopics to be closed. | 5021 number, but do not force already opened subtopics to be closed. |
5022 - 0 means to close topic - hide all offspring. | 5022 - 0 means to close topic -- hide all offspring. |
5023 : - `repeat' | 5023 : - `repeat' |
5024 apply prior element to all siblings at current level, *up to* | 5024 apply prior element to all siblings at current level, *up to* |
5025 those siblings that would be covered by specs following the `:' | 5025 those siblings that would be covered by specs following the `:' |
5026 on the list. Ie, apply to all topics at level but the last | 5026 on the list. Ie, apply to all topics at level but the last |
5027 ones. (Only first of multiple colons at same level is | 5027 ones. (Only first of multiple colons at same level is |
5028 respected - subsequent ones are discarded.) | 5028 respected -- subsequent ones are discarded.) |
5029 * - completely opens the topic, including bodies. | 5029 * - completely opens the topic, including bodies. |
5030 + - shows all the sub headers, but not the bodies | 5030 + - shows all the sub headers, but not the bodies |
5031 - - exposes the body of the corresponding topic. | 5031 - - exposes the body of the corresponding topic. |
5032 | 5032 |
5033 Examples: | 5033 Examples: |
5071 ((eq curr-elem ':) | 5071 ((eq curr-elem ':) |
5072 (setq stay t) | 5072 (setq stay t) |
5073 ;; Expand the `repeat' spec to an explicit version, | 5073 ;; Expand the `repeat' spec to an explicit version, |
5074 ;; w.r.t. remaining siblings: | 5074 ;; w.r.t. remaining siblings: |
5075 (let ((residue ; = # of sibs not covered by remaining spec | 5075 (let ((residue ; = # of sibs not covered by remaining spec |
5076 ;; Dang - could be nice to make use of the chart, sigh: | 5076 ;; Dang, could be nice to make use of the chart, sigh: |
5077 (- (length (allout-chart-siblings)) | 5077 (- (length (allout-chart-siblings)) |
5078 (length spec)))) | 5078 (length spec)))) |
5079 (if (< 0 residue) | 5079 (if (< 0 residue) |
5080 ;; Some residue - cover it with prev-elem: | 5080 ;; Some residue -- cover it with prev-elem: |
5081 (setq spec (append (make-list residue prev-elem) | 5081 (setq spec (append (make-list residue prev-elem) |
5082 spec))))))) | 5082 spec))))))) |
5083 ((numberp curr-elem) | 5083 ((numberp curr-elem) |
5084 (if (and (>= 0 curr-elem) (not (allout-hidden-p))) | 5084 (if (and (>= 0 curr-elem) (not (allout-hidden-p))) |
5085 (save-excursion (allout-hide-current-subtree t) | 5085 (save-excursion (allout-hide-current-subtree t) |
5209 '(if (not (or (allout-goto-prefix-doublechecked) | 5209 '(if (not (or (allout-goto-prefix-doublechecked) |
5210 (allout-next-heading))) | 5210 (allout-next-heading))) |
5211 (error "allout-new-exposure: Can't find any outline topics")) | 5211 (error "allout-new-exposure: Can't find any outline topics")) |
5212 (list 'allout-expose-topic (list 'quote spec)))) | 5212 (list 'allout-expose-topic (list 'quote spec)))) |
5213 | 5213 |
5214 ;;;_ #7 Systematic outline presentation - copying, printing, flattening | 5214 ;;;_ #7 Systematic outline presentation -- copying, printing, flattening |
5215 | 5215 |
5216 ;;;_ - Mapping and processing of topics | 5216 ;;;_ - Mapping and processing of topics |
5217 ;;;_ ( See also Subtree Charting, in Navigation code.) | 5217 ;;;_ ( See also Subtree Charting, in Navigation code.) |
5218 ;;;_ > allout-stringify-flat-index (flat-index) | 5218 ;;;_ > allout-stringify-flat-index (flat-index) |
5219 (defun allout-stringify-flat-index (flat-index &optional context) | 5219 (defun allout-stringify-flat-index (flat-index &optional context) |
5300 Optional START and END indicate bounds of region. | 5300 Optional START and END indicate bounds of region. |
5301 | 5301 |
5302 Optional arg, FORMAT, designates an alternate presentation form for | 5302 Optional arg, FORMAT, designates an alternate presentation form for |
5303 the prefix: | 5303 the prefix: |
5304 | 5304 |
5305 list - Present prefix as numeric section.subsection..., starting with | 5305 list -- Present prefix as numeric section.subsection..., starting with |
5306 section indicated by the list, innermost nesting first. | 5306 section indicated by the list, innermost nesting first. |
5307 `indent' (symbol) - Convert header prefixes to all white space, | 5307 `indent' (symbol) -- Convert header prefixes to all white space, |
5308 except for distinctive bullets. | 5308 except for distinctive bullets. |
5309 | 5309 |
5310 The elements of the list produced are lists that represents a topic | 5310 The elements of the list produced are lists that represents a topic |
5311 header and body. The elements of that list are: | 5311 header and body. The elements of that list are: |
5312 | 5312 |
5327 | 5327 |
5328 (goto-char start) | 5328 (goto-char start) |
5329 (beginning-of-line) | 5329 (beginning-of-line) |
5330 ;; Goto initial topic, and register preceeding stuff, if any: | 5330 ;; Goto initial topic, and register preceeding stuff, if any: |
5331 (if (> (allout-goto-prefix-doublechecked) start) | 5331 (if (> (allout-goto-prefix-doublechecked) start) |
5332 ;; First topic follows beginning point - register preliminary stuff: | 5332 ;; First topic follows beginning point -- register preliminary stuff: |
5333 (setq result (list (list 0 "" nil | 5333 (setq result (list (list 0 "" nil |
5334 (buffer-substring start (1- (point))))))) | 5334 (buffer-substring start (1- (point))))))) |
5335 (while (and (not done) | 5335 (while (and (not done) |
5336 (not (eobp)) ; Loop until we've covered the region. | 5336 (not (eobp)) ; Loop until we've covered the region. |
5337 (not (> (point) end))) | 5337 (not (> (point) end))) |
5395 ;; Reasses format, if any: | 5395 ;; Reasses format, if any: |
5396 (if (and format (listp format)) | 5396 (if (and format (listp format)) |
5397 (cond ((= new-depth depth) | 5397 (cond ((= new-depth depth) |
5398 (setq format (cons (1+ (car format)) | 5398 (setq format (cons (1+ (car format)) |
5399 (cdr format)))) | 5399 (cdr format)))) |
5400 ((> new-depth depth) ; descending - assume by 1: | 5400 ((> new-depth depth) ; descending -- assume by 1: |
5401 (setq format (cons 1 format))) | 5401 (setq format (cons 1 format))) |
5402 (t | 5402 (t |
5403 ; Pop the residue: | 5403 ; Pop the residue: |
5404 (while (< new-depth depth) | 5404 (while (< new-depth depth) |
5405 (setq format (cdr format)) | 5405 (setq format (cdr format)) |
5426 | 5426 |
5427 Apply FUNCTION to exposed portions FROM position TO position in buffer | 5427 Apply FUNCTION to exposed portions FROM position TO position in buffer |
5428 FROMBUF to buffer TOBUF. Sixth optional arg, FORMAT, designates an | 5428 FROMBUF to buffer TOBUF. Sixth optional arg, FORMAT, designates an |
5429 alternate presentation form: | 5429 alternate presentation form: |
5430 | 5430 |
5431 `flat' - Present prefix as numeric section.subsection..., starting with | 5431 `flat' -- Present prefix as numeric section.subsection..., starting with |
5432 section indicated by the START-NUM, innermost nesting first. | 5432 section indicated by the START-NUM, innermost nesting first. |
5433 X`flat-indented' - Prefix is like `flat' for first topic at each | 5433 X`flat-indented' -- Prefix is like `flat' for first topic at each |
5434 X level, but subsequent topics have only leaf topic | 5434 X level, but subsequent topics have only leaf topic |
5435 X number, padded with blanks to line up with first. | 5435 X number, padded with blanks to line up with first. |
5436 `indent' (symbol) - Convert header prefixes to all white space, | 5436 `indent' (symbol) -- Convert header prefixes to all white space, |
5437 except for distinctive bullets. | 5437 except for distinctive bullets. |
5438 | 5438 |
5439 Defaults: | 5439 Defaults: |
5440 FUNCTION: `allout-insert-listified' | 5440 FUNCTION: `allout-insert-listified' |
5441 FROM: region start, if region active, else start of buffer | 5441 FROM: region start, if region active, else start of buffer |
5451 (if (my-region-active-p) | 5451 (if (my-region-active-p) |
5452 (setq from (region-beginning) to (region-end)) | 5452 (setq from (region-beginning) to (region-end)) |
5453 (setq from (point-min) to (point-max)))) | 5453 (setq from (point-min) to (point-max)))) |
5454 (if frombuf | 5454 (if frombuf |
5455 (if (not (bufferp frombuf)) | 5455 (if (not (bufferp frombuf)) |
5456 ;; Specified but not a buffer - get it: | 5456 ;; Specified but not a buffer -- get it: |
5457 (let ((got (get-buffer frombuf))) | 5457 (let ((got (get-buffer frombuf))) |
5458 (if (not got) | 5458 (if (not got) |
5459 (error (concat "allout-process-exposed: source buffer " | 5459 (error (concat "allout-process-exposed: source buffer " |
5460 frombuf | 5460 frombuf |
5461 " not found.")) | 5461 " not found.")) |
5462 (setq frombuf got)))) | 5462 (setq frombuf got)))) |
5463 ;; not specified - default it: | 5463 ;; not specified -- default it: |
5464 (setq frombuf (current-buffer))) | 5464 (setq frombuf (current-buffer))) |
5465 (if tobuf | 5465 (if tobuf |
5466 (if (not (bufferp tobuf)) | 5466 (if (not (bufferp tobuf)) |
5467 (setq tobuf (get-buffer-create tobuf))) | 5467 (setq tobuf (get-buffer-create tobuf))) |
5468 ;; not specified - default it: | 5468 ;; not specified -- default it: |
5469 (setq tobuf (concat "*" (buffer-name frombuf) " exposed*"))) | 5469 (setq tobuf (concat "*" (buffer-name frombuf) " exposed*"))) |
5470 (if (listp format) | 5470 (if (listp format) |
5471 (nreverse format)) | 5471 (nreverse format)) |
5472 | 5472 |
5473 (let* ((listified | 5473 (let* ((listified |
5550 (goto-char start-pt))) | 5550 (goto-char start-pt))) |
5551 ;;;_ > allout-flatten-exposed-to-buffer (&optional arg tobuf) | 5551 ;;;_ > allout-flatten-exposed-to-buffer (&optional arg tobuf) |
5552 (defun allout-flatten-exposed-to-buffer (&optional arg tobuf) | 5552 (defun allout-flatten-exposed-to-buffer (&optional arg tobuf) |
5553 "Present numeric outline of outline's exposed portions in another buffer. | 5553 "Present numeric outline of outline's exposed portions in another buffer. |
5554 | 5554 |
5555 The resulting outline is not compatible with outline mode - use | 5555 The resulting outline is not compatible with outline mode -- use |
5556 `allout-copy-exposed-to-buffer' if you want that. | 5556 `allout-copy-exposed-to-buffer' if you want that. |
5557 | 5557 |
5558 Use `allout-indented-exposed-to-buffer' for indented presentation. | 5558 Use `allout-indented-exposed-to-buffer' for indented presentation. |
5559 | 5559 |
5560 With repeat count, copy the exposed portions of only current topic. | 5560 With repeat count, copy the exposed portions of only current topic. |
5566 (allout-copy-exposed-to-buffer arg tobuf 'flat)) | 5566 (allout-copy-exposed-to-buffer arg tobuf 'flat)) |
5567 ;;;_ > allout-indented-exposed-to-buffer (&optional arg tobuf) | 5567 ;;;_ > allout-indented-exposed-to-buffer (&optional arg tobuf) |
5568 (defun allout-indented-exposed-to-buffer (&optional arg tobuf) | 5568 (defun allout-indented-exposed-to-buffer (&optional arg tobuf) |
5569 "Present indented outline of outline's exposed portions in another buffer. | 5569 "Present indented outline of outline's exposed portions in another buffer. |
5570 | 5570 |
5571 The resulting outline is not compatible with outline mode - use | 5571 The resulting outline is not compatible with outline mode -- use |
5572 `allout-copy-exposed-to-buffer' if you want that. | 5572 `allout-copy-exposed-to-buffer' if you want that. |
5573 | 5573 |
5574 Use `allout-flatten-exposed-to-buffer' for numeric sectional presentation. | 5574 Use `allout-flatten-exposed-to-buffer' for numeric sectional presentation. |
5575 | 5575 |
5576 With repeat count, copy the exposed portions of only current topic. | 5576 With repeat count, copy the exposed portions of only current topic. |
5794 not. When a file with topics pending encryption is saved, topics pending | 5794 not. When a file with topics pending encryption is saved, topics pending |
5795 encryption are encrypted. See allout-encrypt-unencrypted-on-saves for | 5795 encryption are encrypted. See allout-encrypt-unencrypted-on-saves for |
5796 auto-encryption specifics. | 5796 auto-encryption specifics. |
5797 | 5797 |
5798 \*NOTE WELL* that automatic encryption that happens during saves will | 5798 \*NOTE WELL* that automatic encryption that happens during saves will |
5799 default to symmetric encryption - you must deliberately (re)encrypt key-pair | 5799 default to symmetric encryption -- you must deliberately (re)encrypt key-pair |
5800 encrypted topics if you want them to continue to use the key-pair cipher. | 5800 encrypted topics if you want them to continue to use the key-pair cipher. |
5801 | 5801 |
5802 Level-one topics, with prefix consisting solely of an `*' asterisk, cannot be | 5802 Level-one topics, with prefix consisting solely of an `*' asterisk, cannot be |
5803 encrypted. If you want to encrypt the contents of a top-level topic, use | 5803 encrypted. If you want to encrypt the contents of a top-level topic, use |
5804 \\[allout-shift-in] to increase its depth. | 5804 \\[allout-shift-in] to increase its depth. |
5881 (subtree-end (allout-end-of-subtree)) | 5881 (subtree-end (allout-end-of-subtree)) |
5882 (subject-text (buffer-substring-no-properties subtree-beg | 5882 (subject-text (buffer-substring-no-properties subtree-beg |
5883 subtree-end)) | 5883 subtree-end)) |
5884 (subtree-end-char (char-after (1- subtree-end))) | 5884 (subtree-end-char (char-after (1- subtree-end))) |
5885 (subtree-trailing-char (char-after subtree-end)) | 5885 (subtree-trailing-char (char-after subtree-end)) |
5886 ;; kluge - result-text needs to be nil, but we also want to | 5886 ;; kluge -- result-text needs to be nil, but we also want to |
5887 ;; check for the error condition | 5887 ;; check for the error condition |
5888 (result-text (if (or (string= "" subject-text) | 5888 (result-text (if (or (string= "" subject-text) |
5889 (string= "\n" subject-text)) | 5889 (string= "\n" subject-text)) |
5890 (error "No topic contents to %scrypt" | 5890 (error "No topic contents to %scrypt" |
5891 (if was-encrypted "de" "en")) | 5891 (if was-encrypted "de" "en")) |
5968 | 5968 |
5969 If DECRYPT is true (default false), then decrypt instead of encrypt. | 5969 If DECRYPT is true (default false), then decrypt instead of encrypt. |
5970 | 5970 |
5971 FETCH-PASS (default false) forces fresh prompting for the passphrase. | 5971 FETCH-PASS (default false) forces fresh prompting for the passphrase. |
5972 | 5972 |
5973 KEY-TYPE indicates whether to use a 'symmetric or 'keypair cipher. | 5973 KEY-TYPE, either `symmetric' or `keypair', specifies which type |
5974 of cypher to use. | |
5974 | 5975 |
5975 FOR-KEY is human readable identification of the first of the user's | 5976 FOR-KEY is human readable identification of the first of the user's |
5976 eligible secret keys a keypair decryption targets, or else nil. | 5977 eligible secret keys a keypair decryption targets, or else nil. |
5977 | 5978 |
5978 Optional RETRIED is for internal use - conveys the number of failed keys | 5979 Optional RETRIED is for internal use -- conveys the number of failed keys |
5979 that have been solicited in sequence leading to this current call. | 5980 that have been solicited in sequence leading to this current call. |
5980 | 5981 |
5981 Optional PASSPHRASE enables explicit delivery of the decryption passphrase, | 5982 Optional PASSPHRASE enables explicit delivery of the decryption passphrase, |
5982 for verification purposes. | 5983 for verification purposes. |
5983 | 5984 |
5984 Optional REJECTED is for internal use - conveys the number of | 5985 Optional REJECTED is for internal use -- conveys the number of |
5985 rejections due to matches against | 5986 rejections due to matches against |
5986 `allout-encryption-ciphertext-rejection-regexps', as limited by | 5987 `allout-encryption-ciphertext-rejection-regexps', as limited by |
5987 `allout-encryption-ciphertext-rejection-ceiling'. | 5988 `allout-encryption-ciphertext-rejection-ceiling'. |
5988 | 5989 |
5989 Returns the resulting string, or nil if the transformation fails." | 5990 Returns the resulting string, or nil if the transformation fails." |
6076 (pgg-encrypt-symmetric (point-min) (point-max) | 6077 (pgg-encrypt-symmetric (point-min) (point-max) |
6077 passphrase))) | 6078 passphrase))) |
6078 | 6079 |
6079 (if status | 6080 (if status |
6080 (pgg-situate-output (point-min) (point-max)) | 6081 (pgg-situate-output (point-min) (point-max)) |
6081 ;; failed - handle passphrase caching | 6082 ;; failed -- handle passphrase caching |
6082 (if verifying | 6083 (if verifying |
6083 (throw 'encryption-failed nil) | 6084 (throw 'encryption-failed nil) |
6084 (pgg-remove-passphrase-from-cache target-cache-id t) | 6085 (pgg-remove-passphrase-from-cache target-cache-id t) |
6085 (error "Symmetric-cipher %scryption failed - %s" | 6086 (error "Symmetric-cipher %scryption failed -- %s" |
6086 (if decrypt "de" "en") | 6087 (if decrypt "de" "en") |
6087 "try again with different passphrase.")))) | 6088 "try again with different passphrase")))) |
6088 | 6089 |
6089 ;; encrypt 'keypair: | 6090 ;; encrypt 'keypair: |
6090 ((not decrypt) | 6091 ((not decrypt) |
6091 | 6092 |
6092 (setq status | 6093 (setq status |
6113 (setq result-text | 6114 (setq result-text |
6114 (buffer-substring-no-properties | 6115 (buffer-substring-no-properties |
6115 1 (- (point-max) (if decrypt 0 1)))) | 6116 1 (- (point-max) (if decrypt 0 1)))) |
6116 ) | 6117 ) |
6117 | 6118 |
6118 ;; validate result - non-empty | 6119 ;; validate result -- non-empty |
6119 (cond ((not result-text) | 6120 (cond ((not result-text) |
6120 (if verifying | 6121 (if verifying |
6121 nil | 6122 nil |
6122 ;; transform was fruitless, retry w/new passphrase. | 6123 ;; transform was fruitless, retry w/new passphrase. |
6123 (pgg-remove-passphrase-from-cache target-cache-id t) | 6124 (pgg-remove-passphrase-from-cache target-cache-id t) |
6149 ;; Barf if encryption yields extraordinary control chars: | 6150 ;; Barf if encryption yields extraordinary control chars: |
6150 ((and (not decrypt) | 6151 ((and (not decrypt) |
6151 (string-match "[\C-a\C-k\C-o-\C-z\C-@]" | 6152 (string-match "[\C-a\C-k\C-o-\C-z\C-@]" |
6152 result-text)) | 6153 result-text)) |
6153 (error (concat "Encryption produced non-armored text, which" | 6154 (error (concat "Encryption produced non-armored text, which" |
6154 "conflicts with allout mode - reconfigure!"))) | 6155 "conflicts with allout mode -- reconfigure!"))) |
6155 | 6156 |
6156 ;; valid result and just verifying or non-symmetric: | 6157 ;; valid result and just verifying or non-symmetric: |
6157 ((or verifying (not (equal key-type 'symmetric))) | 6158 ((or verifying (not (equal key-type 'symmetric))) |
6158 (if (or verifying decrypt) | 6159 (if (or verifying decrypt) |
6159 (pgg-add-passphrase-to-cache target-cache-id | 6160 (pgg-add-passphrase-to-cache target-cache-id |
6160 passphrase t)) | 6161 passphrase t)) |
6161 result-text) | 6162 result-text) |
6162 | 6163 |
6163 ;; valid result and regular symmetric - "register" | 6164 ;; valid result and regular symmetric -- "register" |
6164 ;; passphrase with mnemonic aids/cache. | 6165 ;; passphrase with mnemonic aids/cache. |
6165 (t | 6166 (t |
6166 (set-buffer allout-buffer) | 6167 (set-buffer allout-buffer) |
6167 (if passphrase | 6168 (if passphrase |
6168 (pgg-add-passphrase-to-cache target-cache-id | 6169 (pgg-add-passphrase-to-cache target-cache-id |
6189 | 6190 |
6190 CACHE-ID is the cache id of the key for the passphrase. | 6191 CACHE-ID is the cache id of the key for the passphrase. |
6191 | 6192 |
6192 PROMPT-ID is the id for use when prompting the user. | 6193 PROMPT-ID is the id for use when prompting the user. |
6193 | 6194 |
6194 KEY-TYPE is either 'symmetric or 'keypair. | 6195 KEY-TYPE is either `symmetric' or `keypair'. |
6195 | 6196 |
6196 ALLOUT-BUFFER is the buffer containing the entry being en/decrypted. | 6197 ALLOUT-BUFFER is the buffer containing the entry being en/decrypted. |
6197 | 6198 |
6198 RETRIED is the number of this attempt to obtain this passphrase. | 6199 RETRIED is the number of this attempt to obtain this passphrase. |
6199 | 6200 |
6252 (setq confirmation (format "%s" got-pass)))) | 6253 (setq confirmation (format "%s" got-pass)))) |
6253 | 6254 |
6254 (if (and (not confirmation) | 6255 (if (and (not confirmation) |
6255 (if (yes-or-no-p | 6256 (if (yes-or-no-p |
6256 (concat "Passphrase differs from established" | 6257 (concat "Passphrase differs from established" |
6257 " - use new one instead? ")) | 6258 " -- use new one instead? ")) |
6258 ;; deactivate password for subsequent | 6259 ;; deactivate password for subsequent |
6259 ;; confirmation: | 6260 ;; confirmation: |
6260 (progn | 6261 (progn |
6261 (pgg-remove-passphrase-from-cache cache-id t) | 6262 (pgg-remove-passphrase-from-cache cache-id t) |
6262 (setq prompt prompt-sans-hint) | 6263 (setq prompt prompt-sans-hint) |
6263 nil) | 6264 nil) |
6264 t)) | 6265 t)) |
6265 (progn (pgg-remove-passphrase-from-cache cache-id t) | 6266 (progn (pgg-remove-passphrase-from-cache cache-id t) |
6266 (error "Wrong passphrase.")))) | 6267 (error "Wrong passphrase.")))) |
6267 ;; No verifier string - force confirmation by repetition of | 6268 ;; No verifier string -- force confirmation by repetition of |
6268 ;; (new) passphrase: | 6269 ;; (new) passphrase: |
6269 ((or fetch-pass (not cached)) | 6270 ((or fetch-pass (not cached)) |
6270 (pgg-remove-passphrase-from-cache cache-id t)))) | 6271 (pgg-remove-passphrase-from-cache cache-id t)))) |
6271 ;; confirmation vs new input - doing pgg-read-passphrase will do the | 6272 ;; confirmation vs new input -- doing pgg-read-passphrase will do the |
6272 ;; right thing, in either case: | 6273 ;; right thing, in either case: |
6273 (if (not confirmation) | 6274 (if (not confirmation) |
6274 (setq confirmation | 6275 (setq confirmation |
6275 (pgg-read-passphrase (concat prompt | 6276 (pgg-read-passphrase (concat prompt |
6276 " ... confirm spelling: ") | 6277 " ... confirm spelling: ") |
6277 cache-id t))) | 6278 cache-id t))) |
6278 (prog1 | 6279 (prog1 |
6279 (if (equal got-pass confirmation) | 6280 (if (equal got-pass confirmation) |
6280 confirmation | 6281 confirmation |
6281 (if (yes-or-no-p (concat "spelling of original and" | 6282 (if (yes-or-no-p (concat "spelling of original and" |
6282 " confirmation differ - retry? ")) | 6283 " confirmation differ -- retry? ")) |
6283 (progn (setq retried (if retried (1+ retried) 1)) | 6284 (progn (setq retried (if retried (1+ retried) 1)) |
6284 (pgg-remove-passphrase-from-cache cache-id t) | 6285 (pgg-remove-passphrase-from-cache cache-id t) |
6285 ;; recurse to this routine: | 6286 ;; recurse to this routine: |
6286 (pgg-read-passphrase prompt-sans-hint cache-id t)) | 6287 (pgg-read-passphrase prompt-sans-hint cache-id t)) |
6287 (pgg-remove-passphrase-from-cache cache-id t) | 6288 (pgg-remove-passphrase-from-cache cache-id t) |
6299 ;;;_ > allout-encrypted-key-info (text) | 6300 ;;;_ > allout-encrypted-key-info (text) |
6300 ;; XXX gpg-specific, alas | 6301 ;; XXX gpg-specific, alas |
6301 (defun allout-encrypted-key-info (text) | 6302 (defun allout-encrypted-key-info (text) |
6302 "Return a pair of the key type and identity of a recipient's secret key. | 6303 "Return a pair of the key type and identity of a recipient's secret key. |
6303 | 6304 |
6304 The key type is one of 'symmetric or 'keypair. | 6305 The key type is one of `symmetric' or `keypair'. |
6305 | 6306 |
6306 If 'keypair, and some of the user's secret keys are among those for which | 6307 If `keypair', and some of the user's secret keys are among those for which |
6307 the message was encoded, return the identity of the first. Otherwise, | 6308 the message was encoded, return the identity of the first. Otherwise, |
6308 return nil for the second item of the pair. | 6309 return nil for the second item of the pair. |
6309 | 6310 |
6310 An error is raised if the text is not encrypted." | 6311 An error is raised if the text is not encrypted." |
6311 (require 'pgg-parse) | 6312 (require 'pgg-parse) |
6477 ;;;_ > allout-encrypt-decrypted (&optional except-mark) | 6478 ;;;_ > allout-encrypt-decrypted (&optional except-mark) |
6478 (defun allout-encrypt-decrypted (&optional except-mark) | 6479 (defun allout-encrypt-decrypted (&optional except-mark) |
6479 "Encrypt topics pending encryption except those containing exemption point. | 6480 "Encrypt topics pending encryption except those containing exemption point. |
6480 | 6481 |
6481 EXCEPT-MARK identifies a point whose containing topics should be excluded | 6482 EXCEPT-MARK identifies a point whose containing topics should be excluded |
6482 from encryption. This supports 'except-current mode of | 6483 from encryption. This supports the `except-current' mode of |
6483 `allout-encrypt-unencrypted-on-saves'. | 6484 `allout-encrypt-unencrypted-on-saves'. |
6484 | 6485 |
6485 If a topic that is currently being edited was encrypted, we return a list | 6486 If a topic that is currently being edited was encrypted, we return a list |
6486 containing the location of the topic and the location of the cursor just | 6487 containing the location of the topic and the location of the cursor just |
6487 before the topic was encrypted. This can be used, eg, to decrypt the topic | 6488 before the topic was encrypted. This can be used, eg, to decrypt the topic |
6543 (save-excursion | 6544 (save-excursion |
6544 (goto-char (point-min)) | 6545 (goto-char (point-min)) |
6545 (if (allout-goto-prefix) | 6546 (if (allout-goto-prefix) |
6546 t | 6547 t |
6547 (allout-open-topic 2) | 6548 (allout-open-topic 2) |
6548 (insert (concat "Dummy outline topic header - see" | 6549 (insert (concat "Dummy outline topic header -- see" |
6549 "`allout-mode' docstring: `^Hm'.")) | 6550 "`allout-mode' docstring: `^Hm'.")) |
6550 (allout-adjust-file-variable | 6551 (allout-adjust-file-variable |
6551 "allout-layout" (or allout-layout '(-1 : 0)))))) | 6552 "allout-layout" (or allout-layout '(-1 : 0)))))) |
6552 ;;;_ > allout-file-vars-section-data () | 6553 ;;;_ > allout-file-vars-section-data () |
6553 (defun allout-file-vars-section-data () | 6554 (defun allout-file-vars-section-data () |
6554 "Return data identifying the file-vars section, or nil if none. | 6555 "Return data identifying the file-vars section, or nil if none. |
6555 | 6556 |
6556 Returns list `(beginning-point prefix-string suffix-string)'." | 6557 Returns a list of the form (BEGINNING-POINT PREFIX-STRING SUFFIX-STRING)." |
6557 ;; minimally gleaned from emacs 21.4 files.el hack-local-variables function. | 6558 ;; minimally gleaned from emacs 21.4 files.el hack-local-variables function. |
6558 (let (beg prefix suffix) | 6559 (let (beg prefix suffix) |
6559 (save-excursion | 6560 (save-excursion |
6560 (goto-char (point-max)) | 6561 (goto-char (point-max)) |
6561 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) | 6562 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |
6653 | 6654 |
6654 (let ((configvar-value (symbol-value configvar-name)) | 6655 (let ((configvar-value (symbol-value configvar-name)) |
6655 got) | 6656 got) |
6656 (dolist (sym configvar-value) | 6657 (dolist (sym configvar-value) |
6657 (if (not (boundp sym)) | 6658 (if (not (boundp sym)) |
6658 (if (yes-or-no-p (format "%s entry `%s' is unbound - remove it? " | 6659 (if (yes-or-no-p (format "%s entry `%s' is unbound -- remove it? " |
6659 configvar-name sym)) | 6660 configvar-name sym)) |
6660 (delq sym (symbol-value configvar-name))) | 6661 (delq sym (symbol-value configvar-name))) |
6661 (push (symbol-value sym) got))) | 6662 (push (symbol-value sym) got))) |
6662 (reverse got))) | 6663 (reverse got))) |
6663 ;;;_ : Topics: | 6664 ;;;_ : Topics: |
6700 got | 6701 got |
6701 " ...pick from: " | 6702 " ...pick from: " |
6702 string | 6703 string |
6703 "")) | 6704 "")) |
6704 nil)))) | 6705 nil)))) |
6705 ;; got something out of loop - return it: | 6706 ;; got something out of loop -- return it: |
6706 got) | 6707 got) |
6707 ) | 6708 ) |
6708 ;;;_ : Strings: | 6709 ;;;_ : Strings: |
6709 ;;;_ > regexp-sans-escapes (string) | 6710 ;;;_ > regexp-sans-escapes (string) |
6710 (defun regexp-sans-escapes (regexp &optional successive-backslashes) | 6711 (defun regexp-sans-escapes (regexp &optional successive-backslashes) |
6711 "Return a copy of REGEXP with all character escapes stripped out. | 6712 "Return a copy of REGEXP with all character escapes stripped out. |
6712 | 6713 |
6713 Representations of actual backslashes - '\\\\\\\\' - are left as a | 6714 Representations of actual backslashes -- '\\\\\\\\' -- are left as a |
6714 single backslash. | 6715 single backslash. |
6715 | 6716 |
6716 Optional arg SUCCESSIVE-BACKSLASHES is used internally for recursion." | 6717 Optional arg SUCCESSIVE-BACKSLASHES is used internally for recursion." |
6717 | 6718 |
6718 (if (string= regexp "") | 6719 (if (string= regexp "") |
6807 (move-overlay o (overlay-start o) beg)) | 6808 (move-overlay o (overlay-start o) beg)) |
6808 (if (> (overlay-end o) end) | 6809 (if (> (overlay-end o) end) |
6809 (move-overlay o end (overlay-end o)) | 6810 (move-overlay o end (overlay-end o)) |
6810 (delete-overlay o))))))) | 6811 (delete-overlay o))))))) |
6811 ) | 6812 ) |
6812 ;;;_ > copy-overlay if necessary - xemacs ~ 21.4 | 6813 ;;;_ > copy-overlay if necessary -- xemacs ~ 21.4 |
6813 (if (not (fboundp 'copy-overlay)) | 6814 (if (not (fboundp 'copy-overlay)) |
6814 (defun copy-overlay (o) | 6815 (defun copy-overlay (o) |
6815 "Return a copy of overlay O." | 6816 "Return a copy of overlay O." |
6816 (let ((o1 (make-overlay (overlay-start o) (overlay-end o) | 6817 (let ((o1 (make-overlay (overlay-start o) (overlay-end o) |
6817 ;; FIXME: there's no easy way to find the | 6818 ;; FIXME: there's no easy way to find the |
6819 (overlay-buffer o))) | 6820 (overlay-buffer o))) |
6820 (props (overlay-properties o))) | 6821 (props (overlay-properties o))) |
6821 (while props | 6822 (while props |
6822 (overlay-put o1 (pop props) (pop props))) | 6823 (overlay-put o1 (pop props) (pop props))) |
6823 o1))) | 6824 o1))) |
6824 ;;;_ > add-to-invisibility-spec if necessary - xemacs ~ 21.4 | 6825 ;;;_ > add-to-invisibility-spec if necessary -- xemacs ~ 21.4 |
6825 (if (not (fboundp 'add-to-invisibility-spec)) | 6826 (if (not (fboundp 'add-to-invisibility-spec)) |
6826 (defun add-to-invisibility-spec (element) | 6827 (defun add-to-invisibility-spec (element) |
6827 "Add ELEMENT to `buffer-invisibility-spec'. | 6828 "Add ELEMENT to `buffer-invisibility-spec'. |
6828 See documentation for `buffer-invisibility-spec' for the kind of elements | 6829 See documentation for `buffer-invisibility-spec' for the kind of elements |
6829 that can be added." | 6830 that can be added." |
6830 (if (eq buffer-invisibility-spec t) | 6831 (if (eq buffer-invisibility-spec t) |
6831 (setq buffer-invisibility-spec (list t))) | 6832 (setq buffer-invisibility-spec (list t))) |
6832 (setq buffer-invisibility-spec | 6833 (setq buffer-invisibility-spec |
6833 (cons element buffer-invisibility-spec)))) | 6834 (cons element buffer-invisibility-spec)))) |
6834 ;;;_ > remove-from-invisibility-spec if necessary - xemacs ~ 21.4 | 6835 ;;;_ > remove-from-invisibility-spec if necessary -- xemacs ~ 21.4 |
6835 (if (not (fboundp 'remove-from-invisibility-spec)) | 6836 (if (not (fboundp 'remove-from-invisibility-spec)) |
6836 (defun remove-from-invisibility-spec (element) | 6837 (defun remove-from-invisibility-spec (element) |
6837 "Remove ELEMENT from `buffer-invisibility-spec'." | 6838 "Remove ELEMENT from `buffer-invisibility-spec'." |
6838 (if (consp buffer-invisibility-spec) | 6839 (if (consp buffer-invisibility-spec) |
6839 (setq buffer-invisibility-spec (delete element | 6840 (setq buffer-invisibility-spec (delete element |
6840 buffer-invisibility-spec))))) | 6841 buffer-invisibility-spec))))) |
6841 ;;;_ > move-beginning-of-line if necessary - older emacs, xemacs | 6842 ;;;_ > move-beginning-of-line if necessary -- older emacs, xemacs |
6842 (if (not (fboundp 'move-beginning-of-line)) | 6843 (if (not (fboundp 'move-beginning-of-line)) |
6843 (defun move-beginning-of-line (arg) | 6844 (defun move-beginning-of-line (arg) |
6844 "Move point to beginning of current line as displayed. | 6845 "Move point to beginning of current line as displayed. |
6845 \(This disregards invisible newlines such as those | 6846 \(This disregards invisible newlines such as those |
6846 which are part of the text that an image rests on.) | 6847 which are part of the text that an image rests on.) |
6860 (previous-property-change (point)) | 6861 (previous-property-change (point)) |
6861 (previous-char-property-change (point)))) | 6862 (previous-char-property-change (point)))) |
6862 (skip-chars-backward "^\n")) | 6863 (skip-chars-backward "^\n")) |
6863 (vertical-motion 0)) | 6864 (vertical-motion 0)) |
6864 ) | 6865 ) |
6865 ;;;_ > move-end-of-line if necessary - older emacs, xemacs | 6866 ;;;_ > move-end-of-line if necessary -- older emacs, xemacs |
6866 (if (not (fboundp 'move-end-of-line)) | 6867 (if (not (fboundp 'move-end-of-line)) |
6867 (defun move-end-of-line (arg) | 6868 (defun move-end-of-line (arg) |
6868 "Move point to end of current line as displayed. | 6869 "Move point to end of current line as displayed. |
6869 \(This disregards invisible newlines such as those | 6870 \(This disregards invisible newlines such as those |
6870 which are part of the text that an image rests on.) | 6871 which are part of the text that an image rests on.) |
6929 "[ \t]*" | 6930 "[ \t]*" |
6930 bullet))) | 6931 bullet))) |
6931 (isearch-repeat 'forward) | 6932 (isearch-repeat 'forward) |
6932 (isearch-mode t))) | 6933 (isearch-mode t))) |
6933 | 6934 |
6934 ;;;_ #11 Unit tests - this should be last item before "Provide" | 6935 ;;;_ #11 Unit tests -- this should be last item before "Provide" |
6935 ;;;_ > allout-run-unit-tests () | 6936 ;;;_ > allout-run-unit-tests () |
6936 (defun allout-run-unit-tests () | 6937 (defun allout-run-unit-tests () |
6937 "Run the various allout unit tests." | 6938 "Run the various allout unit tests." |
6938 (message "Running allout tests...") | 6939 (message "Running allout tests...") |
6939 (allout-test-resumptions) | 6940 (allout-test-resumptions) |
6945 "Completely unbind variable with NAME." | 6946 "Completely unbind variable with NAME." |
6946 (if (local-variable-p name) (kill-local-variable name)) | 6947 (if (local-variable-p name) (kill-local-variable name)) |
6947 (while (boundp name) (makunbound name))) | 6948 (while (boundp name) (makunbound name))) |
6948 ;;;_ > allout-test-resumptions () | 6949 ;;;_ > allout-test-resumptions () |
6949 (defvar allout-tests-globally-unbound nil | 6950 (defvar allout-tests-globally-unbound nil |
6950 "Fodder for allout resumptions tests - defvar just for byte compiler.") | 6951 "Fodder for allout resumptions tests -- defvar just for byte compiler.") |
6951 (defvar allout-tests-globally-true nil | 6952 (defvar allout-tests-globally-true nil |
6952 "Fodder for allout resumptions tests - defvar just for byte compiler.") | 6953 "Fodder for allout resumptions tests -- defvar just for byte compiler.") |
6953 (defvar allout-tests-locally-true nil | 6954 (defvar allout-tests-locally-true nil |
6954 "Fodder for allout resumptions tests - defvar just for byte compiler.") | 6955 "Fodder for allout resumptions tests -- defvar just for byte compiler.") |
6955 (defun allout-test-resumptions () | 6956 (defun allout-test-resumptions () |
6956 "Exercise allout resumptions." | 6957 "Exercise allout resumptions." |
6957 ;; for each resumption case, we also test that the right local/global | 6958 ;; for each resumption case, we also test that the right local/global |
6958 ;; scopes are affected during resumption effects: | 6959 ;; scopes are affected during resumption effects: |
6959 | 6960 |
6985 ;; ensure that prior local value is resumed | 6986 ;; ensure that prior local value is resumed |
6986 (with-temp-buffer | 6987 (with-temp-buffer |
6987 (allout-tests-obliterate-variable 'allout-tests-locally-true) | 6988 (allout-tests-obliterate-variable 'allout-tests-locally-true) |
6988 (set (make-local-variable 'allout-tests-locally-true) t) | 6989 (set (make-local-variable 'allout-tests-locally-true) t) |
6989 (assert (not (default-boundp 'allout-tests-locally-true)) | 6990 (assert (not (default-boundp 'allout-tests-locally-true)) |
6990 nil (concat "Test setup mistake - variable supposed to" | 6991 nil (concat "Test setup mistake -- variable supposed to" |
6991 " not have global binding, but it does.")) | 6992 " not have global binding, but it does.")) |
6992 (assert (local-variable-p 'allout-tests-locally-true) | 6993 (assert (local-variable-p 'allout-tests-locally-true) |
6993 nil (concat "Test setup mistake - variable supposed to have" | 6994 nil (concat "Test setup mistake -- variable supposed to have" |
6994 " local binding, but it lacks one.")) | 6995 " local binding, but it lacks one.")) |
6995 (allout-add-resumptions '(allout-tests-locally-true nil)) | 6996 (allout-add-resumptions '(allout-tests-locally-true nil)) |
6996 (assert (not (default-boundp 'allout-tests-locally-true))) | 6997 (assert (not (default-boundp 'allout-tests-locally-true))) |
6997 (assert (local-variable-p 'allout-tests-locally-true)) | 6998 (assert (local-variable-p 'allout-tests-locally-true)) |
6998 (assert (equal allout-tests-locally-true nil)) | 6999 (assert (equal allout-tests-locally-true nil)) |