all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* allout-mode fixes - mode-specific settings, auto-fill, deactivation hook
@ 2006-07-08 15:48 Ken Manheimer
  2006-07-08 16:31 ` Ken Manheimer
  0 siblings, 1 reply; 4+ messages in thread
From: Ken Manheimer @ 2006-07-08 15:48 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 3374 bytes --]

i have new patch for allout.el.  it fixes a few things:

 - hooks and mode-specific variable settings are properly set to be local,
   and properly cleaned up on mode deactivation
 - auto-fill is not forced active if it wasn't already active when the mode
   was initiated.
 - hotspot key handling is modularized, for consistent use everywhere.
 - a new hook variable, `allout-mode-deactivation-hook', provides a
   complement to `allout-mode-hook'.

the settings cleanup is implemented with an improved settings
suspension/resumption mechanism, accompanied by some much needed unit
tests.  the unit tests are run after the file is loaded if a new
customization option, `allout-run-unit-tests-after-load', is true.
the idea is that allout code developers set this to true, and are
warned quickly about regressions.

the change-log is included below and also attached.  the patch and a
new version of the NEWS file are also attached.  I'm hoping someone
with commit privileges will have a moment to install these changes.
-- 
ken
ken.manheimer@gmail.com
http://myriadicity.net

2006-07-08  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Require 'cl.
	(allout-mode-deactivate-hook): New hook, is run when allout mode
	deactivates.
	(allout-developer): New allout customization subgroup.
	(allout-run-unit-tests-after-load): New allout-developer
	customization variable, when true allout unit tests are run after
	file load.
	(allout-inhibit-auto-fill): Disable auto-fill activity even during
	auto-fill-mode.
	(allout-resumptions): Removed, to be replaced by...
	(allout-add-resumptions): Register variable settings to be
	reinstated by `allout-do-resumptions'.  The settings are made
	buffer-local, but the locality/globality of the suspended setting
	is restored on resumption.
	(allout-do-resumptions): Reinstate all settings suspended using
	`allout-add-resumptions'.
	(allout-test-resumptions): Unit tests (and intermediate variables)
	for resumptions.
	(allout-tests-globally-unbound, allout-tests-globally-true)
	(allout-tests-locally-true): Intermediate variables for
	resumptions unit tests.
	(allout-overlay-preparations): Replaces `allout-set-overlay-category'.
	(allout-exposure-category): Replaces 'allout-overlay-category variable.
	(allout-mode): Use `allout-add-resumptions' and `allout-do-resumptions'
	instead of retired `allout-resumptions'.  For hook functions, use
	`local' parameter so hook settings are created and removed as
	buffer-local settings.  Revise (resumptions) setting
	auto-fill-function so it is set only if already active.  (The
	related fill-function settings are all made in either case, so
	that activating auto-fill-mode activity will have the custom
	allout-mode behaviors (hanging indent on topics, if configured for
	it).  Also, remove all allout-exposure-category overlays on mode
	deactivation.
	(allout-hotspot-key-handler): New function extracted from
	`allout-pre-command-business', so the functionality can be used
	for other purposes, eg as a binding in an overlay.
	(allout-pre-command-business): Use new `allout-hotspot-key-handler'.
	(allout-auto-fill): Respect new `allout-inhibit-auto-fill'
	customization variable.
	(allout-run-unit-tests): Run the (currently quite small)
	repertoire of unit tests.  Called from an eval-after-load statement
	if user has customized `allout-run-unit-tests-after-load' non-nil.

[-- Attachment #2: allout-ChangeLog.txt --]
[-- Type: text/plain, Size: 18285 bytes --]

2006-07-08  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Require 'cl.
	(allout-mode-deactivate-hook): New hook, is run when allout mode
	deactivates.
	(allout-developer): New allout customization subgroup.
	(allout-run-unit-tests-after-load): New allout-developer
	customization variable, when true allout unit tests are run after
	file load.
	(allout-inhibit-auto-fill): Disable auto-fill activity even during
	auto-fill-mode.
	(allout-resumptions): Removed, to be replaced by...
	(allout-add-resumptions): Register variable settings to be
	reinstated by `allout-do-resumptions'.  The settings are made
	buffer-local, but the locality/globality of the suspended setting
	is restored on resumption.
	(allout-do-resumptions): Reinstate all settings suspended using
	`allout-add-resumptions'.
	(allout-test-resumptions): Unit tests (and intermediate variables)
	for resumptions.
	(allout-tests-globally-unbound, allout-tests-globally-true)
	(allout-tests-locally-true): Intermediate variables for
	resumptions unit tests.
	(allout-overlay-preparations): Replaces `allout-set-overlay-category'.
	(allout-exposure-category): Replaces 'allout-overlay-category variable.
	(allout-mode): Use `allout-add-resumptions' and `allout-do-resumptions'
	instead of retired `allout-resumptions'.  For hook functions, use
	`local' parameter so hook settings are created and removed as
	buffer-local settings.  Revise (resumptions) setting
	auto-fill-function so it is set only if already active.  (The
	related fill-function settings are all made in either case, so
	that activating auto-fill-mode activity will have the custom
	allout-mode behaviors (hanging indent on topics, if configured for
	it).  Also, remove all allout-exposure-category overlays on mode
	deactivation.
	(allout-hotspot-key-handler): New function extracted from
	`allout-pre-command-business', so the functionality can be used
	for other purposes, eg as a binding in an overlay.
	(allout-pre-command-business): Use new `allout-hotspot-key-handler'.
	(allout-auto-fill): Respect new `allout-inhibit-auto-fill'
	customization variable.
	(allout-run-unit-tests): Run the (currently quite small)
	repertoire of unit tests.  Called from an eval-after-load statement
	if user has customized `allout-run-unit-tests-after-load' non-nil.

2006-06-17  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: (allout-inhibit-auto-fill): New custom configuration
	variable, makes it easy to inhibit allout auto fill in general or
	on a buffer-by-buffer basis.
	(allout-overlay-preparations): Better name than
	allout-set-overlay-category (particularly when i add a few more
	overlays).
	(allout-next-heading): Fixed bug where it would skip the first
	heading if preceded in the buffer by only a blank line.  Also,
	fixed docstring cut-and-paste error.
	(allout-kill-topic): Add collapsed-cue text property within
	allout-unprotected.

2006-05-11  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: (allout-show-bodies, allout-old-style-prefixes)
	(allout-stylish-prefixes, allout-numbered-bullet)
	(allout-file-xref-bullet, allout-use-hanging-indents): Use simple
	predicates to qualify `safe-local-variable' property, when
	available, else use equivalent lambda.
	(allout-current-topic-collapsed-p): Do the right thing regarding
	trailing blank lines.

2006-05-12  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: (allout-view-change-hook): Mark as being deprecated,
	to be replaced by `allout-exposure-change-hook'.
	(allout-exposure-change-hook): New, replacing
	`allout-view-change-hook'.
	(allout-flag-region): Run new hook `allout-exposure-change-hook',
	in addition to `allout-view-change-hook'.
	(allout-show-bodies, allout-old-style-prefixes)
	(allout-stylish-prefixes, allout-use-hanging-indents): Quote the
	lambda forms to prevent their showing up in variable help
	presentations as inscrutable byte-compiled code.
	(allout-numbered-bullet, allout-file-xref-bullet, allout-layout):
	Use string-or-null-p to qualify safe-local-variable values.
	(allout-reindent-bodies): Use memq to qualify matches against
	valid safe-local-variable values.  Also, quote the lambda as above.
	(allout-use-mode-specific-leader): Add missing candidate-value
	symbols, use memq, and quote the lambda.
	(allout-overlay-interior-modification-handler): Remove unused
	variables `msg' and 'opened'.
	(allout-hidden-p): Constrain invisibility consideration to allout's
	invisibility spec, disregarding invisibility for other reasons.

2006-04-17  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Remove local autoload declaration for
	pgg-gpg-symmetric-key-p, since that's now done in pgg-gpg.el.
	(allout-show-bodies, allout-header-prefix, allout-primary-bullet)
	(allout-plain-bullets-string, allout-distinctive-bullets-string)
	(allout-use-mode-specific-leader, allout-old-style-prefixes)
	(allout-stylish-prefixes, allout-numbered-bullet)
	(allout-file-xref-bullet, allout-presentation-padding)
	(allout-use-hanging-indents, allout-reindent-bodies): Mark as
	safe-local-variable with suitable value spec, and add autoload
	cookie for loaddefs inclusion.  We now use an explicit spec everywhere.
	(move-beginning-of-line, move-end-of-line): Repair so these compat
	functions now actually resituate the point, when appropriate.

2006-04-26  Stefan Monnier  <monnier@iro.umontreal.ca>

	* allout.el (allout-layout, allout-passphrase-verifier-string)
	(allout-passphrase-hint-string): Tighten up a bit the safety predicate.

2006-03-14  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Increment version to 2.2.1 in file commentary.

	(allout-version): Increment to 2.2.1.

	(allout-default-layout): New customization variable, used when the
	file lacks a specific allout-layout.  Uses allout-layout-type for
	recursively nested definition.

	(allout-layout-type): Widget defining allout layouts, necessary for
	self-recursive definition.

	(allout-mode): Incorporate allout-default-layout as fallback for
	allout-layout.

	(allout-layout): Mark as 'safe-local-variable', and refer mention
	fallback to `allout-default-layout' in absence of a specified value.
	(allout-passphrase-verifier-string)
	(allout-passphrase-hint-string): Mark as 'safe-local-variable'.

	(allout-file-passphrase-verifier-string): Obsolete variable, removed.

	(allout-get-encryption-passphrase-verifier): Use correct name of
	passphrase verifier in docstring.

2006-03-03  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Restablish intermediate missing comment header to
	preserve outline structure.
	(allout-beginning-of-current-entry): Skip invisible text.
	(allout-open-topic): Fix opening a topic at end-of-buffer.
	(allout-minor-mode): Move nearer to allout-mode function.

2006-02-17  Eli Zaretskii  <eliz@gnu.org>

	* allout.el (allout-hidden-p): Move this defsubst before
	allout-overlay-interior-modification-handler, where it is first
	used.

2006-02-17  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Use allout invisible-text overlays instead of
	selective display for concealed text.  Also, lots of general
	cleanup, and improved compatibility code.

	(allout-version) Incremented, corrected, revised, and refined
	module commentary.

	(provide 'allout): Moved to the bottom, added a require of overlay.

	(allout-encrypt-unencrypted-on-saves): Defaults to t instead of
	`except-current'.
	(allout-write-file-hook-handler): Minimize delay.
	(count-trailing-whitespace-region): New function so
	auto-encryption of current topic can resituate cursor exactly.
	PGP/GPG encryption trims trailing whitespace from lines, which
	must be accounted for across encryption then decryption.

	(allout-command-prefix): Now defaults to "\C-c<space>" rather than
	just plain "\C-c", to avoid intruding on user's keybinding space.

	(allout-toggle-current-subtree-encryption): Pass along fetch-pass
	parameter, so user request to provide a new password is done.

	(allout-outside-normal-auto-fill-function, allout-auto-fill):
	Refined mechanism for auto-filling behavior while in allout mode.

	(allout-mode): Explicitly specify the mode map in the docstring.
	Clarify provision for various write-file hook var names.
	Adjusted for invisible-text overlays instead of	selective-display.

	(allout-depth): Really return 0 if not within any topic.  This
	rectifies `allout-beginning-of-level' and sequence numbering
	errors that occur when cutting and pasting numbered topics.
	Changed from a in-line subst to a regular function, as well.

	(allout-pre-next-prefix): Renamed from allout-pre-next-preface.

	(allout-end-of-subtree, allout-end-of-subtree)
	(allout-end-of-entry, allout-end-of-current-heading)
	(allout-next-visible-heading, allout-open-topic, allout-show-entry)
	(allout-show-children, allout-show-to-offshoot)
	(allout-hide-current-entry, allout-show-current-entry): Rectified
	handling of trailing blank lines between items.

	(allout-line-boundary-regexp, set-allout-regexp, allout-depth)
	(allout-current-depth, allout-unprotected, allout-hidden-p)
	(allout-on-current-heading-p, allout-listify-exposed)
	(allout-chart-subtree, allout-goto-prefix)
	(allout-back-to-current-heading, allout-get-body-text)
	(allout-snug-back, allout-flag-current-subtree, allout-show-all)
	(allout-hide-region-body, allout-toggle-subtree-encryption)
	(allout-encrypt-string, allout-encrypted-key-info)
	(allout-next-topic-pending-encryption, allout-encrypt-decrypted)
	(allout-file-vars-section-data): Adjusted for use with
	invisible-text overlays instead of selective-display.

	(allout-kill-line, allout-kill-topic, allout-yank-processing):
	Reworked for use with invisible text overlays.

	(allout-current-topic-collapsed-p): New function.

	(allout-hide-current-subtree): Use allout-current-topic-collapsed-p
	to know when to close the containing topic.

	(allout-pre-command-business, allout-post-command-business):
	Simplify undo-batching and dynamic isearch exposure.

	(allout-set-overlay-category): New for invisible-text overlays.
	Sets properties of allout-overlay-category, used by
	allout-flag-region to set invisible-text overlay properties.
	(allout-get-invisibility-overlay): Get the first qualifying
	invisibility overlay, so we can find the extent of it.
	(allout-back-to-visible-text): Get to just before the beginnining
	of the current invisibility overlay, if any.

	(allout-overlay-insert-in-front-handler)
	(allout-overlay-interior-modification-handler)
	(allout-before-change-handler, allout-isearch-end-handler): New
	functions to handle extraordinary actions affecting concealed
	text.

	(allout-flag-region): Use overlays instead of selective-display
	for invisible text - by inheritence from the properties of
	allout-overlay-category in mainline Emacs, and applied
	property-by-property in XEmacs, some recent versions of which
	don't inherit the properties from the category.  Provisions to
	respond to concealed-text edits simplified drastically.

	(allout-isearch-rectification, allout-isearch-was-font-lock)
	(allout-isearch-expose, allout-enwrap-isearch)
	(allout-isearch-abort, allout-pre-was-isearching)
	(allout-isearch-prior-pos, allout-isearch-did-quit)
	(allout-isearch-dynamic-expose)
	(allout-hide-current-entry-completely): Functions deleted.

	(allout-undo-aggregation): Explicit undo aggregation no longer
	necessary due to transition away from selective-display.

	(set-allout-regexp, allout-up-current-level)
	(allout-next-visible-heading, allout-forward-current-level)
	(allout-open-topic, allout-reindent-body, allout-rebullet-topic)
	(allout-kill-line, allout-yank-processing, allout-show-children)
	(allout-expose-topic, allout-old-expose-topic)
	(allout-listify-exposed, allout-insert-latex-header)
	(allout-toggle-subtree-encryption, allout-encrypt-string)
	(remove-from-invisibility-spec, allout-hide-current-subtree):
	Ditched unused variables.

2005-12-02  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el (eval-when-compile): Remove unnecessary load of cl.
	Add fset of allout-real-isearch-abort during compile to fix
	byte-compilation warnings.
	(allout-mode-p): Move definition of this macro above all uses, or
	byte compilation in barren emacs (eg, during emacs build) will
	lack the definition.
	(allout-mode): Move this variable above any uses, or byte
	compilation will fail.
	(allout-resolve-xref): Remove use of personal file-reference function.
	(allout-toggle-current-subtree-encryption): Do the current (ie,
	visible containing) topic, rather than nearest around point.  Doc fix.
	(allout-toggle-subtree-encryption): New function, workhorse that
	works on nearest topic containing point.
	(allout-encrypt-string): Signal requirement for newer version of pgg.
	(allout-resumptions): Doc fix.

2005-10-23  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Remove autoloads for mailcrypt and crypt++.
	Require pgg, pgg-gpg during compilation.
	(allout-version): Increment version number to 2.1, and use a literal
	rather than RCS Id.
	(allout-default-encryption-scheme): Remove.
	(allout-passphrase-verifier-handling)
	(allout-passphrase-verifier-string)
	(allout-file-passphrase-verifier-string)
	(allout-passphrase-hint-string): Rename -key- to -passphrase-.
	(allout-passphrase-hint-handling): Rename and simplify.
	(allout-init): Use `find-file-hook' if available, otherwise
	`find-file-hooks'.
	(allout-mode): Use `write-file-functions' if available, otherwise
	`local-write-file-hooks' and, instead of making auto-save-hook
	buffer local, make the write-file-hook activity contingent to
	allout-mode.
	(allout-mode): Use key-binding substitution in the docstring.
	(allout-kill-line): Spell-out kill ring data structure mutation
	instead of using byte-compiler-complaint-provoking `pop'.
	(allout-insert-listified): Use `insert' rather than `insert-string'
	(allout-toggle-current-subtree-encryption): Update docstring, adjust
	to new gpp-based encryption, use new `allout-encrypted-topic-p'.
	(allout-encrypt-string): Totally revamped vis new underlying
	encryption facilities.
	(allout-mc-activate-passwd): Remove.
	(allout-obtain-passphrase): New, more or less replaces
	allout-mc-activate-passwd.
	(allout-encrypted-key-info): More or less replaces
	allout-encrypted-text-type.
	(outlineify-sticky, outlinify-sticky): Add autoload cookie.
	(my-mark-marker): Use `(featurep 'xemacs)'.

2005-10-20  Ken Manheimer  <ken.manheimer@gmail.com>

	* allout.el: Add autoloads of crypt++ and mailcrypt routines, all
	for encryption functionality.
	Move allout customization subgroup from `editing' to `outlines' group.
	Fix commentary keywords to legitimate ones.
	Update author info (using my current email address, obscurified).
	(allout-encrypt-string, allout-encryption-produce-work-buffer)
	(allout-encrypted-topic-p, allout-encrypted-text-type)
	(allout-mc-activate-passwd, allout-create-encryption-key-verifier)
	(allout-situate-encryption-key-verifier)
	(allout-get-encryption-key-verifier, allout-verify-key)
	(allout-next-topic-pending-encryption)
	(allout-encrypt-decrypted, allout-encrypted-type-prefix): New funcs.
	(outline-topic-encryption-bullet, outline-default-encryption-scheme)
	(outline-key-verifier-handling, outline-key-hint-handling)
	(outline-encrypt-unencrypted-on-saves): New defcustoms.
	(allout-file-key-verifier-string, allout-encryption-scheme)
	(allout-key-verifier-string, allout-key-hint-string)
	(allout-after-save-decrypt): New variables.
	(allout-write-file-hook-handler, allout-auto-save-hook-handler)
	(allout-after-saves-handler): New hook functions.
	(allout-post-command-business): Do allout-after-save-decrypt.
	(allout-enable-file-variable-adjustment): Custom var to enable
	mechanism for adding and adjusting settings of Emacs file variables.
	(allout-adjust-file-variable, allout-file-vars-section-data):
	New functions, implement the mechanism.
	(outlineify-sticky): Use the file vars mechanism.
	(allout-inhibit-protection, allout-during-write-cue)
	(allout-override-protect, allout-before-change-protect): Remove.
	(allout-flag-region, allout-open-topic): Adjust	read-only text.
	(allout-open-line-not-read-only): Add to facilitate read-only
	text based protection.
	(allout-kill-line): Revise to adjust read-only text, clue the
	user about the inhibition.
	(allout-unprotected): Use unwind-protect.
	(allout-shift-in, allout-shift-out): Disallow manually shifting a
	topic deeper than the offspring depth of the previous topic -
	avoiding confusing "containment discontinuities".
	(allout-reindent-bodies): Fix retention of body relative hanging
	indent during promotion of collapsed bodies.
	(allout-open-topic): Make it easy to open new topic with same
	bullet as current topic - topic creation functions provided with
	any universal argument provokes now prompt for bullet, defaulting
	to the bullet of the previous topic.
	(allout-plain-bullets-string, allout-distinctive-bullets-string):
	Plain bullet alternates `.' period and `,' comma only.  All other
	bullets are relegated to special status (but customizable).
	(allout-end-of-entry): Rename from allout-end-of-current-entry
	since it actually operates w.r.t. most immediately containing
	entry, visible or not.
	(allout-hide-current-entry, allout-show-current-entry): Use the
	revised version.
	(allout-old-expose-topic): Solidify deprecation.
	(allout-end-of-subtree): Add so we can span concealed as well
	as visible topics.
	(allout-end-of-current-subtree): Use `allout-end-of-subtree'.
	(allout-end-of-current-heading): Tweak to just respect the first line.
	(allout-get-body-text): Add.
	(allout-ascend-to-depth, allout-ascend): Position at end of prefix
	when invoked interactively.
	(allout-up-current-level): Use `interactive-p'.
	(allout-mode, allout-init): Miscellaneous docstring and
	operational refinements, as well as hookups of new encryption stuff.
	(allout-beginning-of-current-entry): Now works as advertised.
	(allout-end-of-current-entry): Remove of superfluous allout-show-entry.
	(allout-isearch-rectification): Refine condition for isearching.
	(allout-isearch-abort, allout-enwrap-isearch)
	(allout-flag-region, my-region-active-p): Relocate some macros.
	(allout-title): Fallback title is (buffer-name), not
	non-existing (current-buffer-name).
	(subst-char-in-string): Define if absent (for some XEmacs versions).

[-- Attachment #3: allout-NEWS.txt --]
[-- Type: text/plain, Size: 2485 bytes --]

** Changes in Allout

*** Topic cryptography added, enabling easy gpg topic encryption and
decryption.  Per-topic basis enables interspersing encrypted-text and
clear-text within a single file to your heart's content, using symmetric
and/or public key modes.  Time-limited key caching, user-provided
symmetric key hinting and consistency verification, auto-encryption of
pending topics on save, and more, make it easy to use encryption in
powerful ways.

*** `allout-view-change-hook' marked as being deprecated - use
`allout-exposure-change-hook' instead.  Both are currently being used, but
`allout-view-change-hook' will be ignored in a subsequent allout version.

*** Default command prefix changed to "\C-c " (control-c space), to avoid
intruding on user's keybinding space.  Customize the
`allout-command-prefix' variable to your preference.

*** Allout now uses text overlay's `invisible' property (and others) for
concealed text, instead of selective-display.  This simplifies the code, in
particular avoiding the need for kludges for isearch dynamic-display,
discretionary handling of edits of concealed text, undo concerns, etc.

*** Many substantial fixes and refinements, including:

   - repaired inhibition of inadvertent edits to concealed text
   - repaired retention of topic body hanging indent upon topic depth shifts
   - refuse to create "containment discontinuities", where a
     topic is shifted deeper than the offspring-depth of its' container
   - auto-fill-mode is now left inactive when allout-mode starts, if it
     already was inactive.  also, `allout-inhibit-auto-fill' custom
     configuration variable makes it easy to disable auto fill in allout
     outlines in general or on a per-buffer basis.
   - new hook `allout-mode-deactivate-hook', for coordinating with
     deactivation of allout-mode.
   - bulleting variation is simpler and more accommodating, both in the
     default behavior and in ability to vary when creating new topics
   - mode deactivation now does cleans up effectively, more properly
     restoring affected variables and hooks to former state, removing
     overlays, etc.
   - included a few unit-tests for interior functionality.  developers can
     have them automatically run after module w/customization option with
     customization variable `allout-run-unit-tests-after-load'.
   - many, many minor tweaks and fixes.  many internal fixes and
     refinements of docstrings.
   - version number incremented to 2.2

[-- Attachment #4: allout-patch.txt --]
[-- Type: text/plain, Size: 35764 bytes --]

--- allout.el	16 May 2006 08:58:36 -0400	1.76
+++ allout.el	08 Jul 2006 00:41:16 -0400	
@@ -8,6 +8,7 @@
 ;; Created: Dec 1991 - first release to usenet
 ;; Version: 2.2.1
 ;; Keywords: outlines wp languages
+;; Website: http://myriadicity.net/Sundry/EmacsAllout
 
 ;; This file is part of GNU Emacs.
 
@@ -58,7 +59,9 @@
 ;; and more.
 ;;
 ;; See the `allout-mode' function's docstring for an introduction to the
-;; mode.  The development version and helpful notes are available at
+;; mode.
+;;
+;; The latest development version and helpful notes are available at
 ;; http://myriadicity.net/Sundry/EmacsAllout .
 ;;
 ;; The outline menubar additions provide quick reference to many of
@@ -80,6 +83,7 @@
 
 ;;;_* Dependency autoloads
 (require 'overlay)
+(require 'cl)                           ; for `assert', in cl-macs.el.
 (eval-when-compile (progn (require 'pgg)
                           (require 'pgg-gpg)
                           (require 'overlay)
@@ -556,6 +560,25 @@
   :group 'allout-encryption)
 (make-variable-buffer-local 'allout-encrypt-unencrypted-on-saves)
 
+;;;_ + Developer
+;;;_  = allout-developer group
+(defgroup allout-developer nil
+  "Settings for topic encryption features of allout outliner."
+  :group 'allout)
+;;;_  = allout-run-unit-tests-after-load
+(defcustom allout-run-unit-tests-after-load nil
+  "*When non-nil, unit tests will be run after allout is loaded.
+
+Generally, allout code developers are the only ones who'll want to set this.
+
+\(If set, this makes it an even better practice to do byte-compilations
+with a repeat count, so the file is loaded immediate after byte
+compilation.)
+
+See `allout-run-unit-tests' to see what's covered."
+  :type 'boolean
+  :group 'allout-developer)
+
 ;;;_ + Miscellaneous customization
 
 ;;;_  = allout-command-prefix
@@ -615,6 +638,22 @@
 	("=t" allout-latexify-exposed)
 	("=p" allout-flatten-exposed-to-buffer)))
 
+;;;_  = allout-inhibit-auto-fill
+(defcustom allout-inhibit-auto-fill nil
+  "*If non-nil, auto-fill will be inhibited in the allout buffers.
+
+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.\)
+
+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
+else allout's special hanging-indent maintaining auto-fill function,
+`allout-auto-fill'."
+  :type 'boolean :group 'allout)
+(make-variable-buffer-local 'allout-inhibit-auto-fill)
+
 ;;;_  = allout-use-hanging-indents
 (defcustom allout-use-hanging-indents t
   "*If non-nil, topic body text auto-indent defaults to indent of the header.
@@ -993,69 +1032,68 @@
 		      "----"
 		      ["Set Header Lead" allout-reset-header-lead t]
 		      ["Set New Exposure" allout-expose-topic t])))
-;;;_  : Mode-Specific Variable Maintenance Utilities
+;;;_  : Allout Modal-Variables Utilities
 ;;;_   = allout-mode-prior-settings
 (defvar allout-mode-prior-settings nil
-  "Internal `allout-mode' use; settings to be resumed on mode deactivation.")
-(make-variable-buffer-local 'allout-mode-prior-settings)
-;;;_   > allout-resumptions (name &optional value)
-(defun allout-resumptions (name &optional value)
-
-  "Registers or resumes settings over `allout-mode' activation/deactivation.
+  "Internal `allout-mode' use; settings to be resumed on mode deactivation.
 
-First arg is NAME of variable affected.  Optional second arg is list
-containing allout-mode-specific VALUE to be imposed on named
-variable, and to be registered.  \(It's a list so you can specify
-registrations of null values.)  If no value is specified, the
-registered value is returned (encapsulated in the list, so the caller
-can distinguish nil vs no value), and the registration is popped
-from the list."
-
-  (let ((on-list (assq name allout-mode-prior-settings))
-        prior-capsule                   ; By `capsule' i mean a list
-                                        ; containing a value, so we can
-                                        ; distinguish nil from no value.
-        )
-
-    (if value
-
-        ;; Registering:
-        (progn
-          (if on-list
-              nil 	; Already preserved prior value - don't mess with it.
-            ;; Register the old value, or nil if previously unbound:
-            (setq allout-mode-prior-settings
-                  (cons (list name
-                              (if (boundp name) (list (symbol-value name))))
-                        allout-mode-prior-settings)))
-                                        ; And impose the new value, locally:
-	  (progn (make-local-variable name)
-		 (set name (car value))))
-
-      ;; Relinquishing:
-      (if (not on-list)
-
-          ;; Oops, not registered - leave it be:
-          nil
-
-        ;; Some registration:
-                                        ; reestablish it:
-        (setq prior-capsule (car (cdr on-list)))
-        (if prior-capsule
-            (set name (car prior-capsule)) ; Some prior value - reestablish it.
-          (makunbound name))		; Previously unbound - demolish var.
-                                        ; Remove registration:
-        (let (rebuild)
-          (while allout-mode-prior-settings
-            (if (not (eq (car allout-mode-prior-settings)
-                         on-list))
-                (setq rebuild
-                      (cons (car allout-mode-prior-settings)
-                            rebuild)))
-            (setq allout-mode-prior-settings
-                  (cdr allout-mode-prior-settings)))
-          (setq allout-mode-prior-settings rebuild)))))
-  )
+See `allout-add-resumptions' and `allout-do-resumptions'.")
+(make-variable-buffer-local 'allout-mode-prior-settings)
+;;;_   > allout-add-resumptions (&rest pairs)
+(defun allout-add-resumptions (&rest pairs)
+  "Set name/value pairs.
+
+Old settings are preserved for later resumption using `allout-do-resumptions'.
+
+The pairs are lists whose car is the name of the variable and car of the
+cdr is the new value:  '(some-var some-value)'.
+
+The new value is set as a buffer local.
+
+If the variable was not previously buffer-local, then that is noted and the
+`allout-do-resumptions' will just `kill-local-variable' of that binding.
+
+If it previously was buffer-local, the old value is noted and resurrected
+by `allout-do-resumptions'.  \(If the local value was previously void, then
+it is left as nil on resumption.\)
+
+The settings are stored on `allout-mode-prior-settings'."
+  (while pairs
+    (let* ((pair (pop pairs))
+           (name (car pair))
+           (value (cadr pair)))
+      (if (not (symbolp name))
+          (error "Pair's name, %S, must be a symbol, not %s"
+                 name (type-of name)))
+      (when (not (assoc name allout-mode-prior-settings))
+        ;; Not already added as a resumption, create the prior setting entry.
+        (if (local-variable-p name)
+            ;; is already local variable - preserve the prior value:
+            (push (list name (condition-case err
+                                 (symbol-value name)
+                               (void-variable nil)))
+                  allout-mode-prior-settings)
+          ;; wasn't local variable, indicate so for resumption by killing
+          ;; local value, and make it local:
+          (push (list name) allout-mode-prior-settings)
+          (make-local-variable name)))
+      (set name value))))
+;;;_   > allout-do-resumptions ()
+(defun allout-do-resumptions ()
+  "Resume all name/value settings registered by `allout-add-resumptions'.
+
+This is used when concluding allout-mode, to resume selected variables to
+their settings before allout-mode was started."
+
+    (while allout-mode-prior-settings
+      (let* ((pair (pop allout-mode-prior-settings))
+             (name (car pair))
+             (value-cell (cdr pair)))
+        (if (not value-cell)
+            ;; Prior value was global:
+            (kill-local-variable name)
+          ;; Prior value was explicit:
+          (set name (car value-cell))))))
 ;;;_  : Mode-specific incidentals
 ;;;_   > allout-unprotected (expr)
 (defmacro allout-unprotected (expr)
@@ -1065,9 +1103,12 @@
 ;;;_   = allout-mode-hook
 (defvar allout-mode-hook nil
   "*Hook that's run when allout mode starts.")
-;;;_   = allout-overlay-category
-(defvar allout-overlay-category nil
-  "Symbol for use in allout invisible-text overlays as the category.")
+;;;_   = allout-mode-deactivate-hook
+(defvar allout-mode-deactivate-hook nil
+  "*Hook that's run when allout mode ends.")
+;;;_   = allout-exposure-category
+(defvar allout-exposure-category nil
+  "Symbol for use as allout invisible-text overlay category.")
 ;;;_   x allout-view-change-hook
 (defvar allout-view-change-hook nil
   "*\(Deprecated\)  Hook that's run after allout outline exposure changes.
@@ -1293,30 +1334,26 @@
       (setq cur (car menus)
 	    menus (cdr menus))
       (easy-menu-add cur))))
-;;;_  > allout-set-overlay-category
-(defun allout-set-overlay-category ()
-  "Set the properties of the allout invisible-text overlay."
-  (setplist 'allout-overlay-category nil)
-  (put 'allout-overlay-category 'invisible 'allout)
-  (put 'allout-overlay-category 'evaporate t)
+;;;_  > allout-overlay-preparations
+(defun allout-overlay-preparations ()
+  "Set the properties of the allout invisible-text overlay and others."
+  (setplist 'allout-exposure-category nil)
+  (put 'allout-exposure-category 'invisible 'allout)
+  (put 'allout-exposure-category 'evaporate t)
   ;; XXX We use isearch-open-invisible *and* isearch-mode-end-hook.  The
   ;; latter would be sufficient, but it seems that a separate behavior -
   ;; the _transient_ opening of invisible text during isearch - is keyed to
   ;; presence of the isearch-open-invisible property - even though this
   ;; property controls the isearch _arrival_ behavior.  This is the case at
   ;; least in emacs 21, 22.0, and xemacs 21.4.
-  (put 'allout-overlay-category 'isearch-open-invisible
+  (put 'allout-exposure-category 'isearch-open-invisible
        'allout-isearch-end-handler)
   (if (featurep 'xemacs)
-      (put 'allout-overlay-category 'start-open t)
-    (put 'allout-overlay-category 'insert-in-front-hooks
+      (put 'allout-exposure-category 'start-open t)
+    (put 'allout-exposure-category 'insert-in-front-hooks
          '(allout-overlay-insert-in-front-handler)))
-  (if (featurep 'xemacs)
-      (progn (make-variable-buffer-local 'before-change-functions)
-             (add-hook 'before-change-functions
-                       'allout-before-change-handler))
-    (put 'allout-overlay-category 'modification-hooks
-         '(allout-overlay-interior-modification-handler))))
+  (put 'allout-exposure-category 'modification-hooks
+       '(allout-overlay-interior-modification-handler)))
 ;;;_  > allout-mode (&optional toggle)
 ;;;_   : Defun:
 ;;;###autoload
@@ -1575,118 +1612,92 @@
 				       ; active state or *de*activation
 				       ; specifically requested:
       (setq allout-explicitly-deactivated t)
-      (if (string-match "^18\." emacs-version)
-				       ; Revoke those keys that remain
-				       ; as we set them:
-	  (let ((curr-loc (current-local-map)))
-	   (mapcar (function
-		    (lambda (cell)
-		      (if (eq (lookup-key curr-loc (car cell))
-			      (car (cdr cell)))
-			  (define-key curr-loc (car cell)
-			    (assq (car cell) allout-prior-bindings)))))
-		   allout-added-bindings)
-	   (allout-resumptions 'allout-added-bindings)
-	   (allout-resumptions 'allout-prior-bindings)))
 
-      (if allout-old-style-prefixes
-	  (progn
-	   (allout-resumptions 'allout-primary-bullet)
-	   (allout-resumptions 'allout-old-style-prefixes)))
-      ;;(allout-resumptions 'selective-display)
+      (allout-do-resumptions)
+
       (remove-from-invisibility-spec '(allout . t))
-      (set write-file-hook-var-name
-	   (delq 'allout-write-file-hook-handler
-                 (symbol-value write-file-hook-var-name)))
-      (setq auto-save-hook
-	   (delq 'allout-auto-save-hook-handler
-		 auto-save-hook))
-      (allout-resumptions 'paragraph-start)
-      (allout-resumptions 'paragraph-separate)
-      (allout-resumptions 'auto-fill-function)
-      (allout-resumptions 'normal-auto-fill-function)
-      (allout-resumptions 'allout-former-auto-filler)
+      (remove-hook 'pre-command-hook 'allout-pre-command-business t)
+      (remove-hook 'post-command-hook 'allout-post-command-business t)
+      (when (featurep 'xemacs)
+        (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-overlays (point-min) (point-max)
+                       'category 'allout-exposure-category)
+
+      (run-hooks 'allout-mode-deactivate-hook)
       (setq allout-mode nil))
 
      ;; Activation:
      ((not active)
       (setq allout-explicitly-deactivated nil)
       (if allout-old-style-prefixes
-	  (progn			; Inhibit all the fancy formatting:
-	   (allout-resumptions 'allout-primary-bullet '("*"))
-	   (allout-resumptions 'allout-old-style-prefixes '(()))))
+          ;; Inhibit all the fancy formatting:
+          (allout-add-resumptions '((allout-primary-bullet "*")
+                                    (allout-old-style-prefixes ()))))
 
-      (allout-set-overlay-category)     ; Doesn't hurt to redo this.
+      (allout-overlay-preparations)     ; Doesn't hurt to redo this.
 
       (allout-infer-header-lead)
       (allout-infer-body-reindent)
 
       (set-allout-regexp)
 
-				       ; Produce map from current version
-				       ; of allout-keybindings-list:
-      (if (boundp 'minor-mode-map-alist)
-
-	  (progn			; V19, and maybe lucid and
-				       ; epoch, minor-mode key bindings:
-	   (setq allout-mode-map
-		 (produce-allout-mode-map allout-keybindings-list))
-           (substitute-key-definition 'beginning-of-line
-                                      'move-beginning-of-line
-                                      allout-mode-map global-map)
-           (substitute-key-definition 'end-of-line
-                                      'move-end-of-line
-                                      allout-mode-map global-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)
-			    minor-mode-map-alist))
-	       (setq minor-mode-map-alist
-		     (cons '(allout-mode . allout-mode-map)
-			   minor-mode-map-alist))))
-
-				       ; V18 minor-mode key bindings:
-				       ; Stash record of added bindings
-				       ; for later revocation:
-	(allout-resumptions 'allout-added-bindings
-			    (list allout-keybindings-list))
-	(allout-resumptions 'allout-prior-bindings
-			    (list (current-local-map)))
-				       ; and add them:
-	(use-local-map (produce-allout-mode-map allout-keybindings-list
-						(current-local-map)))
-	)
+      ;; 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
+                                 'move-beginning-of-line
+                                 allout-mode-map global-map)
+      (substitute-key-definition 'end-of-line
+                                 'move-end-of-line
+                                 allout-mode-map global-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)
+                       minor-mode-map-alist))
+          (setq minor-mode-map-alist
+                (cons '(allout-mode . allout-mode-map)
+                      minor-mode-map-alist)))
 
       (add-to-invisibility-spec '(allout . t))
-      (make-local-variable 'line-move-ignore-invisible)
-      (setq line-move-ignore-invisible t)
-      (add-hook 'pre-command-hook 'allout-pre-command-business)
-      (add-hook 'post-command-hook 'allout-post-command-business)
-      (add-hook 'isearch-mode-end-hook 'allout-isearch-end-handler)
-      (add-hook write-file-hook-var-name 'allout-write-file-hook-handler)
-      (add-hook 'auto-save-hook 'allout-auto-save-hook-handler)
-				       ; Custom auto-fill func, to support
-				       ; respect for topic headline,
-				       ; hanging-indents, etc:
-      ;; Register prevailing fill func for use by allout-auto-fill:
-      (allout-resumptions 'allout-former-auto-filler (list auto-fill-function))
-      ;; Register allout-auto-fill to be used if filling is active:
-      (allout-resumptions 'auto-fill-function '(allout-auto-fill))
-      (allout-resumptions 'allout-outside-normal-auto-fill-function
-                          (list normal-auto-fill-function))
-      (allout-resumptions 'normal-auto-fill-function '(allout-auto-fill))
-      ;; Paragraphs are broken by topic headlines.
-      (make-local-variable 'paragraph-start)
-      (allout-resumptions 'paragraph-start
-			  (list (concat paragraph-start "\\|^\\("
-					allout-regexp "\\)")))
-      (make-local-variable 'paragraph-separate)
-      (allout-resumptions 'paragraph-separate
-			  (list (concat paragraph-separate "\\|^\\("
-					allout-regexp "\\)")))
-
+      (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)
+      (when (featurep 'xemacs)
+        (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
+                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
+      ;; custom func respects topic headline, maintains hanging-indents,
+      ;; etc.)
+      (if (and auto-fill-function (not allout-inhibit-auto-fill))
+          ;; allout-auto-fill will use the stashed values and so forth.
+          (allout-add-resumptions '(auto-fill-function allout-auto-fill)))
+      (allout-add-resumptions (list 'allout-former-auto-filler
+                                    auto-fill-function)
+                              ;; Register allout-auto-fill to be used if
+                              ;; filling is active:
+                              (list 'allout-outside-normal-auto-fill-function
+                                    normal-auto-fill-function)
+                              '(normal-auto-fill-function allout-auto-fill)
+                              ;; Paragraphs are broken by topic headlines.
+                              (list 'paragraph-start
+                                    (concat paragraph-start "\\|^\\("
+                                            allout-regexp "\\)"))
+                              (list 'paragraph-separate
+                                    (concat paragraph-separate "\\|^\\("
+                                            allout-regexp "\\)")))
       (or (assq 'allout-mode minor-mode-alist)
 	  (setq minor-mode-alist
 	       (cons '(allout-mode " Allout") minor-mode-alist)))
@@ -1702,8 +1713,9 @@
      ;; Reactivation:
      ((setq do-layout t)
       (allout-infer-body-reindent))
-     )					; cond
+     ) ;; end of activation-mode cases.
 
+    ;; Do auto layout if warranted:
     (let ((use-layout (if (listp allout-layout)
                           allout-layout
                         allout-default-layout)))
@@ -1802,9 +1814,14 @@
 
 This before-change handler is used only where modification-hooks
 overlay property is not supported."
-  (if (not (allout-mode-p))
-      nil
-    (allout-overlay-interior-modification-handler nil nil beg end nil)))
+  ;; allout-overlay-interior-modification-handler on an overlay handles
+  ;; this in other emacs, via `allout-exposure-category's 'modification-hooks.
+  (when (and (featurep 'xemacs) (allout-mode-p))
+    ;; process all of the pending overlays:
+    (dolist (overlay (overlays-in beg end))
+      (if (eq (overlay-get ol 'invisible) 'allout)
+          (allout-overlay-interior-modification-handler
+             overlay nil beg end nil)))))
 ;;;_  > allout-isearch-end-handler (&optional overlay)
 (defun allout-isearch-end-handler (&optional overlay)
   "Reconcile allout outline exposure on arriving in hidden text after isearch.
@@ -2018,12 +2035,12 @@
     (if (allout-hidden-p) (forward-char 1))))
 ;;;_   > allout-next-heading ()
 (defsubst allout-next-heading ()
-  "Move to the heading for the topic \(possibly invisible) before 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."
 
-  (if (and (bobp) (not (eobp)))
-       (forward-char 1))
+  (if (and (bobp) (not (eobp)) (looking-at allout-regexp))
+      (forward-char 1))
 
   (if (re-search-forward allout-line-boundary-regexp nil 0)
       (allout-prefix-data		; Got valid location state - set vars:
@@ -2688,36 +2705,52 @@
 
   (if (not (allout-mode-p))
       nil
-    ;; Hot-spot navigation provisions:
     (if (and (eq this-command 'self-insert-command)
 	     (eq (point)(allout-current-bullet-pos)))
-	(let* ((this-key-num (cond
-			      ((numberp last-command-char)
-			       last-command-char)
-			      ;; Only xemacs has characterp.
-			      ((and (fboundp 'characterp)
-				    (apply 'characterp
-                                           (list last-command-char)))
-			       (apply 'char-to-int (list last-command-char)))
-			      (t 0)))
-	       mapped-binding)
-	  (if (zerop this-key-num)
-	      nil
-					; Map upper-register literals
-					; to lower register:
-	    (if (<= 96 this-key-num)
-		(setq this-key-num (- this-key-num 32)))
-					; Check if we have a literal:
-	    (if (and (<= 64 this-key-num)
-		     (>= 96 this-key-num))
-		(setq mapped-binding
-		      (lookup-key 'allout-mode-map
-				  (concat allout-command-prefix
-					  (char-to-string (- this-key-num
-							     64))))))
-	    (if mapped-binding
-		(setq allout-post-goto-bullet t
-		      this-command mapped-binding)))))))
+        (allout-hotspot-key-handler))))
+;;;_   > allout-hotspot-key-handler ()
+(defun allout-hotspot-key-handler ()
+  "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.
+
+Returns the qualifying command, if any, else nil."
+  (interactive)
+  (let* ((key-num (cond ((numberp last-command-char) last-command-char)
+                        ;; for XEmacs character type:
+                        ((and (fboundp 'characterp)
+                              (apply 'characterp (list last-command-char)))
+                         (apply 'char-to-int (list last-command-char)))
+                        (t 0)))
+         mapped-binding
+         (on-bullet (eq (point) (allout-current-bullet-pos))))
+
+    (if (zerop key-num)
+        nil
+
+      (if (and (<= 33 key-num)
+               (setq mapped-binding
+                     (key-binding (concat allout-command-prefix
+                                          (char-to-string
+                                           (if (and (<= 97 key-num) ; "a"
+                                                    (>= 122 key-num)) ; "z"
+                                               (- key-num 96) key-num)))
+                                  t)))
+          ;; Qualified with the allout prefix - do hot-spot operation.
+          (setq allout-post-goto-bullet t)
+        ;; accept-defaults nil, or else we'll get allout-item-icon-key-handler.
+        (setq mapped-binding (key-binding (char-to-string key-num))))
+
+      (while (keymapp mapped-binding)
+        (setq mapped-binding
+              (lookup-key mapped-binding (read-key-sequence-vector nil t))))
+
+      (if mapped-binding
+          (setq allout-post-goto-bullet on-bullet
+                this-command mapped-binding)))))
+
 ;;;_   > allout-find-file-hook ()
 (defun allout-find-file-hook ()
   "Activate `allout-mode' on non-nil `allout-auto-activation', `allout-layout'.
@@ -3146,21 +3179,23 @@
 
 Maintains outline hanging topic indentation if
 `allout-use-hanging-indents' is set."
-  (let ((fill-prefix (if allout-use-hanging-indents
-                         ;; Check for topic header indentation:
-                         (save-excursion
-                           (beginning-of-line)
-                           (if (looking-at allout-regexp)
-                               ;; ... construct indentation to account for
-                               ;; length of topic prefix:
-                               (make-string (progn (allout-end-of-prefix)
-                                                   (current-column))
-                                            ?\ )))))
-        (use-auto-fill-function (or allout-outside-normal-auto-fill-function
-                                    auto-fill-function
-                                    'do-auto-fill)))
-    (if (or allout-former-auto-filler allout-use-hanging-indents)
-        (funcall use-auto-fill-function))))
+
+  (when (not allout-inhibit-auto-fill)
+    (let ((fill-prefix (if allout-use-hanging-indents
+                           ;; Check for topic header indentation:
+                           (save-excursion
+                             (beginning-of-line)
+                             (if (looking-at allout-regexp)
+                                 ;; ... construct indentation to account for
+                                 ;; length of topic prefix:
+                                 (make-string (progn (allout-end-of-prefix)
+                                                     (current-column))
+                                              ?\ )))))
+          (use-auto-fill-function (or allout-outside-normal-auto-fill-function
+                                      auto-fill-function
+                                      'do-auto-fill)))
+      (if (or allout-former-auto-filler allout-use-hanging-indents)
+          (funcall use-auto-fill-function)))))
 ;;;_    > allout-reindent-body (old-depth new-depth &optional number)
 (defun allout-reindent-body (old-depth new-depth &optional number)
   "Reindent body lines which were indented at OLD-DEPTH to NEW-DEPTH.
@@ -3601,8 +3636,10 @@
 	    (forward-char 1)))
 
     (if collapsed
-        (put-text-property beg (1+ beg) 'allout-was-collapsed t)
-      (remove-text-properties beg (1+ beg) '(allout-was-collapsed t)))
+        (allout-unprotected
+         (put-text-property beg (1+ beg) 'allout-was-collapsed t))
+      (allout-unprotected
+       (remove-text-properties beg (1+ beg) '(allout-was-collapsed t))))
     (allout-unprotected (kill-region beg (point)))
     (sit-for 0)
     (save-excursion
@@ -3834,12 +3871,12 @@
 
 Text is shown if flag is nil and hidden otherwise."
   ;; We use outline invisibility spec.
-  (remove-overlays from to 'category 'allout-overlay-category)
+  (remove-overlays from to 'category 'allout-exposure-category)
   (when flag
     (let ((o (make-overlay from to)))
-      (overlay-put o 'category 'allout-overlay-category)
+      (overlay-put o 'category 'allout-exposure-category)
       (when (featurep 'xemacs)
-        (let ((props (symbol-plist 'allout-overlay-category)))
+        (let ((props (symbol-plist 'allout-exposure-category)))
           (while props
             (overlay-put o (pop props) (pop props)))))))
   (run-hooks 'allout-view-change-hook)
@@ -3860,9 +3897,9 @@
                         flag)))
 
 ;;;_  - Topic-specific
-;;;_   > allout-show-entry (&optional inclusive)
-(defun allout-show-entry (&optional inclusive)
-  "Like `allout-show-current-entry', reveals entries nested in hidden topics.
+;;;_   > allout-show-entry ()
+(defun allout-show-entry ()
+  "Like `allout-show-current-entry', but reveals entries in hidden topics.
 
 This is a way to give restricted peek at a concealed locality without the
 expense of exposing its context, but can leave the outline with aberrant
@@ -3977,7 +4014,6 @@
                         t)))
 ;;;_   > allout-show-current-entry (&optional arg)
 (defun allout-show-current-entry (&optional arg)
-
   "Show body following current heading, or hide entry with universal argument."
 
   (interactive "P")
@@ -5919,7 +5955,132 @@
     (isearch-repeat 'forward)
     (isearch-mode t)))
 
-;;;_ #11 Provide
+;;;_ #11 Unit tests
+;;;_  % Run unit tests after load, when `allout-run-unit-tests-after-load':
+(eval-after-load 'allout
+  '(if allout-run-unit-tests-after-load
+     (allout-run-unit-tests)))
+;;;_  > allout-run-unit-tests ()
+(defun allout-run-unit-tests ()
+  "Run the various allout unit tests."
+  (message "Running allout tests...")
+  (allout-test-resumptions)
+  (message "Running allout tests...  Done.")
+  (sit-for .5))
+;;;_  : test resumptions:
+;;;_   > allout-tests-obliterate-variable (name)
+(defun allout-tests-obliterate-variable (name)
+  "Completely unbind variable with NAME."
+  (if (local-variable-p name) (kill-local-variable name))
+  (while (boundp name) (makunbound name)))
+;;;_   > allout-test-resumptions ()
+(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.")
+(defvar allout-tests-locally-true nil
+  "Fodder for allout resumptions tests - defvar just for byte compiler.")
+(defun allout-test-resumptions ()
+  "Exercise allout resumptions."
+  ;; for each resumption case, we also test that the right local/global
+  ;; scopes are affected during resumption effects:
+
+  ;; ensure that previously unbound variables return to the unbound state.
+  (with-temp-buffer
+    (allout-tests-obliterate-variable 'allout-tests-globally-unbound)
+    (allout-add-resumptions '(allout-tests-globally-unbound t))
+    (assert (not (default-boundp 'allout-tests-globally-unbound)))
+    (assert (local-variable-p 'allout-tests-globally-unbound))
+    (assert (boundp 'allout-tests-globally-unbound))
+    (assert (equal allout-tests-globally-unbound t))
+    (allout-do-resumptions)
+    (assert (not (local-variable-p 'allout-tests-globally-unbound)))
+    (assert (not (boundp 'allout-tests-globally-unbound))))
+
+  ;; ensure that variable with prior global value is resumed
+  (with-temp-buffer
+    (allout-tests-obliterate-variable 'allout-tests-globally-true)
+    (setq allout-tests-globally-true t)
+    (allout-add-resumptions '(allout-tests-globally-true nil))
+    (assert (equal (default-value 'allout-tests-globally-true) t))
+    (assert (local-variable-p 'allout-tests-globally-true))
+    (assert (equal allout-tests-globally-true nil))
+    (allout-do-resumptions)
+    (assert (not (local-variable-p 'allout-tests-globally-true)))
+    (assert (boundp 'allout-tests-globally-true))
+    (assert (equal allout-tests-globally-true t)))
+
+  ;; ensure that prior local value is resumed
+  (with-temp-buffer
+    (allout-tests-obliterate-variable 'allout-tests-locally-true)
+    (set (make-local-variable 'allout-tests-locally-true) t)
+    (assert (not (default-boundp 'allout-tests-locally-true))
+            nil (concat "Test setup mistake - variable supposed to"
+                        " not have global binding, but it does."))
+    (assert (local-variable-p 'allout-tests-locally-true)
+            nil (concat "Test setup mistake - variable supposed to have"
+                        " local binding, but it lacks one."))
+    (allout-add-resumptions '(allout-tests-locally-true nil))
+    (assert (not (default-boundp 'allout-tests-locally-true)))
+    (assert (local-variable-p 'allout-tests-locally-true))
+    (assert (equal allout-tests-locally-true nil))
+    (allout-do-resumptions)
+    (assert (boundp 'allout-tests-locally-true))
+    (assert (local-variable-p 'allout-tests-locally-true))
+    (assert (equal allout-tests-locally-true t))
+    (assert (not (default-boundp 'allout-tests-locally-true))))
+
+  ;; ensure that last of multiple resumptions holds, for various scopes.
+  (with-temp-buffer
+    (allout-tests-obliterate-variable 'allout-tests-globally-unbound)
+    (allout-tests-obliterate-variable 'allout-tests-globally-true)
+    (setq allout-tests-globally-true t)
+    (allout-tests-obliterate-variable 'allout-tests-locally-true)
+    (set (make-local-variable 'allout-tests-locally-true) t)
+    (allout-add-resumptions '(allout-tests-globally-unbound t)
+                            '(allout-tests-globally-true nil)
+                            '(allout-tests-locally-true nil))
+    (allout-add-resumptions '(allout-tests-globally-unbound 2)
+                            '(allout-tests-globally-true 3)
+                            '(allout-tests-locally-true 4))
+    ;; reestablish many of the basic conditions are maintained after re-add:
+    (assert (not (default-boundp 'allout-tests-globally-unbound)))
+    (assert (local-variable-p 'allout-tests-globally-unbound))
+    (assert (equal allout-tests-globally-unbound 2))
+    (assert (default-boundp 'allout-tests-globally-true))
+    (assert (local-variable-p 'allout-tests-globally-true))
+    (assert (equal allout-tests-globally-true 3))
+    (assert (not (default-boundp 'allout-tests-locally-true)))
+    (assert (local-variable-p 'allout-tests-locally-true))
+    (assert (equal allout-tests-locally-true 4))
+    (allout-do-resumptions)
+    (assert (not (local-variable-p 'allout-tests-globally-unbound)))
+    (assert (not (boundp 'allout-tests-globally-unbound)))
+    (assert (not (local-variable-p 'allout-tests-globally-true)))
+    (assert (boundp 'allout-tests-globally-true))
+    (assert (equal allout-tests-globally-true t))
+    (assert (boundp 'allout-tests-locally-true))
+    (assert (local-variable-p 'allout-tests-locally-true))
+    (assert (equal allout-tests-locally-true t))
+    (assert (not (default-boundp 'allout-tests-locally-true))))
+
+  ;; ensure that deliberately unbinding registered variables doesn't foul things
+  (with-temp-buffer
+    (allout-tests-obliterate-variable 'allout-tests-globally-unbound)
+    (allout-tests-obliterate-variable 'allout-tests-globally-true)
+    (setq allout-tests-globally-true t)
+    (allout-tests-obliterate-variable 'allout-tests-locally-true)
+    (set (make-local-variable 'allout-tests-locally-true) t)
+    (allout-add-resumptions '(allout-tests-globally-unbound t)
+                            '(allout-tests-globally-true nil)
+                            '(allout-tests-locally-true nil))
+    (allout-tests-obliterate-variable 'allout-tests-globally-unbound)
+    (allout-tests-obliterate-variable 'allout-tests-globally-true)
+    (allout-tests-obliterate-variable 'allout-tests-locally-true)
+    (allout-do-resumptions))
+  )
+
+;;;_ #12 Provide
 (provide 'allout)
 
 ;;;_* Local emacs vars.

[-- Attachment #5: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-10 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-08 15:48 allout-mode fixes - mode-specific settings, auto-fill, deactivation hook Ken Manheimer
2006-07-08 16:31 ` Ken Manheimer
2006-07-08 16:56   ` Ken Manheimer
     [not found]     ` <E1Fza1b-0003Mj-4t@fencepost.gnu.org>
     [not found]       ` <2cd46e7f0607090741k42e10e6ax733c27953e8318d1@mail.gmail.com>
     [not found]         ` <E1FzqAb-00058K-SA@fencepost.gnu.org>
2006-07-10 16:07           ` Ken Manheimer

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.