]> code.delx.au - gnu-emacs/blobdiff - lisp/allout.el
Spelling fixes.
[gnu-emacs] / lisp / allout.el
index f77fb0b47bd3d85d22d7e390a4ad67fd9189d193..480c22d31e0a19a47c24a13869c488f3faaa54db 100644 (file)
@@ -2,12 +2,12 @@
 
 ;; Copyright (C) 1992-1994, 2001-2011  Free Software Foundation, Inc.
 
-;; Author: Ken Manheimer <ken dot manheimer at gmail dot com>
-;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com>
+;; Author: Ken Manheimer <ken dot manheimer at gmail...>
+;; Maintainer: Ken Manheimer <ken dot manheimer at gmail...>
 ;; Created: Dec 1991 -- first release to usenet
 ;; Version: 2.3
 ;; Keywords: outlines, wp, languages, PGP, GnuPG
-;; Website: http://myriadicity.net/Sundry/EmacsAllout
+;; Website: http://myriadicity.net/software-and-systems/craft/emacs-allout
 
 ;; This file is part of GNU Emacs.
 
 ;;    emacs local file variables need to be enabled when the
 ;;    file was visited -- see `enable-local-variables'.)
 ;;  - Configurable per-file initial exposure settings
-;;  - 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.  Encryption is via the Emacs 'epg' library.  See
-;;    allout-toggle-current-subtree-encryption docstring.
+;;  - Symmetric-key and key-pair topic encryption.  Encryption is via the
+;;    Emacs 'epg' library.  See allout-toggle-current-subtree-encryption
+;;    docstring.
 ;;  - Automatic topic-number maintenance
 ;;  - "Hot-spot" operation, for single-keystroke maneuvering and
 ;;    exposure control (see the allout-mode docstring)
@@ -172,7 +170,7 @@ respective allout-mode keybinding variables, `allout-command-prefix',
   ;; the function value keymap of allout-mode-map is used in
   ;; minor-mode-map-alist - update it:
   (fset allout-mode-map allout-mode-map-value))
-;;;_  * intialize the mode map:
+;;;_  * initialize the mode map:
 ;; ensure that allout-mode-map has some setting even if allout-mode hasn't
 ;; been invoked:
 (allout-compose-and-institute-keymap)
@@ -236,7 +234,7 @@ Use vector format for the keys:
   - put literal keys after a '?' question mark, eg: '?a', '?.'
   - enclose control, shift, or meta-modified keys as sequences within
     parentheses, with the literal key, as above, preceded by the name(s)
-    of the modifers, eg: [(control ?a)]
+    of the modifiers, eg: [(control ?a)]
 See the existing keys for examples.
 
 Functions can be bound to multiple keys, but binding keys to
