bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Around advice does not work on forward-char/backward-char


From: Kevin Rodgers
Subject: Re: Around advice does not work on forward-char/backward-char
Date: Wed, 09 Jan 2002 10:32:57 -0700

camalot@picnicpark.org wrote:
> (defadvice next-line (around next-line-test-ad (arg))
>   "Test advice for next-line to demonstrate it is working."
>   (message "Using advised version of forward-char")
>   ad-do-it)
> (ad-activate 'next-line)

Note that you can simplify that:

(defadvice next-line (before next-line-test-ad activate)
  "Test advice for next-line to demonstrate it is working."
  (message "Using advised version of next-line"))

> Eval these and every time you use next-line (e.g. when you type C-n)
> the message will be printed.  Now I'll adapt it for forward-char:
...
> Eval these and no message will be printed when you use forward-char
> (e.g. when you type C-f).

I can confirm this.  next-line is a function and forward-char is a subr,
but that shouldn't make a difference since (key-binding "\C-f") returns
the forward-char symbol.

The interesting thing is that the message is displayed if you invoke
forward-char via M-x.

I wonder if the discrepancy has anything to do with this line in
cmds.c:keys_of_cmds()

  initial_define_key (global_map, Ctl ('F'), "forward-char");

since there's no corresponding call to initial_define_key for next-line.
But unbinding and rebinding C-f to forward-char in the current global
keymap still doesn't result in the advised definition being invoked.

-- 
Kevin Rodgers <kevinr@ihs.com>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]