From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Štěpán Němec" <stepnem@gmail.com>
Cc: Juanma Barranquero <lekktu@gmail.com>,
Kevin Ryde <user42@zip.com.au>,
5293@debbugs.gnu.org
Subject: bug#5293: 23.1; unload-feature on buffer-local hooks
Date: Mon, 06 Apr 2020 14:06:02 -0400 [thread overview]
Message-ID: <jwvsghgcxi5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87zhbojzmv.fsf@gmail.com> ("Štěpán Němec"'s message of "Mon, 06 Apr 2020 19:24:40 +0200")
> @@ -299,7 +299,11 @@ unload-feature
> ;; Known abnormal hooks etc.
> (memq x unload-feature-special-hooks)))
> (dolist (func removables)
> - (remove-hook x func)))))
> + (remove-hook x func)
> + (save-current-buffer
> + (dolist (buffer (buffer-list))
> + (set-buffer buffer)
> + (remove-hook x func t)))))))
> ;; Remove any feature-symbols from auto-mode-alist as well.
> (dolist (func removables)
> (setq auto-mode-alist
Maybe instead of `(dolist (buffer (buffer-list))` within that big
`mapatoms` within `(dolist (func removables)` (which is O(B*F*V) where
B is the number of buffers, F is the number of functions and V is the
number of hook vars), we should instead do it as:
(dolist (buffer (buffer-list))
(dolist (varvar (buffer-local-variables buffer))
(when <var is a hook>
(dolist (func removables)
(remove-hook <var> func t)))))
If we need it to go faster maybe we could also arrange for (add-hook
V F ..) to do (cl-pushnew V (get F 'hooks-where-it-has-been-put)).
So we could do
(let ((relevant-hooks
(mapcan (lambda (f) (get F 'hooks-where-it-has-been-put)) funcs)))
(dolist (buffer (buffer-list))
(dolist (varvar (buffer-local-variables buffer))
(when (memq var relevant-hooks)
(dolist (func removables)
(remove-hook <var> func t)))))
-- Stefan
next prev parent reply other threads:[~2020-04-06 18:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-02 21:06 bug#5293: 23.1; unload-feature on buffer-local hooks Kevin Ryde
2010-01-02 23:14 ` Juanma Barranquero
2011-07-13 20:28 ` Juanma Barranquero
2011-07-15 0:26 ` Kevin Ryde
2011-07-15 0:34 ` Juanma Barranquero
2011-07-15 8:52 ` Štěpán Němec
2011-07-15 11:24 ` Juanma Barranquero
2011-07-15 16:08 ` Štěpán Němec
2011-07-15 16:20 ` Juanma Barranquero
2011-07-16 18:50 ` Stefan Monnier
2011-08-06 1:20 ` Kevin Ryde
2020-04-06 17:24 ` Štěpán Němec
2020-04-06 18:06 ` Stefan Monnier [this message]
2020-04-06 19:17 ` Štěpán Němec
2020-09-30 18:44 ` Lars Ingebrigtsen
2020-10-20 10:20 ` Štěpán Němec
2020-10-20 11:13 ` Lars Ingebrigtsen
2020-10-21 17:00 ` Štěpán Němec
2020-04-06 20:39 ` Juanma Barranquero
2020-04-06 21:27 ` Štěpán Němec
2020-04-06 23:01 ` Juanma Barranquero
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvsghgcxi5.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=5293@debbugs.gnu.org \
--cc=lekktu@gmail.com \
--cc=stepnem@gmail.com \
--cc=user42@zip.com.au \
/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 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).