[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: defadvice question.
From: |
Kevin Rodgers |
Subject: |
Re: defadvice question. |
Date: |
Mon, 21 Sep 2009 21:01:30 -0600 |
User-agent: |
Thunderbird 2.0.0.23 (Macintosh/20090812) |
Michal wrote:
Hallo group members.
when doing C-u M-x cvs-checkout
I wanted to always have in minibuffer history ring, my cvs root, just to
use up arrow key to get it. So I did:
(setenv "CVSROOT" "/my/cvs/root")
(defadvice cvs-checkout
(before cvs-checkout-cvs-root-add-to-history-ring)
(add-to-list 'minibuffer-history (getenv "CVSROOT")))
(ad-activate 'cvs-checkout)
but it does not work. Have You an idea why?
`before' advice runs after the interactive arguments are read. See the
"Combined Definition" node of the Elisp manual (under "Advising Functions").
You can modify the interactive form, like this:
(defadvice cvs-checkout (before minibuffer-history)
"Add CVSROOT environment variable to `minibuffer-history'."
(interactive (let ((minibuffer-history
(cons (getenv "CVSROOT") minibuffer-history)))
...)))
The tricky part is the "...". You could copy the entire interactive form from
cvs-checkout source in pcvs.el, but that defeats the whole purpose of using
advice. You might be able to work around it like this:
(defvar cvs-checkout-interactive-form
(interactive-form 'cvs-checkout))
(defadvice cvs-checkout (before minibuffer-history)
"Add CVSROOT environment variable to `minibuffer-history'."
(interactive (let ((minibuffer-history
(cons (getenv "CVSROOT") minibuffer-history)))
(call-interactively `(lambda (&rest cvs-checkout-args)
,cvs-checkout-interactive-form
cvs-checkout-args)))))
--
Kevin Rodgers
Denver, Colorado, USA
- defadvice question., Michal, 2009/09/16
- Re: defadvice question.,
Kevin Rodgers <=
- Message not available