all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: emacs-devel@gnu.org
Subject: Why is `after-change-functions' reset?
Date: Mon, 17 Feb 2014 19:35:31 +0100	[thread overview]
Message-ID: <878ut9r3ik.fsf@web.de> (raw)

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.




             reply	other threads:[~2014-02-17 18:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 18:35 Michael Heerdegen [this message]
2014-02-17 22:11 ` Why is `after-change-functions' reset? Kalle Olavi Niemitalo
2014-02-18 17:50   ` Michael Heerdegen
2014-02-17 23:49 ` Stefan Monnier
2014-02-17 23:57   ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878ut9r3ik.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.