unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12844: 24.2.50; feature request: advice.el: implement `ad-do-interactive'?
@ 2012-11-09 17:40 Michael Heerdegen
  2012-11-09 19:32 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2012-11-09 17:40 UTC (permalink / raw)
  To: 12844

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






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

end of thread, other threads:[~2012-11-14 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-09 17:40 bug#12844: 24.2.50; feature request: advice.el: implement `ad-do-interactive'? Michael Heerdegen
2012-11-09 19:32 ` Stefan Monnier
2012-11-14 20:38   ` Stefan Monnier

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).