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: Wed, 24 Jan 2007 23:57:28 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

> I previously used defcustom variables to manage something similar to
> define-globalized-mode MY-GLOBAL-MODE MY-MODE. This worked ok. I then used
> the :set function to  turn on the minor mode MY-MODE.

> Using define-minor-mode there is no way to do something similar. There is no
> code that is run when the library file is loaded, even if the minor mode is
> global and that is in my opinion a bug (or at least a very inconvenient
> inconsistency).

Yes, there is code that runs the minor-mode function if it is global and has
been set.  This *should* work.  So please tell us what you tried that failed
to work.

> Actually define-minor-mode says that "other keywords will be passed to
> defcustom if the minor mode is global". Should not this mean that :set
> should be passed to defcustom and therefore be run when loading the library
> file if the minor mode as been customized to be on? I can not see that :set
> is run however.

Try to look at the macro expansion of (define-minor-mode foo-mode
"Foo" :global t) and you'll see it's got a :set.

> Please test it with the defcustom and define-minor-mode set.

I don't know what the above sentence means.

> (define-minor-mode html-site-temp-mode
>   "dummy"
>   :init-value nil
>   :lighter nil
>   :global t
>   :keymap (let ((m (make-sparse-keymap)))
>             (define-key m [f11] (lambda() (interactive) (message
> "html-site-mode-temp f11 here")))
>             m)
>   :set (lambda(sym val)
>          (message ":set html-site-temp-mode: sym=%s, val=%s" sym val)
>          (set-default sym val))
>   (message "body html-site-temp-mode=%s, current-buffer=%s" html-site-mode
> (current-buffer)))

Passing a :set here is likely to lead to surprises.

> As I use to say: I do not want to touch the CVS this close to the release
> since I am unfamiliar with cvs.

It's never too late to learn.  You can start by posting a patch generated
from "cvs diff", at which point "cvs commit -m <message>" should be all
that's needed.

> I would be glad if you changed the name.

So would I, but I don't have much time,


        Stefan




reply via email to

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