@@ -257,13 +255,13 @@ prevails."
 
 This is in contrast to the majority of allout-mode bindings on
 `allout-prefixed-bindings', whose bindings are created with a
-preceeding command key.
+preceding command key.
 
 Use vector format for the keys:
   - put literal keys after a '?' question mark, eg: '?a', '?.'
   - enclose control, shift, or meta-modified keys as sequences within
     parentheses, with the literal key, as above, preceded by the name(s)
-    of the modifers, eg: [(control ?a)]
+    of the modifiers, eg: [(control ?a)]
 See the existing keys for examples."
   :type 'allout-keybindings-binding
   :group 'allout-keybindings
@@ -281,7 +279,7 @@ Intended to be used as the `allout-auto-activation' :set function."
 ;;;_  > allout-setup ()
 ;;;###autoload
 (defun allout-setup ()
-  "Do fundamental emacs session for allout auto-activation.
+  "Do fundamental Emacs session for allout auto-activation.
 
 Establishes allout processing as part of visiting a file if
 `allout-auto-activation' is non-nil, or removes it otherwise.
@@ -300,7 +298,7 @@ Control whether and how allout outline mode is automatically
 activated when files are visited with non-nil buffer-specific
 file variable `allout-layout'.
 
-When allout-auto-activation is \"On\" \(t), allout mode is
+When allout-auto-activation is \"On\" (t), allout mode is
 activated in buffers with non-nil `allout-layout', and the
 specified layout is applied.
 
@@ -312,6 +310,7 @@ Auto-layout is not.
 
 With value nil, inhibit any automatic allout-mode activation."
   :set 'allout-auto-activation-helper
+  ;; FIXME: Using strings here is unusual and less efficient than symbols.
   :type '(choice (const :tag "On" t)
                 (const :tag "Ask about layout" "ask")
                 (const :tag "Mode only" "activate")
@@ -341,7 +340,7 @@ The types of elements in the layout specification are:
          -- positive numbers open to the relative depth indicated by the
             number, but do not force already opened subtopics to be closed.
          -- 0 means to close topic -- hide all subitems.
- :   -- repeat spec -- apply the preceeding element to all siblings at
+ :   -- repeat spec -- apply the preceding 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
@@ -400,6 +399,12 @@ else allout's special hanging-indent maintaining auto-fill function,
   :type 'boolean
   :group 'allout)
 (make-variable-buffer-local 'allout-inhibit-auto-fill)
+;;;_  = allout-inhibit-auto-fill-on-headline
+(defcustom allout-inhibit-auto-fill-on-headline nil
+  "If non-nil, auto-fill will be inhibited while on topic's header line."
+  :type 'boolean
+  :group 'allout)
+(make-variable-buffer-local 'allout-inhibit-auto-fill-on-headline)
 ;;;_  = allout-use-hanging-indents
 (defcustom allout-use-hanging-indents t
   "If non-nil, topic body text auto-indent defaults to indent of the header.
@@ -411,7 +416,7 @@ where auto-fill occurs."
 (make-variable-buffer-local 'allout-use-hanging-indents)
 ;;;###autoload
 (put 'allout-use-hanging-indents 'safe-local-variable
-     (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil)))))
+     (if (fboundp 'booleanp) 'booleanp (lambda (x) (member x '(t nil)))))
 ;;;_  = allout-reindent-bodies
 (defcustom allout-reindent-bodies (if allout-use-hanging-indents
                                    'text)
@@ -430,7 +435,7 @@ those that do not have the variable `comment-start' set.  A value of
 (make-variable-buffer-local 'allout-reindent-bodies)
 ;;;###autoload
 (put 'allout-reindent-bodies 'safe-local-variable
-     '(lambda (x) (memq x '(nil t text force))))
+     (lambda (x) (memq x '(nil t text force))))
 
 ;;;_  = allout-show-bodies
 (defcustom allout-show-bodies nil
@@ -441,7 +446,7 @@ just the header."
 (make-variable-buffer-local 'allout-show-bodies)
 ;;;###autoload
 (put 'allout-show-bodies 'safe-local-variable
-     (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil)))))
+     (if (fboundp 'booleanp) 'booleanp (lambda (x) (member x '(t nil)))))
 
 ;;;_  = allout-beginning-of-line-cycles
 (defcustom allout-beginning-of-line-cycles t
@@ -555,7 +560,7 @@ of this var to take effect."
 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]).
+universal argument (\\[universal-argument]), or during rebulleting (\\[allout-rebullet-current-heading]).
 
 Distinctive bullets are not cycled when topics are shifted or
 otherwise automatically rebulleted, so their marking is
@@ -607,7 +612,7 @@ headers look like comments in the programming language.  It will also use
 the comment-start string, with an '_' appended, for `allout-primary-bullet'.
 
 String values are used as literals, not regular expressions, so
-do not escape any regulare-expression characters.
+do not escape any regular-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 (`.').
@@ -633,7 +638,7 @@ undesired.]"
   :group 'allout)
 ;;;###autoload
 (put 'allout-use-mode-specific-leader 'safe-local-variable
-     '(lambda (x) (or (memq x '(t nil allout-mode-leaders comment-start))
+     (lambda (x) (or (memq x '(t nil allout-mode-leaders comment-start))
                       (stringp x))))
 ;;;_  = allout-mode-leaders
 (defvar allout-mode-leaders '()
@@ -663,7 +668,7 @@ are always respected by the topic maneuvering functions."
 (make-variable-buffer-local 'allout-old-style-prefixes)
 ;;;###autoload
 (put 'allout-old-style-prefixes 'safe-local-variable
-     (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil)))))
+     (if (fboundp 'booleanp) 'booleanp (lambda (x) (member x '(t nil)))))
 ;;;_  = allout-stylish-prefixes -- alternating bullets
 (defcustom allout-stylish-prefixes t
   "Do fancy stuff with topic prefix bullets according to level, etc.
@@ -712,7 +717,7 @@ is non-nil."
 (make-variable-buffer-local 'allout-stylish-prefixes)
 ;;;###autoload
 (put 'allout-stylish-prefixes 'safe-local-variable
-     (if (fboundp 'booleanp) 'booleanp '(lambda (x) (member x '(t nil)))))
+     (if (fboundp 'booleanp) 'booleanp (lambda (x) (member x '(t nil)))))
 
 ;;;_  = allout-numbered-bullet
 (defcustom allout-numbered-bullet "#"
@@ -729,7 +734,7 @@ disables numbering maintenance."
 (put 'allout-numbered-bullet 'safe-local-variable
      (if (fboundp 'string-or-null-p)
          'string-or-null-p
-       '(lambda (x) (or (stringp x) (null x)))))
+       (lambda (x) (or (stringp x) (null x)))))
 ;;;_  = allout-file-xref-bullet
 (defcustom allout-file-xref-bullet "@"
   "Bullet signifying file cross-references, for `allout-resolve-xref'.
@@ -741,7 +746,7 @@ Set this var to the bullet you want to use for file cross-references."
 (put 'allout-file-xref-bullet 'safe-local-variable
      (if (fboundp 'string-or-null-p)
          'string-or-null-p
-       '(lambda (x) (or (stringp x) (null x)))))
+       (lambda (x) (or (stringp x) (null x)))))
 ;;;_  = allout-presentation-padding
 (defcustom allout-presentation-padding 2
   "Presentation-format white-space padding factor, for greater indent."
@@ -754,7 +759,7 @@ Set this var to the bullet you want to use for file cross-references."
 
 ;;;_  = allout-flattened-numbering-abbreviation
 (define-obsolete-variable-alias 'allout-abbreviate-flattened-numbering
-  'allout-flattened-numbering-abbreviation "24.0")
+  'allout-flattened-numbering-abbreviation "24.1")
 (defcustom allout-flattened-numbering-abbreviation nil
   "If non-nil, `allout-flatten-exposed-to-buffer' abbreviates topic
 numbers to minimal amount with some context.  Otherwise, entire
@@ -818,37 +823,32 @@ formatted copy."
   :group 'allout-encryption)
 ;;;_  = allout-encrypt-unencrypted-on-saves
 (defcustom allout-encrypt-unencrypted-on-saves t
-  "When saving, should topics pending encryption be encrypted?
-
-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
-        will be automatically decrypted before any user interaction, so they
-        can continue editing but the copy on the file system will be
-        encrypted.)
-        Auto-saves will use the \"All except current topic\" mode if this
-        one is selected, to avoid practical difficulties -- see below.
- - All except current topic: skip the topic currently being edited, even if
-       it's pending encryption.  This may expose the current topic on the
-       file sytem, but avoids the nuisance of prompts for the encryption
-       passphrase in the middle of editing for, eg, autosaves.
-       This mode is used for auto-saves for both this option and \"Yes\".
- - 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
-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."
-
-  :type '(choice (const :tag "Yes" t)
-                 (const :tag "All except current topic" except-current)
-                 (const :tag "No" nil))
-  :version "22.1"
+  "If non-nil, topics pending encryption are encrypted during buffer saves.
+
+This prevents file-system exposure of un-encrypted contents of
+items marked for encryption.
+
+When non-nil, if the topic currently being edited is decrypted,
+it will be encrypted for saving but automatically decrypted
+before any subsequent user interaction, so it is once again clear
+text for editing though the file system copy is encrypted.
+
+\(Auto-saves are handled differently.  Buffers with plain-text
+exposed encrypted topics are exempted from auto saves until all
+such topics are encrypted.)"
+
+  :type 'boolean
+  :version "23.1"
   :group 'allout-encryption)
 (make-variable-buffer-local 'allout-encrypt-unencrypted-on-saves)
+(defvar allout-auto-save-temporarily-disabled nil
+  "True while topic encryption is pending and auto-saving was active.
+
+The value of `buffer-saved-size' at the time of decryption is used,
+for restoring when all encryptions are established.")
+(defvar allout-just-did-undo nil
+  "True just after undo commands, until allout-post-command-business.")
+(make-variable-buffer-local 'allout-just-did-undo)
 
 ;;;_ + Developer
 ;;;_  = allout-developer group
@@ -910,7 +910,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-auto-activation'
+In buffers where this is non-nil (and if `allout-auto-activation'
 has been customized 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.
@@ -936,7 +936,7 @@ case the value of `allout-default-layout' is used.")
 (make-variable-buffer-local 'allout-layout)
 ;;;###autoload
 (put 'allout-layout 'safe-local-variable
-     '(lambda (x) (or (numberp x) (listp x) (memq x '(: * + -)))))
+     (lambda (x) (or (numberp x) (listp x) (memq x '(: * + -)))))
 
 ;;;_  : Topic header format
 ;;;_   = allout-regexp
@@ -1037,7 +1037,7 @@ suitably economical.")
 (defun allout-lead-with-comment-string (&optional header-lead)
   "Set the topic-header leading string to specified string.
 
-Useful when for encapsulating outline structure in programming
+Useful for encapsulating outline structure in programming
 language comments.  Returns the leading string."
 
   (interactive "P")
@@ -1404,7 +1404,7 @@ their settings before allout-mode was started."
 (defvar allout-mode-deactivate-hook nil
   "*Hook that's run when allout mode ends.")
 (define-obsolete-variable-alias 'allout-mode-deactivate-hook
-  'allout-mode-off-hook "future")
+  'allout-mode-off-hook "24.1")
 ;;;_   = allout-exposure-category
 (defvar allout-exposure-category nil
   "Symbol for use as allout invisible-text overlay category.")
@@ -1440,7 +1440,7 @@ Functions on the hook must take two arguments:
  - DEPTH -- integer indicating the depth of the subtree that was deleted.
  - REMOVED-FROM -- integer indicating the point where the subtree was removed.
 
-Some edits that remove or invalidate items may missed by this hook:
+Some edits that remove or invalidate items may be missed by this hook:
 specifically edits that native allout routines do not control.
 
 This hook might be invoked multiple times by a single command.")
@@ -1461,13 +1461,21 @@ This hook might be invoked multiple times by a single command.")
 (defvar allout-after-copy-or-kill-hook nil
   "*Hook that's run after copying outline text.
 
-Functions on the hook should not take any arguments.")
+Functions on the hook should not require any arguments.")
+;;;_   = allout-post-undo-hook
+(defvar allout-post-undo-hook nil
+  "*Hook that's run after undo activity.
+
+The item that's current when the hook is run *may* be the one
+that was affected by the undo.
+
+Functions on the hook should not require any arguments.")
 ;;;_   = allout-outside-normal-auto-fill-function
 (defvar allout-outside-normal-auto-fill-function nil
-  "Value of normal-auto-fill-function outside of allout mode.
+  "Value of `normal-auto-fill-function' outside of allout mode.
 
-Used by allout-auto-fill to do the mandated normal-auto-fill-function
-wrapped within allout's automatic fill-prefix setting.")
+Used by `allout-auto-fill' to do the mandated `normal-auto-fill-function'
+wrapped within allout's automatic `fill-prefix' setting.")
 (make-variable-buffer-local 'allout-outside-normal-auto-fill-function)
 ;;;_   = prevent redundant activation by desktop mode:
 (add-to-list 'desktop-minor-mode-handlers '(allout-mode . nil))
@@ -1529,14 +1537,14 @@ Entries must be symbols that are bound to the desired values.
 Each value can be a regexp or a list with a regexp followed by a
 substitution string.  If it's just a regexp, all its matches are removed
 before the text is encrypted.  If it's a regexp and a substitution, the
-substition is used against the regexp matches, a la `replace-match'.")
+substitution is used against the regexp matches, a la `replace-match'.")
 (make-variable-buffer-local 'allout-encryption-text-removal-regexps)
 ;;;_   = allout-encryption-ciphertext-rejection-regexps
 (defvar allout-encryption-ciphertext-rejection-regexps nil
   "Variable for regexps matching plaintext to remove before encryption.
 
 This is used to detect strings in encryption results that would
-register as allout mode structural elements, for exmple, as a
+register as allout mode structural elements, for example, as a
 topic prefix.
 
 Entries must be symbols that are bound to the desired regexp values.
@@ -1559,39 +1567,43 @@ See `allout-encryption-ciphertext-rejection-regexps' for rejection reasons.")
 (defmacro allout-mode-p ()
   "Return t if `allout-mode' is active in current buffer."
   'allout-mode)
-;;;_   > allout-write-file-hook-handler ()
-(defun allout-write-file-hook-handler ()
-  "Implement `allout-encrypt-unencrypted-on-saves' policy for file writes."
+;;;_   > allout-write-contents-hook-handler ()
+(defun allout-write-contents-hook-handler ()
+  "Implement `allout-encrypt-unencrypted-on-saves' for file writes
+
+Return nil if all goes smoothly, or else return an informative
+message if an error is encountered.  The message will serve as a
+non-nil return on `write-contents-functions' to prevent saving of
+the buffer while it has decrypted content.
+
+This behavior depends on Emacs versions that implement the
+`write-contents-functions' hook."
 
   (if (or (not (allout-mode-p))
           (not (boundp 'allout-encrypt-unencrypted-on-saves))
           (not allout-encrypt-unencrypted-on-saves))
       nil
-    (let ((except-mark (and (equal allout-encrypt-unencrypted-on-saves
-                                   'except-current)
-                            (point-marker))))
-      (if (save-excursion (goto-char (point-min))
-                          (allout-next-topic-pending-encryption except-mark))
-          (progn
-            (message "auto-encrypting pending topics")
-            (sit-for 0)
-            (condition-case failure
+    (if (save-excursion (goto-char (point-min))
+                        (allout-next-topic-pending-encryption))
+        (progn
+          (message "auto-encrypting pending topics")
+          (sit-for 0)
+          (condition-case failure
+              (progn
                 (setq allout-after-save-decrypt
-                      (allout-encrypt-decrypted except-mark))
-              (error (message
-                      "allout-write-file-hook-handler suppressing error %s"
-                      failure)
-                     (sit-for 2)))))
-      ))
-  nil)
-;;;_   > allout-auto-save-hook-handler ()
-(defun allout-auto-save-hook-handler ()
-  "Implement `allout-encrypt-unencrypted-on-saves' policy for auto save."
-
-  (if (and (allout-mode-p) allout-encrypt-unencrypted-on-saves)
-      ;; Always implement 'except-current policy when enabled.
-      (let ((allout-encrypt-unencrypted-on-saves 'except-current))
-        (allout-write-file-hook-handler))))
+                      (allout-encrypt-decrypted))
+                ;; aok - return nil:
+                nil)
+            (error
+             ;; whoops - probably some still-decrypted items, return non-nil:
+             (let ((text (format (concat "%s contents write inhibited due to"
+                                         " encrypted topic encryption error:"
+                                         " %s")
+                                 (buffer-name (current-buffer))
+                                 failure)))
+               (message text)(sit-for 2)
+               text)))))
+    ))
 ;;;_   > allout-after-saves-handler ()
 (defun allout-after-saves-handler ()
   "Decrypt topic encrypted for save, if it's currently being edited.
@@ -1615,7 +1627,7 @@ and the place for the cursor after the decryption is done."
   )
 ;;;_   > allout-called-interactively-p ()
 (defmacro allout-called-interactively-p ()
-  "A version of called-interactively-p independent of emacs version."
+  "A version of `called-interactively-p' independent of Emacs version."
   ;; ... to ease maintenance of allout without betraying deprecation.
   (if (equal (subr-arity (symbol-function 'called-interactively-p))
              '(0 . 0))
@@ -1644,7 +1656,7 @@ So `allout-post-command-business' should not reactivate it...")
 (defun allout-init (mode)
   "DEPRECATED - configure allout activation by customizing
 `allout-auto-activation'.  This function remains around, limited
-from what it did before, for backwards compatability.
+from what it did before, for backwards compatibility.
 
 MODE is the activation mode - see `allout-auto-activation' for
 valid values."
@@ -1690,17 +1702,19 @@ valid values."
 ;;;###autoload
 (define-minor-mode allout-mode
 ;;;_    . Doc string:
-  "Toggle minor mode for controlling exposure and editing of text outlines.
-\\<allout-mode-map-value>
-
-Allout outline mode always runs as a minor mode.
+  "Toggle Allout outline mode.
+With a prefix argument ARG, enable Allout outline mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil.
 
-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 example, see the allout code itself,
-which is organized as an allout outline.)
+\\<allout-mode-map-value>
+Allout outline mode is a minor mode that 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 example,
+see the allout code itself, which is organized as an allout
+outline.)
 
 In addition to typical outline navigation and exposure, allout includes:
 
@@ -1719,7 +1733,7 @@ Below is a description of the key bindings, and then description
 of special `allout-mode' features and terminology.  See also the
 outline menubar additions for quick reference to many of the
 features.  Customize `allout-auto-activation' to prepare your
-emacs session for automatic activation of `allout-mode'.
+Emacs session for automatic activation of `allout-mode'.
 
 The bindings are those listed in `allout-prefixed-keybindings'
 and `allout-unprefixed-keybindings'.  We recommend customizing
@@ -1767,7 +1781,7 @@ the HOT-SPOT Operation section.
 \\[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
+            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.
@@ -1777,12 +1791,12 @@ the HOT-SPOT Operation section.
         ----------------------------------
 \\[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-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
+\\[allout-yank-pop]     `allout-yank-pop'       Is to `allout-yank' as `yank-pop' is to `yank'.
 
         Topic-oriented Encryption:
         -------------------------
@@ -1822,7 +1836,7 @@ for a save, it is automatically decrypted for continued editing.
 NOTE: A few GnuPG v2 versions improperly preserve incorrect
 symmetric decryption keys, preventing entry of the correct key on
 subsequent decryption attempts until the cache times-out.  That
-can take several minutes.  \(Decryption of other entries is not
+can take several minutes.  (Decryption of other entries is not
 affected.)  Upgrade your EasyPG version, if you can, and you can
 deliberately clear your gpg-agent's cache by sending it a '-HUP'
 signal.
@@ -1858,18 +1872,19 @@ at the beginning of the current entry.
 
                              Extending Allout
 
-Allout exposure and authoring activites all have associated
+Allout exposure and authoring activities 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' \(deprecated)
+`allout-mode-deactivate-hook' (deprecated)
 `allout-mode-off-hook'
 `allout-exposure-change-hook'
 `allout-structure-added-hook'
 `allout-structure-deleted-hook'
 `allout-structure-shifted-hook'
 `allout-after-copy-or-kill-hook'
+`allout-post-undo-hook'
 
                             Terminology
 
@@ -1924,7 +1939,7 @@ PREFIX-LEAD:
         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
+        (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.
@@ -1936,8 +1951,8 @@ BULLET: A character at the end of the ITEM PREFIX, it must be one of
         `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
+        provide a universal argument (\\[universal-argument]) to the
+        TOPIC creation command, or when explicitly 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.
@@ -1955,12 +1970,7 @@ OPEN:    A TOPIC that is not CLOSED, though its OFFSPRING or BODY may be."
   :lighter " Allout"
   :keymap 'allout-mode-map
 
-  (let ((write-file-hook-var-name (cond ((boundp 'write-file-functions)
-                                         'write-file-functions)
-                                        ((boundp 'write-file-hooks)
-                                         'write-file-hooks)
-                                        (t 'local-write-file-hooks)))
-        (use-layout (if (listp allout-layout)
+  (let ((use-layout (if (listp allout-layout)
                         allout-layout
                       allout-default-layout)))
 
@@ -1979,9 +1989,8 @@ OPEN:     A TOPIC that is not CLOSED, though its OFFSPRING or BODY may be."
           (remove-hook 'post-command-hook 'allout-post-command-business t)
           (remove-hook 'before-change-functions 'allout-before-change-handler t)
           (remove-hook 'isearch-mode-end-hook 'allout-isearch-end-handler t)
-          (remove-hook write-file-hook-var-name
-                       'allout-write-file-hook-handler t)
-          (remove-hook 'auto-save-hook 'allout-auto-save-hook-handler t)
+          (remove-hook 'write-contents-functions
+                       'allout-write-contents-hook-handler t)
 
           (remove-overlays (point-min) (point-max)
                            'category 'allout-exposure-category))
@@ -2014,9 +2023,8 @@ OPEN:     A TOPIC that is not CLOSED, though its OFFSPRING or BODY may be."
       (add-hook 'post-command-hook 'allout-post-command-business nil t)
       (add-hook 'before-change-functions 'allout-before-change-handler nil t)
       (add-hook 'isearch-mode-end-hook 'allout-isearch-end-handler nil t)
-      (add-hook write-file-hook-var-name 'allout-write-file-hook-handler
+      (add-hook 'write-contents-functions 'allout-write-contents-hook-handler
                 nil t)
-      (add-hook 'auto-save-hook 'allout-auto-save-hook-handler nil t)
 
       ;; Stash auto-fill settings and adjust so custom allout auto-fill
       ;; func will be used if auto-fill is active or activated.  (The
@@ -2080,7 +2088,7 @@ OPEN:     A TOPIC that is not CLOSED, though its OFFSPRING or BODY may be."
   (save-current-buffer
     (dolist (buffer (buffer-list))
       (set-buffer buffer)
-      (when (allout-mode-p) (allout-mode))))
+      (when (allout-mode-p) (allout-mode -1))))
   ;; continue standard unloading
   nil)
 
@@ -2149,8 +2157,10 @@ internal functions use this feature cohesively bunch changes."
 
 See `allout-overlay-interior-modification-handler' for details."
 
-  (when (and (allout-mode-p) undo-in-progress (allout-hidden-p))
-    (allout-show-children))
+  (when (and (allout-mode-p) undo-in-progress)
+    (setq allout-just-did-undo t)
+    (if (allout-hidden-p)
+        (allout-show-children)))
 
   ;; allout-overlay-interior-modification-handler on an overlay handles
   ;; this in other emacs, via `allout-exposure-category's 'modification-hooks.
@@ -2240,7 +2250,7 @@ to return the current prefix."
                                   allout-recent-prefix-end))
 ;;;_  > allout-recent-bullet ()
 (defmacro allout-recent-bullet ()
-  "Like allout-recent-prefix, but returns bullet of last encountered prefix.
+  "Like `allout-recent-prefix', but returns bullet of last encountered prefix.
 
 All outline functions which directly do string matches to assess
 headings set the variables `allout-recent-prefix-beginning' and
@@ -2273,7 +2283,7 @@ If topic has no offspring, then the next sibling with offspring will
 determine whether or not this one is determined to be aberrant.
 
 If true, then the allout-recent-* settings are calibrated on the
-offspring that qaulifies it as aberrant, ie with depth that
+offspring that qualifies it as aberrant, ie with depth that
 exceeds the topic by more than one."
 
   ;; This is most clearly understood when considering standard-prefix-leader
@@ -2515,7 +2525,7 @@ Outermost is first."
 (defun allout-mark-active-p ()
   "True if the mark is currently or always active."
   ;; `(cond (boundp...))' (or `(if ...)') invokes special byte-compiler
-  ;; provisions, at least in fsf emacs to prevent warnings about lack of,
+  ;; provisions, at least in GNU Emacs to prevent warnings about lack of,
   ;; eg, region-active-p.
   (cond ((boundp 'mark-active)
          mark-active)
@@ -2615,13 +2625,13 @@ The remaining optional args are for internal use by the function.
 Point is left at the end of the subtree.
 
 Charts are used to capture outline structure, so that outline-altering
-routines need assess the structure only once, and then use the chart
+routines need to assess the structure only once, and then use the chart
 for their elaborate manipulations.
 
 The chart entries for the topics are in reverse order, so the
 last topic is listed first.  The entry for each topic consists of
 an integer indicating the point at the beginning of the topic
-prefix.  Charts for offspring consists of a list containing,
+prefix.  Charts for offspring consist of a list containing,
 recursively, the charts for the respective subtopics.  The chart
 for a topics' offspring precedes the entry for the topic itself.
 
@@ -3090,7 +3100,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 traveling backwards)
    item to confirm connectivity with the prior topic, and
  - if confirmed, we have to reestablish the allout-recent-* settings with
    some extra navigation
@@ -3127,7 +3137,7 @@ situation."
                  nil)
         ;; rationale: if any intervening items were at a lower depth, we
         ;; would now be on the first offspring at the target depth -- ie,
-        ;; the preceeding item (per the search direction) must be at a
+        ;; the preceding item (per the search direction) must be at a
         ;; lesser depth.  that's all we need to check.
         (if backward (allout-next-heading) (allout-previous-heading))
         (if (< allout-recent-depth target-depth)
@@ -3176,7 +3186,7 @@ Presumes point is at the start of a topic prefix."
       (if (allout-called-interactively-p) (allout-end-of-prefix)))))
 ;;;_   > allout-next-visible-heading (arg)
 (defun allout-next-visible-heading (arg)
-  "Move to the next ARG'th visible heading line, backward if arg is negative.
+  "Move to the next ARGth visible heading line, backward if ARG is negative.
 
 Move to buffer limit in indicated direction if headings are exhausted."
 
@@ -3296,6 +3306,10 @@ are mapped to the command of the corresponding control-key on the
 Set by `allout-pre-command-business', to support allout addons in
 coordinating with allout activity.")
 (make-variable-buffer-local 'allout-command-counter)
+;;;_   = allout-this-command-hid-text
+(defvar allout-this-command-hid-text nil
+  "True if the most recent allout-mode command hid any text.")
+(make-variable-buffer-local 'allout-this-command-hid-text)
 ;;;_   > allout-post-command-business ()
 (defun allout-post-command-business ()
   "Outline `post-command-hook' function.
@@ -3303,12 +3317,33 @@ coordinating with allout activity.")
 - Implement (and clear) `allout-post-goto-bullet', for hot-spot
   outline commands.
 
+- Move the cursor to the beginning of the entry if it is hidden
+  and collapsing activity just happened.
+
+- If the command we're following was an undo, check for change in
+  the status of encrypted items and adjust auto-save inhibitions
+  accordingly.
+
 - Decrypt topic currently being edited if it was encrypted for a save."
 
-                                       ; Apply any external change func:
   (if (not (allout-mode-p))            ; In allout-mode.
       nil
 
+    (when allout-just-did-undo
+      (setq allout-just-did-undo nil)
+      (run-hooks 'allout-post-undo-hook)
+      (cond ((and (= buffer-saved-size -1)
+                  allout-auto-save-temporarily-disabled)
+             ;; user possibly undid a decryption, disinhibit auto-save:
+             (allout-maybe-resume-auto-save-info-after-encryption))
+            ((save-excursion
+               (save-restriction
+                 (widen)
+                 (goto-char (point-min))
+                 (not (allout-next-topic-pending-encryption))))
+             ;; plain-text encrypted items are present, inhibit auto-save:
+             (allout-inhibit-auto-save-info-for-decryption (buffer-size)))))
+
     (if (and (boundp 'allout-after-save-decrypt)
              allout-after-save-decrypt)
         (allout-after-saves-handler))
@@ -3317,8 +3352,9 @@ coordinating with allout activity.")
     (if (and allout-post-goto-bullet
             (allout-current-bullet-pos))
        (progn (goto-char (allout-current-bullet-pos))
-              (setq allout-post-goto-bullet nil)))
-    ))
+              (setq allout-post-goto-bullet nil))
+      (when (and (allout-hidden-p) allout-this-command-hid-text)
+        (allout-beginning-of-current-entry)))))
 ;;;_   > allout-pre-command-business ()
 (defun allout-pre-command-business ()
   "Outline `pre-command-hook' function for outline buffers.
@@ -3341,8 +3377,8 @@ return to regular interpretation of self-insert characters."
 
   (if (not (allout-mode-p))
       nil
-    ;; Increment allout-command-counter
     (setq allout-command-counter (1+ allout-command-counter))
+    (setq allout-this-command-hid-text nil)
     ;; Do hot-spot navigation.
     (if (and (eq this-command 'self-insert-command)
             (eq (point)(allout-current-bullet-pos)))
@@ -3352,8 +3388,8 @@ return to regular interpretation of self-insert characters."
   "Catchall handling of key bindings in hot-spots.
 
 Translates unmodified keystrokes to corresponding allout commands, when
-they would qualify if prefixed with the allout-command-prefix, and sets
-this-command accordingly.
+they would qualify if prefixed with the `allout-command-prefix', and sets
+`this-command' accordingly.
 
 Returns the qualifying command, if any, else nil."
   (interactive)
@@ -3467,13 +3503,13 @@ Offer one suitable for current depth DEPTH as default."
 (defun allout-make-topic-prefix (&optional prior-bullet
                                             new
                                             depth
-                                            solicit
+                                            instead
                                             number-control
                                             index)
   ;; Depth null means use current depth, non-null means we're either
   ;; opening a new topic after current topic, lower or higher, or we're
   ;; changing level of current topic.
-  ;; Solicit dominates specified bullet-char.
+  ;; Instead dominates specified bullet-char.
 ;;;_    . Doc string:
   "Generate a topic prefix suitable for optional arg DEPTH, or current depth.
 
@@ -3494,17 +3530,20 @@ bullet or previous sibling.
 Third arg DEPTH forces the topic prefix to that depth, regardless of
 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,
-including, eg, a distinctive PRIOR-BULLET.)  If non-nil, then the
-context-specific bullet is used.
+If INSTEAD is:
+
+- nil, then the bullet char for the context is used, per distinction or depth
+- a (numeric) character, then character's string representation is used
+- a string, then the user is asked for bullet with the first char as default
+- anything else, the user is solicited with bullet char per context as default
+
+\(INSTEAD overrides other options, including, eg, a distinctive
+PRIOR-BULLET.)
 
 Fifth arg, NUMBER-CONTROL, matters only if `allout-numbered-bullet'
-is non-nil *and* soliciting was not explicitly invoked.  Then
+is non-nil *and* no specific INSTEAD was specified.  Then
 NUMBER-CONTROL non-nil forces prefix to either numbered or
-denumbered format, depending on the value of the sixth arg, INDEX.
+unnumbered format, depending on the value of the sixth arg, INDEX.
 
 \(Note that NUMBER-CONTROL does *not* apply to level 1 topics.  Sorry...)
 
@@ -3518,7 +3557,7 @@ number is used as the index for the numbered prefix (allowing, eg,
 sequential renumbering to not require this function counting back the
 index for each successive sibling)."
 ;;;_    . Code:
-  ;; The options are ordered in likely frequence of use, most common
+  ;; The options are ordered in likely frequency of use, most common
   ;; highest, least lowest.  Ie, more likely to be doing prefix
   ;; adjustments than soliciting, and yet more than numbering.
   ;; Current prefix is least dominant, but most likely to be commonly
@@ -3551,8 +3590,13 @@ index for each successive sibling)."
            ;; Solicitation overrides numbering and other cases:
            ((progn (setq body (make-string (- depth 2) ?\ ))
                    ;; The actual condition:
-                   solicit)
-            (let* ((got (allout-solicit-alternate-bullet depth solicit)))
+                   instead)
+            (let ((got (cond ((stringp instead)
+                              (if (> (length instead) 0)
+                                  (allout-solicit-alternate-bullet
+                                   depth (substring instead 0 1))))
+                             ((characterp instead) (char-to-string instead))
+                             (t (allout-solicit-alternate-bullet depth)))))
               ;; Gotta check whether we're numbering and got a numbered bullet:
               (setq numbering (and allout-numbered-bullet
                                    (not (and number-control (not index)))
@@ -3763,7 +3807,7 @@ Nuances:
             ;;(if doing-beginning (goto-char doing-beginning))
             (if (not (bobp))
                 ;; We insert a newline char rather than using open-line to
-                ;; avoid rear-stickiness inheritence of read-only property.
+                ;; avoid rear-stickiness inheritance of read-only property.
                 (progn (if (and (not (> depth ref-depth))
                                 (not before))
                            (open-line 1)
@@ -3778,7 +3822,7 @@ Nuances:
                        (if (and (not (eobp))
                                 (or (not (bolp))
                                     (and (not (bobp))
-                                         ;; bolp doesnt detect concealed
+                                         ;; bolp doesn't detect concealed
                                          ;; trailing newlines, compensate:
                                          (save-excursion
                                            (forward-char -1)
@@ -3805,7 +3849,7 @@ Nuances:
 (defun allout-open-subtopic (arg)
   "Open new topic header at deeper level than the current one.
 
-Negative universal arg means to open deeper, but place the new topic
+Negative universal ARG means to open deeper, but place the new topic
 prior to the current one."
   (interactive "p")
   (allout-open-topic 1 (> 0 arg) (< 1 arg)))
@@ -3813,9 +3857,9 @@ prior to the current one."
 (defun allout-open-sibtopic (arg)
   "Open new topic header at same level as the current one.
 
-Positive universal arg means to use the bullet of the prior sibling.
+Positive universal ARG means to use the bullet of the prior sibling.
 
-Negative universal arg means to place the new topic prior to the current
+Negative universal ARG means to place the new topic prior to the current
 one."
   (interactive "p")
   (allout-open-topic 0 (> 0 arg) (not (= 1 arg))))
@@ -3823,7 +3867,7 @@ one."
 (defun allout-open-supertopic (arg)
   "Open new topic header at shallower level than the current one.
 
-Negative universal arg means to open shallower, but place the new
+Negative universal ARG means to open shallower, but place the new
 topic prior to the current one."
 
   (interactive "p")
@@ -3841,7 +3885,9 @@ topic prior to the current one."
 Maintains outline hanging topic indentation if
 `allout-use-hanging-indents' is set."
 
-  (when (not allout-inhibit-auto-fill)
+  (when (and (not allout-inhibit-auto-fill)
+             (or (not allout-inhibit-auto-fill-on-headline)
+                 (not (allout-on-current-heading-p))))
     (let ((fill-prefix (if allout-use-hanging-indents
                            ;; Check for topic header indentation:
                            (save-match-data
@@ -3915,7 +3961,7 @@ Note that refill of indented paragraphs is not done."
                      (allout-end-of-prefix)
                       (setq from allout-recent-prefix-beginning
                             to allout-recent-prefix-end)
-                     (allout-rebullet-heading t        ;;; solicit
+                     (allout-rebullet-heading t        ;;; instead
                                                nil     ;;; depth
                                                nil     ;;; number-control
                                                nil     ;;; index
@@ -3933,8 +3979,8 @@ Note that refill of indented paragraphs is not done."
     (message "Done.")
     (cond (on-bullet (goto-char (allout-current-bullet-pos)))
          (initial-col (move-to-column initial-col)))))
-;;;_    > allout-rebullet-heading (&optional solicit ...)
-(defun allout-rebullet-heading (&optional solicit
+;;;_    > allout-rebullet-heading (&optional instead ...)
+(defun allout-rebullet-heading (&optional instead
                                            new-depth
                                            number-control
                                            index
@@ -3944,11 +3990,11 @@ Note that refill of indented paragraphs is not done."
 
 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
-distinction or depth) is offered.  If non-nil, then the
-context-specific bullet is just used.
+If INSTEAD is:
+- nil, then the bullet char for the context is used, per distinction or depth
+- a (numeric) character, then character's string representation is used
+- a string, then the user is asked for bullet with the first char as default
+- anything else, the user is solicited with bullet char per context as default
 
 Second arg DEPTH forces the topic prefix to that depth, regardless
 of the topic's current depth.
@@ -3983,11 +4029,11 @@ this function."
          (new-prefix (allout-make-topic-prefix current-bullet
                                                 nil
                                                 new-depth
-                                                solicit
+                                                instead
                                                 number-control
                                                 index)))
 
-    ;; Is new one is identical to old?
+    ;; Is new one identical to old?
     (if (and (= current-depth new-depth)
              (string= current-bullet
                       (substring new-prefix (1- (length new-prefix)))))
@@ -4021,6 +4067,8 @@ this function."
                (not (allout-encrypted-topic-p)))
          (allout-reindent-body current-depth new-depth))
 
+      (run-hook-with-args 'allout-exposure-change-hook mb me nil)
+
       ;; Recursively rectify successive siblings of orig topic if
       ;; caller elected for it:
       (if do-successors
@@ -4030,7 +4078,7 @@ this function."
                    (cond ((numberp index) (1+ index))
                          ((not number-control)  (allout-sibling-index))))
              (if (allout-numbered-type-prefix)
-                 (allout-rebullet-heading nil          ;;; solicit
+                 (allout-rebullet-heading nil          ;;; instead
                                            new-depth   ;;; new-depth
                                            number-control;;; number-control
                                            index       ;;; index
@@ -4147,7 +4195,7 @@ a topic and its immediate offspring is greater than one.)"
            (when (< relative-depth 0)
              (save-excursion
                (goto-char local-point)
-               (allout-rebullet-heading nil               ;;; solicit
+               (allout-rebullet-heading nil               ;;; instead
                                         (+ starting-depth relative-depth)
                                         nil            ;;; number
                                         starting-index
@@ -4205,7 +4253,7 @@ Returns final depth."
                                         ; Prime ascender for ascension:
       (setq ascender (1- allout-recent-depth))
       (if (>= allout-recent-depth depth)
-          (allout-rebullet-heading nil ;;; solicit
+          (allout-rebullet-heading nil ;;; instead
                                     nil        ;;; depth
                                     nil        ;;; number-control
                                     nil        ;;; index
@@ -4232,7 +4280,7 @@ rebulleting each topic at this level."
           (use-bullet (equal '(16) denumber))
           (more t))
       (while more
-        (allout-rebullet-heading use-bullet            ;;; solicit
+        (allout-rebullet-heading use-bullet            ;;; instead
                                   depth                        ;;; depth
                                   t                    ;;; number-control
                                   index                        ;;; index
@@ -4248,7 +4296,7 @@ With a negative argument, the item is shifted out using
 
 With an argument greater than one, shift-in the item but not its
 offspring, making the item into a sibling of its former children,
-and a child of sibling that formerly preceeded it.
+and a child of sibling that formerly preceded it.
 
 You are not allowed to shift the first offspring of a topic
 inwards, because that would yield a \"containment
@@ -4359,7 +4407,7 @@ subtopics into siblings of the item."
         (run-hook-with-args 'allout-structure-deleted-hook depth (point))))))
 ;;;_    > allout-copy-line-as-kill ()
 (defun allout-copy-line-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
@@ -4482,8 +4530,9 @@ Topic exposure is marked with text-properties, to be used by
             ;; advance to just after end of this annotation:
             (setq next (allout-next-single-char-property-change
                         (point) 'allout-was-hidden nil end))
-            (overlay-put (make-overlay prev next nil 'front-advance)
-                         'category 'allout-exposure-category)
+            (let ((o (make-overlay prev next nil 'front-advance)))
+              (overlay-put o 'category 'allout-exposure-category)
+              (overlay-put o 'evaporate t))
             (allout-deannotate-hidden prev next)
             (setq prev next)
             (if next (goto-char next)))))
@@ -4579,32 +4628,21 @@ however, are left exactly like normal, non-allout-specific yanks."
                           (progn (widen)
                                  (forward-char -1)
                                  (narrow-to-region subj-beg (point))))))
-                  ;; Preserve new bullet if it's a distinctive one, otherwise
-                  ;; use old one:
-                  (if (string-match (regexp-quote prefix-bullet)
-                                    allout-distinctive-bullets-string)
-                                        ; Delete from bullet of old to
-                                        ; before bullet of new:
-                      (progn
-                        (beginning-of-line)
-                        (allout-unprotected
-                         (delete-region (point) subj-beg))
-                        (set-marker (allout-mark-marker t) subj-end)
-                        (goto-char subj-beg)
-                        (allout-end-of-prefix))
-                                        ; Delete base subj prefix,
-                                        ; leaving old one:
-                    (allout-unprotected
-                     (progn
-                       (delete-region (point) (+ (point)
-                                                 prefix-len
-                                                 (- adjust-to-depth
-                                                    subj-depth)))
+                  ;; Remove new heading prefix:
+                  (allout-unprotected
+                   (progn
+                     (delete-region (point) (+ (point)
+                                               prefix-len
+                                               (- adjust-to-depth
+                                                  subj-depth)))
                                         ; and delete residual subj
                                         ; prefix digits and space:
-                       (while (looking-at "[0-9]") (delete-char 1))
-                       (if (looking-at " ")
-                           (delete-char 1))))))
+                     (while (looking-at "[0-9]") (delete-char 1))
+                     (delete-char -1)
+                     (if (not (eolp))
+                         (forward-char))))
+                  ;; Assert new topic's bullet - minimal effort if unchanged:
+                  (allout-rebullet-heading (string-to-char prefix-bullet)))
               (exchange-point-and-mark))))
       (if rectify-numbering
           (progn
@@ -4615,7 +4653,7 @@ however, are left exactly like normal, non-allout-specific yanks."
               (goto-char subj-beg)
               (if (allout-goto-prefix-doublechecked)
                   (allout-unprotected
-                   (allout-rebullet-heading nil          ;;; solicit
+                   (allout-rebullet-heading nil          ;;; instead
                                             (allout-depth) ;;; depth
                                             nil ;;; number-control
                                             nil ;;; index
@@ -4732,13 +4770,15 @@ arguments as this function, after the exposure changes are made."
   (when flag
     (let ((o (make-overlay from to nil 'front-advance)))
       (overlay-put o 'category 'allout-exposure-category)
+      (overlay-put o 'evaporate t)
       (when (featurep 'xemacs)
         (let ((props (symbol-plist 'allout-exposure-category)))
           (while props
             (condition-case nil
                 ;; as of 2008-02-27, xemacs lacks modification-hooks
                 (overlay-put o (pop props) (pop props))
-              (error nil)))))))
+              (error nil))))))
+    (setq allout-this-command-hid-text t))
   (run-hook-with-args 'allout-exposure-change-hook from to flag))
 ;;;_   > allout-flag-current-subtree (flag)
 (defun allout-flag-current-subtree (flag)
@@ -5366,7 +5406,7 @@ header and body.  The elements of that list are:
 
       (goto-char start)
       (beginning-of-line)
-      ;; Goto initial topic, and register preceeding stuff, if any:
+      ;; Goto initial topic, and register preceding stuff, if any:
       (if (> (allout-goto-prefix-doublechecked) start)
          ;; First topic follows beginning point -- register preliminary stuff:
          (setq result
@@ -5433,7 +5473,7 @@ header and body.  The elements of that list are:
                                     "invalid format" format))))
                 (list depth prefix strings))
                    result))
-       ;; Reasses format, if any:
+       ;; Reassess format, if any:
        (if (and format (listp format))
            (cond ((= new-depth depth)
                   (setq format (cons (1+ (car format))
@@ -5814,12 +5854,12 @@ With repeat count, copy the exposed portions of entire buffer."
 (defun allout-toggle-current-subtree-encryption (&optional keymode-cue)
   "Encrypt clear or decrypt encoded topic text.
 
-Allout uses emacs 'epg' libary to perform encryption.  Symmetric
+Allout uses Emacs 'epg' library to perform encryption.  Symmetric
 and keypair encryption are supported.  All encryption is ascii
 armored.
 
 Entry encryption defaults to symmetric key mode unless keypair
-recipients are associated with the file \(see
+recipients are associated with the file (see
 `epa-file-encrypt-to') or the function is invoked with a
 \(KEYMODE-CUE) universal argument greater than 1.
 
@@ -5831,7 +5871,7 @@ encryption.
 Further, encrypting with a KEYMODE-CUE universal argument greater
 than 4 - eg, preceded by a doubled Ctrl-U - causes association of
 the specified recipients with the file, replacing those currently
-associated with it.  This can be used to deassociate any
+associated with it.  This can be used to dissociate any
 recipients with the file, by selecting no recipients in the
 dialog.
 
@@ -5841,7 +5881,7 @@ 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 currently.  When a
 file with topics pending encryption is saved, topics pending
-encryption are encrypted.  See allout-encrypt-unencrypted-on-saves
+encryption are encrypted.  See `allout-encrypt-unencrypted-on-saves'
 for auto-encryption specifics.
 
 \*NOTE WELL* that automatic encryption that happens during saves will
@@ -5860,7 +5900,7 @@ encrypted.  If you want to encrypt the contents of a top-level topic, use
   "Encrypt clear text or decrypt encoded topic contents (body and subtopics.)
 
 Entry encryption defaults to symmetric key mode unless keypair
-recipients are associated with the file \(see
+recipients are associated with the file (see
 `epa-file-encrypt-to') or the function is invoked with a
 \(KEYMODE-CUE) universal argument greater than 1.
 
@@ -5872,11 +5912,11 @@ encryption.
 Further, encrypting with a KEYMODE-CUE universal argument greater
 than 4 - eg, preceded by a doubled Ctrl-U - causes association of
 the specified recipients with the file, replacing those currently
-associated with it.  This can be used to deassociate any
+associated with it.  This can be used to dissociate any
 recipients with the file, by selecting no recipients in the
 dialog.
 
-Encryption and decryption uses the emacs epg library.
+Encryption and decryption uses the Emacs 'epg' library.
 
 Encrypted text will be ascii-armored.
 
@@ -5891,6 +5931,8 @@ See `allout-toggle-current-subtree-encryption' for more details."
                        " shift it in to make it encryptable")))
 
     (let* ((allout-buffer (current-buffer))
+           ;; for use with allout-auto-save-temporarily-disabled, if necessary:
+           (was-buffer-saved-size buffer-saved-size)
            ;; Assess location:
            (bullet-pos allout-recent-prefix-beginning)
            (after-bullet-pos (point))
@@ -5970,6 +6012,12 @@ See `allout-toggle-current-subtree-encryption' for more details."
            ;; Add the is-encrypted bullet qualifier:
            (goto-char after-bullet-pos)
            (insert "*"))))
+
+      ;; adjust buffer's auto-save eligibility:
+      (if was-encrypted
+          (allout-inhibit-auto-save-info-for-decryption was-buffer-saved-size)
+        (allout-maybe-resume-auto-save-info-after-encryption))
+
       (run-hook-with-args 'allout-structure-added-hook
                           bullet-pos subtree-end))))
 ;;;_  > allout-encrypt-string (text decrypt allout-buffer keymode-cue
@@ -5985,7 +6033,7 @@ If DECRYPT is true (default false), then decrypt instead of encrypt.
 ALLOUT-BUFFER identifies the buffer containing the text.
 
 Entry encryption defaults to symmetric key mode unless keypair
-recipients are associated with the file \(see
+recipients are associated with the file (see
 `epa-file-encrypt-to') or the function is invoked with a
 \(KEYMODE-CUE) universal argument greater than 1.
 
@@ -5997,7 +6045,7 @@ encryption.
 Further, encrypting with a KEYMODE-CUE universal argument greater
 than 4 - eg, preceded by a doubled Ctrl-U - causes association of
 the specified recipients with the file, replacing those currently
-associated with it.  This can be used to deassociate any
+associated with it.  This can be used to dissociate any
 recipients with the file, by selecting no recipients in the
 dialog.
 
@@ -6009,7 +6057,7 @@ rejections due to matches against
 NOTE: A few GnuPG v2 versions improperly preserve incorrect
 symmetric decryption keys, preventing entry of the correct key on
 subsequent decryption attempts until the cache times-out.  That
-can take several minutes.  \(Decryption of other entries is not
+can take several minutes.  (Decryption of other entries is not
 affected.)  Upgrade your EasyPG version, if you can, and you can
 deliberately clear your gpg-agent's cache by sending it a '-HUP'
 signal."
@@ -6021,6 +6069,7 @@ signal."
                         (epg-context-set-passphrase-callback
                          context #'epa-passphrase-callback-function)
                         context))
+
          (encoding (with-current-buffer allout-buffer
                      buffer-file-coding-system))
          (multibyte (with-current-buffer allout-buffer
@@ -6088,9 +6137,14 @@ signal."
 
     (setq result-text
           (if decrypt
-              (epg-decrypt-string epg-context
-                                  (encode-coding-string massaged-text
-                                                        (or encoding 'utf-8)))
+              (condition-case err
+                  (epg-decrypt-string epg-context
+                                      (encode-coding-string massaged-text
+                                                            (or encoding 'utf-8)))
+                (epg-error
+                 (signal 'egp-error
+                         (cons (concat (cadr err) " - gpg version problem?")
+                               (cddr err)))))
             (replace-regexp-in-string "\n$" ""
              (epg-encrypt-string epg-context
                                  (encode-coding-string massaged-text
@@ -6137,8 +6191,29 @@ signal."
                          result-text))
       (error (concat "Encryption produced non-armored text, which"
                      "conflicts with allout mode -- reconfigure!")))
-
      (t result-text))))
+;;;_  > allout-inhibit-auto-save-info-for-decryption
+(defun allout-inhibit-auto-save-info-for-decryption (was-buffer-saved-size)
+  "Temporarily prevent auto-saves in this buffer when an item is decrypted.
+
+WAS-BUFFER-SAVED-SIZE is the value of `buffer-saved-size' *before*
+the decryption."
+  (when (not (or (= buffer-saved-size -1) (= was-buffer-saved-size -1)))
+    (setq allout-auto-save-temporarily-disabled was-buffer-saved-size
+          buffer-saved-size -1)))
+;;;_  > allout-maybe-resume-auto-save-info-after-encryption ()
+(defun allout-maybe-resume-auto-save-info-after-encryption ()
+  "Restore auto-save info, *if* there are no topics pending encryption."
+  (when (and allout-auto-save-temporarily-disabled
+             (= buffer-saved-size -1)
+             (save-excursion
+               (save-restriction
+                 (widen)
+                 (goto-char (point-min))
+                 (not (allout-next-topic-pending-encryption)))))
+    (setq buffer-saved-size allout-auto-save-temporarily-disabled
+          allout-auto-save-temporarily-disabled nil)))
+
 ;;;_  > allout-encrypted-topic-p ()
 (defun allout-encrypted-topic-p ()
   "True if the current topic is encryptable and encrypted."
@@ -6149,17 +6224,13 @@ signal."
          (save-match-data (looking-at "\\*")))
     )
   )
-;;;_  > allout-next-topic-pending-encryption (&optional except-mark)
-(defun allout-next-topic-pending-encryption (&optional except-mark)
+;;;_  > allout-next-topic-pending-encryption ()
+(defun allout-next-topic-pending-encryption ()
   "Return the point of the next topic pending encryption, or nil if none.
 
-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
-immediately following '*' that would mark the topic as being encrypted.  It
-must also have content."
+immediately following '*' that would mark the topic as being encrypted.
+It must also have content."
   (let (done got content-beg)
     (save-match-data
       (while (not done)
@@ -6191,10 +6262,7 @@ must also have content."
                (setq content-beg (point))
                (backward-char 1)
                (allout-end-of-subtree)
-               (if (or (<= (point) content-beg)
-                       (and except-mark
-                            (<= content-beg except-mark)
-                            (>= (point) except-mark)))
+               (if (<= (point) content-beg)
                    ;; Continue looking
                    (setq got nil)
                  ;; Got it!
@@ -6206,14 +6274,10 @@ must also have content."
       )
     )
   )
-;;;_  > allout-encrypt-decrypted (&optional except-mark)
-(defun allout-encrypt-decrypted (&optional except-mark)
+;;;_  > allout-encrypt-decrypted ()
+(defun allout-encrypt-decrypted ()
   "Encrypt topics pending encryption except those containing exemption point.
 
-EXCEPT-MARK identifies a point whose containing topics should be excluded
-from encryption.  This supports the `except-current' mode of
-`allout-encrypt-unencrypted-on-saves'.
-
 If a topic that is currently being edited was encrypted, we return a list
 containing the location of the topic and the location of the cursor just
 before the topic was encrypted.  This can be used, eg, to decrypt the topic
@@ -6229,7 +6293,7 @@ save.  See `allout-encrypt-unencrypted-on-saves' for more info."
              bo-subtree
              editing-topic editing-point)
         (goto-char (point-min))
-        (while (allout-next-topic-pending-encryption except-mark)
+        (while (allout-next-topic-pending-encryption)
           (setq was-modified (buffer-modified-p))
           (when (save-excursion
                   (and (boundp 'allout-encrypt-unencrypted-on-saves)
@@ -6268,7 +6332,7 @@ save.  See `allout-encrypt-unencrypted-on-saves' for more info."
   "Activate outline mode and establish file var so it is started subsequently.
 
 See `allout-layout' and customization of `allout-auto-activation'
-for details on preparing emacs for automatic allout activation."
+for details on preparing Emacs for automatic allout activation."
 
   (interactive "P")
 
@@ -6316,7 +6380,7 @@ Returns a list of the form (BEGINNING-POINT PREFIX-STRING SUFFIX-STRING)."
 (defun allout-adjust-file-variable (varname value)
   "Adjust the setting of an Emacs file variable named VARNAME to VALUE.
 
-This activity is inhibited if either `enable-local-variables'
+This activity is inhibited if either `enable-local-variables' or
 `allout-enable-file-variable-adjustment' are nil.
 
 When enabled, an entry for the variable is created if not already present,
@@ -6506,7 +6570,7 @@ If BEG is bigger than END we return 0."
 (defun allout-mark-marker (&optional force buffer)
   "Accommodate the different signature for `mark-marker' across Emacsen.
 
-XEmacs takes two optional args, while mainline GNU Emacs does not,
+XEmacs takes two optional args, while Emacs does not,
 so pass them along when appropriate."
   (if (featurep 'xemacs)
       (apply 'mark-marker force buffer)
@@ -6597,7 +6661,7 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
       (if (/= arg 1)
           (condition-case nil (line-move (1- arg)) (error nil)))
 
-      ;; Move to beginning-of-line, ignoring fields and invisibles.
+      ;; Move to beginning-of-line, ignoring fields and invisible text.
       (skip-chars-backward "^\n")
       (while (and (not (bobp))
                   (let ((prop