From 4d635ceffbdfc3f709c09d25d28421e7816ecd8f Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 31 Jan 2021 14:35:44 +0100 Subject: Prefer defvar-local in allout * lisp/allout.el (allout-just-did-undo, allout-mode) (allout-layout, allout-regexp, allout-bullets-string) (allout-bullets-string-len, allout-depth-specific-regexp) (allout-depth-one-regexp, allout-line-boundary-regexp) (allout-bob-regexp, allout-header-subtraction) (allout-plain-bullets-string-len, allout-mode-prior-settings) (allout-outside-normal-auto-fill-function) (allout-encryption-plaintext-sanitization-regexps) (allout-encryption-ciphertext-rejection-regexps) (allout-explicitly-deactivated, allout-recent-prefix-beginning) (allout-recent-prefix-end, allout-recent-depth) (allout-recent-end-of-subtree, allout-post-goto-bullet) (allout-command-counter, allout-this-command-hid-text): * lisp/allout-widgets.el (allout-widgets-mode) (allout-widgets-tally, allout-widgets-mode-inhibit) (allout-inhibit-body-modification-hook) (allout-widgets-changes-record) (allout-widgets-undo-exposure-record) (allout-escaped-prefix-regexp, allout-item-icon-keymap) (allout-item-body-keymap, allout-cue-span-keymap) (allout-widgets-last-decoration-timing) (allout-container-item-widget): Prefer defvar-local. --- lisp/allout-widgets.el | 36 ++++++++--------------- lisp/allout.el | 79 +++++++++++++++++--------------------------------- 2 files changed, 39 insertions(+), 76 deletions(-) diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el index d31083e4271..7dcf36851f2 100644 --- a/lisp/allout-widgets.el +++ b/lisp/allout-widgets.el @@ -78,9 +78,8 @@ ;;; during file load, so the involved code must reside above that ;;; definition in the file. ;;;_ = allout-widgets-mode -(defvar allout-widgets-mode nil +(defvar-local allout-widgets-mode nil "Allout mode enhanced with graphical widgets.") -(make-variable-buffer-local 'allout-widgets-mode) ;;;_ : USER CUSTOMIZATION VARIABLES and incidental functions: ;;;_ > defgroup allout-widgets @@ -243,14 +242,13 @@ decreases as obsolete widgets are garbage collected." :version "24.1" :type 'boolean :group 'allout-widgets-developer) -(defvar allout-widgets-tally nil +(defvar-local allout-widgets-tally nil "Hash-table of existing allout widgets, for debugging. Table is maintained only if `allout-widgets-maintain-tally' is non-nil. The table contents will be out of sync if any widgets are created or deleted while this variable is nil.") -(make-variable-buffer-local 'allout-widgets-tally) (defvar allout-widgets-mode-inhibit) ; defined below ;;;_ > allout-widgets-tally-string (defun allout-widgets-tally-string () @@ -295,7 +293,7 @@ to publicize it by making it a customization variable)." (message "%s" msg) msg)) ;;;_ = allout-widgets-mode-inhibit -(defvar allout-widgets-mode-inhibit nil +(defvar-local allout-widgets-mode-inhibit nil "Inhibit `allout-widgets-mode' from activating widgets. This also inhibits automatic adjustment of widgets to track allout outline @@ -310,15 +308,13 @@ buffers where this is set to enable and disable widget enhancements, directly.") ;;;###autoload (put 'allout-widgets-mode-inhibit 'safe-local-variable 'booleanp) -(make-variable-buffer-local 'allout-widgets-mode-inhibit) ;;;_ = allout-inhibit-body-modification-hook -(defvar allout-inhibit-body-modification-hook nil +(defvar-local allout-inhibit-body-modification-hook nil "Override de-escaping of text-prefixes in item bodies during specific changes. This is used by `allout-buffer-modification-handler' to signal such changes to `allout-body-modification-handler', and is always reset by `allout-post-command-business'.") -(make-variable-buffer-local 'allout-inhibit-body-modification-hook) ;;;_ = allout-widgets-icons-cache (defvar allout-widgets-icons-cache nil "Cache allout icon images, as an association list. @@ -358,7 +354,7 @@ See \\[describe-mode] for many more options." The structure includes the guides lines, bullet, and bullet cue.") ;;;_ = allout-widgets-changes-record -(defvar allout-widgets-changes-record nil +(defvar-local allout-widgets-changes-record nil "Record outline changes for processing by post-command hook. Entries on the list are lists whose first element is a symbol indicating @@ -369,14 +365,12 @@ type. For example: The changes are recorded in reverse order, with new values pushed onto the front.") -(make-variable-buffer-local 'allout-widgets-changes-record) ;;;_ = allout-widgets-undo-exposure-record -(defvar allout-widgets-undo-exposure-record nil +(defvar-local allout-widgets-undo-exposure-record nil "Record outline undo traces for processing by post-command hook. The changes are recorded in reverse order, with new values pushed onto the front.") -(make-variable-buffer-local 'allout-widgets-undo-exposure-record) ;;;_ = allout-widgets-last-hook-error (defvar allout-widgets-last-hook-error nil "String holding last error string, for debugging purposes.") @@ -393,13 +387,12 @@ onto the front.") "Maintained true during `allout-widgets-exposure-undo-processor'") ;;;_ , Widget-specific outline text format ;;;_ = allout-escaped-prefix-regexp -(defvar allout-escaped-prefix-regexp "" +(defvar-local allout-escaped-prefix-regexp "" "Regular expression for body text that would look like an item prefix if not altered with an escape sequence.") -(make-variable-buffer-local 'allout-escaped-prefix-regexp) ;;;_ , Widget element formatting ;;;_ = allout-item-icon-keymap -(defvar allout-item-icon-keymap +(defvar-local allout-item-icon-keymap (let ((km (make-sparse-keymap)) (as-parent (if (current-local-map) (make-composed-keymap (current-local-map) @@ -420,9 +413,8 @@ not altered with an escape sequence.") km) "General tree-node key bindings.") -(make-variable-buffer-local 'allout-item-icon-keymap) ;;;_ = allout-item-body-keymap -(defvar allout-item-body-keymap +(defvar-local allout-item-body-keymap (let ((km (make-sparse-keymap)) (as-parent (if (current-local-map) (make-composed-keymap (current-local-map) @@ -432,17 +424,15 @@ not altered with an escape sequence.") (set-keymap-parent km as-parent) km) "General key bindings for the text content of outline items.") -(make-variable-buffer-local 'allout-item-body-keymap) ;;;_ = allout-body-span-category (defvar allout-body-span-category nil "Symbol carrying allout body-text overlay properties.") ;;;_ = allout-cue-span-keymap -(defvar allout-cue-span-keymap +(defvar-local allout-cue-span-keymap (let ((km (make-sparse-keymap))) (set-keymap-parent km allout-item-icon-keymap) km) "Keymap used in the item cue area - the space between the icon and headline.") -(make-variable-buffer-local 'allout-cue-span-keymap) ;;;_ = allout-escapes-category (defvar allout-escapes-category nil "Symbol for category of text property used to hide escapes of prefix-like @@ -477,7 +467,7 @@ including things like: (defvar allout-trailing-category nil "Symbol carrying common properties of an overlay's trailing newline.") ;;;_ , Developer -(defvar allout-widgets-last-decoration-timing nil +(defvar-local allout-widgets-last-decoration-timing nil "Timing details for the last cooperative decoration action. This is maintained when `allout-widgets-time-decoration-activity' is set. @@ -488,7 +478,6 @@ The value is a list containing two elements: When active, the value is revised each time automatic decoration activity happens in the buffer.") -(make-variable-buffer-local 'allout-widgets-last-decoration-timing) ;;;_ . mode hookup ;;;_ > define-minor-mode allout-widgets-mode (arg) ;;;###autoload @@ -693,12 +682,11 @@ outline hot-spot navigation (see `allout-mode')." (allout-get-or-create-item-widget)))))) ;;;_ . settings context ;;;_ = allout-container-item -(defvar allout-container-item-widget nil +(defvar-local allout-container-item-widget nil "A widget for the current outline's overarching container as an item. The item has settings (of the file/connection) and maybe a body, but no icon/bullet.") -(make-variable-buffer-local 'allout-container-item-widget) ;;;_ . Hooks and hook helpers ;;;_ , major command-loop business: ;;;_ > allout-widgets-pre-command-business (&optional recursing) diff --git a/lisp/allout.el b/lisp/allout.el index 39aa29b664a..ff0b67556e0 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -830,9 +830,8 @@ such topics are encrypted.)" 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 +(defvar-local 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 @@ -874,10 +873,10 @@ For details, see `allout-toggle-current-subtree-encryption's docstring." msg)) ;;;_ : Mode activation (defined here because it's referenced early) ;;;_ = allout-mode -(defvar allout-mode nil "Allout outline mode minor-mode flag.") -(make-variable-buffer-local 'allout-mode) +(defvar-local allout-mode nil + "Allout outline mode minor-mode flag.") ;;;_ = allout-layout nil -(defvar allout-layout nil ; LEAVE GLOBAL VALUE NIL -- see docstring. +(defvar-local 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' @@ -903,34 +902,30 @@ followed by the equivalent of `(allout-expose-topic 0 : -1 -1 0)'. `allout-default-layout' describes the specification format. `allout-layout' can additionally have the value t, in which 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 '(: * + -))))) ;;;_ : Topic header format ;;;_ = allout-regexp -(defvar allout-regexp "" +(defvar-local allout-regexp "" "Regular expression to match the beginning of a heading line. Any line whose beginning matches this regexp is considered a heading. This var is set according to the user configuration vars by `allout-set-regexp'.") -(make-variable-buffer-local 'allout-regexp) ;;;_ = allout-bullets-string -(defvar allout-bullets-string "" +(defvar-local allout-bullets-string "" "A string dictating the valid set of outline topic bullets. This var should *not* be set by the user -- it is set by `allout-set-regexp', and is produced from the elements of `allout-plain-bullets-string' and `allout-distinctive-bullets-string'.") -(make-variable-buffer-local 'allout-bullets-string) ;;;_ = allout-bullets-string-len -(defvar allout-bullets-string-len 0 +(defvar-local allout-bullets-string-len 0 "Length of current buffers' `allout-plain-bullets-string'.") -(make-variable-buffer-local 'allout-bullets-string-len) ;;;_ = allout-depth-specific-regexp -(defvar allout-depth-specific-regexp "" +(defvar-local allout-depth-specific-regexp "" "Regular expression to match a heading line prefix for a particular depth. This expression is used to search for depth-specific topic @@ -941,34 +936,28 @@ This var is set according to the user configuration vars by `allout-set-regexp'. It is prepared with format strings for two decimal numbers, which should each be one less than the depth of the topic prefix to be matched.") -(make-variable-buffer-local 'allout-depth-specific-regexp) ;;;_ = allout-depth-one-regexp -(defvar allout-depth-one-regexp "" +(defvar-local allout-depth-one-regexp "" "Regular expression to match a heading line prefix for depth one. This var is set according to the user configuration vars by `allout-set-regexp'. It is prepared with format strings for two decimal numbers, which should each be one less than the depth of the topic prefix to be matched.") -(make-variable-buffer-local 'allout-depth-one-regexp) ;;;_ = allout-line-boundary-regexp -(defvar allout-line-boundary-regexp () +(defvar-local allout-line-boundary-regexp () "`allout-regexp' prepended with a newline for the search target. This is properly set by `allout-set-regexp'.") -(make-variable-buffer-local 'allout-line-boundary-regexp) ;;;_ = allout-bob-regexp -(defvar allout-bob-regexp () +(defvar-local allout-bob-regexp () "Like `allout-line-boundary-regexp', for headers at beginning of buffer.") -(make-variable-buffer-local 'allout-bob-regexp) ;;;_ = allout-header-subtraction -(defvar allout-header-subtraction (1- (length allout-header-prefix)) +(defvar-local allout-header-subtraction (1- (length allout-header-prefix)) "Allout-header prefix length to subtract when computing topic depth.") -(make-variable-buffer-local 'allout-header-subtraction) ;;;_ = allout-plain-bullets-string-len -(defvar allout-plain-bullets-string-len (length allout-plain-bullets-string) +(defvar-local allout-plain-bullets-string-len (length allout-plain-bullets-string) "Length of `allout-plain-bullets-string', updated by `allout-set-regexp'.") -(make-variable-buffer-local 'allout-plain-bullets-string-len) ;;;_ = allout-doublecheck-at-and-shallower (defconst allout-doublecheck-at-and-shallower 3 @@ -1279,11 +1268,10 @@ Also refresh various data structures that hinge on the regexp." ["Set New Exposure" allout-expose-topic t]))) ;;;_ : Allout Modal-Variables Utilities ;;;_ = allout-mode-prior-settings -(defvar allout-mode-prior-settings nil +(defvar-local allout-mode-prior-settings nil "Internal `allout-mode' use; settings to be resumed on mode deactivation. 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. @@ -1466,16 +1454,15 @@ that was affected by the undo.." :version "24.3") ;;;_ = allout-outside-normal-auto-fill-function -(defvar allout-outside-normal-auto-fill-function nil +(defvar-local allout-outside-normal-auto-fill-function nil "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.") -(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)) ;;;_ = allout-after-save-decrypt -(defvar allout-after-save-decrypt nil +(defvar-local allout-after-save-decrypt nil "Internal variable, is nil or has the value of two points: - the location of a topic to be decrypted after saving is done @@ -1483,9 +1470,8 @@ wrapped within allout's automatic `fill-prefix' setting.") This is used to decrypt the topic that was currently being edited, if it was encrypted automatically as part of a file write or autosave.") -(make-variable-buffer-local 'allout-after-save-decrypt) ;;;_ = allout-encryption-plaintext-sanitization-regexps -(defvar allout-encryption-plaintext-sanitization-regexps nil +(defvar-local allout-encryption-plaintext-sanitization-regexps nil "List of regexps whose matches are removed from plaintext before encryption. This is for the sake of removing artifacts, like escapes, that are added on @@ -1498,9 +1484,8 @@ 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 substitution is used against the regexp matches, a la `replace-match'.") -(make-variable-buffer-local 'allout-encryption-plaintext-sanitization-regexps) ;;;_ = allout-encryption-ciphertext-rejection-regexps -(defvar allout-encryption-ciphertext-rejection-regexps nil +(defvar-local 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 @@ -1513,13 +1498,11 @@ Encryptions that result in matches will be retried, up to `allout-encryption-ciphertext-rejection-ceiling' times, after which an error is raised.") -(make-variable-buffer-local 'allout-encryption-ciphertext-rejection-regexps) ;;;_ = allout-encryption-ciphertext-rejection-ceiling -(defvar allout-encryption-ciphertext-rejection-ceiling 5 +(defvar-local allout-encryption-ciphertext-rejection-ceiling 5 "Limit on number of times encryption ciphertext is rejected. See `allout-encryption-ciphertext-rejection-regexps' for rejection reasons.") -(make-variable-buffer-local 'allout-encryption-ciphertext-rejection-ceiling) ;;;_ > allout-mode-p () ;; Must define this macro above any uses, or byte compilation will lack ;; proper def, if file isn't loaded -- eg, during emacs build! @@ -1607,10 +1590,9 @@ non-nil in a lasting way.") ;;;_ #2 Mode environment and activation ;;;_ = allout-explicitly-deactivated -(defvar allout-explicitly-deactivated nil +(defvar-local allout-explicitly-deactivated nil "If t, `allout-mode's last deactivation was deliberate. So `allout-post-command-business' should not reactivate it...") -(make-variable-buffer-local 'allout-explicitly-deactivated) ;;;_ > allout-setup-menubar () (defun allout-setup-menubar () "Populate the current buffer's menubar with `allout-mode' stuff." @@ -2119,21 +2101,17 @@ function can also be used as an `isearch-mode-end-hook'." ;; for just-established data. This optimization can provide ;; significant speed improvement, but it must be employed carefully. ;;;_ = allout-recent-prefix-beginning -(defvar allout-recent-prefix-beginning 0 +(defvar-local allout-recent-prefix-beginning 0 "Buffer point of the start of the last topic prefix encountered.") -(make-variable-buffer-local 'allout-recent-prefix-beginning) ;;;_ = allout-recent-prefix-end -(defvar allout-recent-prefix-end 0 +(defvar-local allout-recent-prefix-end 0 "Buffer point of the end of the last topic prefix encountered.") -(make-variable-buffer-local 'allout-recent-prefix-end) ;;;_ = allout-recent-depth -(defvar allout-recent-depth 0 +(defvar-local allout-recent-depth 0 "Depth of the last topic prefix encountered.") -(make-variable-buffer-local 'allout-recent-depth) ;;;_ = allout-recent-end-of-subtree -(defvar allout-recent-end-of-subtree 0 +(defvar-local allout-recent-end-of-subtree 0 "Buffer point last returned by `allout-end-of-current-subtree'.") -(make-variable-buffer-local 'allout-recent-end-of-subtree) ;;;_ > allout-prefix-data () (defsubst allout-prefix-data () "Register allout-prefix state data. @@ -3213,7 +3191,7 @@ Returns resulting position, else nil if none found." ;;;_ - Fundamental ;;;_ = allout-post-goto-bullet -(defvar allout-post-goto-bullet nil +(defvar-local allout-post-goto-bullet nil "Outline internal var, for `allout-pre-command-business' hot-spot operation. When set, tells post-processing to reposition on topic bullet, and @@ -3221,18 +3199,15 @@ then unset it. Set by `allout-pre-command-business' when implementing hot-spot operation, where literal characters typed over a topic bullet are mapped to the command of the corresponding control-key on the `allout-mode-map-value'.") -(make-variable-buffer-local 'allout-post-goto-bullet) ;;;_ = allout-command-counter -(defvar allout-command-counter 0 +(defvar-local allout-command-counter 0 "Counter that monotonically increases in allout-mode buffers. 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 +(defvar-local 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. -- cgit v1.2.3