aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2009-10-01 04:38:52 +0000
committerStefan Monnier2009-10-01 04:38:52 +0000
commite3a6b82fc7a8698217fa5fc76ef26fa078c18c6b (patch)
tree2797550b1bb348fcaa708bd5b0806e418ccce078
parent8af8468f8bbe7108469a483282f8e819d6f3bd46 (diff)
downloademacs-e3a6b82fc7a8698217fa5fc76ef26fa078c18c6b.tar.gz
emacs-e3a6b82fc7a8698217fa5fc76ef26fa078c18c6b.zip
(byte-compile-defmacro-declaration): New fun.
(byte-compile-file-form-defmumble, byte-compile-defmacro): Use it. (byte-compile-defmacro): Use backquotes.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/bytecomp.el47
2 files changed, 33 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 552ee4538b5..9a0a42f662e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,9 @@
12009-10-01 Stefan Monnier <monnier@iro.umontreal.ca> 12009-10-01 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * emacs-lisp/bytecomp.el (byte-compile-defmacro-declaration): New fun.
4 (byte-compile-file-form-defmumble, byte-compile-defmacro): Use it.
5 (byte-compile-defmacro): Use backquotes.
6
3 * files.el (cd-absolute): Don't abbreviate-file-name (bug#4599). 7 * files.el (cd-absolute): Don't abbreviate-file-name (bug#4599).
4 8
5 * vc-dispatcher.el (vc-resynch-window): Don't revert a buffer which 9 * vc-dispatcher.el (vc-resynch-window): Don't revert a buffer which
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 7903bf6a1d9..79e0885137b 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2429,6 +2429,24 @@ list that represents a doc string reference.
2429(defun byte-compile-file-form-defmacro (form) 2429(defun byte-compile-file-form-defmacro (form)
2430 (byte-compile-file-form-defmumble form t)) 2430 (byte-compile-file-form-defmumble form t))
2431 2431
2432(defun byte-compile-defmacro-declaration (form)
2433 "Generate code for declarations in macro definitions.
2434Remove declarations from the body of the macro definition
2435by side-effects."
2436 (let ((tail (nthcdr 2 form))
2437 (res '()))
2438 (when (stringp (car (cdr tail)))
2439 (setq tail (cdr tail)))
2440 (while (and (consp (car (cdr tail)))
2441 (eq (car (car (cdr tail))) 'declare))
2442 (let ((declaration (car (cdr tail))))
2443 (setcdr tail (cdr (cdr tail)))
2444 (push `(if macro-declaration-function
2445 (funcall macro-declaration-function
2446 ',(car (cdr form)) ',declaration))
2447 res)))
2448 res))
2449
2432(defun byte-compile-file-form-defmumble (form macrop) 2450(defun byte-compile-file-form-defmumble (form macrop)
2433 (let* ((bytecomp-name (car (cdr form))) 2451 (let* ((bytecomp-name (car (cdr form)))
2434 (bytecomp-this-kind (if macrop 'byte-compile-macro-environment 2452 (bytecomp-this-kind (if macrop 'byte-compile-macro-environment
@@ -2498,17 +2516,8 @@ list that represents a doc string reference.
2498 ;; Generate code for declarations in macro definitions. 2516 ;; Generate code for declarations in macro definitions.
2499 ;; Remove declarations from the body of the macro definition. 2517 ;; Remove declarations from the body of the macro definition.
2500 (when macrop 2518 (when macrop
2501 (let ((tail (nthcdr 2 form))) 2519 (dolist (decl (byte-compile-defmacro-declaration form))
2502 (when (stringp (car (cdr tail))) 2520 (prin1 decl bytecomp-outbuffer)))
2503 (setq tail (cdr tail)))
2504 (while (and (consp (car (cdr tail)))
2505 (eq (car (car (cdr tail))) 'declare))
2506 (let ((declaration (car (cdr tail))))
2507 (setcdr tail (cdr (cdr tail)))
2508 (prin1 `(if macro-declaration-function
2509 (funcall macro-declaration-function
2510 ',bytecomp-name ',declaration))
2511 bytecomp-outbuffer)))))
2512 2521
2513 (let* ((new-one (byte-compile-lambda (nthcdr 2 form) t)) 2522 (let* ((new-one (byte-compile-lambda (nthcdr 2 form) t))
2514 (code (byte-compile-byte-code-maker new-one))) 2523 (code (byte-compile-byte-code-maker new-one)))
@@ -4003,13 +4012,15 @@ that suppresses all warnings during execution of BODY."
4003(defun byte-compile-defmacro (form) 4012(defun byte-compile-defmacro (form)
4004 ;; This is not used for file-level defmacros with doc strings. 4013 ;; This is not used for file-level defmacros with doc strings.
4005 (byte-compile-body-do-effect 4014 (byte-compile-body-do-effect
4006 (list (list 'fset (list 'quote (nth 1 form)) 4015 (let ((decls (byte-compile-defmacro-declaration form))
4007 (let ((code (byte-compile-byte-code-maker 4016 (code (byte-compile-byte-code-maker
4008 (byte-compile-lambda (cdr (cdr form)) t)))) 4017 (byte-compile-lambda (cdr (cdr form)) t))))
4009 (if (eq (car-safe code) 'make-byte-code) 4018 `((defalias ',(nth 1 form)
4010 (list 'cons ''macro code) 4019 ,(if (eq (car-safe code) 'make-byte-code)
4011 (list 'quote (cons 'macro (eval code)))))) 4020 `(cons 'macro ,code)
4012 (list 'quote (nth 1 form))))) 4021 `'(macro . ,(eval code))))
4022 ,@decls
4023 ',(nth 1 form)))))
4013 4024
4014(defun byte-compile-defvar (form) 4025(defun byte-compile-defvar (form)
4015 ;; This is not used for file-level defvar/consts with doc strings. 4026 ;; This is not used for file-level defvar/consts with doc strings.