GNU bug report logs - #11686
24.1.50; defun should return name

Previous Next

Package: emacs;

Reported by: Johan Bockgård <bojohan <at> gnu.org>

Date: Tue, 12 Jun 2012 21:02:02 UTC

Severity: normal

Found in version 24.1.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lawrence Mitchell <wence <at> gmx.li>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#11686: 24.1.50; defun should return name
Date: Wed, 13 Jun 2012 10:13:10 +0100
Johan Bockgård wrote:
> With current trunk,

>    (defun NAME ()) => (lambda nil nil)

>    expected        => NAME

> Ditto for defmacro.

Here's a patch, think this is right:

Return NAME, not definition from defun and defmacro

* lisp/emacs-lisp/byte-run.el (defun, defmacro): Return newly created
definition's name, not its definition.


diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 635eef9..fb86b2a 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -135,9 +135,11 @@ interpreted according to `macro-declarations-alist'."
        (if docstring (setq body (cons docstring body)))
        ;; Can't use backquote because it's not defined yet!
        (let* ((fun (list 'function (cons 'lambda (cons arglist body))))
-              (def (list 'defalias
-                         (list 'quote name)
-                         (list 'cons ''macro fun)))
+              (def (cons 'prog1
+                         (list (list 'quote name)
+                               (list 'defalias
+                                     (list 'quote name)
+                                     (list 'cons ''macro fun)))))
               (declarations
                (mapcar
                 #'(lambda (x)
@@ -190,11 +192,13 @@ interpreted according to `defun-declarations-alist'.
                    (t (message "Warning: Unknown defun property %S in %S"
                                (car x) name)))))
                    decls))
-          (def (list 'defalias
-                     (list 'quote name)
-                     (list 'function
-                           (cons 'lambda
-                                 (cons arglist body))))))
+          (def (cons 'prog1
+                     (list (list 'quote name)
+                           (list 'defalias
+                                 (list 'quote name)
+                                 (list 'function
+                                       (cons 'lambda
+                                             (cons arglist body))))))))
       (if declarations
           (cons 'prog1 (cons def declarations))
         def))))





This bug report was last modified 13 years and 30 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.