GNU bug report logs -
#12844
24.2.50; feature request: advice.el: implement `ad-do-interactive'?
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12844 in the body.
You can then email your comments to 12844 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#12844
; Package
emacs
.
(Fri, 09 Nov 2012 17:55:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Michael Heerdegen <michael_heerdegen <at> web.de>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 09 Nov 2012 17:55:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
I faced this situation too often - that's why I decided to file a bug
report now.
`defadvice' provides a pseudo variable `ad-do-it' which we all know, it
is very practical. It makes it often unnecessary to copy and paste code
from the original function if we only want to bind some vars to certain
values etc.
Now I ask if we could do the same for the `interactive' specification.
`defadvice' allows to redefine the interactive spec of the original
function - but if it is a (maybe very complicated) list expression,
there's currently no way to refer to it in `defadvice'.
I want to give an example why this would be useful:
The package `eldoc-eval' by Thierry Volpiatto implements a macro
`with-eldoc-in-minibuffer' that enables displaying eldoc information in
the mode-line while an expression is read from the minibuffer. I wanted
to use this for `debugger-record-expression'. So I tried:
(defadvice debugger-record-expression (around use-eldoc-eval activate)
"Use eldoc-eval when reading the expression."
(with-eldoc-in-minibuffer ad-do-it))
But that doesn't work, because the expression is read in by the
interactive spec of `debugger-record-expression'.
I now have this solution:
(require 'debug)
(defvar debugger-record-expression-orig-interactive-form
(cdr (interactive-form 'debugger-record-expression)))
(eval `(defadvice debugger-record-expression (around use-eldoc-eval activate)
"Use eldoc-eval when reading the expression."
(interactive (with-eldoc-in-minibuffer
(list ,@debugger-record-expression-orig-interactive-form)))
ad-do-it))
Looks not very nice, but works, and it screams for automation. Dunno if
it's really that easy in general, but it would be a good feature. I
often missed something like `ad-do-interactive'. The goal is to use it
like that:
(defadvice debugger-record-expression (around use-eldoc-eval activate)
(interactive (with-eldoc-in-minibuffer ad-do-interactive))
ad-do-it)
Regards,
Michael.
In GNU Emacs 24.2.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
of 2012-11-01 on dex, modified by Debian
(emacs-snapshot package, version 2:20121101-1)
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description: Debian GNU/Linux testing (wheezy)
Configured using:
`configure '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu'
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
'--localstatedir=/var' '--infodir=/usr/share/info'
'--mandir=/usr/share/man' '--with-pop=yes'
'--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.2.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.2.50/site-lisp:/usr/share/emacs/site-lisp'
'--without-compress-info' '--with-crt-dir=/usr/lib/x86_64-linux-gnu/'
'--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes'
'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu'
'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
-Wl,--as-needed -znocombreloc' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''
Important settings:
value of $LC_ALL: de_DE.utf8
value of $LC_TIME: C
value of $LANG: de_DE.utf8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#12844
; Package
emacs
.
(Fri, 09 Nov 2012 19:33:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 12844 <at> debbugs.gnu.org (full text, mbox):
severity 12844 wishlist
thanks
> `defadvice' provides a pseudo variable `ad-do-it' which we all know, it
[...]
> Now I ask if we could do the same for the `interactive' specification.
[...]
> (defadvice debugger-record-expression (around use-eldoc-eval activate)
> (interactive (with-eldoc-in-minibuffer ad-do-interactive))
> ad-do-it)
Interesting!
I have a new advice facility waiting to be installed into trunk (not
a replacement for advice.el, instead something much less ambitious but
which should still cover the needs currently satisfied by `defadvice').
So to tell you the truth, I see advice.el as "on the slow way out" and
am not really interested in developing it further.
But my new advice facility suffers from the same shortcoming you
mention, and I agree it would make sense to try and address it.
So, I don't have a solution to offer yet, but I'll keep it in mind.
Stefan
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Wed, 14 Nov 2012 20:40:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Michael Heerdegen <michael_heerdegen <at> web.de>
:
bug acknowledged by developer.
(Wed, 14 Nov 2012 20:40:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 12844-done <at> debbugs.gnu.org (full text, mbox):
> So, I don't have a solution to offer yet, but I'll keep it in mind.
Actually, it was easy enough to implement. So you can try it out on the
trunk:
(defun sm-test-advice (&rest _args)
(interactive (lambda (spec)
(with-eldoc-in-minibuffer
(advice-eval-interactive-spec spec))))
nil)
(advice-add 'debugger-record-expression :before #'sm-test-advice)
-- Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 13 Dec 2012 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 274 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.