diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-09-20 09:46:36 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-09-20 09:46:36 -0400 |
commit | 95b9712e9e3e8df09ad07423012bfbd978239014 (patch) | |
tree | 04ffa4bc0b34d4ffd3a6ed916b8ec6001a26e119 /lisp/emacs-lisp/macroexp.el | |
parent | f490dab981c46011d22b19b697fc979aa736a221 (diff) | |
download | emacs-95b9712e9e3e8df09ad07423012bfbd978239014.tar.gz |
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): New function.
(macroexp--expand-all): Use it.
(macroexp--funcall-and-return): Remove by folding it into its sole
caller (macroexp--warn-and-return).
* lisp/emacs-lisp/bytecomp.el (byte-compile-warn-obsolete):
Use macroexp--obsolete-warning.
Diffstat (limited to 'lisp/emacs-lisp/macroexp.el')
-rw-r--r-- | lisp/emacs-lisp/macroexp.el | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index f9be3e4fcc4..cab693fecac 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -111,23 +111,30 @@ and also to avoid outputting the warning during normal execution." (funcall (eval (cadr form))) (byte-compile-constant nil))) -(defun macroexp--funcall-and-return (when-compiled when-interpreted 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. - (if (member '(declare-function . byte-compile-macroexpand-declare-function) - macroexpand-all-environment) +(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) - (funcall when-interpreted) - form)) - -(defun macroexp--warn-and-return (msg form) - (macroexp--funcall-and-return - (lambda () (byte-compile-log-warning msg t)) - (lambda () (message "%s" msg)) - form)) + ,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. @@ -148,10 +155,11 @@ Assumes the caller has bound `macroexpand-all-environment'." (car-safe form) (symbolp (car form)) (get (car form) 'byte-obsolete-info)) - (macroexp--funcall-and-return - (lambda () (byte-compile-warn-obsolete (car form))) - #'ignore ;FIXME: We should `message' something. - 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) |