Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Crappyness of Emacs Version 24.5.1 defadvice

36 views
Skip to first unread message

Davin Pearson

unread,
Jun 27, 2016, 1:46:10 AM6/27/16
to

I have recently upgraded Emacs Version 24.5.1

emacs-24.5-bin-i686-mingw32.zip

I have a bunch of defadvice forms for implementing a d-speedbar
feature that is superior to the built in speedbar feature.

(defadvice describe-mode (around d-speedbar activate)
(delete-other-windows)
ad-do-it)

C-h f describe-mode RET says:

:around advice: `ad-Advice-describe-mode'

it used to say:

:around advice: d-speedbar

The old behavior is preferable so I know which file the advice
is coming from.

Davin Pearson

unread,
Jun 28, 2016, 1:58:27 AM6/28/16
to
Could someone tell me how to get the old behavior back?

Dmitry Gutov

unread,
Jun 28, 2016, 7:11:51 AM6/28/16
to Davin Pearson, help-gn...@gnu.org
On 06/28/2016 08:58 AM, Davin Pearson wrote:

> Could someone tell me how to get the old behavior back?

You can use advice-add instead. It will make the help output better,
among other things.

Michael Heerdegen

unread,
Jun 28, 2016, 9:00:18 AM6/28/16
to help-gn...@gnu.org
Dmitry Gutov <dgu...@yandex.ru> writes:

> On 06/28/2016 08:58 AM, Davin Pearson wrote:
>
> > Could someone tell me how to get the old behavior back?
>
> You can use advice-add instead. It will make the help output better,
> among other things.

To say it more clearly: with advice.el, there is no way to get the old
behavior back (unless you load an old version of that file, maybe).

Michael.


Drew Adams

unread,
Jun 28, 2016, 10:22:01 AM6/28/16
to Davin Pearson, help-gn...@gnu.org
> > The old behavior is preferable so I know which file the advice
> > is coming from.
>
> Could someone tell me how to get the old behavior back?

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14734
("REGRESSION: defadvice broken wrt doc strings (C-h f)")

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14070
("incorrect doc from `C-h f' when use `defadvice' with `before'")

This post by Stefan provides the rationale behind the new advice
system. (You might want to read the rest of the thread too.)
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16402#31
("Document nadvice.el stuff in Elisp manual before Emacs 24.4")

Davin Pearson

unread,
Jun 28, 2016, 9:48:53 PM6/28/16
to
I tried the following code but it doesn't work.

(advice-add 'describe-mode
:around
#'(lambda () (delete-other-windows) ad-do-it)
)

Worse still, it brings up the following message when I try C-h f describe-mode RET

:around advice: No documentation

Where do I add the documentation to the advice mechanism?

Michael Heerdegen

unread,
Jun 28, 2016, 9:56:33 PM6/28/16
to help-gn...@gnu.org
Davin Pearson <davin....@gmail.com> writes:

> I tried the following code but it doesn't work.
>
> (advice-add 'describe-mode
> :around
> #'(lambda () (delete-other-windows) ad-do-it)
> )

There is no `ad-do-it' pseudo variable/whatever in nadvice anymore. The
functions that are used as a piece of advice are simply called - and
how tells the doc of `add-function', or the manual.

> Worse still, it brings up the following message when I try C-h f
> describe-mode RET
>
> :around advice: No documentation
>
> Where do I add the documentation to the advice mechanism?

Document the function that "is" the advice.


Michael.


Davin Pearson

unread,
Jun 29, 2016, 3:01:16 AM6/29/16
to
On Wednesday, June 29, 2016 at 1:56:33 PM UTC+12, Michael Heerdegen wrote:
Thanks for your helpful advice. I use defadvice a lot and I am still unsure why Stephen Monier removed that feature.

Davin Pearson

unread,
Jun 29, 2016, 3:05:07 AM6/29/16
to
On Wednesday, June 29, 2016 at 1:56:33 PM UTC+12, Michael Heerdegen wrote:
> Davin Pearson writes:
>
> > I tried the following code but it doesn't work.
> >
> > (advice-add 'describe-mode
> > :around
> > #'(lambda () (delete-other-windows) ad-do-it)
> > )

Why the # character before the lambda form?

Does it do the same thing as (function (lambda () ...))

Alexis

unread,
Jun 29, 2016, 5:03:00 AM6/29/16
to Davin Pearson, help-gn...@gnu.org

Davin Pearson <davin....@gmail.com> writes:

> Thanks for your helpful advice. I use defadvice a lot and I am
> still unsure why Stephen Monier removed that feature.

The current Emacs Lisp Reference Manual suggests the new advice
implementation is simpler (and thus easier for the Emacs devs to
maintain) and has behaviour that's easier to understand:

https://www.gnu.org/software/emacs/manual/html_node/elisp/Porting-old-advices.html#Porting-old-advices


Alexis.

Rémi Vanicat

unread,
Jun 29, 2016, 10:15:25 AM6/29/16
to help-gn...@gnu.org
Davin Pearson <davin....@gmail.com> writes:

> On Wednesday, June 29, 2016 at 2:22:01 AM UTC+12, Drew Adams wrote:
>> > > The old behavior is preferable so I know which file the advice
>> > > is coming from.
>> >
>> > Could someone tell me how to get the old behavior back?
>>
>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14734
>> ("REGRESSION: defadvice broken wrt doc strings (C-h f)")
>>
>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14070
>> ("incorrect doc from `C-h f' when use `defadvice' with `before'")
>>
>> This post by Stefan provides the rationale behind the new advice
>> system. (You might want to read the rest of the thread too.)
>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16402#31
>> ("Document nadvice.el stuff in Elisp manual before Emacs 24.4")
>
> I tried the following code but it doesn't work.
>
> (advice-add 'describe-mode
> :around
> #'(lambda () (delete-other-windows) ad-do-it)
> )
>

(defun my-describe-mode-before-advice (oldfun &optional buffer)
"my documentation"
(delete-other-windows)
(apply oldfun buffer))

(advice-add 'describe-mode :around #'my-describe-mode-before-advice)

Or better with a before advice:

(defun my-describe-mode-before-advice (&optional buffer)
"my documentation"
(delete-other-windows))

(advice-add 'describe-mode :before #'my-desccribe-mode-before-advice)


--
Rémi Vanicat


Michael Heerdegen

unread,
Jun 30, 2016, 8:44:21 AM6/30/16
to help-gn...@gnu.org
Rémi Vanicat <van...@debian.org> writes:

> (defun my-describe-mode-before-advice (oldfun &optional buffer)
> "my documentation"
> (delete-other-windows)
> (apply oldfun buffer))
>
> (advice-add 'describe-mode :around #'my-describe-mode-before-advice)
>
> Or better with a before advice:
>
> (defun my-describe-mode-before-advice (&optional buffer)
> "my documentation"
> (delete-other-windows))
>
> (advice-add 'describe-mode :before #'my-desccribe-mode-before-advice)

No need to repeat the argument list of the original function if you
don't use the arguments in the body:

(defun my-describe-mode-before-advice (&rest _ignore)
"my documentation"
(delete-other-windows))


Michael.


Michael Heerdegen

unread,
Jun 30, 2016, 8:46:29 AM6/30/16
to Davin Pearson, help-gn...@gnu.org
Davin Pearson <davin....@gmail.com> writes:

> Why the # character before the lambda form?
>
> Does it do the same thing as (function (lambda () ...))

Yes, #'THING is equivalent to (function THING). For lambda, it's
redundant in Emacs Lisp, since lambda is self-quoting with `function'.
It doesn't harm, though.


Michael.

Joost Kremers

unread,
Jun 30, 2016, 9:09:32 AM6/30/16
to
Michael Heerdegen wrote:
> Yes, #'THING is equivalent to (function THING). For lambda, it's
> redundant in Emacs Lisp, since lambda is self-quoting with `function'.
> It doesn't harm, though.

To the eyes it does. ;-)


--
Joost Kremers joostk...@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)

Michael Heerdegen

unread,
Jun 30, 2016, 5:17:31 PM6/30/16
to help-gn...@gnu.org
Joost Kremers <joost.m...@gmail.com> writes:

> > Yes, #'THING is equivalent to (function THING). For lambda, it's
> > redundant in Emacs Lisp, since lambda is self-quoting with `function'.
> > It doesn't harm, though.
>
> To the eyes it does. ;-)

;-) does even more harm to the eyes. Better write it as ;-\) to avoid
the unmatched paren. It doesn't look very friendly any more that way,
but that's second-tier.

Michael.


0 new messages