diff options
| author | Ken Manheimer | 2011-02-09 19:31:18 -0500 |
|---|---|---|
| committer | Ken Manheimer | 2011-02-09 19:31:18 -0500 |
| commit | 11c46e150707cc87b7733b57f34bc83e4227d31c (patch) | |
| tree | 02ee0bb711cbad0efe579bcea036fcd3290948e7 /lisp | |
| parent | af4e5f4c5f03cf546e69e33a7103f73381f7c9ea (diff) | |
| download | emacs-11c46e150707cc87b7733b57f34bc83e4227d31c.tar.gz emacs-11c46e150707cc87b7733b57f34bc83e4227d31c.zip | |
Synopsis: Change allout user configuration so auto-activation is controlled
solely by customization `allout-auto-activation'.
(allout-auto-activation-helper) (allout-setup): New autoloads implement new
custom set procedure for allout-auto-activation. Also, explicitly invoke
(allout-setup) after allout-auto-activation is custom-defined, to effect
the settings in emacs sessions besides the few where allout-auto-activation
customization is donea.
(allout-auto-activation): Use allout-auto-activation-helper to :set.
Revise the docstring.
(allout-init): Reduce functionality to just customizing
allout-auto-activation, and mark obsolete.
(allout-mode): Respect string values for allout-auto-activation. Run
allout-after-copy-or-kill-hook without any args.
(allout-mode) (allout-layout) (allout-default-layout) (outlineify-sticky):
Adjust docstring for new scheme.
(allout-after-copy-or-kill-hook): No arguments - hook implementers should
concentrate on the kill ring.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/allout.el | 202 |
1 files changed, 77 insertions, 125 deletions
diff --git a/lisp/allout.el b/lisp/allout.el index 49c2dba322a..5d87415a57f 100644 --- a/lisp/allout.el +++ b/lisp/allout.el | |||
| @@ -62,18 +62,15 @@ | |||
| 62 | ;; The latest development version and helpful notes are available at | 62 | ;; The latest development version and helpful notes are available at |
| 63 | ;; http://myriadicity.net/Sundry/EmacsAllout . | 63 | ;; http://myriadicity.net/Sundry/EmacsAllout . |
| 64 | ;; | 64 | ;; |
| 65 | ;; The outline menubar additions provide quick reference to many of | 65 | ;; The outline menubar additions provide quick reference to many of the |
| 66 | ;; the features, and see the docstring of the variable `allout-init' | 66 | ;; features. See the docstring of the variables `allout-layout' and |
| 67 | ;; for instructions on priming your Emacs session for automatic | ||
| 68 | ;; activation of allout-mode. | ||
| 69 | ;; | ||
| 70 | ;; See the docstring of the variables `allout-layout' and | ||
| 71 | ;; `allout-auto-activation' for details on automatic activation of | 67 | ;; `allout-auto-activation' for details on automatic activation of |
| 72 | ;; `allout-mode' as a minor mode. (It has changed since allout | 68 | ;; `allout-mode' as a minor mode. (`allout-init' is deprecated in favor of |
| 73 | ;; 3.x, for those of you that depend on the old method.) | 69 | ;; a purely customization-based method.) |
| 74 | ;; | 70 | ;; |
| 75 | ;; Note -- the lines beginning with `;;;_' are outline topic headers. | 71 | ;; Note -- the lines beginning with `;;;_' are outline topic headers. |
| 76 | ;; Just `ESC-x eval-buffer' to give it a whirl. | 72 | ;; Customize `allout-auto-activation' to enable, then revisit this |
| 73 | ;; buffer to give it a whirl. | ||
| 77 | 74 | ||
| 78 | ;; ken manheimer (ken dot manheimer at gmail dot com) | 75 | ;; ken manheimer (ken dot manheimer at gmail dot com) |
| 79 | 76 | ||
| @@ -271,35 +268,56 @@ See the existing keys for examples." | |||
| 271 | :set 'allout-compose-and-institute-keymap | 268 | :set 'allout-compose-and-institute-keymap |
| 272 | ) | 269 | ) |
| 273 | 270 | ||
| 271 | ;;;_ > allout-auto-activation-helper (var value) | ||
| 272 | ;;;###autoload | ||
| 273 | (defun allout-auto-activation-helper (var value) | ||
| 274 | "Institute `allout-auto-activation'. | ||
| 275 | |||
| 276 | Intended to be used as the `allout-auto-activation' :set function." | ||
| 277 | (set-default var value) | ||
| 278 | (allout-setup)) | ||
| 279 | ;;;_ > allout-setup () | ||
| 280 | ;;;###autoload | ||
| 281 | (defun allout-setup () | ||
| 282 | "Do fundamental emacs session for allout auto-activation. | ||
| 283 | |||
| 284 | Establishes allout processing as part of visiting a file if | ||
| 285 | `allout-auto-activation' is non-nil, or removes it otherwise. | ||
| 286 | |||
| 287 | The proper way to use this is through customizing the setting of | ||
| 288 | `allout-auto-activation'." | ||
| 289 | (if (not allout-auto-activation) | ||
| 290 | (remove-hook 'find-file-hook 'allout-find-file-hook) | ||
| 291 | (add-hook 'find-file-hook 'allout-find-file-hook))) | ||
| 274 | ;;;_ = allout-auto-activation | 292 | ;;;_ = allout-auto-activation |
| 293 | ;;;###autoload | ||
| 275 | (defcustom allout-auto-activation nil | 294 | (defcustom allout-auto-activation nil |
| 276 | "Regulates auto-activation modality of allout outlines -- see `allout-init'. | 295 | "Configure allout outline mode auto-activation. |
| 277 | 296 | ||
| 278 | Setq-default by `allout-init' to regulate whether or not allout | 297 | Control whether and how allout outline mode is automatically |
| 279 | outline mode is automatically activated when the buffer-specific | 298 | activated when files are visited with non-nil buffer-specific |
| 280 | variable `allout-layout' is non-nil, and whether or not the layout | 299 | file variable `allout-layout'. |
| 281 | dictated by `allout-layout' should be imposed on mode activation. | ||
| 282 | 300 | ||
| 283 | With value t, auto-mode-activation and auto-layout are enabled. | 301 | When allout-auto-activation is \"On\" \(t), allout mode is |
| 284 | \(This also depends on `allout-find-file-hook' being installed in | 302 | activated in buffers with non-nil `allout-layout', and the |
| 285 | `find-file-hook', which is also done by `allout-init'.) | 303 | specified layout is applied. |
| 286 | 304 | ||
| 287 | With value `ask', auto-mode-activation is enabled, and endorsement for | 305 | With value \"ask\", auto-mode-activation is enabled, and endorsement for |
| 288 | performing auto-layout is asked of the user each time. | 306 | performing auto-layout is asked of the user each time. |
| 289 | 307 | ||
| 290 | With value `activate', only auto-mode-activation is enabled, | 308 | With value \"activate\", only auto-mode-activation is enabled. |
| 291 | auto-layout is not. | 309 | Auto-layout is not. |
| 292 | 310 | ||
| 293 | With value nil, neither auto-mode-activation nor auto-layout are | 311 | With value nil, neither auto-mode-activation nor auto-layout are |
| 294 | enabled. | 312 | enabled, and allout auto-activation processing is removed from |
| 295 | 313 | file visiting activities." | |
| 296 | See the docstring for `allout-init' for the proper interface to | 314 | :set 'allout-auto-activation-helper |
| 297 | this variable." | ||
| 298 | :type '(choice (const :tag "On" t) | 315 | :type '(choice (const :tag "On" t) |
| 299 | (const :tag "Ask about layout" "ask") | 316 | (const :tag "Ask about layout" "ask") |
| 300 | (const :tag "Mode only" "activate") | 317 | (const :tag "Mode only" "activate") |
| 301 | (const :tag "Off" nil)) | 318 | (const :tag "Off" nil)) |
| 302 | :group 'allout) | 319 | :group 'allout) |
| 320 | (allout-setup) | ||
| 303 | ;;;_ = allout-default-layout | 321 | ;;;_ = allout-default-layout |
| 304 | (defcustom allout-default-layout '(-2 : 0) | 322 | (defcustom allout-default-layout '(-2 : 0) |
| 305 | "Default allout outline layout specification. | 323 | "Default allout outline layout specification. |
| @@ -311,7 +329,7 @@ layout specifications. | |||
| 311 | A list value specifies a default layout for the current buffer, | 329 | A list value specifies a default layout for the current buffer, |
| 312 | to be applied upon activation of `allout-mode'. Any non-nil | 330 | to be applied upon activation of `allout-mode'. Any non-nil |
| 313 | value will automatically trigger `allout-mode', provided | 331 | value will automatically trigger `allout-mode', provided |
| 314 | `allout-init' has been called to enable this behavior. | 332 | `allout-auto-activation' has been customized to enable it. |
| 315 | 333 | ||
| 316 | The types of elements in the layout specification are: | 334 | The types of elements in the layout specification are: |
| 317 | 335 | ||
| @@ -890,10 +908,10 @@ For details, see `allout-toggle-current-subtree-encryption's docstring." | |||
| 890 | (defvar allout-layout nil ; LEAVE GLOBAL VALUE NIL -- see docstring. | 908 | (defvar allout-layout nil ; LEAVE GLOBAL VALUE NIL -- see docstring. |
| 891 | "Buffer-specific setting for allout layout. | 909 | "Buffer-specific setting for allout layout. |
| 892 | 910 | ||
| 893 | In buffers where this is non-nil (and if `allout-init' has been run, to | 911 | In buffers where this is non-nil \(and if `allout-auto-activation' |
| 894 | enable this behavior), `allout-mode' will be automatically activated. The | 912 | has been customized to enable this behavior), `allout-mode' will be |
| 895 | layout dictated by the value will be used to set the initial exposure when | 913 | automatically activated. The layout dictated by the value will be used to |
| 896 | `allout-mode' is activated. | 914 | set the initial exposure when `allout-mode' is activated. |
| 897 | 915 | ||
| 898 | \*You should not setq-default this variable non-nil unless you want every | 916 | \*You should not setq-default this variable non-nil unless you want every |
| 899 | visited file to be treated as an allout file.* | 917 | visited file to be treated as an allout file.* |
| @@ -906,9 +924,9 @@ example, the following lines at the bottom of an Emacs Lisp file: | |||
| 906 | ;;;End: | 924 | ;;;End: |
| 907 | 925 | ||
| 908 | dictate activation of `allout-mode' mode when the file is visited | 926 | dictate activation of `allout-mode' mode when the file is visited |
| 909 | \(presuming allout-init was already run), followed by the | 927 | \(presuming proper `allout-auto-activation' customization), |
| 910 | equivalent of `(allout-expose-topic 0 : -1 -1 0)'. (This is | 928 | followed by the equivalent of `(allout-expose-topic 0 : -1 -1 0)'. |
| 911 | the layout used for the allout.el source file.) | 929 | \(This is the layout used for the allout.el source file.) |
| 912 | 930 | ||
| 913 | `allout-default-layout' describes the specification format. | 931 | `allout-default-layout' describes the specification format. |
| 914 | `allout-layout' can additionally have the value `t', in which | 932 | `allout-layout' can additionally have the value `t', in which |
| @@ -1441,9 +1459,7 @@ This hook might be invoked multiple times by a single command.") | |||
| 1441 | (defvar allout-after-copy-or-kill-hook nil | 1459 | (defvar allout-after-copy-or-kill-hook nil |
| 1442 | "*Hook that's run after copying outline text. | 1460 | "*Hook that's run after copying outline text. |
| 1443 | 1461 | ||
| 1444 | Functions on the hook should take two arguments: | 1462 | Functions on the hook should not take any arguments.") |
| 1445 | |||
| 1446 | START, END -- integers indicating the span containing the copied text.") | ||
| 1447 | ;;;_ = allout-outside-normal-auto-fill-function | 1463 | ;;;_ = allout-outside-normal-auto-fill-function |
| 1448 | (defvar allout-outside-normal-auto-fill-function nil | 1464 | (defvar allout-outside-normal-auto-fill-function nil |
| 1449 | "Value of normal-auto-fill-function outside of allout mode. | 1465 | "Value of normal-auto-fill-function outside of allout mode. |
| @@ -1621,84 +1637,19 @@ non-nil in a lasting way.") | |||
| 1621 | "If t, `allout-mode's last deactivation was deliberate. | 1637 | "If t, `allout-mode's last deactivation was deliberate. |
| 1622 | So `allout-post-command-business' should not reactivate it...") | 1638 | So `allout-post-command-business' should not reactivate it...") |
| 1623 | (make-variable-buffer-local 'allout-explicitly-deactivated) | 1639 | (make-variable-buffer-local 'allout-explicitly-deactivated) |
| 1624 | ;;;_ > allout-init (&optional mode) | 1640 | ;;;_ > allout-init (mode) |
| 1625 | (defun allout-init (&optional mode) | 1641 | (defun allout-init (mode) |
| 1626 | "Prime `allout-mode' to enable/disable auto-activation, wrt `allout-layout'. | 1642 | "DEPRECATED - configure allout activation by customizing |
| 1627 | 1643 | `allout-auto-activation'. This function remains around, limited | |
| 1628 | MODE is one of the following symbols: | 1644 | from what it did before, for backwards compatability. |
| 1629 | 1645 | ||
| 1630 | - nil (or no argument) deactivate auto-activation/layout; | 1646 | MODE is the activation mode - see `allout-auto-activation' for |
| 1631 | - `activate', enable auto-activation only; | 1647 | valid values." |
| 1632 | - `ask', enable auto-activation, and enable auto-layout but with | 1648 | |
| 1633 | confirmation for layout operation solicited from user each time; | 1649 | (custom-set-variables (list 'allout-auto-activation (format "%s" mode))) |
| 1634 | - `report', just report and return the current auto-activation state; | 1650 | (format "%s" mode)) |
| 1635 | - anything else (eg, t) for auto-activation and auto-layout, without | 1651 | (make-obsolete 'allout-init |
| 1636 | any confirmation check. | 1652 | "customize 'allout-auto-activation' instead." "23.3") |
| 1637 | |||
| 1638 | Use this function to setup your Emacs session for automatic activation | ||
| 1639 | of allout outline mode, contingent to the buffer-specific setting of | ||
| 1640 | the `allout-layout' variable. (See `allout-layout' and | ||
| 1641 | `allout-expose-topic' docstrings for more details on auto layout). | ||
| 1642 | |||
| 1643 | `allout-init' works by setting up (or removing) the `allout-mode' | ||
| 1644 | find-file-hook, and giving `allout-auto-activation' a suitable | ||
| 1645 | setting. | ||
| 1646 | |||
| 1647 | To prime your Emacs session for full auto-outline operation, include | ||
| 1648 | the following two lines in your Emacs init file: | ||
| 1649 | |||
| 1650 | \(require 'allout) | ||
| 1651 | \(allout-init t)" | ||
| 1652 | |||
| 1653 | (interactive) | ||
| 1654 | (if (allout-called-interactively-p) | ||
| 1655 | (progn | ||
| 1656 | (setq mode | ||
| 1657 | (completing-read | ||
| 1658 | (concat "Select outline auto setup mode " | ||
| 1659 | "(empty for report, ? for options) ") | ||
| 1660 | '(("nil")("full")("activate")("deactivate") | ||
| 1661 | ("ask") ("report") ("")) | ||
| 1662 | nil | ||
| 1663 | t)) | ||
| 1664 | (if (string= mode "") | ||
| 1665 | (setq mode 'report) | ||
| 1666 | (setq mode (intern-soft mode))))) | ||
| 1667 | (let | ||
| 1668 | ;; convenience aliases, for consistent ref to respective vars: | ||
| 1669 | ((hook 'allout-find-file-hook) | ||
| 1670 | (find-file-hook-var-name (if (boundp 'find-file-hook) | ||
| 1671 | 'find-file-hook | ||
| 1672 | 'find-file-hooks)) | ||
| 1673 | (curr-mode 'allout-auto-activation)) | ||
| 1674 | |||
| 1675 | (cond ((not mode) | ||
| 1676 | (set find-file-hook-var-name | ||
| 1677 | (delq hook (symbol-value find-file-hook-var-name))) | ||
| 1678 | (if (allout-called-interactively-p) | ||
| 1679 | (message "Allout outline mode auto-activation inhibited."))) | ||
| 1680 | ((eq mode 'report) | ||
| 1681 | (if (not (memq hook (symbol-value find-file-hook-var-name))) | ||
| 1682 | (allout-init nil) | ||
| 1683 | ;; Just punt and use the reports from each of the modes: | ||
| 1684 | (allout-init (symbol-value curr-mode)))) | ||
| 1685 | (t (add-hook find-file-hook-var-name hook) | ||
| 1686 | (set curr-mode ; `set', not `setq'! | ||
| 1687 | (cond ((eq mode 'activate) | ||
| 1688 | (message | ||
| 1689 | "Outline mode auto-activation enabled.") | ||
| 1690 | 'activate) | ||
| 1691 | ((eq mode 'report) | ||
| 1692 | ;; Return the current mode setting: | ||
| 1693 | (allout-init mode)) | ||
| 1694 | ((eq mode 'ask) | ||
| 1695 | (message | ||
| 1696 | (concat "Outline mode auto-activation and " | ||
| 1697 | "-layout (upon confirmation) enabled.")) | ||
| 1698 | 'ask) | ||
| 1699 | ((message | ||
| 1700 | "Outline mode auto-activation and -layout enabled.") | ||
| 1701 | 'full))))))) | ||
| 1702 | ;;;_ > allout-setup-menubar () | 1653 | ;;;_ > allout-setup-menubar () |
| 1703 | (defun allout-setup-menubar () | 1654 | (defun allout-setup-menubar () |
| 1704 | "Populate the current buffer's menubar with `allout-mode' stuff." | 1655 | "Populate the current buffer's menubar with `allout-mode' stuff." |
| @@ -1764,9 +1715,8 @@ and many other features. | |||
| 1764 | Below is a description of the key bindings, and then description | 1715 | Below is a description of the key bindings, and then description |
| 1765 | of special `allout-mode' features and terminology. See also the | 1716 | of special `allout-mode' features and terminology. See also the |
| 1766 | outline menubar additions for quick reference to many of the | 1717 | outline menubar additions for quick reference to many of the |
| 1767 | features, and see the docstring of the function `allout-init' for | 1718 | features. Customize `allout-auto-activation' to prepare your |
| 1768 | instructions on priming your emacs session for automatic | 1719 | emacs session for automatic activation of `allout-mode'. |
| 1769 | activation of `allout-mode'. | ||
| 1770 | 1720 | ||
| 1771 | The bindings are those listed in `allout-prefixed-keybindings' | 1721 | The bindings are those listed in `allout-prefixed-keybindings' |
| 1772 | and `allout-unprefixed-keybindings'. We recommend customizing | 1722 | and `allout-unprefixed-keybindings'. We recommend customizing |
| @@ -1850,7 +1800,8 @@ M-x outlineify-sticky Activate outline mode for current buffer, | |||
| 1850 | Like above 'copy-exposed', but convert topic | 1800 | Like above 'copy-exposed', but convert topic |
| 1851 | prefixes to section.subsection... numeric | 1801 | prefixes to section.subsection... numeric |
| 1852 | format. | 1802 | format. |
| 1853 | \\[eval-expression] (allout-init t) Setup Emacs session for outline mode | 1803 | \\[customize-variable] allout-auto-activation |
| 1804 | Prepare Emacs session for allout outline mode | ||
| 1854 | auto-activation. | 1805 | auto-activation. |
| 1855 | 1806 | ||
| 1856 | Topic Encryption | 1807 | Topic Encryption |
| @@ -2092,8 +2043,8 @@ OPEN: A TOPIC that is not CLOSED, though its OFFSPRING or BODY may be." | |||
| 2092 | (when (and allout-layout | 2043 | (when (and allout-layout |
| 2093 | allout-auto-activation | 2044 | allout-auto-activation |
| 2094 | use-layout | 2045 | use-layout |
| 2095 | (and (not (eq allout-auto-activation 'activate)) | 2046 | (and (not (string= allout-auto-activation "activate")) |
| 2096 | (if (eq allout-auto-activation 'ask) | 2047 | (if (string= allout-auto-activation "ask") |
| 2097 | (if (y-or-n-p (format "Expose %s with layout '%s'? " | 2048 | (if (y-or-n-p (format "Expose %s with layout '%s'? " |
| 2098 | (buffer-name) | 2049 | (buffer-name) |
| 2099 | use-layout)) | 2050 | use-layout)) |
| @@ -3448,7 +3399,7 @@ Returns the qualifying command, if any, else nil." | |||
| 3448 | (defun allout-find-file-hook () | 3399 | (defun allout-find-file-hook () |
| 3449 | "Activate `allout-mode' on non-nil `allout-auto-activation', `allout-layout'. | 3400 | "Activate `allout-mode' on non-nil `allout-auto-activation', `allout-layout'. |
| 3450 | 3401 | ||
| 3451 | See `allout-init' for setup instructions." | 3402 | See `allout-auto-activation' for setup instructions." |
| 3452 | (if (and allout-auto-activation | 3403 | (if (and allout-auto-activation |
| 3453 | (not (allout-mode-p)) | 3404 | (not (allout-mode-p)) |
| 3454 | allout-layout) | 3405 | allout-layout) |
| @@ -4394,7 +4345,7 @@ subtopics into siblings of the item." | |||
| 4394 | (if (and (not beg-hidden) (not end-hidden)) | 4345 | (if (and (not beg-hidden) (not end-hidden)) |
| 4395 | (allout-unprotected (kill-line arg)) | 4346 | (allout-unprotected (kill-line arg)) |
| 4396 | (kill-line arg)) | 4347 | (kill-line arg)) |
| 4397 | (run-hook-with-args 'allout-after-copy-or-kill-hook beg end) | 4348 | (run-hooks 'allout-after-copy-or-kill-hook) |
| 4398 | (allout-deannotate-hidden beg end) | 4349 | (allout-deannotate-hidden beg end) |
| 4399 | 4350 | ||
| 4400 | (if allout-numbered-bullet | 4351 | (if allout-numbered-bullet |
| @@ -4446,7 +4397,7 @@ Topic exposure is marked with text-properties, to be used by | |||
| 4446 | (unwind-protect ; for possible barf-if-buffer-read-only. | 4397 | (unwind-protect ; for possible barf-if-buffer-read-only. |
| 4447 | (allout-unprotected (kill-region beg end)) | 4398 | (allout-unprotected (kill-region beg end)) |
| 4448 | (allout-deannotate-hidden beg end) | 4399 | (allout-deannotate-hidden beg end) |
| 4449 | (run-hook-with-args 'allout-after-copy-or-kill-hook beg end) | 4400 | (run-hooks 'allout-after-copy-or-kill-hook) |
| 4450 | 4401 | ||
| 4451 | (save-excursion | 4402 | (save-excursion |
| 4452 | (allout-renumber-to-depth depth)) | 4403 | (allout-renumber-to-depth depth)) |
| @@ -4503,7 +4454,8 @@ Topic exposure is marked with text-properties, to be used by | |||
| 4503 | (allout-unprotected | 4454 | (allout-unprotected |
| 4504 | (let ((inhibit-read-only t) | 4455 | (let ((inhibit-read-only t) |
| 4505 | (buffer-undo-list t)) | 4456 | (buffer-undo-list t)) |
| 4506 | (remove-text-properties begin end '(allout-was-hidden t))))) | 4457 | (remove-text-properties begin (min end (point-max)) |
| 4458 | '(allout-was-hidden t))))) | ||
| 4507 | ;;;_ > allout-hide-by-annotation (begin end) | 4459 | ;;;_ > allout-hide-by-annotation (begin end) |
| 4508 | (defun allout-hide-by-annotation (begin end) | 4460 | (defun allout-hide-by-annotation (begin end) |
| 4509 | "Translate text properties indicating exposure status into actual exposure." | 4461 | "Translate text properties indicating exposure status into actual exposure." |
| @@ -6312,8 +6264,8 @@ save. See `allout-encrypt-unencrypted-on-saves' for more info." | |||
| 6312 | (defun outlineify-sticky (&optional arg) | 6264 | (defun outlineify-sticky (&optional arg) |
| 6313 | "Activate outline mode and establish file var so it is started subsequently. | 6265 | "Activate outline mode and establish file var so it is started subsequently. |
| 6314 | 6266 | ||
| 6315 | See doc-string for `allout-layout' and `allout-init' for details on | 6267 | See `allout-layout' and customization of `allout-auto-activation' |
| 6316 | setup for auto-startup." | 6268 | for details on preparing emacs for automatic allout activation." |
| 6317 | 6269 | ||
| 6318 | (interactive "P") | 6270 | (interactive "P") |
| 6319 | 6271 | ||