Show
Ignore:
Timestamp:
04/16/06 21:46:31 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/allout.el

    r4037 r4058  
    77;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com> 
    88;; Created: Dec 1991 - first release to usenet 
    9 ;; Version: 2.
     9;; Version: 2.2.
    1010;; Keywords: outlines wp languages 
    1111 
     
    2929;;; Commentary: 
    3030 
    31 ;; Allout outline mode provides extensive outline formatting and 
    32 ;; and manipulation beyond standard emacs outline mode.  It provides 
    33 ;; for structured editing of outlines, as well as navigation and 
    34 ;; exposure.  It also provides for syntax-sensitive text like 
    35 ;; programming languages.  (For an example, see the allout code 
    36 ;; itself, which is organized in ;; an outline framework.) 
     31;; Allout outline minor mode provides extensive outline formatting and 
     32;; and manipulation beyond standard emacs outline mode.  Some features: 
    3733;; 
    38 ;; Some features: 
    39 ;; 
    40 ;;  - classic outline-mode topic-oriented navigation and exposure adjustment 
    41 ;;  - topic-oriented editing including coherent topic and subtopic 
    42 ;;    creation, promotion, demotion, cut/paste across depths, etc 
    43 ;;  - incremental search with dynamic exposure and reconcealment of text 
    44 ;;  - customizable bullet format enbles programming-language specific 
    45 ;;    outlining, for ultimate code-folding editing.  (allout code itself is 
    46 ;;    formatted as an outline - do ESC-x eval-current-buffer in allout.el 
    47 ;;    to try it out.) 
    48 ;;  - configurable per-file initial exposure settings 
    49 ;;  - symmetric-key and key-pair topic encryption, plus symmetric passphrase 
     34;;  - Classic outline-mode topic-oriented navigation and exposure adjustment 
     35;;  - Topic-oriented editing including coherent topic and subtopic 
     36;;    creation, promotion, demotion, cut/paste across depths, etc. 
     37;;  - Incremental search with dynamic exposure and reconcealment of text 
     38;;  - Customizable bullet format - enables programming-language specific 
     39;;    outlining, for code-folding editing.  (Allout code itself is to try it; 
     40;;    formatted as an outline - do ESC-x eval-current-buffer in allout.el; but 
     41;;    emacs local file variables need to be enabled when the 
     42;;    file was visited - see `enable-local-variables'.) 
     43;;  - Configurable per-file initial exposure settings 
     44;;  - Symmetric-key and key-pair topic encryption, plus symmetric passphrase 
    5045;;    mnemonic support, with verification against an established passphrase 
    5146;;    (using a stashed encrypted dummy string) and user-supplied hint 
    52 ;;    maintenance.  (see allout-toggle-current-subtree-encryption docstring.) 
    53 ;;  - automatic topic-number maintenance 
    54 ;;  - "hot-spot" operation, for single-keystroke maneuvering and 
     47;;    maintenance.  (See allout-toggle-current-subtree-encryption docstring.) 
     48;;  - Automatic topic-number maintenance 
     49;;  - "Hot-spot" operation, for single-keystroke maneuvering and 
    5550;;    exposure control (see the allout-mode docstring) 
    56 ;;  - easy rendering of exposed portions into numbered, latex, indented, etc 
     51;;  - Easy rendering of exposed portions into numbered, latex, indented, etc 
    5752;;    outline styles 
     53;;  - Careful attention to whitespace - enabling blank lines between items 
     54;;    and maintenance of hanging indentation (in paragraph auto-fill and 
     55;;    across topic promotion and demotion) of topic bodies consistent with 
     56;;    indentation of their topic header. 
    5857;; 
    5958;; and more. 
     59;; 
     60;; See the `allout-mode' function's docstring for an introduction to the 
     61;; mode.  The development version and helpful notes are available at 
     62;; http://myriadicity.net/Sundry/EmacsAllout . 
    6063;; 
    6164;; The outline menubar additions provide quick reference to many of 
     
    7679;;; Code: 
    7780 
    78 ;;;_* Provide 
    79 ;(provide 'outline) 
    80 (provide 'allout) 
    81  
    8281;;;_* Dependency autoloads 
     82(require 'overlay) 
    8383(eval-when-compile (progn (require 'pgg) 
    8484                          (require 'pgg-gpg) 
    85                           (fset 'allout-real-isearch-abort 
    86                                 (symbol-function 'isearch-abort)) 
     85                          (require 'overlay) 
    8786                          )) 
    8887(autoload 'pgg-gpg-symmetric-key-p "pgg-gpg" 
     
    9089 
    9190;;;_* USER CUSTOMIZATION VARIABLES: 
     91 
     92;;;_ > defgroup allout 
    9293(defgroup allout nil 
    9394  "Extensive outline mode for use alone and with other modes." 
     
    126127                (const :tag "Off" nil)) 
    127128  :group 'allout) 
    128 ;;;_  = allout-layout 
    129 (defvar allout-layout nil 
    130   "*Layout specification and provisional mode trigger for allout outlines. 
    131  
    132 Buffer-specific. 
    133  
    134 A list value specifies a default layout for the current buffer, to be 
    135 applied upon activation of `allout-mode'.  Any non-nil value will 
    136 automatically trigger `allout-mode' \(provided `allout-init' has been called 
    137 to enable this behavior). 
    138  
    139 See the docstring for `allout-init' for details on setting up for 
    140 auto-mode-activation, and for `allout-expose-topic' for the format of 
    141 the layout specification. 
    142  
    143 You can associate a particular outline layout with a file by setting 
    144 this var via the file's local variables.  For example, the following 
    145 lines at the bottom of an Emacs Lisp file: 
    146  
    147 ;;;Local variables: 
    148 ;;;allout-layout: \(0 : -1 -1 0) 
    149 ;;;End: 
    150  
    151 will, modulo the above-mentioned conditions, cause the mode to be 
    152 activated when the file is visited, followed by the equivalent of 
    153 `\(allout-expose-topic 0 : -1 -1 0)'.  \(This is the layout used for 
    154 the allout.el, itself.) 
     129;;;_  = allout-default-layout 
     130(defcustom allout-default-layout '(-2 : 0) 
     131  "*Default allout outline layout specification. 
     132 
     133This setting specifies the outline exposure to use when 
     134`allout-layout' has the local value `t'.  This docstring describes the 
     135layout specifications. 
     136 
     137A list value specifies a default layout for the current buffer, 
     138to be applied upon activation of `allout-mode'.  Any non-nil 
     139value will automatically trigger `allout-mode', provided 
     140`allout-init' has been called to enable this behavior. 
     141 
     142The types of elements in the layout specification are: 
     143 
     144 integer - dictate the relative depth to open the corresponding topic(s), 
     145           where: 
     146         - negative numbers force the topic to be closed before opening 
     147           to the absolute value of the number, so all siblings are open 
     148           only to that level. 
     149         - positive numbers open to the relative depth indicated by the 
     150           number, but do not force already opened subtopics to be closed. 
     151         - 0 means to close topic - hide all subitems. 
     152 :   - repeat spec - apply the preceeding element to all siblings at 
     153       current level, *up to* those siblings that would be covered by specs 
     154       following the `:' on the list.  Ie, apply to all topics at level but 
     155       trailing ones accounted for by trailing specs.  \(Only the first of 
     156       multiple colons at the same level is honored - later ones are ignored.) 
     157 *   - completely exposes the topic, including bodies 
     158 +   - exposes all subtopics, but not the bodies 
     159 -   - exposes the body of the corresponding topic, but not subtopics 
     160 list - a nested layout spec, to be applied intricately to its 
     161        corresponding item(s) 
     162 
     163Examples: 
     164 '(-2 : 0) 
     165        Collapse the top-level topics to show their children and 
     166        grandchildren, but completely collapse the final top-level topic. 
     167 '(-1 () : 1 0) 
     168        Close the first topic so only the immediate subtopics are shown, 
     169        leave the subsequent topics exposed as they are until the second 
     170        second to last topic, which is exposed at least one level, and 
     171        completely close the last topic. 
     172 '(-2 : -1 *) 
     173        Expose children and grandchildren of all topics at current 
     174        level except the last two; expose children of the second to 
     175        last and completely expose the last one, including its subtopics. 
     176 
     177See `allout-expose-topic' for more about the exposure process. 
    155178 
    156179Also, allout's mode-specific provisions will make topic prefixes default 
    157180to the comment-start string, if any, of the language of the file.  This 
    158 is modulo the setting of `allout-use-mode-specific-leader', which see.") 
    159 (make-variable-buffer-local 'allout-layout) 
     181is modulo the setting of `allout-use-mode-specific-leader', which see." 
     182  :type 'allout-layout-type 
     183  :group 'allout) 
     184;;;_  : allout-layout-type 
     185(define-widget 'allout-layout-type 'lazy 
     186  "Allout layout format customization basic building blocks." 
     187  :type '(repeat 
     188          (choice (integer :tag "integer (<= zero is strict)") 
     189                  (const :tag ": (repeat prior)" :) 
     190                  (const :tag "* (completely expose)" *) 
     191                  (const :tag "+ (expose all offspring, headlines only)" +) 
     192                  (const :tag "- (expose topic body but not offspring)" -) 
     193                  (allout-layout-type :tag "<Nested layout>")))) 
     194 
    160195;;;_  = allout-show-bodies 
    161196(defcustom allout-show-bodies nil 
     
    451486(make-variable-buffer-local 'allout-passphrase-hint-handling) 
    452487;;;_  = allout-encrypt-unencrypted-on-saves 
    453 (defcustom allout-encrypt-unencrypted-on-saves 'except-curren
     488(defcustom allout-encrypt-unencrypted-on-saves
    454489  "*When saving, should topics pending encryption be encrypted? 
    455490 
     
    486521 
    487522;;;_  = allout-command-prefix 
    488 (defcustom allout-command-prefix "\C-c" 
    489   "*Key sequence to be used as prefix for outline mode command key bindings." 
     523(defcustom allout-command-prefix "\C-c " 
     524  "*Key sequence to be used as prefix for outline mode command key bindings. 
     525 
     526Default is '\C-c<space>'; just '\C-c' is more short-and-sweet, if you're 
     527willing to let allout use a bunch of \C-c keybindings." 
    490528  :type 'string 
    491529  :group 'allout) 
     
    539577        ("=p" allout-flatten-exposed-to-buffer))) 
    540578 
    541 ;;;_  = allout-isearch-dynamic-expose 
    542 (defcustom allout-isearch-dynamic-expose t 
    543   "*Non-nil enable dynamic exposure of hidden incremental-search 
    544 targets as they're encountered." 
    545   :type 'boolean 
    546   :group 'allout) 
    547 (make-variable-buffer-local 'allout-isearch-dynamic-expose) 
    548  
    549579;;;_  = allout-use-hanging-indents 
    550580(defcustom allout-use-hanging-indents t 
     
    552582Ie, it is indented to be just past the header prefix.  This is 
    553583relevant mostly for use with indented-text-mode, or other situations 
    554 where auto-fill occurs. 
    555  
    556 \[This feature no longer depends in any way on the `filladapt.el' 
    557 lisp-archive package.\]" 
     584where auto-fill occurs." 
    558585  :type 'boolean 
    559586  :group 'allout) 
     
    598625;;;_  : Version 
    599626;;;_   = allout-version 
    600 (defvar allout-version "2.1" 
     627(defvar allout-version "2.2.1" 
    601628  "Version of currently loaded outline package.  \(allout.el)") 
    602629;;;_   > allout-version 
     
    612639(defvar allout-mode nil "Allout outline mode minor-mode flag.") 
    613640(make-variable-buffer-local 'allout-mode) 
     641;;;_   = allout-layout nil 
     642(defvar allout-layout nil            ; LEAVE GLOBAL VALUE NIL - see docstring. 
     643  "Buffer-specific setting for allout layout. 
     644 
     645In buffers where this is non-nil \(and if `allout-init' has been run, to 
     646enable this behavior), `allout-mode' will be automatically activated.  The 
     647layout dictated by the value will be used to set the initial exposure when 
     648`allout-mode' is activated. 
     649 
     650\*You should not setq-default this variable non-nil unless you want every 
     651visited file to be treated as an allout file.* 
     652 
     653The value would typically be set by a file local variable.  For 
     654example, the following lines at the bottom of an Emacs Lisp file: 
     655 
     656;;;Local variables: 
     657;;;allout-layout: \(0 : -1 -1 0) 
     658;;;End: 
     659 
     660dictate activation of `allout-mode' mode when the file is visited 
     661\(presuming allout-init was already run), followed by the 
     662equivalent of `\(allout-expose-topic 0 : -1 -1 0)'.  \(This is 
     663the layout used for the allout.el source file.) 
     664 
     665`allout-default-layout' describes the specification format. 
     666`allout-layout' can additionally have the value `t', in which 
     667case the value of `allout-default-layout' is used.") 
     668(make-variable-buffer-local 'allout-layout) 
     669;;;###autoload 
     670(put 'allout-layout 'safe-local-variable t) 
     671 
    614672;;;_  : Topic header format 
    615673;;;_   = allout-regexp 
     
    637695  "`allout-regexp' with outline style beginning-of-line anchor. 
    638696 
    639 \(Ie, C-j, *or* C-m, for prefixes of hidden topics).  This is properl
    640 set when `allout-regexp' is produced by `set-allout-regexp', so 
    641 that (match-beginning 2) and (match-end 2) delimit the prefix.") 
     697This is properly set when `allout-regexp' is produced b
     698`set-allout-regexp', so that (match-beginning 2) and (match-end 
     6992) delimit the prefix.") 
    642700(make-variable-buffer-local 'allout-line-boundary-regexp) 
    643701;;;_   = allout-bob-regexp 
     
    754812        cur-len 
    755813        cur-char 
    756         cur-char-string 
    757         index 
    758         new-string) 
     814        index) 
    759815    (while strings 
    760       (setq new-string "") (setq index 0) 
     816      (setq index 0) 
    761817      (setq cur-len (length (setq cur-string (symbol-value (car strings))))) 
    762818      (while (< index cur-len) 
     
    789845                               "+\\|\^l")) 
    790846  (setq allout-line-boundary-regexp 
    791         (concat "\\([\n\r]\\)\\(" allout-regexp "\\)")) 
     847        (concat "\\(\n\\)\\(" allout-regexp "\\)")) 
    792848  (setq allout-bob-regexp 
    793849        (concat "\\(\\`\\)\\(" allout-regexp "\\)")) 
     
    9561012  ) 
    9571013;;;_  : Mode-specific incidentals 
    958 ;;;_   = allout-pre-was-isearching nil 
    959 (defvar allout-pre-was-isearching nil 
    960   "Cue for isearch-dynamic-exposure mechanism, implemented in 
    961 allout-pre- and -post-command-hooks.") 
    962 (make-variable-buffer-local 'allout-pre-was-isearching) 
    963 ;;;_   = allout-isearch-prior-pos nil 
    964 (defvar allout-isearch-prior-pos nil 
    965   "Cue for isearch-dynamic-exposure tracking, used by 
    966 `allout-isearch-expose'.") 
    967 (make-variable-buffer-local 'allout-isearch-prior-pos) 
    968 ;;;_   = allout-isearch-did-quit 
    969 (defvar allout-isearch-did-quit nil 
    970   "Distinguishes isearch conclusion and cancellation. 
    971  
    972 Maintained by allout-isearch-abort \(which is wrapped around the real 
    973 isearch-abort), and monitored by allout-isearch-expose for action.") 
    974 (make-variable-buffer-local 'allout-isearch-did-quit) 
    9751014;;;_   > allout-unprotected (expr) 
    9761015(defmacro allout-unprotected (expr) 
    977   "Enable internal outline operations to alter read-only text." 
    978   `(let ((was-inhibit-r-o inhibit-read-only)) 
    979      (unwind-protect 
    980          (progn 
    981            (setq inhibit-read-only t) 
    982            ,expr) 
    983        (setq inhibit-read-only was-inhibit-r-o) 
    984        ) 
    985      ) 
    986   ) 
    987 ;;;_   = allout-undo-aggregation 
    988 (defvar allout-undo-aggregation 30 
    989   "Amount of successive self-insert actions to bunch together per undo. 
    990  
    991 This is purely a kludge variable, regulating the compensation for a bug in 
    992 the way that `before-change-functions' and undo interact.") 
    993 (make-variable-buffer-local 'allout-undo-aggregation) 
     1016  "Enable internal outline operations to alter invisible text." 
     1017  `(let ((inhibit-read-only t)) 
     1018     ,expr)) 
     1019;;;_   = allout-mode-hook 
     1020(defvar allout-mode-hook nil 
     1021  "*Hook that's run when allout mode starts.") 
     1022;;;_   = allout-overlay-category 
     1023(defvar allout-overlay-category nil 
     1024  "Symbol for use in allout invisible-text overlays as the category.") 
     1025;;;_   = allout-view-change-hook 
     1026(defvar allout-view-change-hook nil 
     1027  "*Hook that's run after allout outline visibility changes.") 
     1028 
     1029;;;_   = allout-outside-normal-auto-fill-function 
     1030(defvar allout-outside-normal-auto-fill-function nil 
     1031  "Value of normal-auto-fill-function outside of allout mode. 
     1032 
     1033Used by allout-auto-fill to do the mandated normal-auto-fill-function 
     1034wrapped within allout's automatic fill-prefix setting.") 
     1035(make-variable-buffer-local 'allout-outside-normal-auto-fill-function) 
    9941036;;;_   = file-var-bug hack 
    9951037(defvar allout-v18/19-file-var-hack nil 
     
    9971039mode from prop-line file-var activation.  Used by `allout-mode' function 
    9981040to track repeats.") 
    999 ;;;_   = allout-file-passphrase-verifier-string 
    1000 (defvar allout-file-passphrase-verifier-string nil 
    1001   "Name for use as a file variable for verifying encryption passphrase 
    1002 across sessions.") 
    1003 (make-variable-buffer-local 'allout-file-passphrase-verifier-string) 
    10041041;;;_   = allout-passphrase-verifier-string 
    10051042(defvar allout-passphrase-verifier-string nil 
     
    10171054`allout-enable-file-variable-adjustment' for details about that.") 
    10181055(make-variable-buffer-local 'allout-passphrase-verifier-string) 
     1056(put 'allout-passphrase-verifier-string 'safe-local-variable t) 
    10191057;;;_   = allout-passphrase-hint-string 
    10201058(defvar allout-passphrase-hint-string "" 
     
    10281066`allout-enable-file-variable-adjustment' for details about that.") 
    10291067(make-variable-buffer-local 'allout-passphrase-hint-string) 
     1068(put 'allout-passphrase-hint-string 'safe-local-variable t) 
    10301069(setq-default allout-passphrase-hint-string "") 
    10311070;;;_   = allout-after-save-decrypt 
     
    10601099          (progn 
    10611100            (message "auto-encrypting pending topics") 
    1062             (sit-for 2
     1101            (sit-for 0
    10631102            (condition-case failure 
    10641103                (setq allout-after-save-decrypt 
     
    11851224                          "Outline mode auto-activation and -layout enabled.") 
    11861225                         'full))))))) 
    1187  
    11881226;;;_  > allout-setup-menubar () 
    11891227(defun allout-setup-menubar () 
     
    11981236            menus (cdr menus)) 
    11991237      (easy-menu-add cur)))) 
     1238;;;_  > allout-set-overlay-category 
     1239(defun allout-set-overlay-category () 
     1240  "Set the properties of the allout invisible-text overlay." 
     1241  (setplist 'allout-overlay-category nil) 
     1242  (put 'allout-overlay-category 'invisible 'allout) 
     1243  (put 'allout-overlay-category 'evaporate t) 
     1244  ;; XXX We use isearch-open-invisible *and* isearch-mode-end-hook.  The 
     1245  ;; latter would be sufficient, but it seems that a separate behavior - 
     1246  ;; the _transient_ opening of invisible text during isearch - is keyed to 
     1247  ;; presence of the isearch-open-invisible property - even though this 
     1248  ;; property controls the isearch _arrival_ behavior.  This is the case at 
     1249  ;; least in emacs 21, 22.0, and xemacs 21.4. 
     1250  (put 'allout-overlay-category 'isearch-open-invisible 
     1251       'allout-isearch-end-handler) 
     1252  (if (featurep 'xemacs) 
     1253      (put 'allout-overlay-category 'start-open t) 
     1254    (put 'allout-overlay-category 'insert-in-front-hooks 
     1255         '(allout-overlay-insert-in-front-handler))) 
     1256  (if (featurep 'xemacs) 
     1257      (progn (make-variable-buffer-local 'before-change-functions) 
     1258             (add-hook 'before-change-functions 
     1259                       'allout-before-change-handler)) 
     1260    (put 'allout-overlay-category 'modification-hooks 
     1261         '(allout-overlay-interior-modification-handler)))) 
    12001262;;;_  > allout-mode (&optional toggle) 
    12011263;;;_   : Defun: 
     
    12041266;;;_    . Doc string: 
    12051267  "Toggle minor mode for controlling exposure and editing of text outlines. 
     1268\\<allout-mode-map> 
    12061269 
    12071270Optional arg forces mode to re-initialize iff arg is positive num or 
     
    12451308\\[allout-backward-current-level] allout-backward-current-level   | \\[allout-show-all] allout-show-all 
    12461309\\[allout-end-of-entry] allout-end-of-entry 
    1247 \\[allout-beginning-of-current-entry,] allout-beginning-of-current-entry, alternately, goes to hot-spot 
     1310\\[allout-beginning-of-current-entry] allout-beginning-of-current-entry, alternately, goes to hot-spot 
    12481311 
    12491312        Topic Header Production: 
    12501313        ----------------------- 
    1251 \\[allout-open-sibtopic]  allout-open-sibtopic        Create a new sibling after current topic. 
    1252 \\[allout-open-subtopic]  allout-open-subtopic        ... an offspring of current topic. 
    1253 \\[allout-open-supertopic]  allout-open-supertopic    ... a sibling of the current topic's parent. 
     1314\\[allout-open-sibtopic]       allout-open-sibtopic   Create a new sibling after current topic. 
     1315\\[allout-open-subtopic]       allout-open-subtopic   ... an offspring of current topic. 
     1316\\[allout-open-supertopic]     allout-open-supertopic ... a sibling of the current topic's parent. 
    12541317 
    12551318        Topic Level and Prefix Adjustment: 
    12561319        --------------------------------- 
    1257 \\[allout-shift-in]  allout-shift-in  Shift current topic and all offspring deeper. 
    1258 \\[allout-shift-out]  allout-shift-out        ... less deep. 
    1259 \\[allout-rebullet-current-heading]  allout-rebullet-current-heading Prompt for alternate bullet for 
     1320\\[allout-shift-in]    allout-shift-in        Shift current topic and all offspring deeper. 
     1321\\[allout-shift-out]   allout-shift-out       ... less deep. 
     1322\\[allout-rebullet-current-heading]    allout-rebullet-current-heading Prompt for alternate bullet for 
    12601323                                         current topic. 
    12611324\\[allout-rebullet-topic]       allout-rebullet-topic   Reconcile bullets of topic and its offspring 
    12621325                                - distinctive bullets are not changed, others 
    12631326                                  alternated according to nesting depth. 
    1264 \\[allout-number-siblings]  allout-number-siblings    Number bullets of topic and siblings - the 
     1327\\[allout-number-siblings]     allout-number-siblings Number bullets of topic and siblings - the 
    12651328                                offspring are not affected.  With repeat 
    12661329                                count, revoke numbering. 
     
    12681331        Topic-oriented Killing and Yanking: 
    12691332        ---------------------------------- 
    1270 \\[allout-kill-topic]     allout-kill-topic   Kill current topic, including offspring. 
    1271 \\[allout-kill-line]     allout-kill-line     Like kill-line, but reconciles numbering, etc. 
    1272 \\[allout-yank]     allout-yank               Yank, adjusting depth of yanked topic to 
     1333\\[allout-kill-topic]  allout-kill-topic      Kill current topic, including offspring. 
     1334\\[allout-kill-line]   allout-kill-line       Like kill-line, but reconciles numbering, etc. 
     1335\\[allout-yank]        allout-yank            Yank, adjusting depth of yanked topic to 
    12731336                                depth of heading if yanking into bare topic 
    12741337                                heading (ie, prefix sans text). 
    1275 \\[allout-yank-pop]     allout-yank-pop Is to allout-yank as yank-pop is to yank 
     1338\\[allout-yank-pop]     allout-yank-pop Is to allout-yank as yank-pop is to yank 
     1339 
     1340        Topic-oriented Encryption: 
     1341        ------------------------- 
     1342\\[allout-toggle-current-subtree-encryption]    allout-toggle-current-subtree-encryption Encrypt/Decrypt topic content 
    12761343 
    12771344        Misc commands: 
     
    12801347                                and establish a default file-var setting 
    12811348                                for `allout-layout'. 
    1282 \\[allout-mark-topic]     allout-mark-topic 
     1349\\[allout-mark-topic]          allout-mark-topic 
    12831350\\[allout-copy-exposed-to-buffer]     allout-copy-exposed-to-buffer 
    12841351                                Duplicate outline, sans concealed text, to 
    12851352                                buffer with name derived from derived from that 
    12861353                                of current buffer - \"*BUFFERNAME exposed*\". 
    1287 \\[allout-flatten-exposed-to-buffer]     allout-flatten-exposed-to-buffer 
     1354\\[allout-flatten-exposed-to-buffer]   allout-flatten-exposed-to-buffer 
    12881355                                Like above 'copy-exposed', but convert topic 
    12891356                                prefixes to section.subsection... numeric 
    12901357                                format. 
    1291 ESC ESC (allout-init t)       Setup Emacs session for outline mode 
     1358\\[eval-expression] (allout-init t)   Setup Emacs session for outline mode 
    12921359                                auto-activation. 
    12931360 
    1294                   Encrypted Entries 
    1295  
    1296 Outline mode supports easily togglable gpg encryption of topics, with 
    1297 niceties like support for symmetric and key-pair modes, passphrase timeout, 
    1298 passphrase consistency checking, user-provided hinting for symmetric key 
    1299 mode, and auto-encryption of topics pending encryption on save.  The aim is 
    1300 to enable reliable topic privacy while preventing accidents like neglected 
    1301 encryption, encryption with a mistaken passphrase, forgetting which 
    1302 passphrase was used, and other practical pitfalls. 
     1361                  Topic Encryption 
     1362 
     1363Outline mode supports gpg encryption of topics, with support for 
     1364symmetric and key-pair modes, passphrase timeout, passphrase 
     1365consistency checking, user-provided hinting for symmetric key 
     1366mode, and auto-encryption of topics pending encryption on save. 
     1367\(Topics pending encryption are, by default, automatically 
     1368encrypted during file saves; if you're editing the contents of 
     1369such a topic, it is automatically decrypted for continued 
     1370editing.)  The aim is reliable topic privacy while preventing 
     1371accidents like neglected encryption before saves, forgetting 
     1372which passphrase was used, and other practical pitfalls. 
    13031373 
    13041374See `allout-toggle-current-subtree-encryption' function docstring and 
     
    13101380navigation and exposure control. 
    13111381 
    1312 \\<allout-mode-map> 
    13131382When the text cursor is positioned directly on the bullet character of 
    13141383a topic, regular characters (a to z) invoke the commands of the 
    13151384corresponding allout-mode keymap control chars.  For example, \"f\" 
    1316 would invoke the command typically bound to \"C-c C-f\" 
     1385would invoke the command typically bound to \"C-c<space>C-f\" 
    13171386\(\\[allout-forward-current-level] `allout-forward-current-level'). 
    13181387 
    1319 Thus, by positioning the cursor on a topic bullet, you can execute 
    1320 the outline navigation and manipulation commands with a single 
    1321 keystroke.  Non-literal chars never get this special translation, so 
    1322 you can use them to get away from the hot-spot, and back to normal 
    1323 operation. 
     1388Thus, by positioning the cursor on a topic bullet, you can 
     1389execute the outline navigation and manipulation commands with a 
     1390single keystroke.  Regular navigation keys (eg, \\[forward-char], \\[next-line]) never get 
     1391this special translation, so you can use them to get out of the 
     1392hot-spot and back to normal operation. 
    13241393 
    13251394Note that the command `allout-beginning-of-current-entry' \(\\[allout-beginning-of-current-entry]\) 
    13261395will move to the hot-spot when the cursor is already located at the 
    1327 beginning of the current entry, so you can simply hit \\[allout-beginning-of-current-entry] 
     1396beginning of the current entry, so you usually can hit \\[allout-beginning-of-current-entry] 
    13281397twice in a row to get to the hot-spot. 
    13291398 
     
    13331402 
    13341403TOPIC:  A basic, coherent component of an Emacs outline.  It can 
    1335         contain other topics, and it can be subsumed by other topics, 
     1404        contain and be contained by other topics. 
    13361405CURRENT topic: 
    13371406        The visible topic most immediately containing the cursor. 
     
    13771446PREFIX-PADDING: 
    13781447        Spaces or asterisks which separate the prefix-lead and the 
    1379         bullet, according to the depth of the topic. 
     1448        bullet, determining the depth of the topic. 
    13801449BULLET: A character at the end of the topic prefix, it must be one of 
    13811450        the characters listed on `allout-plain-bullets-string' or 
    13821451        `allout-distinctive-bullets-string'.  (See the documentation 
    13831452        for these variables for more details.)  The default choice of 
    1384         bullet when generating varies in a cycle with the depth of the 
    1385         topic. 
     1453        bullet when generating topics varies in a cycle with the depth of 
     1454        the topic. 
    13861455ENTRY:  The text contained in a topic before any offspring. 
    13871456BODY:   Same as ENTRY. 
     
    13941463        Topics and entry text whose display is inhibited.  Contiguous 
    13951464        units of concealed text is represented by `...' ellipses. 
    1396         (Ref the `selective-display' var.) 
    13971465 
    13981466        Concealed topics are effectively collapsed within an ancestor. 
     
    14161484         (same-complex-command (eq allout-v18/19-file-var-hack 
    14171485                                  (car command-history))) 
    1418          (write-file-hook-var-name (if (boundp 'write-file-functions) 
    1419                                        'write-file-functions 
    1420                                      'local-write-file-hooks)) 
     1486         (write-file-hook-var-name (cond ((boundp 'write-file-functions) 
     1487                                          'write-file-functions) 
     1488                                         ((boundp 'write-file-hooks) 
     1489                                          'write-file-hooks) 
     1490                                         (t 'local-write-file-hooks))) 
    14211491         do-layout 
    14221492         ) 
     
    14661536           (allout-resumptions 'allout-primary-bullet) 
    14671537           (allout-resumptions 'allout-old-style-prefixes))) 
    1468       (allout-resumptions 'selective-display) 
    1469       (if (and (boundp 'before-change-functions) before-change-functions) 
    1470           (allout-resumptions 'before-change-functions)) 
     1538      ;;(allout-resumptions 'selective-display) 
     1539      (remove-from-invisibility-spec '(allout . t)) 
    14711540      (set write-file-hook-var-name 
    14721541           (delq 'allout-write-file-hook-handler 
     
    14771546      (allout-resumptions 'paragraph-start) 
    14781547      (allout-resumptions 'paragraph-separate) 
    1479       (allout-resumptions (if (string-match "^18" emacs-version) 
    1480                               'auto-fill-hook 
    1481                             'auto-fill-function)) 
     1548      (allout-resumptions 'auto-fill-function) 
     1549      (allout-resumptions 'normal-auto-fill-function) 
    14821550      (allout-resumptions 'allout-former-auto-filler) 
    14831551      (setq allout-mode nil)) 
     
    14901558           (allout-resumptions 'allout-primary-bullet '("*")) 
    14911559           (allout-resumptions 'allout-old-style-prefixes '(())))) 
     1560 
     1561      (allout-set-overlay-category)     ; Doesn't hurt to redo this. 
    14921562 
    14931563      (allout-infer-header-lead) 
     
    15261596        ) 
    15271597 
    1528                                        ; selective-display is the 
    1529                                        ; emacs conditional exposure 
    1530                                        ; mechanism: 
    1531       (allout-resumptions 'selective-display '(t)) 
     1598      (add-to-invisibility-spec '(allout . t)) 
     1599      (make-local-variable 'line-move-ignore-invisible) 
     1600      (setq line-move-ignore-invisible t) 
    15321601      (add-hook 'pre-command-hook 'allout-pre-command-business) 
    15331602      (add-hook 'post-command-hook 'allout-post-command-business) 
     1603      (add-hook 'isearch-mode-end-hook 'allout-isearch-end-handler) 
    15341604      (add-hook write-file-hook-var-name 'allout-write-file-hook-handler) 
    15351605      (add-hook 'auto-save-hook 'allout-auto-save-hook-handler) 
     
    15371607                                       ; respect for topic headline, 
    15381608                                       ; hanging-indents, etc: 
    1539       (let* ((fill-func-var (if (string-match "^18" emacs-version) 
    1540                                'auto-fill-hook 
    1541                              'auto-fill-function)) 
    1542             (fill-func (symbol-value fill-func-var))) 
    1543         ;; Register prevailing fill func for use by allout-auto-fill: 
    1544         (allout-resumptions 'allout-former-auto-filler (list fill-func)) 
    1545         ;; Register allout-auto-fill to be used if filling is active: 
    1546         (allout-resumptions fill-func-var '(allout-auto-fill))) 
     1609      ;; Register prevailing fill func for use by allout-auto-fill: 
     1610      (allout-resumptions 'allout-former-auto-filler (list auto-fill-function)) 
     1611      ;; Register allout-auto-fill to be used if filling is active: 
     1612      (allout-resumptions 'auto-fill-function '(allout-auto-fill)) 
     1613      (allout-resumptions 'allout-outside-normal-auto-fill-function 
     1614                          (list normal-auto-fill-function)) 
     1615      (allout-resumptions 'normal-auto-fill-function '(allout-auto-fill)) 
    15471616      ;; Paragraphs are broken by topic headlines. 
    15481617      (make-local-variable 'paragraph-start) 
     
    15641633          (setq do-layout t)) 
    15651634 
    1566       (if (and allout-isearch-dynamic-expose 
    1567                (not (fboundp 'allout-real-isearch-abort))) 
    1568           (allout-enwrap-isearch)) 
    1569  
    15701635      (run-hooks 'allout-mode-hook) 
    15711636      (setq allout-mode t)) 
     
    15761641     )                                  ; cond 
    15771642 
    1578     (if (and do-layout 
    1579              allout-auto-activation 
    1580              (listp allout-layout) 
    1581              (and (not (eq allout-auto-activation 'activate)) 
    1582                   (if (eq allout-auto-activation 'ask) 
    1583                       (if (y-or-n-p (format "Expose %s with layout '%s'? " 
    1584                                             (buffer-name) 
    1585                                             allout-layout)) 
    1586                           t 
    1587                         (message "Skipped %s layout." (buffer-name)) 
    1588                         nil) 
    1589                     t))) 
    1590         (save-excursion 
    1591           (message "Adjusting '%s' exposure..." (buffer-name)) 
    1592           (goto-char 0) 
    1593           (allout-this-or-next-heading) 
    1594           (condition-case err 
    1595               (progn 
    1596                 (apply 'allout-expose-topic (list allout-layout)) 
    1597                 (message "Adjusting '%s' exposure... done." (buffer-name))) 
    1598             ;; Problem applying exposure - notify user, but don't 
    1599             ;; interrupt, eg, file visit: 
    1600             (error (message "%s" (car (cdr err))) 
    1601                    (sit-for 1))))) 
     1643    (let ((use-layout (if (listp allout-layout) 
     1644                          allout-layout 
     1645                        allout-default-layout))) 
     1646      (if (and do-layout 
     1647               allout-auto-activation 
     1648               use-layout 
     1649               (and (not (eq allout-auto-activation 'activate)) 
     1650                    (if (eq allout-auto-activation 'ask) 
     1651                        (if (y-or-n-p (format "Expose %s with layout '%s'? " 
     1652                                              (buffer-name) 
     1653                                              use-layout)) 
     1654                            t 
     1655                          (message "Skipped %s layout." (buffer-name)) 
     1656                          nil) 
     1657                      t))) 
     1658          (save-excursion 
     1659            (message "Adjusting '%s' exposure..." (buffer-name)) 
     1660            (goto-char 0) 
     1661            (allout-this-or-next-heading) 
     1662            (condition-case err 
     1663                (progn 
     1664                  (apply 'allout-expose-topic (list use-layout)) 
     1665                  (message "Adjusting '%s' exposure... done." (buffer-name))) 
     1666              ;; Problem applying exposure - notify user, but don't 
     1667              ;; interrupt, eg, file visit: 
     1668              (error (message "%s" (car (cdr err))) 
     1669                     (sit-for 1)))))) 
    16021670    allout-mode 
    16031671    )                                   ; let* 
     
    16051673;;;_  > allout-minor-mode 
    16061674(defalias 'allout-minor-mode 'allout-mode) 
     1675 
     1676;;;_  - Position Assessment 
     1677;;;_   > allout-hidden-p (&optional pos) 
     1678(defsubst allout-hidden-p (&optional pos) 
     1679  "Non-nil if the character after point is invisible." 
     1680  (get-char-property (or pos (point)) 'invisible)) 
     1681 
     1682;;;_  > allout-overlay-insert-in-front-handler (ol after beg end 
     1683;;;                                                &optional prelen) 
     1684(defun allout-overlay-insert-in-front-handler (ol after beg end 
     1685                                                  &optional prelen) 
     1686  "Shift the overlay so stuff inserted in front of it are excluded." 
     1687  (if after 
     1688      (move-overlay ol (1+ beg) (overlay-end ol)))) 
     1689;;;_  > allout-overlay-interior-modification-handler (ol after beg end 
     1690;;;                                                      &optional prelen) 
     1691(defun allout-overlay-interior-modification-handler (ol after beg end 
     1692                                                        &optional prelen) 
     1693  "Get confirmation before making arbitrary changes to invisible text. 
     1694 
     1695We expose the invisible text and ask for confirmation.  Refusal or 
     1696keyboard-quit abandons the changes, with keyboard-quit additionally 
     1697reclosing the opened text. 
     1698 
     1699No confirmation is necessary when inhibit-read-only is set - eg, allout 
     1700internal functions use this feature cohesively bunch changes." 
     1701 
     1702  (when (and (not inhibit-read-only) (not after)) 
     1703    (let ((start (point)) 
     1704          (ol-start (overlay-start ol)) 
     1705          (ol-end (overlay-end ol)) 
     1706          (msg "Change within concealed text disallowed.") 
     1707          opened 
     1708          first) 
     1709      (goto-char beg) 
     1710      (while (< (point) end) 
     1711        (when (allout-hidden-p) 
     1712          (allout-show-to-offshoot) 
     1713          (if (allout-hidden-p) 
     1714              (save-excursion (forward-char 1) 
     1715                              (allout-show-to-offshoot))) 
     1716          (when (not first) 
     1717            (setq opened t) 
     1718            (setq first (point)))) 
     1719        (goto-char (if (featurep 'xemacs) 
     1720                       (next-property-change (1+ (point)) nil end) 
     1721                     (next-char-property-change (1+ (point)) end)))) 
     1722      (when first 
     1723        (goto-char first) 
     1724        (condition-case nil 
     1725            (if (not 
     1726                 (yes-or-no-p 
     1727                  (substitute-command-keys 
     1728                   (concat "Modify concealed text?  (\"no\" just aborts," 
     1729                           " \\[keyboard-quit] also reconceals) ")))) 
     1730                (progn (goto-char start) 
     1731                       (error "Concealed-text change refused."))) 
     1732          (quit (allout-flag-region ol-start ol-end nil) 
     1733                (allout-flag-region ol-start ol-end t) 
     1734                (error "Concealed-text change abandoned, text reconcealed.")))) 
     1735      (goto-char start)))) 
     1736;;;_  > allout-before-change-handler (beg end) 
     1737(defun allout-before-change-handler (beg end) 
     1738  "Protect against changes to invisible text. 
     1739 
     1740See allout-overlay-interior-modification-handler for details. 
     1741 
     1742This before-change handler is used only where modification-hooks 
     1743overlay property is not supported." 
     1744  (if (not (allout-mode-p)) 
     1745      nil 
     1746    (allout-overlay-interior-modification-handler nil nil beg end nil))) 
     1747;;;_  > allout-isearch-end-handler (&optional overlay) 
     1748(defun allout-isearch-end-handler (&optional overlay) 
     1749  "Reconcile allout outline exposure on arriving in hidden text after isearch. 
     1750 
     1751Optional OVERLAY parameter is for when this function is used by 
     1752`isearch-open-invisible' overlay property.  It is otherwise unused, so this 
     1753function can also be used as an `isearch-mode-end-hook'." 
     1754 
     1755  (if (and (allout-mode-p) (allout-hidden-p)) 
     1756      (allout-show-to-offshoot))) 
    16071757 
    16081758;;;_ #3 Internal Position State-Tracking - "allout-recent-*" funcs 
     
    16761826Actually, returns prefix beginning point." 
    16771827  (save-excursion 
    1678     (beginning-of-line) 
     1828    (allout-beginning-of-current-line) 
    16791829    (and (looking-at allout-regexp) 
    16801830         (allout-prefix-data (match-beginning 0) (match-end 0))))) 
     
    16871837                       (looking-at allout-regexp)) 
    16881838       (= (point)(save-excursion (allout-end-of-prefix)(point))))) 
    1689 ;;;_    > allout-hidden-p () 
    1690 (defmacro allout-hidden-p () 
    1691   "True if point is in hidden text." 
    1692   '(save-excursion 
    1693      (and (re-search-backward "[\n\r]" () t) 
    1694           (= ?\r (following-char))))) 
    1695 ;;;_    > allout-visible-p () 
    1696 (defmacro allout-visible-p () 
    1697   "True if point is not in hidden text." 
    1698   (interactive) 
    1699   '(not (allout-hidden-p))) 
    17001839;;;_   : Location attributes 
    17011840;;;_    > allout-depth () 
    1702 (defsubst allout-depth () 
    1703   "Like `allout-current-depth', but respects hidden as well as visible topics." 
     1841(defun allout-depth () 
     1842  "Return depth of topic most immediately containing point. 
     1843 
     1844Return zero if point is not within any topic. 
     1845 
     1846Like `allout-current-depth', but respects hidden as well as visible topics." 
    17041847  (save-excursion 
    1705     (if (allout-goto-prefix) 
    1706         (allout-recent-depth) 
    1707       (progn 
    1708         ;; Oops, no prefix, zero prefix data: 
    1709         (allout-prefix-data (point)(point)) 
    1710         ;; ... and return 0: 
    1711         0)))) 
     1848    (let ((start-point (point))) 
     1849      (if (and (allout-goto-prefix) 
     1850               (not (< start-point (point)))) 
     1851          (allout-recent-depth) 
     1852        (progn 
     1853          ;; Oops, no prefix, zero prefix data: 
     1854          (allout-prefix-data (point)(point)) 
     1855          ;; ... and return 0: 
     1856          0))))) 
    17121857;;;_    > allout-current-depth () 
    1713 (defmacro allout-current-depth () 
    1714   "Return nesting depth of visible topic most immediately containing point." 
    1715   '(save-excursion 
    1716      (if (allout-back-to-current-heading) 
    1717          (max 1 
    1718               (- allout-recent-prefix-end 
    1719                  allout-recent-prefix-beginning 
    1720                  allout-header-subtraction)) 
    1721        0))) 
     1858(defun allout-current-depth () 
     1859  "Return depth of visible topic most immediately containing point. 
     1860 
     1861Return zero if point is not within any topic." 
     1862  (save-excursion 
     1863    (if (allout-back-to-current-heading) 
     1864        (max 1 
     1865             (- allout-recent-prefix-end 
     1866                allout-recent-prefix-beginning 
     1867                allout-header-subtraction)) 
     1868      0))) 
    17221869;;;_    > allout-get-current-prefix () 
    17231870(defun allout-get-current-prefix () 
     
    17351882(defun allout-current-bullet () 
    17361883  "Return bullet of current (visible) topic heading, or none if none found." 
    1737   (condition-case err 
     1884  (condition-case nil 
    17381885      (save-excursion 
    17391886        (allout-back-to-current-heading) 
     
    17841931  ) 
    17851932 
    1786 ;;;_  - Navigation macros 
     1933;;;_  - Navigation routines 
     1934;;;_   > allout-beginning-of-current-line () 
     1935(defun allout-beginning-of-current-line () 
     1936  "Like beginning of line, but to visible text." 
     1937 
     1938  ;; XXX We would use `(move-beginning-of-line 1)', but it gets 
     1939  ;; stuck on some hidden newlines, eg at column 80, as of GNU Emacs 22.0.50. 
     1940  ;; Conversely, `beginning-of-line' can make no progress in other 
     1941  ;; situations.  Both are necessary, in the order used below. 
     1942  (move-beginning-of-line 1) 
     1943  (beginning-of-line) 
     1944  (while (or (not (bolp)) (allout-hidden-p)) 
     1945    (beginning-of-line) 
     1946    (if (or (allout-hidden-p) (not (bolp))) 
     1947        (forward-char -1)))) 
     1948;;;_   > allout-end-of-current-line () 
     1949(defun allout-end-of-current-line () 
     1950  "Move to the end of line, past concealed text if any." 
     1951  ;; XXX This is for symmetry with `allout-beginning-of-current-line' - 
     1952  ;; `move-end-of-line' doesn't suffer the same problem as 
     1953  ;; `move-beginning-of-line'. 
     1954  (end-of-line) 
     1955  (while (allout-hidden-p) 
     1956    (end-of-lin