diff options
| author | Stefan Monnier | 2012-09-20 09:46:36 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-09-20 09:46:36 -0400 |
| commit | 95b9712e9e3e8df09ad07423012bfbd978239014 (patch) | |
| tree | 04ffa4bc0b34d4ffd3a6ed916b8ec6001a26e119 | |
| parent | f490dab981c46011d22b19b697fc979aa736a221 (diff) | |
| download | emacs-95b9712e9e3e8df09ad07423012bfbd978239014.tar.gz emacs-95b9712e9e3e8df09ad07423012bfbd978239014.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 16 | ||||
| -rw-r--r-- | lisp/emacs-lisp/macroexp.el | 46 |
3 files changed, 39 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7f9a15d9dfc..8b99fc29252 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2012-09-20 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2012-09-20 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/macroexp.el (macroexp--obsolete-warning): New function. | ||
| 4 | (macroexp--expand-all): Use it. | ||
| 5 | (macroexp--funcall-and-return): Remove by folding it into its sole | ||
| 6 | caller (macroexp--warn-and-return). | ||
| 7 | * emacs-lisp/bytecomp.el (byte-compile-warn-obsolete): | ||
| 8 | Use macroexp--obsolete-warning. | ||
| 9 | |||
| 3 | * calc/calc.el: Fix last change by removing the whole chunk, since it | 10 | * calc/calc.el: Fix last change by removing the whole chunk, since it |
| 4 | was only needed back when Calc was not bundled. | 11 | was only needed back when Calc was not bundled. |
| 5 | 12 | ||
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'." | |||
| 1115 | "Warn that SYMBOL (a variable or function) is obsolete." | 1115 | "Warn that SYMBOL (a variable or function) is obsolete." |
| 1116 | (when (byte-compile-warning-enabled-p 'obsolete) | 1116 | (when (byte-compile-warning-enabled-p 'obsolete) |
| 1117 | (let* ((funcp (get symbol 'byte-obsolete-info)) | 1117 | (let* ((funcp (get symbol 'byte-obsolete-info)) |
| 1118 | (obsolete (or funcp (get symbol 'byte-obsolete-variable))) | 1118 | (msg (macroexp--obsolete-warning |
| 1119 | (instead (car obsolete)) | 1119 | symbol |
| 1120 | (asof (nth 2 obsolete))) | 1120 | (or funcp (get symbol 'byte-obsolete-variable)) |
| 1121 | (if funcp "function" "variable")))) | ||
| 1121 | (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs)) | 1122 | (unless (and funcp (memq symbol byte-compile-not-obsolete-funcs)) |
| 1122 | (byte-compile-warn "`%s' is an obsolete %s%s%s" symbol | 1123 | (byte-compile-warn "%s" msg))))) |
| 1123 | (if funcp "function" "variable") | ||
| 1124 | (if asof (concat " (as of " asof ")") "") | ||
| 1125 | (cond ((stringp instead) | ||
| 1126 | (concat "; " instead)) | ||
| 1127 | (instead | ||
| 1128 | (format "; use `%s' instead." instead)) | ||
| 1129 | (t "."))))))) | ||
| 1130 | 1124 | ||
| 1131 | (defun byte-compile-report-error (error-info) | 1125 | (defun byte-compile-report-error (error-info) |
| 1132 | "Report Lisp error in compilation. ERROR-INFO is the error data." | 1126 | "Report Lisp error in compilation. ERROR-INFO is the error data." |
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." | |||
| 111 | (funcall (eval (cadr form))) | 111 | (funcall (eval (cadr form))) |
| 112 | (byte-compile-constant nil))) | 112 | (byte-compile-constant nil))) |
| 113 | 113 | ||
| 114 | (defun macroexp--funcall-and-return (when-compiled when-interpreted form) | 114 | (defun macroexp--warn-and-return (msg form) |
| 115 | ;; FIXME: ¡¡Major Ugly Hack!! To determine whether the output of this | 115 | (let ((when-compiled (lambda () (byte-compile-log-warning msg t)))) |
| 116 | ;; macro-expansion will be processed by the byte-compiler, we check | 116 | (cond |
| 117 | ;; circumstantial evidence. | 117 | ((null msg) form) |
| 118 | (if (member '(declare-function . byte-compile-macroexpand-declare-function) | 118 | ;; FIXME: ¡¡Major Ugly Hack!! To determine whether the output of this |
| 119 | macroexpand-all-environment) | 119 | ;; macro-expansion will be processed by the byte-compiler, we check |
| 120 | ;; circumstantial evidence. | ||
| 121 | ((member '(declare-function . byte-compile-macroexpand-declare-function) | ||
| 122 | macroexpand-all-environment) | ||
| 120 | `(progn | 123 | `(progn |
| 121 | (macroexp--funcall-if-compiled ',when-compiled) | 124 | (macroexp--funcall-if-compiled ',when-compiled) |
| 122 | ,form) | 125 | ,form)) |
| 123 | (funcall when-interpreted) | 126 | (t |
| 124 | form)) | 127 | (message "%s" msg) |
| 125 | 128 | form)))) | |
| 126 | (defun macroexp--warn-and-return (msg form) | 129 | |
| 127 | (macroexp--funcall-and-return | 130 | (defun macroexp--obsolete-warning (fun obsolescence-data type) |
| 128 | (lambda () (byte-compile-log-warning msg t)) | 131 | (let ((instead (car obsolescence-data)) |
| 129 | (lambda () (message "%s" msg)) | 132 | (asof (nth 2 obsolescence-data))) |
| 130 | form)) | 133 | (format "`%s' is an obsolete %s%s%s" fun type |
| 134 | (if asof (concat " (as of " asof ")") "") | ||
| 135 | (cond ((stringp instead) (concat "; " instead)) | ||
| 136 | (instead (format "; use `%s' instead." instead)) | ||
| 137 | (t "."))))) | ||
| 131 | 138 | ||
| 132 | (defun macroexp--expand-all (form) | 139 | (defun macroexp--expand-all (form) |
| 133 | "Expand all macros in FORM. | 140 | "Expand all macros in FORM. |
| @@ -148,10 +155,11 @@ Assumes the caller has bound `macroexpand-all-environment'." | |||
| 148 | (car-safe form) | 155 | (car-safe form) |
| 149 | (symbolp (car form)) | 156 | (symbolp (car form)) |
| 150 | (get (car form) 'byte-obsolete-info)) | 157 | (get (car form) 'byte-obsolete-info)) |
| 151 | (macroexp--funcall-and-return | 158 | (let* ((fun (car form)) |
| 152 | (lambda () (byte-compile-warn-obsolete (car form))) | 159 | (obsolete (get fun 'byte-obsolete-info))) |
| 153 | #'ignore ;FIXME: We should `message' something. | 160 | (macroexp--warn-and-return |
| 154 | new-form) | 161 | (macroexp--obsolete-warning fun obsolete "macro") |
| 162 | new-form)) | ||
| 155 | new-form))) | 163 | new-form))) |
| 156 | (pcase form | 164 | (pcase form |
| 157 | (`(cond . ,clauses) | 165 | (`(cond . ,clauses) |