aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2012-09-19 15:59:52 -0400
committerStefan Monnier <[email protected]>2012-09-19 15:59:52 -0400
commitce97595bd4604270075a0a7ff04bceaa97b42d9f (patch)
tree820cc64a02f01472a80e3aa848501e325ef52f58 /lisp
parent46624b4fa190e1bc7265494ff2f4b9990f577830 (diff)
* lisp/emacs-lisp/macroexp.el (macroexp--funcall-if-compiled): Rename from
macroexp--eval-if-compile. (macroexp--funcall-and-return, macroexp--warn-and-return): New funs. (macroexp--expand-all): Use them. Fixes: debbugs:12371
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/emacs-lisp/macroexp.el50
2 files changed, 35 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8d90c818d2..d5e01ed08a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,10 @@
2012-09-19 Stefan Monnier <[email protected]>
+ * emacs-lisp/macroexp.el (macroexp--funcall-if-compiled): Rename from
+ macroexp--eval-if-compile.
+ (macroexp--funcall-and-return, macroexp--warn-and-return): New funs.
+ (macroexp--expand-all): Use them (bug#12371).
+
* doc-view.el (doc-view-guess-paper-size)
(doc-view-scale-bounding-box): Fix unbound `caddr'.
@@ -174,8 +179,8 @@
(display-buffer-function): Mark as obsolete.
* progmodes/compile.el (compilation-parse-errors): Accept list
- values similar to font-lock-keywords (Bug#12136). Suggested by
- Oleksandr Manzyuk.
+ values similar to font-lock-keywords (Bug#12136).
+ Suggested by Oleksandr Manzyuk.
(compilation-error-regexp-alist): Doc fix.
2012-09-15 Glenn Morris <[email protected]>
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 13064800cd..6a84be0672 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -100,19 +100,34 @@ 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)))
-(autoload 'byte-compile-warn-obsolete "bytecomp")
-(autoload 'byte-compile-log-warning "bytecomp")
+(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)
+ `(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))
(defun macroexp--expand-all (form)
"Expand all macros in FORM.
@@ -133,9 +148,10 @@ 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)
+ (macroexp--funcall-and-return
+ (lambda () (byte-compile-warn-obsolete ',(car form)))
+ #'ignore ;FIXME: We should `message' something.
+ new-form)
new-form)))
(pcase form
(`(cond . ,clauses)
@@ -178,26 +194,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