From 458faaf4c39936a5e7d187684cbf0fe0b161bb0a Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 31 Jan 2021 18:45:47 +0100 Subject: [PATCH] Prefer defvar-local in textmodes/*.el This skips libraries that might want compatibility with Emacs 24.2. * lisp/textmodes/artist.el (artist-curr-go) (artist-line-char-set, artist-line-char, artist-fill-char-set) (artist-fill-char, artist-erase-char, artist-default-fill-char) (artist-draw-region-min-y, artist-draw-region-max-y) (artist-borderless-shapes): * lisp/textmodes/css-mode.el (css--at-ids, css--bang-ids) (css--nested-selectors-allowed): * lisp/textmodes/enriched.el (enriched-old-bindings): * lisp/textmodes/flyspell.el (flyspell-generic-check-word-predicate) (flyspell-consider-dash-as-word-delimiter-flag) (flyspell-dash-dictionary, flyspell-dash-local-dictionary) (flyspell-word-cache-start, flyspell-word-cache-end) (flyspell-word-cache-word, flyspell-word-cache-result) (flyspell-changes, flyspell-auto-correct-pos) (flyspell-auto-correct-region, flyspell-auto-correct-ring) (flyspell-auto-correct-word): * lisp/textmodes/ispell.el (ispell-local-dictionary-overridden) (ispell-local-pdict, ispell-buffer-session-localwords): * lisp/textmodes/refill.el (refill-ignorable-overlay) (refill-doit): * lisp/textmodes/sgml-mode.el (html--buffer-classes-cache) (html--buffer-ids-cache): * lisp/textmodes/table.el (table-mode-indicator): * lisp/textmodes/tex-mode.el (tex-send-command-modified-tick): * lisp/textmodes/two-column.el (2C-autoscroll-start, 2C-mode): Prefer defvar-local. --- lisp/textmodes/artist.el | 30 +++++++++------------------ lisp/textmodes/css-mode.el | 9 +++------ lisp/textmodes/enriched.el | 3 +-- lisp/textmodes/flyspell.el | 39 ++++++++++++------------------------ lisp/textmodes/ispell.el | 10 +++------ lisp/textmodes/refill.el | 6 ++---- lisp/textmodes/sgml-mode.el | 6 ++---- lisp/textmodes/table.el | 3 +-- lisp/textmodes/tex-mode.el | 3 +-- lisp/textmodes/two-column.el | 6 ++---- 10 files changed, 38 insertions(+), 77 deletions(-) diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el index 13b7118d2f2..e66adb43e75 100644 --- a/lisp/textmodes/artist.el +++ b/lisp/textmodes/artist.el @@ -411,50 +411,40 @@ be in `artist-spray-chars', or spraying will behave strangely.") (defvar artist-mode-name " Artist" "Name of Artist mode beginning with a space (appears in the mode-line).") -(defvar artist-curr-go 'pen-line +(defvar-local artist-curr-go 'pen-line "Current selected graphics operation.") -(make-variable-buffer-local 'artist-curr-go) -(defvar artist-line-char-set nil +(defvar-local artist-line-char-set nil "Boolean to tell whether user has set some char to use when drawing lines.") -(make-variable-buffer-local 'artist-line-char-set) -(defvar artist-line-char nil +(defvar-local artist-line-char nil "Char to use when drawing lines.") -(make-variable-buffer-local 'artist-line-char) -(defvar artist-fill-char-set nil +(defvar-local artist-fill-char-set nil "Boolean to tell whether user has set some char to use when filling.") -(make-variable-buffer-local 'artist-fill-char-set) -(defvar artist-fill-char nil +(defvar-local artist-fill-char nil "Char to use when filling.") -(make-variable-buffer-local 'artist-fill-char) -(defvar artist-erase-char ?\s +(defvar-local artist-erase-char ?\s "Char to use when erasing.") -(make-variable-buffer-local 'artist-erase-char) -(defvar artist-default-fill-char ?. +(defvar-local artist-default-fill-char ?. "Char to use when a fill-char is required but none is set.") -(make-variable-buffer-local 'artist-default-fill-char) ; This variable is not buffer local (defvar artist-copy-buffer nil "Copy buffer.") -(defvar artist-draw-region-min-y 0 +(defvar-local artist-draw-region-min-y 0 "Line-number for top-most visited line for draw operation.") -(make-variable-buffer-local 'artist-draw-region-min-y) -(defvar artist-draw-region-max-y 0 +(defvar-local artist-draw-region-max-y 0 "Line-number for bottom-most visited line for draw operation.") -(make-variable-buffer-local 'artist-draw-region-max-y) -(defvar artist-borderless-shapes nil +(defvar-local artist-borderless-shapes nil "When non-nil, draw shapes without border. The fill char is used instead, if it is set.") -(make-variable-buffer-local 'artist-borderless-shapes) (defvar artist-prev-next-op-alist nil "Assoc list for looking up next and/or previous draw operation. diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 9186e520086..622853da456 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -71,9 +71,8 @@ "while") "Additional identifiers that appear in the form @foo in SCSS.") -(defvar css--at-ids css-at-ids +(defvar-local css--at-ids css-at-ids "List of at-rules for the current mode.") -(make-variable-buffer-local 'css--at-ids) (defconst css-bang-ids '("important") @@ -83,9 +82,8 @@ '("default" "global" "optional") "Additional identifiers that appear in the form !foo in SCSS.") -(defvar css--bang-ids css-bang-ids +(defvar-local css--bang-ids css-bang-ids "List of bang-rules for the current mode.") -(make-variable-buffer-local 'css--bang-ids) (defconst css-descriptor-ids '("ascent" "baseline" "bbox" "cap-height" "centerline" "definition-src" @@ -1374,9 +1372,8 @@ the string PROPERTY." "List of HTML tags. Used to provide completion of HTML tags in selectors.") -(defvar css--nested-selectors-allowed nil +(defvar-local css--nested-selectors-allowed nil "Non-nil if nested selectors are allowed in the current mode.") -(make-variable-buffer-local 'css--nested-selectors-allowed) (defvar css-class-list-function #'ignore "Called to provide completions of class names. diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el index 1aac96413e4..bac209cdef6 100644 --- a/lisp/textmodes/enriched.el +++ b/lisp/textmodes/enriched.el @@ -165,10 +165,9 @@ execute malicious Lisp code, if that code came from an external source." :version "26.1" :group 'enriched) -(defvar enriched-old-bindings nil +(defvar-local enriched-old-bindings nil "Store old variable values that we change when entering mode. The value is a list of \(VAR VALUE VAR VALUE...).") -(make-variable-buffer-local 'enriched-old-bindings) ;; The next variable is buffer local if and only if Enriched mode is ;; enabled. The buffer local value records whether diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index d8503168846..83dba7177ab 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -304,12 +304,11 @@ If this variable is nil, all regions are treated as small." (define-obsolete-variable-alias 'flyspell-generic-check-word-p 'flyspell-generic-check-word-predicate "25.1") -(defvar flyspell-generic-check-word-predicate nil +(defvar-local flyspell-generic-check-word-predicate nil "Function providing per-mode customization over which words are flyspelled. Returns t to continue checking, nil otherwise. Flyspell mode sets this variable to whatever is the `flyspell-mode-predicate' property of the major mode name.") -(make-variable-buffer-local 'flyspell-generic-check-word-predicate) ;;*--- mail mode -------------------------------------------------------*/ (put 'mail-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) @@ -466,13 +465,10 @@ If this is set, also unbind `mouse-2'." :version "28.1") ;; dash character machinery -(defvar flyspell-consider-dash-as-word-delimiter-flag nil +(defvar-local flyspell-consider-dash-as-word-delimiter-flag nil "Non-nil means that the `-' char is considered as a word delimiter.") -(make-variable-buffer-local 'flyspell-consider-dash-as-word-delimiter-flag) -(defvar flyspell-dash-dictionary nil) -(make-variable-buffer-local 'flyspell-dash-dictionary) -(defvar flyspell-dash-local-dictionary nil) -(make-variable-buffer-local 'flyspell-dash-local-dictionary) +(defvar-local flyspell-dash-dictionary nil) +(defvar-local flyspell-dash-local-dictionary nil) ;;*---------------------------------------------------------------------*/ ;;* Highlighting */ @@ -714,14 +710,10 @@ has been used, the current word is not checked." ;;*---------------------------------------------------------------------*/ ;;* flyspell-word-cache ... */ ;;*---------------------------------------------------------------------*/ -(defvar flyspell-word-cache-start nil) -(defvar flyspell-word-cache-end nil) -(defvar flyspell-word-cache-word nil) -(defvar flyspell-word-cache-result '_) -(make-variable-buffer-local 'flyspell-word-cache-start) -(make-variable-buffer-local 'flyspell-word-cache-end) -(make-variable-buffer-local 'flyspell-word-cache-word) -(make-variable-buffer-local 'flyspell-word-cache-result) +(defvar-local flyspell-word-cache-start nil) +(defvar-local flyspell-word-cache-end nil) +(defvar-local flyspell-word-cache-word nil) +(defvar-local flyspell-word-cache-result '_) ;;*---------------------------------------------------------------------*/ ;;* The flyspell pre-hook, store the current position. In the */ @@ -827,8 +819,7 @@ before the current command." ;;* the post command hook, we will check, if the word at this */ ;;* position has to be spell checked. */ ;;*---------------------------------------------------------------------*/ -(defvar flyspell-changes nil) -(make-variable-buffer-local 'flyspell-changes) +(defvar-local flyspell-changes nil) ;;*---------------------------------------------------------------------*/ ;;* flyspell-after-change-function ... */ @@ -1894,14 +1885,10 @@ as returned by `ispell-parse-output'." ;;*---------------------------------------------------------------------*/ ;;* flyspell-auto-correct-cache ... */ ;;*---------------------------------------------------------------------*/ -(defvar flyspell-auto-correct-pos nil) -(defvar flyspell-auto-correct-region nil) -(defvar flyspell-auto-correct-ring nil) -(defvar flyspell-auto-correct-word nil) -(make-variable-buffer-local 'flyspell-auto-correct-pos) -(make-variable-buffer-local 'flyspell-auto-correct-region) -(make-variable-buffer-local 'flyspell-auto-correct-ring) -(make-variable-buffer-local 'flyspell-auto-correct-word) +(defvar-local flyspell-auto-correct-pos nil) +(defvar-local flyspell-auto-correct-region nil) +(defvar-local flyspell-auto-correct-ring nil) +(defvar-local flyspell-auto-correct-word nil) ;;*---------------------------------------------------------------------*/ ;;* flyspell-check-previous-highlighted-word ... */ diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 8d49a7c54c8..ea46270508e 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -351,9 +351,8 @@ If nil, the default personal dictionary for your spelling checker is used." :type 'boolean :group 'ispell) -(defvar ispell-local-dictionary-overridden nil +(defvar-local ispell-local-dictionary-overridden nil "Non-nil means the user has explicitly set this buffer's Ispell dictionary.") -(make-variable-buffer-local 'ispell-local-dictionary-overridden) (defcustom ispell-local-dictionary nil "If non-nil, the dictionary to be used for Ispell commands in this buffer. @@ -1748,7 +1747,7 @@ Note - substrings of other matches must come last (e.g. \"<[tT][tT]/\" and \"<[^ \\t\\n>]\").") (put 'ispell-html-skip-alists 'risky-local-variable t) -(defvar ispell-local-pdict ispell-personal-dictionary +(defvar-local ispell-local-pdict ispell-personal-dictionary "A buffer local variable containing the current personal dictionary. If non-nil, the value must be a string, which is a file name. @@ -1758,18 +1757,15 @@ to calling \\[ispell-change-dictionary]. This variable is automatically set when defined in the file with either `ispell-pdict-keyword' or the local variable syntax.") -(make-variable-buffer-local 'ispell-local-pdict) ;;;###autoload(put 'ispell-local-pdict 'safe-local-variable 'stringp) (defvar ispell-buffer-local-name nil "Contains the buffer name if local word definitions were used. Ispell is then restarted because the local words could conflict.") -(defvar ispell-buffer-session-localwords nil +(defvar-local ispell-buffer-session-localwords nil "List of words accepted for session in this buffer.") -(make-variable-buffer-local 'ispell-buffer-session-localwords) - (defvar ispell-parser 'use-mode-name "Indicates whether ispell should parse the current buffer as TeX Code. Special value `use-mode-name' tries to guess using the name of `major-mode'. diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el index 6edd9aeb7ef..8f4f3c5a231 100644 --- a/lisp/textmodes/refill.el +++ b/lisp/textmodes/refill.el @@ -88,10 +88,9 @@ ;;; "Refilling paragraphs on changes." ;;; :group 'fill) -(defvar refill-ignorable-overlay nil +(defvar-local refill-ignorable-overlay nil "Portion of the most recently filled paragraph not needing filling. This is used to optimize refilling.") -(make-variable-buffer-local 'refill-ignorable-overlay) (defun refill-adjust-ignorable-overlay (overlay afterp beg end &optional len) "Adjust OVERLAY to not include the about-to-be-modified region." @@ -149,7 +148,7 @@ This is used to optimize refilling.") "Like `fill-paragraph' but don't delete whitespace at paragraph end." (refill-fill-paragraph-at (point) arg)) -(defvar refill-doit nil +(defvar-local refill-doit nil "Non-nil tells `refill-post-command-function' to do its processing. Set by `refill-after-change-function' in `after-change-functions' and unset by `refill-post-command-function' in `post-command-hook', and @@ -157,7 +156,6 @@ sometimes `refill-pre-command-function' in `pre-command-hook'. This ensures refilling is only done once per command that causes a change, regardless of the number of after-change calls from commands doing complex processing.") -(make-variable-buffer-local 'refill-doit) (defun refill-after-change-function (beg end len) "Function for `after-change-functions' which just sets `refill-doit'." diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index c50c544cb54..3e29f055ece 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2290,19 +2290,17 @@ This takes effect when first loading the library.") nil t) (match-string-no-properties 1)))) -(defvar html--buffer-classes-cache nil +(defvar-local html--buffer-classes-cache nil "Cache for `html-current-buffer-classes'. When set, this should be a cons cell where the CAR is the buffer's tick counter (as produced by `buffer-modified-tick'), and the CDR is the list of class names found in the buffer.") -(make-variable-buffer-local 'html--buffer-classes-cache) -(defvar html--buffer-ids-cache nil +(defvar-local html--buffer-ids-cache nil "Cache for `html-current-buffer-ids'. When set, this should be a cons cell where the CAR is the buffer's tick counter (as produced by `buffer-modified-tick'), and the CDR is the list of class names found in the buffer.") -(make-variable-buffer-local 'html--buffer-ids-cache) (declare-function libxml-parse-html-region "xml.c" (start end &optional base-url discard-comments)) diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 071684d3c4d..06785e458b2 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el @@ -859,11 +859,10 @@ cell to cache and cache to cell.") "Non-nil inhibits auto fill paragraph when `table-with-cache-buffer' exits. This is always set to nil at the entry to `table-with-cache-buffer' before executing body forms.") -(defvar table-mode-indicator nil +(defvar-local table-mode-indicator nil "For mode line indicator") ;; This is not a real minor-mode but placed in the minor-mode-alist ;; so that we can show the indicator on the mode line handy. -(make-variable-buffer-local 'table-mode-indicator) (unless (assq table-mode-indicator minor-mode-alist) (push '(table-mode-indicator (table-fixed-width-mode " Fixed-Table" " Table")) minor-mode-alist)) diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index ce665e61656..d5a79ad0ac5 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el @@ -2044,8 +2044,7 @@ In the tex shell buffer this command behaves like `comint-send-input'." (with-current-buffer buffer (setq default-directory directory)))) -(defvar tex-send-command-modified-tick 0) -(make-variable-buffer-local 'tex-send-command-modified-tick) +(defvar-local tex-send-command-modified-tick 0) (defun tex-shell-proc () (or (tex-shell-running) (error "No TeX subprocess"))) diff --git a/lisp/textmodes/two-column.el b/lisp/textmodes/two-column.el index 36aad84c0e6..d072ab16c3c 100644 --- a/lisp/textmodes/two-column.el +++ b/lisp/textmodes/two-column.el @@ -218,15 +218,13 @@ minus this value." ;; Markers seem to be the only buffer-id not affected by renaming a buffer. ;; This nevertheless loses when a buffer is killed. The variable-name is ;; required by `describe-mode'. -(defvar 2C-mode nil +(defvar-local 2C-mode nil "Marker to the associated buffer, if non-nil.") -(make-variable-buffer-local '2C-mode) (put '2C-mode 'permanent-local t) (setq minor-mode-alist (cons '(2C-mode " 2C") minor-mode-alist)) -(defvar 2C-autoscroll-start nil) -(make-variable-buffer-local '2C-autoscroll-start) +(defvar-local 2C-autoscroll-start nil) ;;;;; base functions ;;;;; -- 2.39.2