unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Why is `after-change-functions' reset?
@ 2014-02-17 18:35 Michael Heerdegen
  2014-02-17 22:11 ` Kalle Olavi Niemitalo
  2014-02-17 23:49 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Heerdegen @ 2014-02-17 18:35 UTC (permalink / raw)
  To: emacs-devel

Hello,

I'm working on a library that adds a function to
`after-change-functions'.

After some time, the thing stops working.  I look at the value of
`after-change-functions' and my added function is missing.

So I thought there would have been some error that caused
`after-change-functions' to be reset.  But I can preclude that - there
is no error, no error message, etc.

I had a hard time to find some recipe for emacs -Q.  Here it comes:

--8<---------------cut here---------------start------------->8---
(progn
  
  (defun foo (&rest _) ())
  
  (add-hook 'after-change-functions 'foo)
  
  (defun complain ()
    (when (not (memq 'foo (default-value 'after-change-functions)))
      (message "Why does this happen?")
      (cancel-timer complain-timer)))
  
  (defvar complain-timer
    (run-with-idle-timer .03 .03 #'complain))

  (require 'cl-lib)
  (completing-read "Hit tab and C-g:  "
		   (cl-loop for i from 1 to 100000
			    collect (format "%d" i))))
--8<---------------cut here---------------end--------------->8---

Evaluate it and hit tab (for completion) and C-g C-g in succession.
When you repeat this a few times, you get "Why does this happen?".

Is this expected behavior?  In my original situation, quitting was not
involved, the above recipe was just the first reproducible program I had
discovered.


Thanks,

Michael.




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

end of thread, other threads:[~2014-02-18 17:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17 18:35 Why is `after-change-functions' reset? Michael Heerdegen
2014-02-17 22:11 ` Kalle Olavi Niemitalo
2014-02-18 17:50   ` Michael Heerdegen
2014-02-17 23:49 ` Stefan Monnier
2014-02-17 23:57   ` Michael Heerdegen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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