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

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

Q on after-change-functions


From: Drew Adams
Subject: Q on after-change-functions
Date: Tue, 21 Feb 2006 17:57:53 -0800

In Emacs 22 or 20 -

I do this:

  (set-buffer (window-buffer (minibuffer-window)))
  (add-hook 'after-change-functions 'foobar nil 'local)

(BTW, is there an easier way to get the minibuffer buffer than via its
window?)

Then I do this:

  (set-buffer (window-buffer (minibuffer-window)))
  (describe-variable 'after-change-functions)

That prints this, showing (I think) that `foobar' is in the minibuffer-local
value of `after-change-functions':

  after-change-functions's value is (foobar t)
  Local in buffer  *Minibuf-0*; global value is nil

I then do this:

(defun foobar (a b c) (message "phooey!"))

When I then do, say, `M-x abcdef' I'm expecting that `foobar' will be called
each time I insert a character in the minibuffer: a b c ... Likewise each
time I delete characters from the minibuffer input. I'm expecting any change
to the text in buffer minibuffer to provoke `foobar'. (I haven't yet started
to wonder how to turn it off for things like prompt insertion!)

However, `foobar' never gets called, as seen by using `debug-on-entry
foobar' (and by the lack of any message from `foobar').

What am I missing? Suggestions? I'm trying to pick up any user changes to
input in the minibuffer. I don't, however, want to trigger `foobar' for
insertion of prompts and such by program.

Currently, I use a different approach, redefining several basic editing keys
(character, word, etc. insertion and deletion) so that they do both 1) their
normal thing and 2) call `foobar'. That works well, but I thought perhaps
`after-change-functions' might provide a simpler, more elegant
implementation. In any case, I'm curious about how it works.





reply via email to

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