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

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

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


From: camalot
Subject: Around advice does not work on forward-char/backward-char
Date: 03 Jan 2002 06:04:36 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.1.1 (i386-mingw-nt5.0.2195)
 of 2001-10-31 on AMIDON-K-LT-W2K
configured using `configure --with-gcc (2.95)'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  locale-coding-system: iso-latin-1
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

I am trying to write a minor mode for which I want to advise the basic
cursor movement commands forward-char, backward-char, next-line, and
previous-line to do something different in certain situations
(basically to skip certain lines of text).  It is working fine for
next-line/previous-line, but not for forward-char/backward-char.  I
tried to come up with the simplest test case to show the problem I
could think of.  So, here is code that works for next-line:

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

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:

(defadvice forward-char (around forward-char-test-ad (arg))
  "Test advice for forward-char to demonstrate it isn't working."
  (message "Using advised version of forward-char")
  ad-do-it)
(ad-activate 'forward-char)

Eval these and no message will be printed when you use next-line
(e.g. when you type C-f)  Furthermore, if I attempt to disable the
advice on forward-char using:

(ad-disable-advice 'forward-char 'around 'forward-char-test-ad)

I get a backtrace:

  signal(error ("ad-disable-advice: `forward-char' has no around advice 
matching `forward-char-test-ad'"))
  error("ad-disable-advice: `%s' has no %s advice matching `%s'" forward-char 
around forward-char-test-ad)
  ad-disable-advice(forward-char around forward-char-test-ad)
  eval((ad-disable-advice (quote forward-char) (quote around) (quote 
forward-char-test-ad)))
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
* call-interactively(eval-last-sexp)

Is there something fundamental about forward-char and backward-char
that prevents them from being advised?  I assume they are implemented
in C, could that be the problem?  Is there anyway around it?

I was trying to use the advice so that I could avoid having to save
off all the old keybindings for cursor motion and restore them all when
I exit my minor mode.  Plus, I hoped that by doing it that way my
minor mode would pickup whatever keys the user was using for cursor
motion, even if they had been changed.

Thanks for any help you can provide.

    -- Keith
  
Recent input:
n SPC o f SPC n e x t - l i n e " ) <backspace> ) <return> 
<tab> a d - d o - i t ) C-x C-e <return> <return> ( 
a d - a c t i v a t e SPC ' n e x t - l i n e ) C-x 
C-e C-p C-p C-p C-p C-n C-n C-n C-n C-n C-p C-p C-p 
C-p C-p C-n C-n C-n C-n C-n C-a C-n M-x r e p o r t 
- e m a c - <backspace> s - b u <tab> <return>

Recent messages:
Making completion list...
setq: Quit
forward-char
line-move: End of buffer [2 times]
next-line [2 times]
Using advised version of next-line [5 times]
line-move: End of buffer
Using advised version of next-line [6 times]
line-move: End of buffer
Loading emacsbug...done



reply via email to

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