From 558276b04039b95b5b5998bb94e7c8c5bac7fa2d Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 1 Oct 2024 20:22:34 +0200 Subject: [PATCH] Prefer defvar-local where possible * lisp/editorconfig.el (editorconfig-properties-hash): * lisp/emacs-lisp/comp-run.el (comp-last-scanned-async-output): * lisp/info-look.el (info-lookup-mode): * lisp/mh-e/mh-folder.el (mh-generate-sequence-font-lock): * lisp/net/tramp.el (tramp-temp-buffer-file-name): * lisp/obsolete/iswitchb.el (iswitchb-eoinput): * lisp/obsolete/longlines.el (longlines-wrap-beg, longlines-wrap-end) (longlines-wrap-point, longlines-showing, longlines-decoded): * lisp/obsolete/tpu-edt.el (tpu-newline-and-indent-p) (tpu-newline-and-indent-string, tpu-saved-delete-func) (tpu-buffer-local-map, tpu-mark-flag): * lisp/progmodes/python.el (python-check-custom-command): * lisp/textmodes/reftex.el (reftex-docstruct-symbol) (reftex-isearch-minor-mode): Prefer defvar-local where possible, and the package does not support Emacs 24.3 or earlier. (cherry picked from commit e792856b001f260572b4012241748c41e045c638) --- lisp/editorconfig.el | 11 +++-------- lisp/emacs-lisp/comp-run.el | 3 +-- lisp/info-look.el | 3 +-- lisp/net/tramp.el | 4 +--- lisp/obsolete/longlines.el | 16 +++++----------- lisp/progmodes/python.el | 4 +--- lisp/textmodes/reftex.el | 6 ++---- 7 files changed, 14 insertions(+), 33 deletions(-) diff --git a/lisp/editorconfig.el b/lisp/editorconfig.el index 8d239229dcb..c21e12559a6 100644 --- a/lisp/editorconfig.el +++ b/lisp/editorconfig.el @@ -283,14 +283,11 @@ If set, enable that mode when `trim_trailing_whitespace` is set to true. Otherwise, use `delete-trailing-whitespace'." :type 'symbol) -(defvar editorconfig-properties-hash nil +(defvar-local editorconfig-properties-hash nil "Hash object of EditorConfig properties that was enabled for current buffer. Set by `editorconfig-apply' and nil if that is not invoked in current buffer yet.") -(make-variable-buffer-local 'editorconfig-properties-hash) -(put 'editorconfig-properties-hash - 'permanent-local - t) +(put 'editorconfig-properties-hash 'permanent-local t) (defvar editorconfig-lisp-use-default-indent nil "Selectively ignore the value of indent_size for Lisp files. @@ -464,9 +461,7 @@ heuristic for those modes not found there." (defvar-local editorconfig--apply-coding-system-currently nil "Used internally.") -(put 'editorconfig--apply-coding-system-currently - 'permanent-local - t) +(put 'editorconfig--apply-coding-system-currently 'permanent-local t) (defun editorconfig-merge-coding-systems (end-of-line charset) "Return merged coding system symbol of END-OF-LINE and CHARSET." diff --git a/lisp/emacs-lisp/comp-run.el b/lisp/emacs-lisp/comp-run.el index a659d7f68b7..3c7802c2ee0 100644 --- a/lisp/emacs-lisp/comp-run.el +++ b/lisp/emacs-lisp/comp-run.el @@ -186,8 +186,7 @@ processes from `comp-async-compilations'" (max 1 (/ (num-processors) 2)))) native-comp-async-jobs-number)) -(defvar comp-last-scanned-async-output nil) -(make-variable-buffer-local 'comp-last-scanned-async-output) +(defvar-local comp-last-scanned-async-output nil) ;; From warnings.el (defvar warning-suppress-types) (defun comp--accept-and-process-async-output (process) diff --git a/lisp/info-look.el b/lisp/info-look.el index a115da8a20e..285d6c3c3cd 100644 --- a/lisp/info-look.el +++ b/lisp/info-look.el @@ -46,11 +46,10 @@ "Major mode sensitive help agent." :group 'help :group 'languages) -(defvar info-lookup-mode nil +(defvar-local info-lookup-mode nil "Symbol of the current buffer's help mode. Help is provided according to the buffer's major mode if value is nil. Automatically becomes buffer local when set in any fashion.") -(make-variable-buffer-local 'info-lookup-mode) (defcustom info-lookup-other-window-flag t "Non-nil means pop up the Info buffer in another window." diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 80e3d63623a..8961b872a8a 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -853,11 +853,9 @@ filename part, though.") "Buffer name for a temporary buffer. It shall be used in combination with `generate-new-buffer-name'.") -(defvar tramp-temp-buffer-file-name nil +(defvar-local tramp-temp-buffer-file-name nil "File name of a persistent local temporary file. Useful for \"rsync\" like methods.") - -(make-variable-buffer-local 'tramp-temp-buffer-file-name) (put 'tramp-temp-buffer-file-name 'permanent-local t) (defcustom tramp-syntax 'default diff --git a/lisp/obsolete/longlines.el b/lisp/obsolete/longlines.el index f065bcaff26..3cfde4cb298 100644 --- a/lisp/obsolete/longlines.el +++ b/lisp/obsolete/longlines.el @@ -80,17 +80,11 @@ This is used when `longlines-show-hard-newlines' is on." ;;; Internal variables -(defvar longlines-wrap-beg nil) -(defvar longlines-wrap-end nil) -(defvar longlines-wrap-point nil) -(defvar longlines-showing nil) -(defvar longlines-decoded nil) - -(make-variable-buffer-local 'longlines-wrap-beg) -(make-variable-buffer-local 'longlines-wrap-end) -(make-variable-buffer-local 'longlines-wrap-point) -(make-variable-buffer-local 'longlines-showing) -(make-variable-buffer-local 'longlines-decoded) +(defvar-local longlines-wrap-beg nil) +(defvar-local longlines-wrap-end nil) +(defvar-local longlines-wrap-point nil) +(defvar-local longlines-showing nil) +(defvar-local longlines-decoded nil) ;;; Mode diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 6e7a398aee7..3fbe2a47102 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -5574,10 +5574,8 @@ def __FFAP_get_module_path(objstr): "Buffer name used for check commands." :type 'string) -(defvar python-check-custom-command nil +(defvar-local python-check-custom-command nil "Internal use.") -;; XXX: Avoid `defvar-local' for compat with Emacs<24.3 -(make-variable-buffer-local 'python-check-custom-command) (defun python-check (command) "Check a Python file (default current buffer's file). diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index efe38337001..165afd5a746 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el @@ -273,8 +273,7 @@ on the menu bar. (defvar reftex-multifile-index 0) ;; Variable holding the symbol with the label list of the document. -(defvar reftex-docstruct-symbol nil) -(make-variable-buffer-local 'reftex-docstruct-symbol) +(defvar-local reftex-docstruct-symbol nil) (defun reftex-next-multifile-index () ;; Return the next free index for multifile symbols. @@ -2116,8 +2115,7 @@ IGNORE-WORDS List of words which should be removed from the string." ;; Define a menu for the menu bar if Emacs is running under X -(defvar reftex-isearch-minor-mode nil) -(make-variable-buffer-local 'reftex-isearch-minor-mode) +(defvar-local reftex-isearch-minor-mode nil) (easy-menu-define reftex-mode-menu reftex-mode-map "Menu used in RefTeX mode." -- 2.39.2