--- Begin Message ---
Subject: |
24.2.50; feature request: advice.el: implement `ad-do-interactive'? |
Date: |
Fri, 09 Nov 2012 18:40:08 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
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
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#12844: 24.2.50; feature request: advice.el: implement `ad-do-interactive'? |
Date: |
Wed, 14 Nov 2012 15:38:58 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
> 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
--- End Message ---