From 32c6732d16385f242b1109517f25e9aefd6caa5c Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 3 Jan 2021 15:43:31 -0500 Subject: * lisp/emacs-lisp/byte-run.el (make-obsolete): Make `when` mandatory (define-obsolete-function-alias, make-obsolete-variable) (define-obsolete-variable-alias): Adjust similarly. --- lisp/emacs-lisp/byte-run.el | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index 8334c09bf9f..0f8dd5a2842 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -372,7 +372,7 @@ convention was modified." (puthash (indirect-function function) signature advertised-signature-table)) -(defun make-obsolete (obsolete-name current-name &optional when) +(defun make-obsolete (obsolete-name current-name when) "Make the byte-compiler warn that function OBSOLETE-NAME is obsolete. OBSOLETE-NAME should be a function name or macro name (a symbol). @@ -381,17 +381,14 @@ If CURRENT-NAME is a string, that is the `use instead' message \(it should end with a period, and not start with a capital). WHEN should be a string indicating when the function was first made obsolete, for example a date or a release number." - (declare (advertised-calling-convention - ;; New code should always provide the `when' argument. - (obsolete-name current-name when) "23.1")) (put obsolete-name 'byte-obsolete-info ;; The second entry used to hold the `byte-compile' handler, but ;; is not used any more nowadays. (purecopy (list current-name nil when))) obsolete-name) -(defmacro define-obsolete-function-alias (obsolete-name current-name - &optional when docstring) +(defmacro define-obsolete-function-alias ( obsolete-name current-name when + &optional docstring) "Set OBSOLETE-NAME's function definition to CURRENT-NAME and mark it obsolete. \(define-obsolete-function-alias \\='old-fun \\='new-fun \"22.1\" \"old-fun's doc.\") @@ -405,15 +402,13 @@ WHEN should be a string indicating when the function was first made obsolete, for example a date or a release number. See the docstrings of `defalias' and `make-obsolete' for more details." - (declare (doc-string 4) - (advertised-calling-convention - ;; New code should always provide the `when' argument. - (obsolete-name current-name when &optional docstring) "23.1")) + (declare (doc-string 4)) `(progn (defalias ,obsolete-name ,current-name ,docstring) (make-obsolete ,obsolete-name ,current-name ,when))) -(defun make-obsolete-variable (obsolete-name current-name &optional when access-type) +(defun make-obsolete-variable ( obsolete-name current-name when + &optional access-type) "Make the byte-compiler warn that OBSOLETE-NAME is obsolete. The warning will say that CURRENT-NAME should be used instead. If CURRENT-NAME is a string, that is the `use instead' message. @@ -421,16 +416,13 @@ WHEN should be a string indicating when the variable was first made obsolete, for example a date or a release number. ACCESS-TYPE if non-nil should specify the kind of access that will trigger obsolescence warnings; it can be either `get' or `set'." - (declare (advertised-calling-convention - ;; New code should always provide the `when' argument. - (obsolete-name current-name when &optional access-type) "23.1")) (put obsolete-name 'byte-obsolete-variable (purecopy (list current-name access-type when))) obsolete-name) -(defmacro define-obsolete-variable-alias (obsolete-name current-name - &optional when docstring) +(defmacro define-obsolete-variable-alias ( obsolete-name current-name when + &optional docstring) "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete. WHEN should be a string indicating when the variable was first @@ -459,10 +451,7 @@ For the benefit of Customize, if OBSOLETE-NAME has any of the following properties, they are copied to CURRENT-NAME, if it does not already have them: `saved-value', `saved-variable-comment'." - (declare (doc-string 4) - (advertised-calling-convention - ;; New code should always provide the `when' argument. - (obsolete-name current-name when &optional docstring) "23.1")) + (declare (doc-string 4)) `(progn (defvaralias ,obsolete-name ,current-name ,docstring) ;; See Bug#4706. -- cgit v1.2.3 From 9973019764250ac1f4d77a6b426cdd9c241151c5 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 5 Jan 2021 12:28:37 -0500 Subject: * lisp/emacs-lisp/package.el: Load package-quickstart without package.el Speed up startup when `package-quickstart` is in use by making it possible to load the quickstart file without having to load `package.el` at all. (package-user-dir, package-directory-list, package-quickstart-file): Preload those variables. (package--get-activatable-pkg): New fun, extracted from `package-activate`. (package-activate): Use it. (package--activate-all): New function, extracted from `package-activate-all`. (package-activate-all): Use it and make the function preloaded. (package--archives-initialize): New function. (package-install): Use it. (list-packages): Avoid `switch-to-buffer`. (package-get-descriptor): New function. * lisp/startup.el (command-line): Simplify the code now that package-user-dir and package-directory-list are preloaded. * lisp/emacs-lisp/autoload.el (make-autoload): Add support for `:initialize #'custom-initialize-delay` in `defcustom`. --- lisp/emacs-lisp/autoload.el | 8 +++- lisp/emacs-lisp/package.el | 90 ++++++++++++++++++++++++++++++--------------- lisp/startup.el | 12 +----- 3 files changed, 68 insertions(+), 42 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 1786b5cd6a8..77de05a6f68 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -221,12 +221,18 @@ expression, in which case we want to handle forms differently." ;; Convert defcustom to less space-consuming data. ((eq car 'defcustom) (let ((varname (car-safe (cdr-safe form))) + (initializer (plist-get (nthcdr 4 form) :initialize)) (init (car-safe (cdr-safe (cdr-safe form)))) (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))) ) `(progn - (defvar ,varname ,init ,doc) + ,(if (null initializer) + `(defvar ,varname ,init ,doc) + `(progn (defvar ,varname nil ,doc) + (let ((exp ',init)) + (put ',varname 'standard-value (list exp)) + (,(eval initializer t) ',varname exp)))) (custom-autoload ',varname ,file ,(condition-case nil (null (cadr (memq :set form))) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 40ba1355513..a38363df23e 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -173,12 +173,12 @@ with \"-q\"). Even if the value is nil, you can type \\[package-initialize] to make installed packages available at any time, or you can -call (package-initialize) in your init-file." +call (package-activate-all) in your init-file." :type 'boolean :version "24.1") (defcustom package-load-list '(all) - "List of packages for `package-initialize' to make available. + "List of packages for `package-activate-all' to make available. Each element in this list should be a list (NAME VERSION), or the symbol `all'. The symbol `all' says to make available the latest installed versions of all packages not specified by other @@ -292,15 +292,18 @@ the package will be unavailable." :risky t :version "24.4") +;;;###autoload (defcustom package-user-dir (locate-user-emacs-file "elpa") "Directory containing the user's Emacs Lisp packages. The directory name should be absolute. Apart from this directory, Emacs also looks for system-wide packages in `package-directory-list'." :type 'directory + :initialize #'custom-initialize-delay :risky t :version "24.1") +;;;###autoload (defcustom package-directory-list ;; Defaults are subdirs named "elpa" in the site-lisp dirs. (let (result) @@ -315,6 +318,7 @@ Each directory name should be absolute. These directories contain packages intended for system-wide; in contrast, `package-user-dir' contains packages for personal use." :type '(repeat directory) + :initialize #'custom-initialize-delay :risky t :version "24.1") @@ -587,9 +591,8 @@ package." ;;; Installed packages ;; The following variables store information about packages present in ;; the system. The most important of these is `package-alist'. The -;; command `package-initialize' is also closely related to this -;; section, but it is left for a later section because it also affects -;; other stuff. +;; command `package-activate-all' is also closely related to this +;; section. (defvar package--builtins nil "Alist of built-in packages. @@ -608,7 +611,7 @@ name (a symbol) and DESCS is a non-empty list of `package-desc' structures, sorted by decreasing versions. This variable is set automatically by `package-load-descriptor', -called via `package-initialize'. To change which packages are +called via `package-activate-all'. To change which packages are loaded and/or activated, customize `package-load-list'.") (put 'package-alist 'risky-local-variable t) @@ -869,6 +872,20 @@ DIR, sorted by most recently loaded last." (lambda (x y) (< (cdr x) (cdr y)))))))) ;;;; `package-activate' + +(defun package--get-activatable-pkg (pkg-name) + ;; Is "activatable" a word? + (let ((pkg-descs (cdr (assq pkg-name package-alist)))) + ;; Check if PACKAGE is available in `package-alist'. + (while + (when pkg-descs + (let ((available-version (package-desc-version (car pkg-descs)))) + (or (package-disabled-p pkg-name available-version) + ;; Prefer a builtin package. + (package-built-in-p pkg-name available-version)))) + (setq pkg-descs (cdr pkg-descs))) + (car pkg-descs))) + ;; This function activates a newer version of a package if an older ;; one was already activated. It also loads a features of this ;; package which were already loaded. @@ -876,24 +893,16 @@ DIR, sorted by most recently loaded last." "Activate the package named PACKAGE. If FORCE is true, (re-)activate it if it's already activated. Newer versions are always activated, regardless of FORCE." - (let ((pkg-descs (cdr (assq package package-alist)))) - ;; Check if PACKAGE is available in `package-alist'. - (while - (when pkg-descs - (let ((available-version (package-desc-version (car pkg-descs)))) - (or (package-disabled-p package available-version) - ;; Prefer a builtin package. - (package-built-in-p package available-version)))) - (setq pkg-descs (cdr pkg-descs))) + (let ((pkg-desc (package--get-activatable-pkg package))) (cond ;; If no such package is found, maybe it's built-in. - ((null pkg-descs) + ((null pkg-desc) (package-built-in-p package)) ;; If the package is already activated, just return t. ((and (memq package package-activated-list) (not force)) t) ;; Otherwise, proceed with activation. - (t (package-activate-1 (car pkg-descs) nil 'deps))))) + (t (package-activate-1 pkg-desc nil 'deps))))) ;;; Installation -- Local operations @@ -1616,9 +1625,8 @@ that code in the early init-file." ;; `package--initialized' is t. (package--build-compatibility-table)) -(defvar package-quickstart-file) - ;;;###autoload +(progn ;; Make the function usable without loading `package.el'. (defun package-activate-all () "Activate all installed packages. The variable `package-load-list' controls which packages to load." @@ -1633,12 +1641,16 @@ The variable `package-load-list' controls which packages to load." ;; save this file so it doesn't need any decoding). (let ((load-source-file-function nil)) (load qs nil 'nomessage)) - (dolist (elt (package--alist)) - (condition-case err - (package-activate (car elt)) - ;; Don't let failure of activation of a package arbitrarily stop - ;; activation of further packages. - (error (message "%s" (error-message-string err)))))))) + (require 'package) + (package--activate-all))))) + +(defun package--activate-all () + (dolist (elt (package--alist)) + (condition-case err + (package-activate (car elt)) + ;; Don't let failure of activation of a package arbitrarily stop + ;; activation of further packages. + (error (message "%s" (error-message-string err)))))) ;;;; Populating `package-archive-contents' from archives ;; This subsection populates the variables listed above from the @@ -2066,6 +2078,13 @@ PACKAGES are satisfied, i.e. that PACKAGES is computed using `package-compute-transaction'." (mapc #'package-install-from-archive packages)) +(defun package--archives-initialize () + "Make sure the list of installed and remote packages are initialized." + (unless package--initialized + (package-initialize t)) + (unless package-archive-contents + (package-refresh-contents))) + ;;;###autoload (defun package-install (pkg &optional dont-select) "Install the package PKG. @@ -2086,10 +2105,7 @@ to install it but still mark it as selected." (progn ;; Initialize the package system to get the list of package ;; symbols for completion. - (unless package--initialized - (package-initialize t)) - (unless package-archive-contents - (package-refresh-contents)) + (package--archives-initialize) (list (intern (completing-read "Install package: " (delq nil @@ -2099,6 +2115,7 @@ to install it but still mark it as selected." package-archive-contents)) nil t)) nil))) + (package--archives-initialize) (add-hook 'post-command-hook #'package-menu--post-refresh) (let ((name (if (package-desc-p pkg) (package-desc-name pkg) @@ -3714,7 +3731,7 @@ short description." (package-menu--generate nil t))) ;; The package menu buffer has keybindings. If the user types ;; `M-x list-packages', that suggests it should become current. - (switch-to-buffer buf))) + (pop-to-buffer-same-window buf))) ;;;###autoload (defalias 'package-list-packages 'list-packages) @@ -4042,10 +4059,12 @@ activations need to be changed, such as when `package-load-list' is modified." :type 'boolean :version "27.1") +;;;###autoload (defcustom package-quickstart-file (locate-user-emacs-file "package-quickstart.el") "Location of the file used to speed up activation of packages at startup." :type 'file + :initialize #'custom-initialize-delay :version "27.1") (defun package--quickstart-maybe-refresh () @@ -4111,6 +4130,8 @@ activations need to be changed, such as when `package-load-list' is modified." ;; no-update-autoloads: t ;; End: ")) + ;; FIXME: Do it asynchronously in an Emacs subprocess, and + ;; don't show the byte-compiler warnings. (byte-compile-file package-quickstart-file))) (defun package--imenu-prev-index-position-function () @@ -4131,6 +4152,15 @@ beginning of the line." (package-version-join (package-desc-version package-desc)) (package-desc-summary package-desc)))) +;;;; Introspection + +(defun package-get-descriptor (pkg-name) + "Return the `package-desc' of PKG-NAME." + (unless package--initialized (package-initialize 'no-activate)) + (or (package--get-activatable-pkg pkg-name) + (cadr (assq pkg-name package-alist)) + (cadr (assq pkg-name package-archive-contents)))) + (provide 'package) ;;; package.el ends here diff --git a/lisp/startup.el b/lisp/startup.el index dfac0c8ed0c..57fd87f20f9 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1230,17 +1230,7 @@ please check its value") package-enable-at-startup (not (bound-and-true-p package--activated)) (catch 'package-dir-found - (let (dirs) - (if (boundp 'package-directory-list) - (setq dirs package-directory-list) - (dolist (f load-path) - (and (stringp f) - (equal (file-name-nondirectory f) "site-lisp") - (push (expand-file-name "elpa" f) dirs)))) - (push (if (boundp 'package-user-dir) - package-user-dir - (locate-user-emacs-file "elpa")) - dirs) + (let ((dirs (cons package-user-dir package-directory-list))) (dolist (dir dirs) (when (file-directory-p dir) (dolist (subdir (directory-files dir)) -- cgit v1.2.3 From 7d7bfbf0346114b116e14a4338ea235d12674f13 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 5 Jan 2021 17:57:15 -0500 Subject: * lisp/emacs-lisp/autoload.el: Improve last change It turns out there were other places that used `custom-initialize-delay` on autoloaded variables and used various hacks to make it work with `autoload.el`. The new code makes those hacks unneeded. Also, there's no point trying to "optimize" those rare cases anyway, so I simplified the `autoload.el` code for those cases. (make-autoload): For non-trivial cases, just include the whole `defcustom` instead of trying to mimic it. * lisp/mail/rmail.el (rmail-spool-directory): Remove hacks. * lisp/info.el (Info-default-directory-list): Remove `progn` hack. * lisp/custom.el (custom-declare-variable) (custom-handle-all-keywords): Don't use pseudo-group `nil`. --- lisp/custom.el | 8 ++++++-- lisp/emacs-lisp/autoload.el | 31 ++++++++++++++++++------------- lisp/info.el | 21 +++++++++------------ lisp/mail/rmail.el | 11 +---------- 4 files changed, 34 insertions(+), 37 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/custom.el b/lisp/custom.el index dfa8539c44f..d9d0898dcb7 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -161,7 +161,9 @@ set to nil, as the value is no longer rogue." ;; Whether automatically buffer-local. buffer-local) (unless (memq :group args) - (custom-add-to-group (custom-current-group) symbol 'custom-variable)) + (let ((cg (custom-current-group))) + (when cg + (custom-add-to-group cg symbol 'custom-variable)))) (while args (let ((keyword (pop args))) (unless (symbolp keyword) @@ -525,7 +527,9 @@ If no such group is found, return nil." "For customization option SYMBOL, handle keyword arguments ARGS. Third argument TYPE is the custom option type." (unless (memq :group args) - (custom-add-to-group (custom-current-group) symbol type)) + (let ((cg (custom-current-group))) + (when cg + (custom-add-to-group cg symbol type)))) (while args (let ((arg (car args))) (setq args (cdr args)) diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 77de05a6f68..ec7492dd4b1 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -220,22 +220,27 @@ expression, in which case we want to handle forms differently." ;; Convert defcustom to less space-consuming data. ((eq car 'defcustom) - (let ((varname (car-safe (cdr-safe form))) - (initializer (plist-get (nthcdr 4 form) :initialize)) - (init (car-safe (cdr-safe (cdr-safe form)))) - (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) - ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))) - ) + (let* ((varname (car-safe (cdr-safe form))) + (props (nthcdr 4 form)) + (initializer (plist-get props :initialize)) + (init (car-safe (cdr-safe (cdr-safe form)))) + (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form))))) + ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form))))) + ) `(progn - ,(if (null initializer) - `(defvar ,varname ,init ,doc) - `(progn (defvar ,varname nil ,doc) - (let ((exp ',init)) - (put ',varname 'standard-value (list exp)) - (,(eval initializer t) ',varname exp)))) + ,(if (not (member initializer '(nil 'custom-initialize-default + #'custom-initialize-default + 'custom-initialize-reset + #'custom-initialize-reset))) + form + `(defvar ,varname ,init ,doc)) + ;; When we include the complete `form', this `custom-autoload' + ;; is not indispensable, but it still helps in case the `defcustom' + ;; doesn't specify its group explicitly, and probably in a few other + ;; corner cases. (custom-autoload ',varname ,file ,(condition-case nil - (null (cadr (memq :set form))) + (null (plist-get props :set)) (error nil)))))) ((eq car 'defgroup) diff --git a/lisp/info.el b/lisp/info.el index ef94aa945f2..62d7b583ff2 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -160,17 +160,14 @@ A header-line does not scroll with the rest of the buffer." :version "24.4") ;; This is a defcustom largely so that we can get the benefit -;; of custom-initialize-delay. Perhaps it would work to make it a -;; defvar and explicitly give it a standard-value property, and -;; call custom-initialize-delay on it. -;; The progn forces the autoloader to include the whole thing, not -;; just an abbreviated version. The value is initialized at startup -;; time, when command-line calls custom-reevaluate-setting on all -;; the defcustoms in custom-delayed-init-variables. This is -;; somewhat sub-optimal, as ideally this should be done when Info -;; mode is first invoked. +;; of `custom-initialize-delay'. Perhaps it would work to make it a +;; `defvar' and explicitly give it a `standard-value' property, and +;; call `custom-initialize-delay' on it. +;; The value is initialized at startup time, when command-line calls +;; `custom-reevaluate-setting' on all the defcustoms in +;; `custom-delayed-init-variables'. This is somewhat sub-optimal, as ideally +;; this should be done when Info mode is first invoked. ;;;###autoload -(progn (defcustom Info-default-directory-list (let* ((config-dir (file-name-as-directory @@ -232,8 +229,8 @@ the environment variable INFOPATH is set. Although this is a customizable variable, that is mainly for technical reasons. Normally, you should either set INFOPATH or customize `Info-additional-directory-list', rather than changing this variable." - :initialize 'custom-initialize-delay - :type '(repeat directory))) + :initialize #'custom-initialize-delay + :type '(repeat directory)) (defvar Info-directory-list nil "List of directories to search for Info documentation files. diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 69797837cd2..29460cc20f5 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -160,13 +160,6 @@ its character representation and its display representation.") :group 'rmail :version "21.1") -;;;###autoload -(put 'rmail-spool-directory 'standard-value - '((cond ((file-exists-p "/var/mail") "/var/mail/") - ((file-exists-p "/var/spool/mail") "/var/spool/mail/") - ((memq system-type '(hpux usg-unix-v)) "/usr/mail/") - (t "/usr/spool/mail/")))) - ;;;###autoload (defcustom rmail-spool-directory (purecopy @@ -181,12 +174,10 @@ its character representation and its display representation.") (t "/usr/spool/mail/"))) "Name of directory used by system mailer for delivering new mail. Its name should end with a slash." - :initialize 'custom-initialize-delay + :initialize #'custom-initialize-delay :type 'directory :group 'rmail) -;;;###autoload(custom-initialize-delay 'rmail-spool-directory nil) - (defcustom rmail-movemail-program nil "If non-nil, the file name of the `movemail' program." :group 'rmail-retrieve -- cgit v1.2.3 From cf672c66711c0aa24500cab99eb7f2ef63b02bf2 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 5 Jan 2021 21:26:03 -0500 Subject: * lisp/emacs-lisp/package.el (package-activate-all): Another tweak `package-quickstart.el` files presume `package-activated-list` is a bound variable, so make sure this is the case even when `package.el` is not yet loaded. --- lisp/emacs-lisp/package.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index a38363df23e..453e86c7831 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1640,6 +1640,8 @@ The variable `package-load-list' controls which packages to load." ;; 2 when loading the .el file (this assumes we were careful to ;; save this file so it doesn't need any decoding). (let ((load-source-file-function nil)) + (unless (boundp 'package-activated-list) + (setq package-activated-list nil)) (load qs nil 'nomessage)) (require 'package) (package--activate-all))))) -- cgit v1.2.3 From 96bbbaec5c1b2612946ff08abf9d43e7478e8c43 Mon Sep 17 00:00:00 2001 From: Michael Heerdegen Date: Tue, 22 Dec 2020 05:44:47 +0100 Subject: Fix obsolete variable warnings about class names * lisp/emacs-lisp/eieio-core.el (eieio-defclass-autoload): Try to make the wording of the warning about the obsoleted variable less confusing. * lisp/emacs-lisp/bytecomp.el (byte-compile-check-variable): Don't warn for lexical variables (Bug#39169). Fix spurious `or'. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp/warn-obsolete-variable-bound\.el): New test. * test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el: New file. --- lisp/emacs-lisp/bytecomp.el | 9 +++++---- lisp/emacs-lisp/eieio-core.el | 3 ++- .../bytecomp-resources/warn-obsolete-variable-bound.el | 7 +++++++ test/lisp/emacs-lisp/bytecomp-tests.el | 3 +++ 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 76457814acd..360da6b6ba6 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3441,10 +3441,11 @@ for symbols generated by the byte compiler itself." (and od (not (memq var byte-compile-not-obsolete-vars)) (not (memq var byte-compile-global-not-obsolete-vars)) - (or (pcase (nth 1 od) - ('set (not (eq access-type 'reference))) - ('get (eq access-type 'reference)) - (_ t))))) + (not (memq var byte-compile-lexical-variables)) + (pcase (nth 1 od) + ('set (not (eq access-type 'reference))) + ('get (eq access-type 'reference)) + (_ t)))) (byte-compile-warn-obsolete var)))) (defsubst byte-compile-dynamic-variable-op (base-op var) diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 3e5e9b95235..a8361c0d4b4 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el @@ -215,7 +215,8 @@ It creates an autoload function for CNAME's constructor." ;; turn this into a usable self-pointing symbol (when eieio-backward-compatibility (set cname cname) - (make-obsolete-variable cname (format "use \\='%s instead" cname) + (make-obsolete-variable cname (format "\ +use \\='%s or turn off `eieio-backward-compatibility' instead" cname) "25.1")) (setf (cl--find-class cname) newc) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el new file mode 100644 index 00000000000..e65a541e6e3 --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el @@ -0,0 +1,7 @@ +;;; -*- lexical-binding: t -*- + +(make-obsolete-variable 'bytecomp--tests-obsolete-var-2 nil "99.99") + +(defun foo () + (let ((bytecomp--tests-obsolete-var-2 2)) + bytecomp--tests-obsolete-var-2)) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 5e5f99dbdab..a07af188fac 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -625,6 +625,9 @@ Subtests signal errors if something goes wrong." (bytecomp--define-warning-file-test "warn-obsolete-variable.el" "bytecomp--tests-obs.*obsolete.*99.99") +(bytecomp--define-warning-file-test "warn-obsolete-variable-bound.el" + "bytecomp--tests-obs.*obsolete.*99.99" t) + (bytecomp--define-warning-file-test "warn-redefine-defun-as-macro.el" "as both function and macro") -- cgit v1.2.3