diff options
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/byte-run.el | 2 | ||||
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 16 | ||||
-rw-r--r-- | lisp/emacs-lisp/cl-lib.el | 2 | ||||
-rw-r--r-- | lisp/emacs-lisp/debug.el | 10 | ||||
-rw-r--r-- | lisp/emacs-lisp/macroexp.el | 57 | ||||
-rw-r--r-- | lisp/emacs-lisp/shadow.el | 8 |
6 files changed, 57 insertions, 38 deletions
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index d1382f42b19..93e890a20c9 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -312,7 +312,7 @@ This uses `defvaralias' and `make-obsolete-variable' (which see). See the Info node `(elisp)Variable Aliases' for more details. If CURRENT-NAME is a defcustom (more generally, any variable -where OBSOLETE-NAME may be set, e.g. in a .emacs file, before the +where OBSOLETE-NAME may be set, e.g. in an init file, before the alias is defined), then the define-obsolete-variable-alias statement should be evaluated before the defcustom, if user customizations are to be respected. The simplest way to achieve diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index c42ae21aae5..7a229750178 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1115,18 +1115,12 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." "Warn that SYMBOL (a variable or function) is obsolete." (when (byte-compile-warning-enabled-p 'obsolete) (let* ((funcp (get symbol 'byte-obsolete-info)) - (obsolete (or funcp (get symbol 'byte-obsolete-variable))) - (instead (car obsolete)) - (asof (nth 2 obsolete))) + (msg (macroexp--obsolete-warning + symbol + (or funcp (get symbol 'byte-obsolete-variable)) + (if funcp "function" "variable")))) (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs)) - (byte-compile-warn "`%s' is an obsolete %s%s%s" symbol - (if funcp "function" "variable") - (if asof (concat " (as of " asof ")") "") - (cond ((stringp instead) - (concat "; " instead)) - (instead - (format "; use `%s' instead." instead)) - (t "."))))))) + (byte-compile-warn "%s" msg))))) (defun byte-compile-report-error (error-info) "Report Lisp error in compilation. ERROR-INFO is the error data." diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el index 532c81c502c..5749ff91b40 100644 --- a/lisp/emacs-lisp/cl-lib.el +++ b/lisp/emacs-lisp/cl-lib.el @@ -121,7 +121,7 @@ a future Emacs interpreter will be able to use it.") ;;; Generalized variables. ;; These macros are defined here so that they -;; can safely be used in .emacs files. +;; can safely be used in init files. (defmacro cl-incf (place &optional x) "Increment PLACE by X (1 by default). diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 774b4d3d600..6fd52d67b90 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -75,9 +75,9 @@ window previously showing the debugger buffer. The value used here is passed to `quit-restore-window'." :type '(choice (const :tag "Keep alive" nil) - (const :tag "Append" 'append) - (const :tag "Bury" 'bury) - (const :tag "Kill" 'kill)) + (const :tag "Append" append) + (const :tag "Bury" bury) + (const :tag "Kill" kill)) :group 'debugger :version "24.2") @@ -166,6 +166,7 @@ first will be printed into the backtrace buffer." (with-current-buffer (get-buffer "*Backtrace*") (list major-mode (buffer-string))))) (debugger-buffer (get-buffer-create "*Backtrace*")) + (debugger-old-buffer (current-buffer)) (debugger-window nil) (debugger-step-after-exit nil) (debugger-will-be-back nil) @@ -265,7 +266,8 @@ first will be printed into the backtrace buffer." ;; Make sure we unbind buffer-read-only in the right buffer. (save-excursion (recursive-edit)))) - (when (and (window-live-p debugger-window) + (when (and (not debugger-will-be-back) + (window-live-p debugger-window) (eq (window-buffer debugger-window) debugger-buffer)) ;; Record height of debugger window. (setq debugger-previous-window-height diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 394225d697e..cab693fecac 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -100,17 +100,42 @@ each clause." (error (message "Compiler-macro error for %S: %S" (car form) err) form))) -(defun macroexp--eval-if-compile (&rest _forms) +(defun macroexp--funcall-if-compiled (_form) "Pseudo function used internally by macroexp to delay warnings. The purpose is to delay warnings to bytecomp.el, so they can use things like `byte-compile-log-warning' to get better file-and-line-number data and also to avoid outputting the warning during normal execution." nil) -(put 'macroexp--eval-if-compile 'byte-compile +(put 'macroexp--funcall-if-compiled 'byte-compile (lambda (form) - (mapc (lambda (x) (funcall (eval x))) (cdr form)) + (funcall (eval (cadr form))) (byte-compile-constant nil))) +(defun macroexp--warn-and-return (msg form) + (let ((when-compiled (lambda () (byte-compile-log-warning msg t)))) + (cond + ((null msg) form) + ;; FIXME: ¡¡Major Ugly Hack!! To determine whether the output of this + ;; macro-expansion will be processed by the byte-compiler, we check + ;; circumstantial evidence. + ((member '(declare-function . byte-compile-macroexpand-declare-function) + macroexpand-all-environment) + `(progn + (macroexp--funcall-if-compiled ',when-compiled) + ,form)) + (t + (message "%s" msg) + form)))) + +(defun macroexp--obsolete-warning (fun obsolescence-data type) + (let ((instead (car obsolescence-data)) + (asof (nth 2 obsolescence-data))) + (format "`%s' is an obsolete %s%s%s" fun type + (if asof (concat " (as of " asof ")") "") + (cond ((stringp instead) (concat "; " instead)) + (instead (format "; use `%s' instead." instead)) + (t "."))))) + (defun macroexp--expand-all (form) "Expand all macros in FORM. This is an internal version of `macroexpand-all'. @@ -130,9 +155,11 @@ Assumes the caller has bound `macroexpand-all-environment'." (car-safe form) (symbolp (car form)) (get (car form) 'byte-obsolete-info)) - `(progn (macroexp--eval-if-compile - (lambda () (byte-compile-warn-obsolete ',(car form)))) - ,new-form) + (let* ((fun (car form)) + (obsolete (get fun 'byte-obsolete-info))) + (macroexp--warn-and-return + (macroexp--obsolete-warning fun obsolete "macro") + new-form)) new-form))) (pcase form (`(cond . ,clauses) @@ -175,26 +202,16 @@ Assumes the caller has bound `macroexpand-all-environment'." ;; First arg is a function: (`(,(and fun (or `funcall `apply `mapcar `mapatoms `mapconcat `mapc)) ',(and f `(lambda . ,_)) . ,args) - (byte-compile-log-warning + (macroexp--warn-and-return (format "%s quoted with ' rather than with #'" (list 'lambda (nth 1 f) '...)) - t) - ;; We don't use `macroexp--cons' since there's clearly a change. - (cons fun - (cons (macroexp--expand-all (list 'function f)) - (macroexp--all-forms args)))) + (macroexp--expand-all `(,fun ,f . ,args)))) ;; Second arg is a function: (`(,(and fun (or `sort)) ,arg1 ',(and f `(lambda . ,_)) . ,args) - (byte-compile-log-warning + (macroexp--warn-and-return (format "%s quoted with ' rather than with #'" (list 'lambda (nth 1 f) '...)) - t) - ;; We don't use `macroexp--cons' since there's clearly a change. - (cons fun - (cons (macroexp--expand-all arg1) - (cons (macroexp--expand-all - (list 'function f)) - (macroexp--all-forms args))))) + (macroexp--expand-all `(,fun ,arg1 ,f . ,args)))) (`(,func . ,_) ;; Macro expand compiler macros. This cannot be delayed to ;; byte-optimize-form because the output of the compiler-macro can diff --git a/lisp/emacs-lisp/shadow.el b/lisp/emacs-lisp/shadow.el index 286c4937b5b..bceec296ad8 100644 --- a/lisp/emacs-lisp/shadow.el +++ b/lisp/emacs-lisp/shadow.el @@ -158,8 +158,14 @@ See the documentation for `list-load-path-shadows' for further information." (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2)))))))) (defvar load-path-shadows-font-lock-keywords + ;; The idea is that shadows of files supplied with Emacs are more + ;; serious than various versions of external packages shadowing each + ;; other. `((,(format "hides \\(%s.*\\)" - (file-name-directory (locate-library "simple.el"))) + (file-name-directory + (or (locate-library "simple") + (file-name-as-directory + (expand-file-name "../lisp" data-directory))))) . (1 font-lock-warning-face))) "Keywords to highlight in `load-path-shadows-mode'.") |