From: Juanma Barranquero <lekktu@gmail.com>
To: Kevin Ryde <user42@zip.com.au>
Cc: 5293-done@debbugs.gnu.org
Subject: bug#5293: 23.1; unload-feature on buffer-local hooks
Date: Wed, 13 Jul 2011 22:28:02 +0200 [thread overview]
Message-ID: <CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@mail.gmail.com> (raw)
In-Reply-To: <87hbr4p67t.fsf@blah.blah>
> Evalling the code in try-foo.el below loads then unloads foo.el. It
> gets an error
>
> void-function foo-message
>
> where I hoped unload-feature might have purged that `foo-message' from
> `after-change-functions'.
>
> I suppose looking in all buffers is more work for unload-feature, but
> would be a good protection against bad things happening later. I expect
> some of the standard hooks like `after-change-functions' are used
> buffer-local most of the time.
You're right that some hooks are used buffer-locally most of the time,
but it's also true that in many cases they are used from a major mode,
i.e., in your case, if foo.el defined a foo-mode and set
`after-change-functions' locally in foo-mode buffers, unload-feature
would do OK (with the current trunk, not any released Emacsen).
As it is, foo.el is doing something non-standard, and unload-feature
cannot try to revert by itself every non-standard thing packages do.
That's why FEATURE-unload-function exists. So, in this case, the right
fix would be adding this function to foo.el:
(defun foo-unload-function ()
"Unload foo.el."
(ignore-errors
(with-current-buffer (get-buffer "foo-buffer")
(remove-hook 'after-change-functions 'foo-message t)))
;; continue standard unloading
nil)
That said, there are improvements that could be made to unload-feature
(for example, trying to automatically deactivate minor modes being
undefined), but I'm not sure that looking in every buffer-local
variable of every live buffer is a sensible thing to do. I'm closing
this one because it is not really a bug. We can open a wishlist bug
for unload-feature is you want.
Juanma
next prev parent reply other threads:[~2011-07-13 20:28 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 [this message]
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
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='CAAeL0SS_nH7ywDknYydqfd+7qMmhEDjN0rG4KjtOs=hfyxWAyQ@mail.gmail.com' \
--to=lekktu@gmail.com \
--cc=5293-done@debbugs.gnu.org \
--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).