emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/bytecomp.el


From: Stefan Monnier
Subject: [Emacs-diffs] emacs/lisp ChangeLog emacs-lisp/bytecomp.el
Date: Thu, 01 Oct 2009 04:38:56 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        09/10/01 04:38:55

Modified files:
        lisp           : ChangeLog 
        lisp/emacs-lisp: bytecomp.el 

Log message:
        (byte-compile-defmacro-declaration): New fun.
        (byte-compile-file-form-defmumble, byte-compile-defmacro): Use it.
        (byte-compile-defmacro): Use backquotes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16312&r2=1.16313
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/bytecomp.el?cvsroot=emacs&r1=2.263&r2=2.264

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16312
retrieving revision 1.16313
diff -u -b -r1.16312 -r1.16313
--- ChangeLog   1 Oct 2009 04:10:10 -0000       1.16312
+++ ChangeLog   1 Oct 2009 04:38:52 -0000       1.16313
@@ -1,5 +1,9 @@
 2009-10-01  Stefan Monnier  <address@hidden>
 
+       * emacs-lisp/bytecomp.el (byte-compile-defmacro-declaration): New fun.
+       (byte-compile-file-form-defmumble, byte-compile-defmacro): Use it.
+       (byte-compile-defmacro): Use backquotes.
+
        * files.el (cd-absolute): Don't abbreviate-file-name (bug#4599).
 
        * vc-dispatcher.el (vc-resynch-window): Don't revert a buffer which

Index: emacs-lisp/bytecomp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.263
retrieving revision 2.264
diff -u -b -r2.263 -r2.264
--- emacs-lisp/bytecomp.el      17 Sep 2009 07:29:46 -0000      2.263
+++ emacs-lisp/bytecomp.el      1 Oct 2009 04:38:55 -0000       2.264
@@ -2429,6 +2429,24 @@
 (defun byte-compile-file-form-defmacro (form)
   (byte-compile-file-form-defmumble form t))
 
+(defun byte-compile-defmacro-declaration (form)
+  "Generate code for declarations in macro definitions.
+Remove declarations from the body of the macro definition
+by side-effects."
+  (let ((tail (nthcdr 2 form))
+        (res '()))
+    (when (stringp (car (cdr tail)))
+      (setq tail (cdr tail)))
+    (while (and (consp (car (cdr tail)))
+                (eq (car (car (cdr tail))) 'declare))
+      (let ((declaration (car (cdr tail))))
+        (setcdr tail (cdr (cdr tail)))
+        (push `(if macro-declaration-function
+                   (funcall macro-declaration-function
+                            ',(car (cdr form)) ',declaration))
+              res)))
+    res))
+
 (defun byte-compile-file-form-defmumble (form macrop)
   (let* ((bytecomp-name (car (cdr form)))
         (bytecomp-this-kind (if macrop 'byte-compile-macro-environment
@@ -2498,17 +2516,8 @@
     ;; Generate code for declarations in macro definitions.
     ;; Remove declarations from the body of the macro definition.
     (when macrop
-      (let ((tail (nthcdr 2 form)))
-       (when (stringp (car (cdr tail)))
-         (setq tail (cdr tail)))
-       (while (and (consp (car (cdr tail)))
-                   (eq (car (car (cdr tail))) 'declare))
-         (let ((declaration (car (cdr tail))))
-           (setcdr tail (cdr (cdr tail)))
-           (prin1 `(if macro-declaration-function
-                       (funcall macro-declaration-function
-                                ',bytecomp-name ',declaration))
-                  bytecomp-outbuffer)))))
+      (dolist (decl (byte-compile-defmacro-declaration form))
+        (prin1 decl bytecomp-outbuffer)))
 
     (let* ((new-one (byte-compile-lambda (nthcdr 2 form) t))
           (code (byte-compile-byte-code-maker new-one)))
@@ -4003,13 +4012,15 @@
 (defun byte-compile-defmacro (form)
   ;; This is not used for file-level defmacros with doc strings.
   (byte-compile-body-do-effect
-   (list (list 'fset (list 'quote (nth 1 form))
-              (let ((code (byte-compile-byte-code-maker
+   (let ((decls (byte-compile-defmacro-declaration form))
+         (code (byte-compile-byte-code-maker
                            (byte-compile-lambda (cdr (cdr form)) t))))
-                (if (eq (car-safe code) 'make-byte-code)
-                    (list 'cons ''macro code)
-                  (list 'quote (cons 'macro (eval code))))))
-        (list 'quote (nth 1 form)))))
+     `((defalias ',(nth 1 form)
+         ,(if (eq (car-safe code) 'make-byte-code)
+              `(cons 'macro ,code)
+            `'(macro . ,(eval code))))
+       ,@decls
+       ',(nth 1 form)))))
 
 (defun byte-compile-defvar (form)
   ;; This is not used for file-level defvar/consts with doc strings.




reply via email to

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