emacs-devel
[Top][All Lists]
Advanced

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

Re: How global is a define-global-minor-mode mode?


From: Stefan Monnier
Subject: Re: How global is a define-global-minor-mode mode?
Date: Sun, 21 Jan 2007 18:11:00 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

>> I am trying to use define-global-minor-mode, see below. I have
>> customized the global mode to be t, but when I open new buffers the
>> minor mode is not set in them. Is this a bug in
>> define-global-minor-mode?

> Seems to be working fine.  Your recipe is a little vague, but here is
> a simple example:

> 1.  Evaluate the following in *scratch* buffer:

>   (define-minor-mode foo-mode
>    "Foo."
>    nil
>    " foo"
>    :group 'foo)

>   (define-global-minor-mode html-site-global-mode foo-mode
>     (lambda () (foo-mode 1))
>     :group 'foo)

> 2. M-x customize-option RET foo RET
> 3. Click on "Toggle" (global-foo-mode is turned on)
> 4. Click on "Set for Current Session"
> 5. C-x C-f asdf RET (open a new file)
> 6. Observe the presence of the " foo" lighter in the modeline.

> There is one subtlety, which is that if you save the custom option for
> future sessions, it won't activate foo-mode in future sessions unless
> the above code defining foo-mode and global-foo-mode is already
> loaded.  But I don't think that's necessary a bug; it's a flaw but not
> one that's easily avoidable.

Isn't it the case that it works if the minor mode function corresponding to
the variable is autoloaded?  Otherwise, IIRC you need to add a :require
to the definition of the minor mode.


        Stefan




reply via email to

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