Subject: bug#5294: 23.1; unload-feature disable minor-mode

From: Juanma Barranquero <[email-masked]>
Date: Wed, 6 Jan 2010 01:23:41 +0100

On Wed, Jan 6, 2010 at 00:31, Kevin Ryde <[email-masked]> wrote:

> To, umm, get slightly back on-topic -- as an alternative for unloading
> minor modes, if the mode is currently enabled in a buffer, or enabled
> globally for a global, then unload-feature might refuse to unload
> (except under FORCE) on that basis that in-use is a kind of dependency
> on the feature's code etc.  The same might be applied to major modes,
> ie. refuse to unload if in use.

That would be too restrictive; there are instances in which just
deactivating the mode(s) and unloading the package is just what the
user expects. Also, FORCE already has a defined meaning: to bypass
checks for package dependencies, not safety checks for all kinds of
things a package may set up.

> Some generality could be had if there was a way that define-minor-mode
> might tie-in a test that unload-feature would reach when considering
> whether to unload.

How is passing that test (presumibly, either a form or a predicate
function) to define-minor-mode better than putting it into
FEATURE-unload-function?

> define-minor-mode might like to run some code on the
> actual unload too, to reverse some of `add-minor-mode', like removing
> from minor-mode-list (unless perhaps autoloaded minor mode funcs could
> stay there happily enough).

Which can be done from FEATURE-unload-function.

At first you talked about add-ons which would want to piggyback into
the unloading of a package, and I don't think that's a good idea, but
if a package author is really interested on it, it is doable with
advices, etc. But your examples in this message are all things that
can already be done on FEATURE-unload-function, for those packages
that really need it.

If you consider that going through the full buffer list, checking for
the mode and disabling it is too cumbersome, perhaps you can write a
helper function that could be called from the unload function...

    Juanma