unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Advising a non-interactive function?
@ 2009-08-31 16:08 Elena
  2009-08-31 18:33 ` Joost Kremers
  2009-08-31 20:26 ` Barry Margolin
  0 siblings, 2 replies; 5+ messages in thread
From: Elena @ 2009-08-31 16:08 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

can you advise a function which takes arguments not available via
"interactive" (for instance: 'define-key')? How would the 'defadvice'
look?

Thanks


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

* Re: Advising a non-interactive function?
  2009-08-31 16:08 Advising a non-interactive function? Elena
@ 2009-08-31 18:33 ` Joost Kremers
  2009-08-31 20:53   ` Elena
  2009-08-31 20:26 ` Barry Margolin
  1 sibling, 1 reply; 5+ messages in thread
From: Joost Kremers @ 2009-08-31 18:33 UTC (permalink / raw)
  To: help-gnu-emacs

Elena wrote:
> can you advise a function which takes arguments not available via
> "interactive" (for instance: 'define-key')? How would the 'defadvice'
> look?

what makes you think that a non-interactive function cannot be defadvice'd?


-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

* Re: Advising a non-interactive function?
  2009-08-31 16:08 Advising a non-interactive function? Elena
  2009-08-31 18:33 ` Joost Kremers
@ 2009-08-31 20:26 ` Barry Margolin
  1 sibling, 0 replies; 5+ messages in thread
From: Barry Margolin @ 2009-08-31 20:26 UTC (permalink / raw)
  To: help-gnu-emacs

In article 
<cc34aef4-4080-4c67-a0c7-6bc9df2ba313@o13g2000vbl.googlegroups.com>,
 Elena <egarrulo@gmail.com> wrote:

> Hello,
> 
> can you advise a function which takes arguments not available via
> "interactive" (for instance: 'define-key')? How would the 'defadvice'
> look?

There's nothing about advice that's specific to interactive functions.  
The advice would look the same.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


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

* Re: Advising a non-interactive function?
  2009-08-31 18:33 ` Joost Kremers
@ 2009-08-31 20:53   ` Elena
  2009-08-31 22:02     ` Andreas Politz
  0 siblings, 1 reply; 5+ messages in thread
From: Elena @ 2009-08-31 20:53 UTC (permalink / raw)
  To: help-gnu-emacs

On 31 Ago, 20:33, Joost Kremers <joostkrem...@yahoo.com> wrote:
> what makes you think that a non-interactive function cannot be defadvice'd?

According to the docs, every function can be advised, but I've never
seen an example showing how to advise a function which took arguments
not available by a call to 'interactive'. For instance, how would you
define a 'before advice' to 'define-key', whose prototype is this:

(define-key keymap key def)

Thanks.


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

* Re: Advising a non-interactive function?
  2009-08-31 20:53   ` Elena
@ 2009-08-31 22:02     ` Andreas Politz
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Politz @ 2009-08-31 22:02 UTC (permalink / raw)
  To: help-gnu-emacs


(defadvice define-key (before my-advice
                              (km k def)
                              activate)
  (message "The %s key will now be bound" k))

There are different possibilities.

(info "(elisp) Argument Access in Advice")

-ap





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

end of thread, other threads:[~2009-08-31 22:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-31 16:08 Advising a non-interactive function? Elena
2009-08-31 18:33 ` Joost Kremers
2009-08-31 20:53   ` Elena
2009-08-31 22:02     ` Andreas Politz
2009-08-31 20:26 ` Barry Margolin

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