From 59e8c37d61d313335408f8f23e3025b499200266 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 31 Jan 2021 18:46:17 +0100 Subject: Prefer defvar-local in progmodes/*.el This skips libraries that might want compatibility with Emacs 24.2. * lisp/progmodes/compile.el (compilation-auto-jump-to-next) (compilation--previous-directory-cache, compilation--parsed) (compilation-gcpro): * lisp/progmodes/cpp.el (cpp-overlay-list, cpp-edit-buffer) (cpp-parse-symbols, cpp-edit-symbols): * lisp/progmodes/ebnf2ps.el (ebnf-eps-upper-x, ebnf-eps-upper-y) (ebnf-eps-prod-width, ebnf-eps-max-height, ebnf-eps-max-width): * lisp/progmodes/f90.el (f90-cache-position): * lisp/progmodes/gud.el (gud-marker-acc): * lisp/progmodes/js.el (js--quick-match-re) (js--quick-match-re-func, js--cache-end, js--last-parse-pos) (js--state-at-last-parse-pos, js--tmp-location): * lisp/progmodes/octave.el (inferior-octave-directory-tracker-resync): * lisp/progmodes/sh-script.el (sh-header-marker): Prefer defvar-local. --- lisp/progmodes/compile.el | 15 +++++---------- lisp/progmodes/cpp.el | 18 +++++++----------- lisp/progmodes/ebnf2ps.el | 15 +++++---------- lisp/progmodes/f90.el | 3 +-- lisp/progmodes/gud.el | 3 +-- lisp/progmodes/js.el | 19 ++++++------------- lisp/progmodes/octave.el | 3 +-- lisp/progmodes/sh-script.el | 3 +-- 8 files changed, 27 insertions(+), 52 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 2c1e6ff52ec..614ed7d835d 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -953,13 +953,11 @@ Faces `compilation-error-face', `compilation-warning-face', :type 'boolean :version "23.1") -(defvar compilation-auto-jump-to-next nil +(defvar-local compilation-auto-jump-to-next nil "If non-nil, automatically jump to the next error encountered.") -(make-variable-buffer-local 'compilation-auto-jump-to-next) -;; (defvar compilation-buffer-modtime nil +;; (defvar-local compilation-buffer-modtime nil ;; "The buffer modification time, for buffers not associated with files.") -;; (make-variable-buffer-local 'compilation-buffer-modtime) (defvar compilation-skip-to-next-location t "If non-nil, skip multiple error messages for the same source location.") @@ -1087,13 +1085,12 @@ from a different message." (:conc-name compilation--message->)) loc type end-loc rule) -(defvar compilation--previous-directory-cache nil +(defvar-local compilation--previous-directory-cache nil "A pair (POS . RES) caching the result of previous directory search. Basically, this pair says that calling (previous-single-property-change POS \\='compilation-directory) returned RES, i.e. there is no change of `compilation-directory' between POS and RES.") -(make-variable-buffer-local 'compilation--previous-directory-cache) (defun compilation--flush-directory-cache (start _end) (cond @@ -1600,8 +1597,7 @@ to `compilation-error-regexp-alist' if RULES is nil." (match-beginning mn) (match-end mn) 'font-lock-face (cadr props))))))))) -(defvar compilation--parsed -1) -(make-variable-buffer-local 'compilation--parsed) +(defvar-local compilation--parsed -1) (defun compilation--ensure-parse (limit) "Make sure the text has been parsed up to LIMIT." @@ -2673,9 +2669,8 @@ This is the value of `next-error-function' in Compilation buffers." (compilation--loc->marker end-loc)) (setf (compilation--loc->visited loc) t))) -(defvar compilation-gcpro nil +(defvar-local compilation-gcpro nil "Internal variable used to keep some values from being GC'd.") -(make-variable-buffer-local 'compilation-gcpro) (defun compilation-fake-loc (marker file &optional line col) "Preassociate MARKER with FILE. diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el index 4ea1674db02..b2c2e8dab57 100644 --- a/lisp/progmodes/cpp.el +++ b/lisp/progmodes/cpp.el @@ -112,9 +112,8 @@ If nil, `cpp-progress-message' prints no progress messages." :group 'cpp :version "26.1") -(defvar cpp-overlay-list nil) -;; List of cpp overlays active in the current buffer. -(make-variable-buffer-local 'cpp-overlay-list) +(defvar-local cpp-overlay-list nil + "List of cpp overlays active in the current buffer.") (defvar cpp-callback-data) (defvar cpp-state-stack) @@ -134,9 +133,8 @@ If nil, `cpp-progress-message' prints no progress messages." (defvar cpp-button-event nil) ;; This will be t in the callback for `cpp-make-button'. -(defvar cpp-edit-buffer nil) -;; Real buffer whose cpp display information we are editing. -(make-variable-buffer-local 'cpp-edit-buffer) +(defvar-local cpp-edit-buffer nil + "Real buffer whose cpp display information we are editing.") (defconst cpp-branch-list ;; Alist of branches. @@ -211,9 +209,8 @@ or a cons cell (background-color . COLOR)." ;;; Parse Buffer: -(defvar cpp-parse-symbols nil +(defvar-local cpp-parse-symbols nil "List of cpp macros used in the local buffer.") -(make-variable-buffer-local 'cpp-parse-symbols) (defconst cpp-parse-regexp ;; Regexp matching all tokens needed to find conditionals. @@ -471,9 +468,8 @@ A prefix arg suppresses display of that buffer." -(defvar cpp-edit-symbols nil) -;; Symbols defined in the edit buffer. -(make-variable-buffer-local 'cpp-edit-symbols) +(defvar-local cpp-edit-symbols nil + "Symbols defined in the edit buffer.") (define-derived-mode cpp-edit-mode fundamental-mode "CPP Edit" "Major mode for editing the criteria for highlighting cpp conditionals. diff --git a/lisp/progmodes/ebnf2ps.el b/lisp/progmodes/ebnf2ps.el index 6f9509d152b..b376423c185 100644 --- a/lisp/progmodes/ebnf2ps.el +++ b/lisp/progmodes/ebnf2ps.el @@ -2941,16 +2941,11 @@ See `ebnf-style-database' documentation." (defvar ebnf-eps-executing nil) (defvar ebnf-eps-header-comment nil) (defvar ebnf-eps-footer-comment nil) -(defvar ebnf-eps-upper-x 0.0) -(make-variable-buffer-local 'ebnf-eps-upper-x) -(defvar ebnf-eps-upper-y 0.0) -(make-variable-buffer-local 'ebnf-eps-upper-y) -(defvar ebnf-eps-prod-width 0.0) -(make-variable-buffer-local 'ebnf-eps-prod-width) -(defvar ebnf-eps-max-height 0.0) -(make-variable-buffer-local 'ebnf-eps-max-height) -(defvar ebnf-eps-max-width 0.0) -(make-variable-buffer-local 'ebnf-eps-max-width) +(defvar-local ebnf-eps-upper-x 0.0) +(defvar-local ebnf-eps-upper-y 0.0) +(defvar-local ebnf-eps-prod-width 0.0) +(defvar-local ebnf-eps-max-height 0.0) +(defvar-local ebnf-eps-max-width 0.0) (defvar ebnf-eps-context nil diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 2641387986d..92b165bc641 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -926,9 +926,8 @@ then the presence of the token here allows a line-break before or after the other character, where a break would not normally be allowed. This minor issue currently only affects \"(/\" and \"/)\".") -(defvar f90-cache-position nil +(defvar-local f90-cache-position nil "Temporary position used to speed up region operations.") -(make-variable-buffer-local 'f90-cache-position) ;; Hideshow support. diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 259da2fd019..eb114acdabc 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -638,8 +638,7 @@ The option \"--fullname\" must be included in this value." ;; receive a chunk of text which looks like it might contain the ;; beginning of a marker, we save it here between calls to the ;; filter. -(defvar gud-marker-acc "") -(make-variable-buffer-local 'gud-marker-acc) +(defvar-local gud-marker-acc "") (defun gud-gdb-marker-filter (string) (setq gud-marker-acc (concat gud-marker-acc string)) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 33bea59e3ba..cdf6536fc7e 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -717,26 +717,20 @@ This variable is like `sgml-attribute-offset'." table) "Syntax table for `js-mode'.") -(defvar js--quick-match-re nil +(defvar-local js--quick-match-re nil "Autogenerated regexp used by `js-mode' to match buffer constructs.") -(defvar js--quick-match-re-func nil +(defvar-local js--quick-match-re-func nil "Autogenerated regexp used by `js-mode' to match constructs and functions.") -(make-variable-buffer-local 'js--quick-match-re) -(make-variable-buffer-local 'js--quick-match-re-func) - -(defvar js--cache-end 1 +(defvar-local js--cache-end 1 "Last valid buffer position for the `js-mode' function cache.") -(make-variable-buffer-local 'js--cache-end) -(defvar js--last-parse-pos nil +(defvar-local js--last-parse-pos nil "Latest parse position reached by `js--ensure-cache'.") -(make-variable-buffer-local 'js--last-parse-pos) -(defvar js--state-at-last-parse-pos nil +(defvar-local js--state-at-last-parse-pos nil "Parse state at `js--last-parse-pos'.") -(make-variable-buffer-local 'js--state-at-last-parse-pos) (defun js--maybe-join (prefix separator suffix &rest list) "Helper function for `js--update-quick-match-re'. @@ -1505,8 +1499,7 @@ REGEXPS, but only if FRAMEWORK is in `js-enabled-frameworks'." (when (memq (quote ,framework) js-enabled-frameworks) (re-search-forward ,regexps limit t))))) -(defvar js--tmp-location nil) -(make-variable-buffer-local 'js--tmp-location) +(defvar-local js--tmp-location nil) (defun js--forward-destructuring-spec (&optional func) "Move forward over a JavaScript destructuring spec. diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index a14a8d75a78..c37bb1c7112 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -964,8 +964,7 @@ output is passed to the filter `inferior-octave-output-digest'." (setq list (cdr list))) (set-process-filter proc filter)))) -(defvar inferior-octave-directory-tracker-resync nil) -(make-variable-buffer-local 'inferior-octave-directory-tracker-resync) +(defvar-local inferior-octave-directory-tracker-resync nil) (defun inferior-octave-directory-tracker (string) "Tracks `cd' commands issued to the inferior Octave process. diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index fd689527676..f588ad99c9d 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -541,10 +541,9 @@ sign. See `sh-feature'." :group 'sh-script) -(defvar sh-header-marker nil +(defvar-local sh-header-marker nil "When non-nil is the end of header for prepending by \\[sh-execute-region]. That command is also used for setting this variable.") -(make-variable-buffer-local 'sh-header-marker) (defcustom sh-beginning-of-command "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~[:alnum:]:]\\)" -- cgit v1.2.3