unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* trunk defadvice doesn't preserve original function
@ 2007-10-22  3:02 Katsumi Yamaoka
  2007-10-23  6:06 ` Katsumi Yamaoka
  0 siblings, 1 reply; 3+ messages in thread
From: Katsumi Yamaoka @ 2007-10-22  3:02 UTC (permalink / raw)
  To: emacs-devel

Hi,

Performing (defadvice foo ...) twice breaks `foo' if bytecomp
has been loaded.  You can reproduce this with `emacs -Q' as
follows:

(require 'bytecomp)

(defun foo ()
  "foo")

(symbol-function 'foo)
 => (lambda nil "foo")

(defadvice foo (around testing activate)
  (setq ad-return-value (concat ad-do-it "+bar")))

(symbol-function 'foo)
 => #[nil "\301^X\302 \211^P\303P\211^P)\207"
      [ad-return-value nil ad-Orig-foo "+bar"]
      3 #("Advice doc string" 0 17 (ad-advice-info foo))]
(symbol-function 'ad-Orig-foo)
 => (lambda nil "foo")

(defadvice foo (around testing activate)
  (setq ad-return-value (concat ad-do-it "+bar")))

(symbol-function 'foo)
 => #[nil "\301^X\302 \211^P\303P\211^P)\207"
      [ad-return-value nil ad-Orig-foo "+bar"]
      3 #("Advice doc string" 0 17 (ad-advice-info foo))]
(symbol-function 'ad-Orig-foo)
 => #[nil "\301^X\302 \211^P\303P\211^P)\207"
      [ad-return-value nil ad-Orig-foo "+bar"]
      3 #("Advice doc string" 0 17 (ad-advice-info foo))]

That is, `ad-Orig-foo' calls `ad-Orig-foo' itself.  Because of
this, re-loading ~/.emacs file containing defadvice forms causes
the ``Lisp nesting exceeds `max-lisp-eval-depth'' error.

I don't know what's going on in the trunk but Unicode-2 has no
such problem.

Regards,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: trunk defadvice doesn't preserve original function
  2007-10-22  3:02 trunk defadvice doesn't preserve original function Katsumi Yamaoka
@ 2007-10-23  6:06 ` Katsumi Yamaoka
  2007-10-23  8:24   ` Juanma Barranquero
  0 siblings, 1 reply; 3+ messages in thread
From: Katsumi Yamaoka @ 2007-10-23  6:06 UTC (permalink / raw)
  To: emacs-devel

>>>>> Katsumi Yamaoka wrote:

> Performing (defadvice foo ...) twice breaks `foo' if bytecomp
> has been loaded.

I found that the cause is:

2007-10-20  Juanma Barranquero  <lekktu@gmail.com>

	* doc.c (Fdocumentation): Check for advice in all cases.

This made `ad-real-documentation' (i.e. #<subr documentation>)
return the return value of `ad-make-advised-docstring', while it
was that of `ad-make-advised-definition-docstring' before.
Because of this change, the return value of
`ad-real-documentation' does not have the `ad-advice-info' text
property now, and `ad-advised-definition-p' returns nil even for
an advised function.  This is why `defadvice' always behaves as
is used for the first time for a function.  Here is a patch:

2007-10-23  Katsumi Yamaoka  <yamaoka@jpl.org>

	* emacs-lisp/advice.el (ad-make-advised-docstring): Add
	ad-advice-info text property to doc string.

*** advice.el~	Tue Oct 16 07:45:57 2007
--- advice.el	Tue Oct 23 06:06:00 2007
***************
*** 3004,3011 ****
  	(if advice-docstring
  	    (push advice-docstring paragraphs))))
      (setq origdoc (if paragraphs
! 		      ;; separate paragraphs with blank lines:
! 		      (mapconcat 'identity (nreverse paragraphs) "\n\n")))
      (help-add-fundoc-usage origdoc usage)))
  
  (defun ad-make-plain-docstring (function)
--- 3004,3013 ----
  	(if advice-docstring
  	    (push advice-docstring paragraphs))))
      (setq origdoc (if paragraphs
! 		      (propertize
! 		       ;; separate paragraphs with blank lines:
! 		       (mapconcat 'identity (nreverse paragraphs) "\n\n")
! 		       'ad-advice-info function)))
      (help-add-fundoc-usage origdoc usage)))
  
  (defun ad-make-plain-docstring (function)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: trunk defadvice doesn't preserve original function
  2007-10-23  6:06 ` Katsumi Yamaoka
@ 2007-10-23  8:24   ` Juanma Barranquero
  0 siblings, 0 replies; 3+ messages in thread
From: Juanma Barranquero @ 2007-10-23  8:24 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: emacs-devel

On 10/23/07, Katsumi Yamaoka <yamaoka@jpl.org> wrote:

> I found that the cause is:
>
> 2007-10-20  Juanma Barranquero  <lekktu@gmail.com>
>
>         * doc.c (Fdocumentation): Check for advice in all cases.

Why am I not surprised? Since advice.el's change on 2007-10-14 this is
like the fourth bug we fight...

             Juanma

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-10-23  8:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-22  3:02 trunk defadvice doesn't preserve original function Katsumi Yamaoka
2007-10-23  6:06 ` Katsumi Yamaoka
2007-10-23  8:24   ` Juanma Barranquero

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).