all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: 12844@debbugs.gnu.org
Subject: bug#12844: 24.2.50; feature request: advice.el: implement `ad-do-interactive'?
Date: Fri, 09 Nov 2012 18:40:08 +0100	[thread overview]
Message-ID: <87k3tuvfnr.fsf@web.de> (raw)

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






             reply	other threads:[~2012-11-09 17:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-09 17:40 Michael Heerdegen [this message]
2012-11-09 19:32 ` bug#12844: 24.2.50; feature request: advice.el: implement `ad-do-interactive'? Stefan Monnier
2012-11-14 20:38   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3tuvfnr.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=12844@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.