(allout-prefix-data): Doc fix.
[bpt/emacs.git] / lisp / allout.el
index b7ae0f5..43642e6 100644 (file)
@@ -1,7 +1,7 @@
 ;;; allout.el --- extensive outline mode for use alone and with other modes
 
 ;; Copyright (C) 1992, 1993, 1994, 2001, 2002, 2003, 2004,
-;;   2005, 2006 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Ken Manheimer <ken dot manheimer at gmail dot com>
 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com>
@@ -14,7 +14,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -45,7 +45,9 @@
 ;;  - Symmetric-key and key-pair topic encryption, plus symmetric passphrase
 ;;    mnemonic support, with verification against an established passphrase
 ;;    (using a stashed encrypted dummy string) and user-supplied hint
-;;    maintenance.  (See allout-toggle-current-subtree-encryption docstring.)
+;;    maintenance.  (See allout-toggle-current-subtree-encryption docstring.
+;;    Currently only GnuPG encryption is supported, and integration
+;;    with gpg-agent is not yet implemented.)
 ;;  - Automatic topic-number maintenance
 ;;  - "Hot-spot" operation, for single-keystroke maneuvering and
 ;;    exposure control (see the allout-mode docstring)
@@ -162,7 +164,7 @@ The types of elements in the layout specification are:
  :   - repeat spec - apply the preceeding element to all siblings at
        current level, *up to* those siblings that would be covered by specs
        following the `:' on the list.  Ie, apply to all topics at level but
-       trailing ones accounted for by trailing specs.  \(Only the first of
+       trailing ones accounted for by trailing specs.  (Only the first of
        multiple colons at the same level is honored - later ones are ignored.)
  *   - completely exposes the topic, including bodies
  +   - exposes all subtopics, but not the bodies
@@ -230,9 +232,9 @@ advance as follows:
  - if the cursor is on the headline and not the start of the headline:
    then it goes to the start of the headline
  - if the cursor is on the start of the headline:
-   then it goes to the bullet character \(for hotspot navigation\)
+   then it goes to the bullet character (for hotspot navigation)
  - if the cursor is on the bullet character:
-   then it goes to the first column of that line \(the headline\)
+   then it goes to the first column of that line (the headline)
  - if the cursor is on the first column of the headline:
    then it goes to the start of the headline within the item body.
 
@@ -322,29 +324,42 @@ of this var to take effect."
 (defcustom allout-distinctive-bullets-string "*+-=>()[{}&!?#%\"X@$~_\\:;^"
   "*Persistent outline header bullets used to distinguish special topics.
 
-These bullets are used to distinguish topics from the run-of-the-mill
-ones.  They are not used in the standard topic headers created by
-the topic-opening, shifting, and rebulleting \(eg, on topic shift,
-topic paste, blanket rebulleting) routines, but are offered among the
-choices for rebulleting.  They are not altered by the above automatic
-rebulleting, so they can be used to characterize topics, eg:
+These bullets are distinguish topics with particular character.
+They are not used by default in the topic creation routines, but
+are offered as options when you modify topic creation with a
+universal argument \(\\[universal-argument]), or during rebulleting \(\\[allout-rebullet-current-heading]).
 
- `?' question topics
- `\(' parenthetic comment \(with a matching close paren inside)
- `[' meta-note \(with a matching close ] inside)
- `\"' a quotation
- `=' value settings
- `~' \"more or less\"
- `^' see above
+Distinctive bullets are not cycled when topics are shifted or
+otherwise automatically rebulleted, so their marking is
+persistent until deliberately changed.  Their significance is
+purely by convention, however.  Some conventions suggest
+themselves:
 
- ... for example.  (`#' typically has a special meaning to the software,
-according to the value of `allout-numbered-bullet'.)
+ `(' - open paren - an aside or incidental point
+ `?' - question mark - uncertain or outright question
+ `!' - exclamation point/bang - emphatic
+ `[' - open square bracket - meta-note, about item instead of item's subject
+ `\"' - double quote - a quotation or other citation
+ `=' - equal sign - an assignement, equating a name with some connotation
+ `^' - carat - relates to something above
 
-See `allout-plain-bullets-string' for the selection of
-alternating bullets.
+Some are more elusive, but their rationale may be recognizable:
+
+ `+' - plus - pending consideration, completion
+ `_' - underscore - done, completed
+ `&' - ampersand - addendum, furthermore
+
+\(Some other non-plain bullets have special meaning to the
+software.  By default:
+
+ `~' marks encryptable topics - see `allout-topic-encryption-bullet'
+ `#' marks auto-numbered bullets - see `allout-numbered-bullet'.)
+
+See `allout-plain-bullets-string' for the standard, alternating
+bullets.
 
 You must run `set-allout-regexp' in order for outline mode to
-reconcile to changes of this value.
+adopt changes of this value.
 
 DO NOT include the close-square-bracket, `]', on either of the bullet
 strings."
@@ -367,20 +382,20 @@ String values are used as literals, not regular expressions, so
 do not escape any regulare-expression characters.
 
 Value t means to first check for assoc value in `allout-mode-leaders'
-alist, then use comment-start string, if any, then use default \(`.').
+alist, then use comment-start string, if any, then use default (`.').
 \(See note about use of comment-start strings, below.)
 
 Set to the symbol for either of `allout-mode-leaders' or
 `comment-start' to use only one of them, respectively.
 
-Value nil means to always use the default \(`.') and leave
+Value nil means to always use the default (`.') and leave
 `allout-primary-bullet' unaltered.
 
 comment-start strings that do not end in spaces are tripled in
 the header-prefix, and an `_' underscore is tacked on the end, to
 distinguish them from regular comment strings.  comment-start
 strings that do end in spaces are not tripled, but an underscore
-is substituted for the space. [This presumes that the space is
+is substituted for the space.  [This presumes that the space is
 for appearance, not comment syntax.  You can use
 `allout-mode-leaders' to override this behavior, when
 undesired.]"
@@ -605,7 +620,7 @@ The idea is to prevent file-system exposure of any un-encrypted stuff, and
 mostly covers both deliberate file writes and auto-saves.
 
  - Yes: encrypt all topics pending encryption, even if it's the one
-        currently being edited.  \(In that case, the currently edited topic
+        currently being edited.  (In that case, the currently edited topic
         will be automatically decrypted before any user interaction, so they
         can continue editing but the copy on the file system will be
         encrypted.)
@@ -619,7 +634,7 @@ mostly covers both deliberate file writes and auto-saves.
  - No: leave it to the user to encrypt any unencrypted topics.
 
 For practical reasons, auto-saves always use the 'except-current policy
-when auto-encryption is enabled.  \(Otherwise, spurious passphrase prompts
+when auto-encryption is enabled.  (Otherwise, spurious passphrase prompts
 and unavoidable timing collisions are too disruptive.)  If security for a
 file requires that even the current topic is never auto-saved in the clear,
 disable auto-saves for that file."
@@ -717,8 +732,8 @@ unless optional third, non-nil element is present.")
 
 You can customize this setting to set it for all allout buffers, or set it
 in individual buffers if you want to inhibit auto-fill only in particular
-buffers.  \(You could use a function on `allout-mode-hook' to inhibit
-auto-fill according, eg, to the major mode.\)
+buffers.  (You could use a function on `allout-mode-hook' to inhibit
+auto-fill according, eg, to the major mode.)
 
 If you don't set this and auto-fill-mode is enabled, allout will use the
 value that `normal-auto-fill-function', if any, when allout mode starts, or
@@ -732,7 +747,7 @@ else allout's special hanging-indent maintaining auto-fill function,
 (defcustom allout-use-hanging-indents t
   "*If non-nil, topic body text auto-indent defaults to indent of the header.
 Ie, it is indented to be just past the header prefix.  This is
-relevant mostly for use with indented-text-mode, or other situations
+relevant mostly for use with `indented-text-mode', or other situations
 where auto-fill occurs."
   :type 'boolean
   :group 'allout)
@@ -783,7 +798,7 @@ For details, see `allout-toggle-current-subtree-encryption's docstring."
 ;;;_  : Version
 ;;;_   = allout-version
 (defvar allout-version "2.2.1"
-  "Version of currently loaded outline package.  \(allout.el)")
+  "Version of currently loaded outline package.  (allout.el)")
 ;;;_   > allout-version
 (defun allout-version (&optional here)
   "Return string describing the loaded outline version."
@@ -800,7 +815,7 @@ For details, see `allout-toggle-current-subtree-encryption's docstring."
 (defvar allout-layout nil            ; LEAVE GLOBAL VALUE NIL - see docstring.
   "Buffer-specific setting for allout layout.
 
-In buffers where this is non-nil \(and if `allout-init' has been run, to
+In buffers where this is non-nil (and if `allout-init' has been run, to
 enable this behavior), `allout-mode' will be automatically activated.  The
 layout dictated by the value will be used to set the initial exposure when
 `allout-mode' is activated.
@@ -812,12 +827,12 @@ The value would typically be set by a file local variable.  For
 example, the following lines at the bottom of an Emacs Lisp file:
 
 ;;;Local variables:
-;;;allout-layout: \(0 : -1 -1 0)
+;;;allout-layout: (0 : -1 -1 0)
 ;;;End:
 
 dictate activation of `allout-mode' mode when the file is visited
 \(presuming allout-init was already run), followed by the
-equivalent of `\(allout-expose-topic 0 : -1 -1 0)'.  \(This is
+equivalent of `(allout-expose-topic 0 : -1 -1 0)'.  (This is
 the layout used for the allout.el source file.)
 
 `allout-default-layout' describes the specification format.
@@ -895,14 +910,9 @@ This is properly set by `set-allout-regexp'.")
   "Validate apparent topics of this depth and shallower as being non-aberrant.
 
 Verified with `allout-aberrant-container-p'.  This check's usefulness is
-limited to shallow prospects, because the determination of aberrance
-depends on the mistaken item being followed by a legitimate item of
-excessively greater depth.
-
-A level of 2 is safest, so that yanks, which must ignore
-aberrance while rectifying the yanked text to their new location,
-is least likely to be fooled by aberrant topics in the yanked
-text.")
+limited to shallow depths, because the determination of aberrance
+is according to the mistaken item being followed by a legitimate item of
+excessively greater depth.")
 ;;;_   X allout-reset-header-lead (header-lead)
 (defun allout-reset-header-lead (header-lead)
   "*Reset the leading string used to identify topic headers."
@@ -935,7 +945,7 @@ Works according to settings of:
        `allout-use-mode-specific-leader'
 and    `allout-mode-leaders'.
 
-Apply this via \(re)activation of `allout-mode', rather than
+Apply this via (re)activation of `allout-mode', rather than
 invoking it directly."
   (let* ((use-leader (and (boundp 'allout-use-mode-specific-leader)
                          (if (or (stringp allout-use-mode-specific-leader)
@@ -982,7 +992,7 @@ invoking it directly."
 (defun allout-infer-body-reindent ()
   "Determine proper setting for `allout-reindent-bodies'.
 
-Depends on default setting of `allout-reindent-bodies' \(which see)
+Depends on default setting of `allout-reindent-bodies' (which see)
 and presence of setting for `comment-start', to tell whether the
 file is programming code."
   (if (and allout-reindent-bodies
@@ -1114,10 +1124,10 @@ Also refresh various data structures that hinge on the regexp."
 (defvar allout-mode-map nil "Keybindings for (allout) outline minor mode.")
 ;;;_   > produce-allout-mode-map (keymap-alist &optional base-map)
 (defun produce-allout-mode-map (keymap-list &optional base-map)
-  "Produce keymap for use as allout-mode-map, from KEYMAP-LIST.
+  "Produce keymap for use as `allout-mode-map', from KEYMAP-LIST.
 
 Built on top of optional BASE-MAP, or empty sparse map if none specified.
-See doc string for allout-keybindings-list for format of binding list."
+See doc string for `allout-keybindings-list' for format of binding list."
   (let ((map (or base-map (make-sparse-keymap)))
        (pref (list allout-command-prefix)))
     (mapcar (function
@@ -1300,7 +1310,7 @@ their settings before allout-mode was started."
   "Symbol for use as allout invisible-text overlay category.")
 ;;;_   x allout-view-change-hook
 (defvar allout-view-change-hook nil
-  "*\(Deprecated\) A hook run after allout outline exposure changes.
+  "*(Deprecated) A hook run after allout outline exposure changes.
 
 Switch to using `allout-exposure-change-hook' instead.  Both hooks are
 currently respected, but the other conveys the details of the exposure
@@ -1511,13 +1521,18 @@ and the place for the cursor after the decryption is done."
     (goto-char (cadr allout-after-save-decrypt))
     (setq allout-after-save-decrypt nil))
   )
-;;;_   = allout-during-yank-processing nil
-;; XXX allout yanks adjust the level of the topic being pasted to that of
-;; their target location.  aberrance must be inhibited to allow that
-;; reconciliation.  (this means that actually aberrant topics won't be
-;; treated specially while being pasted.)
-(defvar allout-during-yank-processing nil
-  "Internal state, inhibits aberrance doublecheck while adjusting yanks.")
+;;;_   = allout-inhibit-aberrance-doublecheck nil
+;; In some exceptional moments, disparate topic depths need to be allowed
+;; momentarily, eg when one topic is being yanked into another and they're
+;; about to be reconciled.  let-binding allout-inhibit-aberrance-doublecheck
+;; prevents the aberrance doublecheck to allow, eg, the reconciliation
+;; processing to happen in the presence of such discrepancies.  It should
+;; almost never be needed, however.
+(defvar allout-inhibit-aberrance-doublecheck nil
+  "Internal state, for momentarily inhibits aberrance doublecheck.
+
+This should only be momentarily let-bound non-nil, not set
+non-nil in a lasting way.")
 
 ;;;_ #2 Mode activation
 ;;;_  = allout-explicitly-deactivated
@@ -1531,12 +1546,12 @@ So `allout-post-command-business' should not reactivate it...")
 
 MODE is one of the following symbols:
 
- - nil \(or no argument) deactivate auto-activation/layout;
+ - nil (or no argument) deactivate auto-activation/layout;
  - `activate', enable auto-activation only;
  - `ask', enable auto-activation, and enable auto-layout but with
    confirmation for layout operation solicited from user each time;
  - `report', just report and return the current auto-activation state;
- - anything else \(eg, t) for auto-activation and auto-layout, without
+ - anything else (eg, t) for auto-activation and auto-layout, without
    any confirmation check.
 
 Use this function to setup your Emacs session for automatic activation
@@ -1598,7 +1613,7 @@ the following two lines in your Emacs init file:
                        ((eq mode 'ask)
                         (message
                          (concat "Outline mode auto-activation and "
-                                 "-layout \(upon confirmation) enabled."))
+                                 "-layout (upon confirmation) enabled."))
                         'ask)
                        ((message
                          "Outline mode auto-activation and -layout enabled.")
@@ -1643,98 +1658,118 @@ the following two lines in your Emacs init file:
   "Toggle minor mode for controlling exposure and editing of text outlines.
 \\<allout-mode-map>
 
-Optional arg forces mode to re-initialize iff arg is positive num or
-symbol.  Allout outline mode always runs as a minor mode.
+Optional prefix argument TOGGLE forces the mode to re-initialize
+if it is positive, otherwise it turns the mode off.  Allout
+outline mode always runs as a minor mode.
 
 Allout outline mode provides extensive outline oriented formatting and
 manipulation.  It enables structural editing of outlines, as well as
 navigation and exposure.  It also is specifically aimed at
-accommodating syntax-sensitive text like programming languages.  \(For
+accommodating syntax-sensitive text like programming languages.  (For
 an example, see the allout code itself, which is organized as an allout
 outline.)
 
-In addition to outline navigation and exposure, allout includes:
+In addition to typical outline navigation and exposure, allout includes:
 
- - topic-oriented repositioning, promotion/demotion, cut, and paste
- - integral outline exposure-layout
+ - topic-oriented authoring, including keystroke-based topic creation,
+   repositioning, promotion/demotion, cut, and paste
  - incremental search with dynamic exposure and reconcealment of hidden text
- - automatic topic-number maintenance
+ - adjustable format, so programming code can be developed in outline-structure
  - easy topic encryption and decryption
- - \"Hot-spot\" operation, for single-keystroke maneuvering and
-    exposure control.  \(See the allout-mode docstring.)
+ - \"Hot-spot\" operation, for single-keystroke maneuvering and exposure control
+ - integral outline layout, for automatic initial exposure when visiting a file
+ - independent extensibility, using comprehensive exposure and authoring hooks
 
 and many other features.
 
-Below is a description of the bindings, and then explanation of
+Below is a description of the key bindings, and then explanation of
 special `allout-mode' features and terminology.  See also the outline
 menubar additions for quick reference to many of the features, and see
 the docstring of the function `allout-init' for instructions on
 priming your emacs session for automatic activation of `allout-mode'.
 
-
-The bindings are dictated by the `allout-keybindings-list' and
-`allout-command-prefix' variables.
-
-       Navigation:                                Exposure Control:
-       ----------                                 ----------------
-\\[allout-next-visible-heading] allout-next-visible-heading     | \\[allout-hide-current-subtree] allout-hide-current-subtree
-\\[allout-previous-visible-heading] allout-previous-visible-heading | \\[allout-show-children] allout-show-children
-\\[allout-up-current-level] allout-up-current-level         | \\[allout-show-current-subtree] allout-show-current-subtree
-\\[allout-forward-current-level] allout-forward-current-level    | \\[allout-show-current-entry] allout-show-current-entry
-\\[allout-backward-current-level] allout-backward-current-level   | \\[allout-show-all] allout-show-all
-\\[allout-end-of-entry] allout-end-of-entry
-\\[allout-beginning-of-current-entry] allout-beginning-of-current-entry, alternately, goes to hot-spot
-
-       Topic Header Production:
-       -----------------------
-\\[allout-open-sibtopic]       allout-open-sibtopic    Create a new sibling after current topic.
-\\[allout-open-subtopic]       allout-open-subtopic    ... an offspring of current topic.
-\\[allout-open-supertopic]     allout-open-supertopic  ... a sibling of the current topic's parent.
-
-       Topic Level and Prefix Adjustment:
-       ---------------------------------
-\\[allout-shift-in]    allout-shift-in Shift current topic and all offspring deeper.
-\\[allout-shift-out]   allout-shift-out        ... less deep.
-\\[allout-rebullet-current-heading]    allout-rebullet-current-heading Prompt for alternate bullet for
-                                        current topic.
-\\[allout-rebullet-topic]      allout-rebullet-topic   Reconcile bullets of topic and its offspring
-                               - distinctive bullets are not changed, others
-                                 alternated according to nesting depth.
-\\[allout-number-siblings]     allout-number-siblings  Number bullets of topic and siblings - the
-                               offspring are not affected.  With repeat
-                               count, revoke numbering.
-
-       Topic-oriented Killing and Yanking:
-       ----------------------------------
-\\[allout-kill-topic]  allout-kill-topic       Kill current topic, including offspring.
-\\[allout-copy-topic-as-kill]  allout-copy-topic-as-kill Copy current topic, including offspring.
-\\[allout-kill-line]   allout-kill-line        kill-line, attending to outline structure.
-\\[allout-copy-line-as-kill]   allout-copy-line-as-kill Copy line but don't delete it.
-\\[allout-yank]        allout-yank             Yank, adjusting depth of yanked topic to
-                               depth of heading if yanking into bare topic
-                               heading (ie, prefix sans text).
-\\[allout-yank-pop]    allout-yank-pop Is to allout-yank as yank-pop is to yank
-
-       Topic-oriented Encryption:
-       -------------------------
-\\[allout-toggle-current-subtree-encryption]   allout-toggle-current-subtree-encryption Encrypt/Decrypt topic content
-
-       Misc commands:
-       -------------
-M-x outlineify-sticky          Activate outline mode for current buffer,
-                               and establish a default file-var setting
-                               for `allout-layout'.
-\\[allout-mark-topic]          allout-mark-topic
-\\[allout-copy-exposed-to-buffer]     allout-copy-exposed-to-buffer
-                               Duplicate outline, sans concealed text, to
-                               buffer with name derived from derived from that
-                               of current buffer - \"*BUFFERNAME exposed*\".
-\\[allout-flatten-exposed-to-buffer]   allout-flatten-exposed-to-buffer
-                               Like above 'copy-exposed', but convert topic
-                               prefixes to section.subsection... numeric
-                               format.
-\\[eval-expression] (allout-init t)    Setup Emacs session for outline mode
-                               auto-activation.
+The bindings are dictated by the customizable `allout-keybindings-list'
+variable.  We recommend customizing `allout-command-prefix' to use just
+`\\C-c' as the command prefix, if the allout bindings don't conflict with
+any personal bindings you have on \\C-c.  In any case, outline structure
+navigation and authoring is simplified by positioning the cursor on an
+item's bullet character, the \"hot-spot\" - then you can invoke allout
+commands with just the un-prefixed, un-control-shifted command letters.
+This is described further in the HOT-SPOT Operation section.
+
+        Exposure Control:
+        ----------------
+\\[allout-hide-current-subtree]   `allout-hide-current-subtree'
+\\[allout-show-children] `allout-show-children'
+\\[allout-show-current-subtree] `allout-show-current-subtree'
+\\[allout-show-current-entry] `allout-show-current-entry'
+\\[allout-show-all]   `allout-show-all'
+
+        Navigation:
+        ----------
+\\[allout-next-visible-heading] `allout-next-visible-heading'
+\\[allout-previous-visible-heading] `allout-previous-visible-heading'
+\\[allout-up-current-level] `allout-up-current-level'
+\\[allout-forward-current-level] `allout-forward-current-level'
+\\[allout-backward-current-level] `allout-backward-current-level'
+\\[allout-end-of-entry] `allout-end-of-entry'
+\\[allout-beginning-of-current-entry] `allout-beginning-of-current-entry' (alternately, goes to hot-spot)
+\\[allout-beginning-of-line]  `allout-beginning-of-line' - like regular beginning-of-line, but
+     if immediately repeated cycles to the beginning of the current item
+     and then to the hot-spot (if `allout-beginning-of-line-cycles' is set).
+
+
+        Topic Header Production:
+        -----------------------
+\\[allout-open-sibtopic] `allout-open-sibtopic' Create a new sibling after current topic.
+\\[allout-open-subtopic]   `allout-open-subtopic' ... an offspring of current topic.
+\\[allout-open-supertopic] `allout-open-supertopic' ... a sibling of the current topic's parent.
+
+        Topic Level and Prefix Adjustment:
+        ---------------------------------
+\\[allout-shift-in] `allout-shift-in'   Shift current topic and all offspring deeper
+\\[allout-shift-out] `allout-shift-out' ... less deep
+\\[allout-rebullet-current-heading] `allout-rebullet-current-heading' Prompt for alternate bullet for
+            current topic
+\\[allout-rebullet-topic] `allout-rebullet-topic'   Reconcile bullets of topic and
+            its' offspring - distinctive bullets are not changed, others
+            are alternated according to nesting depth.
+\\[allout-number-siblings] `allout-number-siblings'  Number bullets of topic and siblings -
+           the offspring are not affected.
+           With repeat count, revoke numbering.
+
+        Topic-oriented Killing and Yanking:
+        ----------------------------------
+\\[allout-kill-topic] `allout-kill-topic'   Kill current topic, including offspring.
+\\[allout-copy-topic-as-kill] `allout-copy-topic-as-kill' Copy current topic, including offspring.
+\\[allout-kill-line]     `allout-kill-line'    kill-line, attending to outline structure.
+\\[allout-copy-line-as-kill]     `allout-copy-line-as-kill' Copy line but don't delete it.
+\\[allout-yank] `allout-yank'        Yank, adjusting depth of yanked topic to
+                             depth of heading if yanking into bare topic
+                             heading (ie, prefix sans text).
+\\[allout-yank-pop]     `allout-yank-pop'       Is to allout-yank as yank-pop is to yank
+
+        Topic-oriented Encryption:
+        -------------------------
+\\[allout-toggle-current-subtree-encryption] `allout-toggle-current-subtree-encryption'
+          Encrypt/Decrypt topic content
+
+        Misc commands:
+        -------------
+M-x outlineify-sticky       Activate outline mode for current buffer,
+                            and establish a default file-var setting
+                            for `allout-layout'.
+\\[allout-mark-topic]       `allout-mark-topic'
+\\[allout-copy-exposed-to-buffer] `allout-copy-exposed-to-buffer'
+                            Duplicate outline, sans concealed text, to
+                            buffer with name derived from derived from that
+                            of current buffer - \"*BUFFERNAME exposed*\".
+\\[allout-flatten-exposed-to-buffer] `allout-flatten-exposed-to-buffer'
+                            Like above 'copy-exposed', but convert topic
+                            prefixes to section.subsection... numeric
+                            format.
+\\[eval-expression] (allout-init t) Setup Emacs session for outline mode
+                            auto-activation.
 
                   Topic Encryption
 
@@ -1742,17 +1777,22 @@ Outline mode supports gpg encryption of topics, with support for
 symmetric and key-pair modes, passphrase timeout, passphrase
 consistency checking, user-provided hinting for symmetric key
 mode, and auto-encryption of topics pending encryption on save.
-\(Topics pending encryption are, by default, automatically
-encrypted during file saves; if you're editing the contents of
-such a topic, it is automatically decrypted for continued
-editing.)  The aim is reliable topic privacy while preventing
-accidents like neglected encryption before saves, forgetting
-which passphrase was used, and other practical pitfalls.
 
-See `allout-toggle-current-subtree-encryption' function docstring and
-`allout-encrypt-unencrypted-on-saves' customization variable for details.
+Topics pending encryption are, by default, automatically
+encrypted during file saves.  If the contents of the topic
+containing the cursor was encrypted for a save, it is
+automatically decrypted for continued editing.
 
-                HOT-SPOT Operation
+The aim of these measures is reliable topic privacy while
+preventing accidents like neglected encryption before saves,
+forgetting which passphrase was used, and other practical
+pitfalls.
+
+See `allout-toggle-current-subtree-encryption' function docstring
+and `allout-encrypt-unencrypted-on-saves' customization variable
+for details.
+
+                 HOT-SPOT Operation
 
 Hot-spot operation provides a means for easy, single-keystroke outline
 navigation and exposure control.
@@ -1765,85 +1805,111 @@ would invoke the command typically bound to \"C-c<space>C-f\"
 
 Thus, by positioning the cursor on a topic bullet, you can
 execute the outline navigation and manipulation commands with a
-single keystroke.  Regular navigation keys (eg, \\[forward-char], \\[next-line]) never get
+single keystroke.  Regular navigation keys (eg, \\[forward-char], \\[next-line]) don't get
 this special translation, so you can use them to get out of the
-hot-spot and back to normal operation.
+hot-spot and back to normal editing operation.
+
+In allout-mode, the normal beginning-of-line command (\\[allout-beginning-of-line]]) is
+replaced with one that makes it easy to get to the hot-spot.  If you
+repeat it immediately it cycles (if `allout-beginning-of-line-cycles'
+is set) to the beginning of the item and then, if you hit it again
+immediately, to the hot-spot.  Similarly, `allout-beginning-of-current-entry'
+\(\\[allout-beginning-of-current-entry]) moves to the hot-spot when the cursor is already located
+at the beginning of the current entry.
 
-Note that the command `allout-beginning-of-current-entry' \(\\[allout-beginning-of-current-entry]\)
-will move to the hot-spot when the cursor is already located at the
-beginning of the current entry, so you usually can hit \\[allout-beginning-of-current-entry]
-twice in a row to get to the hot-spot.
+                             Extending Allout
 
-                           Terminology
+Allout exposure and authoring activites all have associated
+hooks, by which independent code can cooperate with allout
+without changes to the allout core.  Here are key ones:
+
+`allout-mode-hook'
+`allout-mode-deactivate-hook'
+`allout-exposure-change-hook'
+`allout-structure-added-hook'
+`allout-structure-deleted-hook'
+`allout-structure-shifted-hook'
+
+                            Terminology
 
 Topic hierarchy constituents - TOPICS and SUBTOPICS:
 
-TOPIC: A basic, coherent component of an Emacs outline.  It can
-       contain and be contained by other topics.
-CURRENT topic:
-       The visible topic most immediately containing the cursor.
-DEPTH: The degree of nesting of a topic; it increases with
-       containment.  Also called the:
-LEVEL: The same as DEPTH.
+ITEM:   A unitary outline element, including the HEADER and ENTRY text.
+TOPIC:  An ITEM and any ITEMs contained within it, ie having greater DEPTH
+        and with no intervening items of lower DEPTH than the container.
+CURRENT ITEM:
+        The visible ITEM most immediately containing the cursor.
+DEPTH:  The degree of nesting of an ITEM; it increases with containment.
+        The DEPTH is determined by the HEADER PREFIX.  The DEPTH is also
+        called the:
+LEVEL:  The same as DEPTH.
 
 ANCESTORS:
-       The topics that contain a topic.
-PARENT:        A topic's immediate ancestor.  It has a depth one less than
-       the topic.
+        Those ITEMs whose TOPICs contain an ITEM.
+PARENT: An ITEM's immediate ANCESTOR.  It has a DEPTH one less than that
+        of the ITEM.
 OFFSPRING:
-       The topics contained by a topic;
+        The ITEMs contained within an ITEM's TOPIC.
 SUBTOPIC:
-       An immediate offspring of a topic;
-CHILDREN:
-       The immediate offspring of a topic.
+        An OFFSPRING of its ANCESTOR TOPICs.
+CHILD:
+        An immediate SUBTOPIC of its PARENT.
 SIBLINGS:
-       Topics having the same parent and depth.
+        TOPICs having the same PARENT and DEPTH.
 
 Topic text constituents:
 
-HEADER:        The first line of a topic, include the topic PREFIX and header
-       text.
-PREFIX: The leading text of a topic which distinguishes it from normal
-        text.  It has a strict form, which consists of a prefix-lead
-        string, padding, and a bullet.  The bullet may be followed by a
+HEADER: The first line of an ITEM, include the ITEM PREFIX and HEADER
+        text.
+ENTRY:  The text content of an ITEM, before any OFFSPRING, but including
+        the HEADER text and distinct from the ITEM PREFIX.
+BODY:   Same as ENTRY.
+PREFIX: The leading text of an ITEM which distinguishes it from normal
+        ENTRY text.  Allout recognizes the outline structure according
+        to the strict PREFIX format.  It consists of a PREFIX-LEAD string,
+        PREFIX-PADDING, and a BULLET.  The BULLET might be followed by a
         number, indicating the ordinal number of the topic among its
-        siblings, a space, and then the header text.
+        siblings, or an asterisk indicating encryption, plus an optional
+        space.  After that is the ITEM HEADER text, which is not part of
+        the PREFIX.
 
-       The relative length of the PREFIX determines the nesting depth
-       of the topic.
+        The relative length of the PREFIX determines the nesting DEPTH
+        of the ITEM.
 PREFIX-LEAD:
-       The string at the beginning of a topic prefix, normally a `.'.
-       It can be customized by changing the setting of
-       `allout-header-prefix' and then reinitializing `allout-mode'.
-
-       By setting the prefix-lead to the comment-string of a
-       programming language, you can embed outline structuring in
-       program code without interfering with the language processing
-       of that code.  See `allout-use-mode-specific-leader'
-       docstring for more detail.
+        The string at the beginning of a HEADER PREFIX, by default a `.'.
+        It can be customized by changing the setting of
+        `allout-header-prefix' and then reinitializing `allout-mode'.
+
+        When the PREFIX-LEAD is set to the comment-string of a
+        programming language, outline structuring can be embedded in
+        program code without interfering with processing of the text
+        (by emacs or the language processor) as program code.  This
+        setting happens automatically when allout mode is used in
+        programming-mode buffers.  See `allout-use-mode-specific-leader'
+        docstring for more detail.
 PREFIX-PADDING:
-       Spaces or asterisks which separate the prefix-lead and the
-       bullet, determining the depth of the topic.
-BULLET: A character at the end of the topic prefix, it must be one of
-       the characters listed on `allout-plain-bullets-string' or
-        `allout-distinctive-bullets-string'.  (See the documentation
-        for these variables for more details.)  The default choice of
-       bullet when generating topics varies in a cycle with the depth of
-       the topic.
-ENTRY: The text contained in a topic before any offspring.
-BODY:  Same as ENTRY.
-
-
+        Spaces or asterisks which separate the PREFIX-LEAD and the
+        bullet, determining the ITEM's DEPTH.
+BULLET: A character at the end of the ITEM PREFIX, it must be one of
+        the characters listed on `allout-plain-bullets-string' or
+        `allout-distinctive-bullets-string'.  When creating a TOPIC,
+        plain BULLETs are by default used, according to the DEPTH of the
+        TOPIC.  Choice among the distinctive BULLETs is offered when you
+        provide a universal argugment \(\\[universal-argument]) to the
+        TOPIC creation command, or when explictly rebulleting a TOPIC.  The
+        significance of the various distinctive bullets is purely by
+        convention.  See the documentation for the above bullet strings for
+        more details.
 EXPOSURE:
-       The state of a topic which determines the on-screen visibility
-       of its offspring and contained text.
+        The state of a TOPIC which determines the on-screen visibility
+        of its OFFSPRING and contained ENTRY text.
 CONCEALED:
-       Topics and entry text whose display is inhibited.  Contiguous
-       units of concealed text is represented by `...' ellipses.
+        TOPICs and ENTRY text whose EXPOSURE is inhibited.  Concealed
+        text is represented by \"...\" ellipses.
 
-       Concealed topics are effectively collapsed within an ancestor.
-CLOSED:        A topic whose immediate offspring and body-text is concealed.
-OPEN:  A topic that is not closed, though its offspring or body may be."
+        CONCEALED TOPICs are effectively collapsed within an ANCESTOR.
+CLOSED: A TOPIC whose immediate OFFSPRING and body-text is CONCEALED.
+OPEN:  A TOPIC that is not CLOSED, though its OFFSPRING or BODY may be."
 ;;;_    . Code
   (interactive "P")
 
@@ -1934,22 +2000,8 @@ OPEN:    A topic that is not closed, though its offspring or body may be."
          extend))
 
       ;; Produce map from current version of allout-keybindings-list:
-      (setq allout-mode-map
-            (produce-allout-mode-map allout-keybindings-list))
-      (substitute-key-definition 'beginning-of-line
-                                 'allout-beginning-of-line
-                                 allout-mode-map global-map)
-      (substitute-key-definition 'move-beginning-of-line
-                                 'allout-beginning-of-line
-                                 allout-mode-map global-map)
-      (substitute-key-definition 'end-of-line
-                                 'allout-end-of-line
-                                 allout-mode-map global-map)
-      (substitute-key-definition 'move-end-of-line
-                                 'allout-end-of-line
-                                 allout-mode-map global-map)
+      (allout-setup-mode-map)
       (produce-allout-mode-menubar-entries)
-      (fset 'allout-mode-map allout-mode-map)
 
       ;; Include on minor-mode-map-alist, if not already there:
       (if (not (member '(allout-mode . allout-mode-map)
@@ -1959,6 +2011,7 @@ OPEN:     A topic that is not closed, though its offspring or body may be."
                       minor-mode-map-alist)))
 
       (add-to-invisibility-spec '(allout . t))
+
       (allout-add-resumptions '(line-move-ignore-invisible t))
       (add-hook 'pre-command-hook 'allout-pre-command-business nil t)
       (add-hook 'post-command-hook 'allout-post-command-business nil t)
@@ -2039,6 +2092,31 @@ OPEN:    A topic that is not closed, though its offspring or body may be."
     allout-mode
     )                                  ; let*
   )                                    ; defun
+
+(defun allout-setup-mode-map ()
+  "Establish allout-mode bindings."
+  (setq-default allout-mode-map
+                (produce-allout-mode-map allout-keybindings-list))
+  (setq allout-mode-map
+        (produce-allout-mode-map allout-keybindings-list))
+  (substitute-key-definition 'beginning-of-line
+                             'allout-beginning-of-line
+                             allout-mode-map global-map)
+  (substitute-key-definition 'move-beginning-of-line
+                             'allout-beginning-of-line
+                             allout-mode-map global-map)
+  (substitute-key-definition 'end-of-line
+                             'allout-end-of-line
+                             allout-mode-map global-map)
+  (substitute-key-definition 'move-end-of-line
+                             'allout-end-of-line
+                             allout-mode-map global-map)
+  (fset 'allout-mode-map allout-mode-map))
+
+;; ensure that allout-mode-map has some setting even if allout-mode hasn't
+;; been invoked:
+(allout-setup-mode-map)
+
 ;;;_  > allout-minor-mode
 (defalias 'allout-minor-mode 'allout-mode)
 
@@ -2062,10 +2140,10 @@ OPEN:   A topic that is not closed, though its offspring or body may be."
   "Get confirmation before making arbitrary changes to invisible text.
 
 We expose the invisible text and ask for confirmation.  Refusal or
-keyboard-quit abandons the changes, with keyboard-quit additionally
+`keyboard-quit' abandons the changes, with keyboard-quit additionally
 reclosing the opened text.
 
-No confirmation is necessary when inhibit-read-only is set - eg, allout
+No confirmation is necessary when `inhibit-read-only' is set - eg, allout
 internal functions use this feature cohesively bunch changes."
 
   (when (and (not inhibit-read-only) (not after))
@@ -2113,7 +2191,7 @@ See allout-overlay-interior-modification-handler for details."
   (when (and (featurep 'xemacs) (allout-mode-p))
     ;; process all of the pending overlays:
     (save-excursion
-      (got-char beg)
+      (goto-char beg)
       (let ((overlay (allout-get-invisibility-overlay)))
        (allout-overlay-interior-modification-handler
         overlay nil beg end nil)))))
@@ -2156,7 +2234,8 @@ function can also be used as an `isearch-mode-end-hook'."
 (defsubst allout-prefix-data ()
   "Register allout-prefix state data.
 
-For reference by `allout-recent' funcs.  Returns BEGINNING."
+For reference by `allout-recent' funcs.  Return
+the new value of `allout-recent-prefix-beginning'."
   (setq allout-recent-prefix-end (or (match-end 1) (match-end 2))
         allout-recent-prefix-beginning (or (match-beginning 1)
                                            (match-beginning 2))
@@ -2212,7 +2291,7 @@ to return the current depth of the most recently matched topic."
   (and
    ;; presume integrity of outline and yanked content during yank - necessary,
    ;; to allow for level disparity of yank location and yanked text:
-   (not allout-during-yank-processing)
+   (not allout-inhibit-aberrance-doublecheck)
    ;; allout-doublecheck-at-and-shallower is ceiling for doublecheck:
    (<= allout-recent-depth allout-doublecheck-at-and-shallower)))
 ;;;_     > allout-aberrant-container-p ()
@@ -2453,11 +2532,11 @@ Outermost is first."
             (t (allout-end-of-entry))))))
 ;;;_   > allout-next-heading ()
 (defsubst allout-next-heading ()
-  "Move to the heading for the topic \(possibly invisible) after this one.
+  "Move to the heading for the topic (possibly invisible) after this one.
 
 Returns the location of the heading, or nil if none found.
 
-We skip anomolous low-level topics, a la `allout-aberrant-container-p'."
+We skip anomalous low-level topics, a la `allout-aberrant-container-p'."
   (if (looking-at allout-regexp)
       (forward-char 1))
 
@@ -2476,11 +2555,11 @@ We skip anomolous low-level topics, a la `allout-aberrant-container-p'."
   (if (not (allout-goto-prefix-doublechecked)) (allout-next-heading)))
 ;;;_   > allout-previous-heading ()
 (defun allout-previous-heading ()
-  "Move to the prior \(possibly invisible) heading line.
+  "Move to the prior (possibly invisible) heading line.
 
 Return the location of the beginning of the heading, or nil if not found.
 
-We skip anomolous low-level topics, a la `allout-aberrant-container-p'."
+We skip anomalous low-level topics, a la `allout-aberrant-container-p'."
 
   (if (bobp)
       nil
@@ -2526,7 +2605,7 @@ We skip anomolous low-level topics, a la `allout-aberrant-container-p'."
 (defun allout-chart-subtree (&optional levels visible orig-depth prev-depth)
   "Produce a location \"chart\" of subtopics of the containing topic.
 
-Optional argument LEVELS specifies a depth limit \(relative to start
+Optional argument LEVELS specifies a depth limit (relative to start
 depth) for the chart.  Null LEVELS means no limit.
 
 When optional argument VISIBLE is non-nil, the chart includes
@@ -2663,7 +2742,7 @@ start point."
     result))
 ;;;_   X allout-chart-spec (chart spec &optional exposing)
 ;; (defun allout-chart-spec (chart spec &optional exposing)
-;;   "Not yet \(if ever) implemented.
+;;   "Not yet (if ever) implemented.
 
 ;; Produce exposure directives given topic/subtree CHART and an exposure SPEC.
 
@@ -2684,7 +2763,7 @@ start point."
 ;;  - bare positive values indicate that this topic header should be
 ;;    opened.
 ;;  - Lists signify the beginning and end points of regions that should
-;;    be flagged, and the flag to employ.  (For concealment: `\(\?r\)', and
+;;    be flagged, and the flag to employ.  (For concealment: `(\?r)', and
 ;;    exposure:"
 ;;   (while spec
 ;;     (cond ((listp spec)
@@ -2721,7 +2800,7 @@ Returns the point at the beginning of the prefix, or nil if none."
 (defun allout-goto-prefix-doublechecked ()
   "Put point at beginning of immediately containing outline topic.
 
-Like `allout-goto-prefix', but shallow topics \(according to
+Like `allout-goto-prefix', but shallow topics (according to
 `allout-doublecheck-at-and-shallower') are checked and
 disqualified for child containment discontinuity, according to
 `allout-aberrant-container-p'."
@@ -2749,7 +2828,7 @@ otherwise skip white space between bullet and ensuing text."
     (allout-current-depth)))
 ;;;_   > allout-current-bullet-pos ()
 (defun allout-current-bullet-pos ()
-  "Return position of current \(visible) topic's bullet."
+  "Return position of current (visible) topic's bullet."
 
   (if (not (allout-current-depth))
       nil
@@ -2887,11 +2966,31 @@ collapsed."
         (if (interactive-p) (allout-end-of-prefix))
         (and last-ascended allout-recent-depth))))
 ;;;_   > allout-ascend ()
-(defun allout-ascend ()
-  "Ascend one level, returning t if successful, nil if not."
+(defun allout-ascend (&optional dont-move-if-unsuccessful)
+  "Ascend one level, returning resulting depth if successful, nil if not.
+
+Point is left at the beginning of the level whether or not
+successful, unless optional DONT-MOVE-IF-UNSUCCESSFUL is set, in
+which case point is returned to its original starting location."
+  (if dont-move-if-unsuccessful
+      (setq dont-move-if-unsuccessful (point)))
   (prog1
       (if (allout-beginning-of-level)
-          (allout-previous-heading))
+          (let ((bolevel (point))
+                (bolevel-depth allout-recent-depth))
+            (allout-previous-heading)
+            (cond ((< allout-recent-depth bolevel-depth)
+                   allout-recent-depth)
+                  ((= allout-recent-depth bolevel-depth)
+                   (if dont-move-if-unsuccessful
+                       (goto-char dont-move-if-unsuccessful))
+                   (allout-depth)
+                   nil)
+                  (t
+                   ;; some topic after very first is lower depth than first:
+                   (goto-char bolevel)
+                   (allout-depth)
+                   nil))))
     (if (interactive-p) (allout-end-of-prefix))))
 ;;;_   > allout-descend-to-depth (depth)
 (defun allout-descend-to-depth (depth)
@@ -2982,7 +3081,7 @@ Return the start point of the new topic if successful, nil otherwise.
 
 Costs more than regular `allout-next-sibling' for short traversals:
 
- - we have to check the prior \(next, if travelling backwards)
+ - we have to check the prior (next, if travelling backwards)
    item to confirm connectivity with the prior topic, and
  - if confirmed, we have to reestablish the allout-recent-* settings with
    some extra navigation
@@ -3211,7 +3310,7 @@ reinterpreted as the corresponding control-character in the
 the cursor which has moved as a result of such reinterpretation is
 positioned on the bullet character of the destination topic.
 
-The upshot is that you can get easy, single \(ie, unmodified\) key
+The upshot is that you can get easy, single (ie, unmodified) key
 outline maneuvering operations by positioning the cursor on the bullet
 char.  When in this mode you can use regular cursor-positioning
 command/keystrokes to relocate the cursor off of a bullet character to
@@ -3321,7 +3420,7 @@ Offer one suitable for current depth DEPTH as default."
                    (allout-get-bullet)))))
 ;;;_   > allout-encrypted-type-prefix (&optional prefix)
 (defun allout-encrypted-type-prefix (&optional prefix)
-  "True if current header prefix bullet is for an encrypted entry \(body)."
+  "True if current header prefix bullet is for an encrypted entry (body)."
   (and allout-topic-encryption-bullet
         (string= allout-topic-encryption-bullet
                  (if prefix
@@ -3372,8 +3471,8 @@ the current topics' depth.
 
 If SOLICIT is non-nil, then the choice of bullet is solicited from
 user.  If it's a character, then that character is offered as the
-default, otherwise the one suited to the context \(according to
-distinction or depth) is offered.  \(This overrides other options,
+default, otherwise the one suited to the context (according to
+distinction or depth) is offered.  (This overrides other options,
 including, eg, a distinctive PRIOR-BULLET.)  If non-nil, then the
 context-specific bullet is used.
 
@@ -3497,13 +3596,11 @@ whitespace - in which case open is done on the current line.
 
 When adding an offspring, it will be added immediately after the parent if
 the other offspring are exposed, or after the last child if the offspring
-are hidden.  \(The intervening offspring will be exposed in the latter
+are hidden.  (The intervening offspring will be exposed in the latter
 case.)
 
 If OFFER-RECENT-BULLET is true, offer to use the bullet of the prior sibling.
 
-Runs
-
 Nuances:
 
 - Creation of new topics is with respect to the visible topic
@@ -3817,7 +3914,7 @@ All args are optional.
 
 If SOLICIT is non-nil, then the choice of bullet is solicited from
 user.  If it's a character, then that character is offered as the
-default, otherwise the one suited to the context \(according to
+default, otherwise the one suited to the context (according to
 distinction or depth) is offered.  If non-nil, then the
 context-specific bullet is just used.
 
@@ -3828,9 +3925,9 @@ Third arg NUMBER-CONTROL can force the prefix to or away from
 numbered form.  It has effect only if `allout-numbered-bullet' is
 non-nil and soliciting was not explicitly invoked (via first arg).
 Its effect, numbering or denumbering, then depends on the setting
-of the forth arg, INDEX.
+of the fourth arg, INDEX.
 
-If NUMBER-CONTROL is non-nil and forth arg INDEX is nil, then the
+If NUMBER-CONTROL is non-nil and fourth arg INDEX is nil, then the
 prefix of the topic is forced to be non-numbered.  Null index and
 non-nil NUMBER-CONTROL forces denumbering.  Non-nil INDEX (and
 non-nil NUMBER-CONTROL) forces a numbered-prefix form.  If non-nil
@@ -3914,8 +4011,8 @@ this function."
 
 Descends into invisible as well as visible topics, however.
 
-When optional sans-offspring is non-nil, subtopics are not
-shifted.  \(Shifting a topic outwards without shifting its
+When optional SANS-OFFSPRING is non-nil, subtopics are not
+shifted.  (Shifting a topic outwards without shifting its
 offspring is disallowed, since this would create a \"containment
 discontinuity\", where the depth difference between a topic and
 its immediate offspring is greater than one.)
@@ -3956,10 +4053,10 @@ Several subsequent args are for internal recursive use by the function
 itself: STARTING-DEPTH, STARTING-POINT, and INDEX.
 
 Finally, if optional SANS-OFFSPRING is non-nil then the offspring
-are not shifted.  \(Shifting a topic outwards without shifting
+are not shifted.  (Shifting a topic outwards without shifting
 its offspring is disallowed, since this would create a
 \"containment discontinuity\", where the depth difference between
-a topic and its immediate offspring is greater than one..)"
+a topic and its immediate offspring is greater than one.)"
 
   ;; XXX the recursion here is peculiar, and in general the routine may
   ;; need simplification with refactoring.
@@ -4145,7 +4242,10 @@ the file can be adjusted to any positive depth, however."
                      (> (1+ current-depth)
                         (1+ predecessor-depth)))
                 (error (concat "Disallowed shift deeper than"
-                               " containing topic's children."))))))
+                               " containing topic's children."))
+              (allout-back-to-current-heading)
+              (if (< allout-recent-depth (1+ current-depth))
+                  (allout-show-children))))))
     (let ((where (point)))
       (allout-rebullet-topic 1 (and (> arg 1) 'sans-offspring))
       (run-hook-with-args 'allout-structure-shifted-hook arg where))))
@@ -4242,7 +4342,7 @@ Trailing whitespace is killed with a topic if that whitespace:
    previous one.
 
 Topic exposure is marked with text-properties, to be used by
-allout-yank-processing for exposure recovery."
+`allout-yank-processing' for exposure recovery."
 
   (interactive)
   (let* ((inhibit-field-text-motion t)
@@ -4273,7 +4373,7 @@ allout-yank-processing for exposure recovery."
     (run-hook-with-args 'allout-structure-deleted-hook depth (point))))
 ;;;_    > allout-copy-topic-as-kill ()
 (defun allout-copy-topic-as-kill ()
-  "Like allout-kill-topic, but save to kill ring instead of deleting."
+  "Like `allout-kill-topic', but save to kill ring instead of deleting."
   (interactive)
   (let ((buffer-read-only t))
     (condition-case nil
@@ -4382,13 +4482,12 @@ however, are left exactly like normal, non-allout-specific yanks."
                                        ; region around subject:
   (if (< (allout-mark-marker t) (point))
       (exchange-point-and-mark))
-  (let* ( ;; inhibit aberrance doublecheck while reconciling disparate pastes:
-         (allout-during-yank-processing t)
-         (subj-beg (point))
+  (let* ((subj-beg (point))
          (into-bol (bolp))
          (subj-end (allout-mark-marker t))
          ;; 'resituate' if yanking an entire topic into topic header:
-         (resituate (and (allout-e-o-prefix-p)
+         (resituate (and (let ((allout-inhibit-aberrance-doublecheck t))
+                           (allout-e-o-prefix-p))
                          (looking-at allout-regexp)
                          (allout-prefix-data)))
          ;; `rectify-numbering' if resituating (where several topics may
@@ -4396,7 +4495,7 @@ however, are left exactly like normal, non-allout-specific yanks."
          (rectify-numbering (or resituate
                                 (and into-bol (looking-at allout-regexp)))))
     (if resituate
-                                        ; The yanked stuff is a topic:
+        ;; Yanking a topic into the start of a topic - reconcile to fit:
         (let* ((inhibit-field-text-motion t)
                (prefix-len (if (not (match-end 1))
                                1
@@ -4437,7 +4536,7 @@ however, are left exactly like normal, non-allout-specific yanks."
                   (while more
                     (allout-back-to-current-heading)
                                         ; go as high as we can in each bunch:
-                    (while (allout-ascend))
+                    (while (allout-ascend t))
                     (save-excursion
                       (allout-unprotected
                        (allout-rebullet-topic-grunt (- adjust-to-depth
@@ -4466,7 +4565,8 @@ however, are left exactly like normal, non-allout-specific yanks."
                    (progn
                      (delete-region (point) (+ (point)
                                                prefix-len
-                                               (- adjust-to-depth subj-depth)))
+                                               (- adjust-to-depth
+                                                  subj-depth)))
                                         ; and delete residual subj
                                         ; prefix digits and space:
                      (while (looking-at "[0-9]") (delete-char 1))
@@ -4589,9 +4689,9 @@ by pops to non-distinctive yanks.  Bug..."
   "Conceal text between FROM and TO if FLAG is non-nil, else reveal it.
 
 Exposure-change hook `allout-exposure-change-hook' is run with the same
-arguments as this function, after the exposure changes are made.  \(The old
+arguments as this function, after the exposure changes are made.  (The old
 `allout-view-change-hook' is being deprecated, and eventually will not be
-invoked.\)"
+invoked.)"
 
   ;; We use outline invisibility spec.
   (remove-overlays from to 'category 'allout-exposure-category)
@@ -4775,8 +4875,8 @@ Useful for coherently exposing to a random point in a hidden region."
       )))
 ;;;_   > allout-show-current-subtree (&optional arg)
 (defun allout-show-current-subtree (&optional arg)
-  "Show everything within the current topic.  With a repeat-count,
-expose this topic and its siblings."
+  "Show everything within the current topic.
+With a repeat-count, expose this topic and its siblings."
   (interactive "P")
   (save-excursion
     (if (<= (allout-current-depth) 0)
@@ -4891,7 +4991,7 @@ SPEC is either a number or a list.
 
 Successive specs on a list are applied to successive sibling topics.
 
-A simple spec \(either a number, one of a few symbols, or the null
+A simple spec (either a number, one of a few symbols, or the null
 list) dictates the exposure for the corresponding topic.
 
 Non-null lists recursively designate exposure specs for respective
@@ -4914,7 +5014,7 @@ Simple (numeric and null-list) specs are interpreted as follows:
        apply prior element to all siblings at current level, *up to*
        those siblings that would be covered by specs following the `:'
        on the list.  Ie, apply to all topics at level but the last
-       ones.  \(Only first of multiple colons at same level is
+       ones.  (Only first of multiple colons at same level is
        respected - subsequent ones are discarded.)
   *  - completely opens the topic, including bodies.
   +  - shows all the sub headers, but not the bodies
@@ -4997,7 +5097,7 @@ Examples:
 ;;;_   > allout-old-expose-topic (spec &rest followers)
 (defun allout-old-expose-topic (spec &rest followers)
 
-  "Deprecated.  Use `allout-expose-topic' \(with different schema
+  "Deprecated.  Use `allout-expose-topic' (with different schema
 format) instead.
 
 Dictate wholesale exposure scheme for current topic, according to SPEC.
@@ -5189,12 +5289,12 @@ the subject region.
 
 Optional START and END indicate bounds of region.
 
-optional arg, FORMAT, designates an alternate presentation form for
+Optional arg, FORMAT, designates an alternate presentation form for
 the prefix:
 
  list - Present prefix as numeric section.subsection..., starting with
        section indicated by the list, innermost nesting first.
- `indent' \(symbol) -  Convert header prefixes to all white space,
+ `indent' (symbol) -  Convert header prefixes to all white space,
                       except for distinctive bullets.
 
 The elements of the list produced are lists that represents a topic
@@ -5319,11 +5419,11 @@ FROMBUF to buffer TOBUF.  Sixth optional arg, FORMAT, designates an
 alternate presentation form:
 
  `flat' - Present prefix as numeric section.subsection..., starting with
-        section indicated by the start-num, innermost nesting first.
+        section indicated by the START-NUM, innermost nesting first.
  X`flat-indented' - Prefix is like `flat' for first topic at each
  X                level, but subsequent topics have only leaf topic
  X                number, padded with blanks to line up with first.
- `indent' \(symbol) -  Convert header prefixes to all white space,
+ `indent' (symbol) -  Convert header prefixes to all white space,
                       except for distinctive bullets.
 
 Defaults:
@@ -5475,7 +5575,7 @@ used verbatim."
 ;;;_   > allout-latex-verb-quote (string &optional flow)
 (defun allout-latex-verb-quote (string &optional flow)
   "Return copy of STRING for literal reproduction across LaTeX processing.
-Expresses the original characters \(including carriage returns) of the
+Expresses the original characters (including carriage returns) of the
 string across LaTeX processing."
   (mapconcat (function
              (lambda (char)
@@ -5487,9 +5587,9 @@ string across LaTeX processing."
             ""))
 ;;;_   > allout-latex-verbatim-quote-curr-line ()
 (defun allout-latex-verbatim-quote-curr-line ()
-  "Express line for exact \(literal) representation across LaTeX processing.
+  "Express line for exact (literal) representation across LaTeX processing.
 
-Adjust line contents so it is unaltered \(from the original line)
+Adjust line contents so it is unaltered (from the original line)
 across LaTeX processing, within the context of a `verbatim'
 environment.  Leaves point at the end of the line."
   (let ((inhibit-field-text-motion t))
@@ -5664,29 +5764,29 @@ With repeat count, copy the exposed portions of entire buffer."
   "Encrypt clear or decrypt encoded text of visibly-containing topic's contents.
 
 Optional FETCH-PASS universal argument provokes key-pair encryption with
-single universal argument.  With doubled universal argument \(value = 16),
+single universal argument.  With doubled universal argument (value = 16),
 it forces prompting for the passphrase regardless of availability from the
 passphrase cache.  With no universal argument, the appropriate passphrase
 is obtained from the cache, if available, else from the user.
 
-Currently only GnuPG encryption is supported.
+Only GnuPG encryption is supported.
 
-\**NOTE WELL** that the encrypted text must be ascii-armored.  For gnupg
+\*NOTE WELL* that the encrypted text must be ascii-armored.  For gnupg
 encryption, include the option ``armor'' in your ~/.gnupg/gpg.conf file.
 
 Both symmetric-key and key-pair encryption is implemented.  Symmetric is
-the default, use a single \(x4) universal argument for keypair mode.
+the default, use a single (x4) universal argument for keypair mode.
 
 Encrypted topic's bullet is set to a `~' to signal that the contents of the
-topic \(body and subtopics, but not heading) is pending encryption or
+topic (body and subtopics, but not heading) is pending encryption or
 encrypted.  `*' asterisk immediately after the bullet signals that the body
 is encrypted, its' absence means the topic is meant to be encrypted but is
 not.  When a file with topics pending encryption is saved, topics pending
 encryption are encrypted.  See allout-encrypt-unencrypted-on-saves for
 auto-encryption specifics.
 
-\**NOTE WELL** that automatic encryption that happens during saves will
-default to symmetric encryption - you must manually \(re)encrypt key-pair
+\*NOTE WELL* that automatic encryption that happens during saves will
+default to symmetric encryption - you must deliberately (re)encrypt key-pair
 encrypted topics if you want them to continue to use the key-pair cipher.
 
 Level-one topics, with prefix consisting solely of an `*' asterisk, cannot be
@@ -5698,10 +5798,8 @@ encrypted.  If you want to encrypt the contents of a top-level topic, use
 The encryption passphrase is solicited if not currently available in the
 passphrase cache from a recent encryption action.
 
-The solicited passphrase is retained for reuse in a buffer-specific cache
-for some set period of time \(default, 60 seconds), after which the string
-is nulled.  The passphrase cache timeout is customized by setting
-`pgg-passphrase-cache-expiry'.
+The solicited passphrase is retained for reuse in a cache, if enabled.  See
+`pgg-cache-passphrase' and `pgg-passphrase-cache-expiry' for details.
 
   Symmetric Passphrase Hinting and Verification
 
@@ -5722,7 +5820,7 @@ verifier across Emacs sessions.
 Similarly, `allout-passphrase-hint-string' stores a user-provided reminder
 about their passphrase, and `allout-passphrase-hint-handling' specifies
 when the hint is presented, or if passphrase hints are disabled.  If
-enabled \(see the `allout-passphrase-hint-handling' docstring for details),
+enabled (see the `allout-passphrase-hint-handling' docstring for details),
 the hint string is stored in the local-variables section of the file, and
 solicited whenever the passphrase is changed."
   (interactive "P")
@@ -5733,15 +5831,16 @@ solicited whenever the passphrase is changed."
   )
 ;;;_  > allout-toggle-subtree-encryption (&optional fetch-pass)
 (defun allout-toggle-subtree-encryption (&optional fetch-pass)
-  "Encrypt clear text or decrypt encoded topic contents \(body and subtopics.)
+  "Encrypt clear text or decrypt encoded topic contents (body and subtopics.)
 
 Optional FETCH-PASS universal argument provokes key-pair encryption with
-single universal argument.  With doubled universal argument \(value = 16),
+single universal argument.  With doubled universal argument (value = 16),
 it forces prompting for the passphrase regardless of availability from the
 passphrase cache.  With no universal argument, the appropriate passphrase
 is obtained from the cache, if available, else from the user.
 
-Currently only GnuPG encryption is supported.
+Currently only GnuPG encryption is supported, and integration
+with gpg-agent is not yet implemented.
 
 \**NOTE WELL** that the encrypted text must be ascii-armored.  For gnupg
 encryption, include the option ``armor'' in your ~/.gnupg/gpg.conf file.
@@ -5757,7 +5856,7 @@ See `allout-toggle-current-subtree-encryption' for more details."
                        " shift it in to make it encryptable")))
 
     (let* ((allout-buffer (current-buffer))
-           ;; Asses location:
+           ;; Assess location:
            (bullet-pos allout-recent-prefix-beginning)
            (after-bullet-pos (point))
            (was-encrypted
@@ -5791,7 +5890,29 @@ See `allout-toggle-current-subtree-encryption' for more details."
                       '(symmetric nil)))
            (for-key-type (car key-info))
            (for-key-identity (cadr key-info))
-           (fetch-pass (and fetch-pass (member fetch-pass '(16 (16))))))
+           (fetch-pass (and fetch-pass (member fetch-pass '(16 (16)))))
+           (was-coding-system buffer-file-coding-system))
+
+      (when (not was-encrypted)
+        ;; ensure that non-ascii chars pending encryption are noticed before
+        ;; they're encrypted, so the coding system is set to accomodate
+        ;; them.
+        (setq buffer-file-coding-system
+              (select-safe-coding-system subtree-beg subtree-end))
+        ;; if the coding system for the text being encrypted is different
+        ;; than that prevailing, then there a real risk that the coding
+        ;; system can't be noticed by emacs when the file is visited.  to
+        ;; mitigate that, offer to preserve the coding system using a file
+        ;; local variable.
+        (if (and (not (equal buffer-file-coding-system
+                             was-coding-system))
+                 (yes-or-no-p
+                  (format (concat "Register coding system %s as file local"
+                                  " var?  Necessary when only encrypted text"
+                                  " is in that coding system. ")
+                          buffer-file-coding-system)))
+            (allout-adjust-file-variable "buffer-file-coding-system"
+                                         buffer-file-coding-system)))
 
       (setq result-text
             (allout-encrypt-string subject-text was-encrypted
@@ -5880,6 +6001,10 @@ Returns the resulting string, or nil if the transformation fails."
                                       target-prompt-id
                                     (or (buffer-file-name allout-buffer)
                                         target-prompt-id))))
+         (encoding (with-current-buffer allout-buffer
+                     buffer-file-coding-system))
+         (multibyte (with-current-buffer allout-buffer
+                     enable-multibyte-characters))
          (strip-plaintext-regexps
           (if (not decrypt)
               (allout-get-configvar-values
@@ -5891,7 +6016,8 @@ Returns the resulting string, or nil if the transformation fails."
          (rejected (or rejected 0))
          (rejections-left (- allout-encryption-ciphertext-rejection-ceiling
                              rejected))
-         result-text status)
+         result-text status
+         )
 
     (if (and fetch-pass (not passphrase))
         ;; Force later fetch by evicting passphrase from the cache.
@@ -5899,12 +6025,9 @@ Returns the resulting string, or nil if the transformation fails."
 
     (catch 'encryption-failed
 
-        ;; Obtain the passphrase if we don't already have one and we're not
-        ;; doing a keypair encryption:
-        (if (not (or passphrase
-                     (and (equal key-type 'keypair)
-                          (not decrypt))))
-
+        ;; We handle only symmetric-key passphrase caching.
+        (if (and (not passphrase)
+                 (not (equal key-type 'keypair)))
             (setq passphrase (allout-obtain-passphrase for-key
                                                        target-cache-id
                                                        target-prompt-id
@@ -5916,6 +6039,13 @@ Returns the resulting string, or nil if the transformation fails."
 
           (insert text)
 
+          ;; convey the text characteristics of the original buffer:
+          (set-buffer-multibyte multibyte)
+          (when encoding
+            (set-buffer-file-coding-system encoding)
+            (if (not decrypt)
+                (encode-coding-region (point-min) (point-max) encoding)))
+
           (when (and strip-plaintext-regexps (not decrypt))
             (dolist (re strip-plaintext-regexps)
               (let ((re (if (listp re) (car re) re))
@@ -6163,8 +6293,8 @@ of the availability of a cached copy."
 
 The key type is one of 'symmetric or 'keypair.
 
-if 'keypair, and some of the user's secret keys are among those for which
-the message was encoded, return the identity of the first.  otherwise,
+If 'keypair, and some of the user's secret keys are among those for which
+the message was encoded, return the identity of the first.  Otherwise,
 return nil for the second item of the pair.
 
 An error is raised if the text is not encrypted."
@@ -6209,7 +6339,7 @@ An error is raised if the text is not encrypted."
 See `allout-passphrase-verifier-string' and `allout-passphrase-hint-string'
 settings.
 
-PASSPHRASE is the passphrase being mnemonicized
+PASSPHRASE is the passphrase being mnemonicized.
 
 OUTLINE-BUFFER is the buffer of the outline being adjusted.
 
@@ -6287,7 +6417,7 @@ EXCEPT-MARK identifies a point whose containing topics should be excluded
 from encryption.  This supports 'except-current mode of
 `allout-encrypt-unencrypted-on-saves'.
 
-Such a topic has the allout-topic-encryption-bullet without an
+Such a topic has the `allout-topic-encryption-bullet' without an
 immediately following '*' that would mark the topic as being encrypted.  It
 must also have content."
   (let (done got content-beg)
@@ -6447,7 +6577,7 @@ This activity is inhibited if either `enable-local-variables'
 When enabled, an entry for the variable is created if not already present,
 or changed if established with a different value.  The section for the file
 variables, itself, is created if not already present.  When created, the
-section lines \(including the section line) exist as second-level topics in
+section lines (including the section line) exist as second-level topics in
 a top-level topic at the end of the file.
 
 `enable-local-variables' must be true for any of this to happen."
@@ -6617,7 +6747,7 @@ If BEG is bigger than END we return 0."
   (cond ((null list) nil)
         ((atom (car list)) (cons (car list) (allout-flatten (cdr list))))
         (t (append (allout-flatten (car list)) (allout-flatten (cdr list))))))
-;;;_  : Compatability:
+;;;_  : Compatibility:
 ;;;_   > allout-mark-marker to accommodate divergent emacsen:
 (defun allout-mark-marker (&optional force buffer)
   "Accommodate the different signature for `mark-marker' across Emacsen.
@@ -6776,7 +6906,7 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
 ;;;_ #10 Unfinished
 ;;;_  > allout-bullet-isearch (&optional bullet)
 (defun allout-bullet-isearch (&optional bullet)
-  "Isearch \(regexp) for topic with bullet BULLET."
+  "Isearch (regexp) for topic with bullet BULLET."
   (interactive)
   (if (not bullet)
       (setq bullet (solicit-char-in-string
@@ -6809,7 +6939,7 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
 (defvar allout-tests-globally-unbound nil
   "Fodder for allout resumptions tests - defvar just for byte compiler.")
 (defvar allout-tests-globally-true nil
-  "Fodder for allout resumptions tests - defvar just just for byte compiler.")
+  "Fodder for allout resumptions tests - defvar just for byte compiler.")
 (defvar allout-tests-locally-true nil
   "Fodder for allout resumptions tests - defvar just for byte compiler.")
 (defun allout-test-resumptions ()