emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: doc of defining minor modes


From: Drew Adams
Subject: RE: doc of defining minor modes
Date: Thu, 18 May 2006 10:55:23 -0700

    Customize might load a file just because a variable has been
    customized from it.

And?

    > Third, I don't see why we are stating this guideline /
    > recommendation / prescription. Users can always set the mode value
    > to nil in their init files, which, for a mode that always toggles
    > based on changes to this variable (which is the normal, recommended
    > case) will inhibit mode enabling upon load.

    Uh what?  Why should that happen?

Why shouldn't it? It works for me.

 (setq my-mode nil) ; Inhibit turning on when loaded.

By "enabling upon load" I don't mean turning the mode on systematically when
the file is loaded; I mean setting the variable value to non-nil unless it
is already defined. That's the way it works for me, at least: if the
variable is already defined, then loading the library does not set it. IOW,
I'm speaking only of the :init-value for define-minor-mode - the _default_
value if the user specifies none.

I interpreted the doc passage quoted as essentially saying that libraries
should not use ":init-value t". If I misinterpreted the passage, then what
was the real message?

    > That was the spin used previously in this doc, I believe, and I
    > think it is the correct recommendation. We should say something like
    > this (the idea, if not the wording):
    >
    >   Unless the mode automatically toggles upon changes to the mode
    >   variable, do not enable the mode upon load. Why? Because users
    >   have no way to inhibit enabling in that case.

    How do you suppose to inhibit enabling when the mode "automatically
    toggles upon changes" in this case?

By "automatically..." I mean the usual and recommended case of a minor mode
turning on and off when its variable's value changes. Inhibit default
enabling with this in your .emacs: (setq my-mode nil)

Am I missing something here?

    > That is the only case where it is important not to enable the mode
    > upon load, AFAIK. The part about modes that don't respect their
    > variable is missing in the current guideline - it speaks of
    > "painless" and "harmless", but nowhere does it explain what the pain
    > or harm is.

    Files may even get autoloaded when going through a menu.

And?

That a file gets loaded via customize of through a menu or via cosmic ray is
not the point/problem, AFAICT. The point is what that library does. If a
particular library would cause harm by enabling a minor mode by default upon
loading, then it should not do that. Otherwise, where's the beef?

The problem is not that libraries can be loaded in various under-the-covers
ways at any unforeseen time. The problem is for each library writer to
determine if enabling the mode by default upon load is appropriate. If not,
don't do that.

It would be helpful to add guidelines with examples of things that libraries
might do that would make it inappropriate to enable their mode by default
upon load. IOW, specifics please.

    > I personally think that perhaps most normal (respectful) minor modes
    > should be enabled upon load, but I wouldn't go so far as to proclaim
    > that in the doc. Enabling the mode by default upon load
    > (i.e. enabling unless the variable is nil) is "harmless", unless I'm
    > missing something. If I am missing something, then maybe that
    > something needs to be added to the doc.

    Stuff connected with autoloads and customization groups triggers at
    unusual moments.

Too vague for me. Please formulate any specific problems that should be
added to the doc, in place of a blanket "Don't do that".





reply via email to

[Prev in Thread] Current Thread [Next in Thread]