* Problem with after-change-functions hook
@ 2006-03-19 4:28 user240
0 siblings, 0 replies; 6+ messages in thread
From: user240 @ 2006-03-19 4:28 UTC (permalink / raw)
I am trying to create a hook so as to run a function when a certain buffer
changes. I put this in a mode definition function:
(add-hook 'after-change-functions 'function nil t)
but the resulting hook appears to be global, as the function take effect on
all buffers!? What do I do to restrict the hook to the buffer that the mode
function was run?
--
View this message in context: http://www.nabble.com/Problem-with-after-change-functions-hook-t1305186.html#a3477857
Sent from the Emacs - Help forum at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with after-change-functions hook
[not found] <mailman.11.1142742504.3795.help-gnu-emacs@gnu.org>
@ 2006-03-21 17:04 ` Stefan Monnier
2006-03-26 1:38 ` user240
[not found] ` <mailman.37.1143337105.9694.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2006-03-21 17:04 UTC (permalink / raw)
> I am trying to create a hook so as to run a function when a certain buffer
> changes. I put this in a mode definition function:
> (add-hook 'after-change-functions 'function nil t)
Other than the use of the name `function', this looks correct.
> but the resulting hook appears to be global, as the function take effect on
> all buffers!?
That shouldn't be the case. What makes you think this is the case?
What does C-h v after-change-functions RET say when called in the buffer
(the one where you want the hook to be active)?
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with after-change-functions hook
2006-03-21 17:04 ` Problem with after-change-functions hook Stefan Monnier
@ 2006-03-26 1:38 ` user240
[not found] ` <mailman.37.1143337105.9694.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: user240 @ 2006-03-26 1:38 UTC (permalink / raw)
In the buffer I want the hook to be active I get:
"
`after-change-functions' is a simple built-in variable.
Value: (function)
Documentation:
List of functions to call after each text change.
Three arguments are passed to each function: the positions of
the beginning and end of the range of changed text,
and the length of the pre-change text replaced by that range.
(For an insertion, the pre-change length is zero;
for a deletion, that length is the number of characters deleted,
and the post-change beginning and end are at the same place.)
Buffer changes made while executing `after-change-functions'
don't call any before-change or after-change functions.
"
and the same for every other buffer, including the minibuffer.
note - I'm using xemacs 21.4.17 in Ubuntu linux.
--
View this message in context: http://www.nabble.com/Problem-with-after-change-functions-hook-t1305186.html#a3592948
Sent from the Emacs - Help forum at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with after-change-functions hook
[not found] ` <mailman.37.1143337105.9694.help-gnu-emacs@gnu.org>
@ 2006-03-26 4:46 ` Stefan Monnier
2006-03-27 21:19 ` user240
[not found] ` <mailman.42.1143494361.2481.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2006-03-26 4:46 UTC (permalink / raw)
> In the buffer I want the hook to be active I get:
> "
> `after-change-functions' is a simple built-in variable.
> Value: (function)
[...]
> and the same for every other buffer, including the minibuffer.
> note - I'm using xemacs 21.4.17 in Ubuntu linux.
In this case I'd first use another name than `function' (this may be the
cause of your problems, and it's an extremely bad choice in any case).
Then I'd try to call `make-local-hook' before add-hook.
And if that doesn't help, I'd ask on compe.emacs.xemacs because it may
simply be a behavior that's different on XEmacs.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with after-change-functions hook
2006-03-26 4:46 ` Stefan Monnier
@ 2006-03-27 21:19 ` user240
[not found] ` <mailman.42.1143494361.2481.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: user240 @ 2006-03-27 21:19 UTC (permalink / raw)
I'd don't actually use that name, I just used it to [paraphrase?] my code.
I have also used different and unique names instead, and the problem
persisted.
The manual says that using 't' as the optional local argument is equivolent
to using the make-local-hook function.
My problem might be a peculiarity of xemacs, but it seems unlikely. I will
test the same code with emacs (nox) soon.
--
View this message in context: http://www.nabble.com/Problem-with-after-change-functions-hook-t1305186.html#a3618296
Sent from the Emacs - Help forum at Nabble.com.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Problem with after-change-functions hook
[not found] ` <mailman.42.1143494361.2481.help-gnu-emacs@gnu.org>
@ 2006-03-29 5:27 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2006-03-29 5:27 UTC (permalink / raw)
> The manual says that using 't' as the optional local argument is equivolent
> to using the make-local-hook function.
Which manual? This is true for Emacs >= 21, but not for Emacs-20 and maybe
not for XEmacs either, or at least not for all versions.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-03-29 5:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.11.1142742504.3795.help-gnu-emacs@gnu.org>
2006-03-21 17:04 ` Problem with after-change-functions hook Stefan Monnier
2006-03-26 1:38 ` user240
[not found] ` <mailman.37.1143337105.9694.help-gnu-emacs@gnu.org>
2006-03-26 4:46 ` Stefan Monnier
2006-03-27 21:19 ` user240
[not found] ` <mailman.42.1143494361.2481.help-gnu-emacs@gnu.org>
2006-03-29 5:27 ` Stefan Monnier
2006-03-19 4:28 user240
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).