emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110115: * lisp/emacs-lisp/macroexp.e


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110115: * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): New function.
Date: Thu, 20 Sep 2012 09:46:36 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110115
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2012-09-20 09:46:36 -0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/bytecomp.el
  lisp/emacs-lisp/macroexp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-09-20 13:44:45 +0000
+++ b/lisp/ChangeLog    2012-09-20 13:46:36 +0000
@@ -1,5 +1,12 @@
 2012-09-20  Stefan Monnier  <address@hidden>
 
+       * 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).
+       * emacs-lisp/bytecomp.el (byte-compile-warn-obsolete):
+       Use macroexp--obsolete-warning.
+
        * calc/calc.el: Fix last change by removing the whole chunk, since it
        was only needed back when Calc was not bundled.
 

=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- a/lisp/emacs-lisp/bytecomp.el       2012-09-13 02:41:46 +0000
+++ b/lisp/emacs-lisp/bytecomp.el       2012-09-20 13:46:36 +0000
@@ -1115,18 +1115,12 @@
   "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."

=== modified file 'lisp/emacs-lisp/macroexp.el'
--- a/lisp/emacs-lisp/macroexp.el       2012-09-20 03:29:41 +0000
+++ b/lisp/emacs-lisp/macroexp.el       2012-09-20 13:46:36 +0000
@@ -111,23 +111,30 @@
        (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))
+         ,form))
+     (t
+      (message "%s" msg)
+      form))))
 
-(defun macroexp--warn-and-return (msg form)
-  (macroexp--funcall-and-return
-   (lambda () (byte-compile-log-warning msg t))
-   (lambda () (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 @@
                      (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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]