all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `define-globalized-minor-mode': why the need for a separate TURN-ON function?
@ 2012-04-05 15:44 Drew Adams
  2012-04-07  3:56 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2012-04-05 15:44 UTC (permalink / raw)
  To: emacs-devel

I've only looked briefly at this, and am no doubt not noticing something.

Anyway, why for `define-globalized-minor-mode' must one define a separate
TURN-ON function to turn the mode on, but using the (local) minor-mode function
suffices to turn it off?

The relevant code in the definition of `define-globalized-minor-mode' seems to
be this part:

;; Go through existing buffers.
(dolist (buf (buffer-list))
  (with-current-buffer buf
    (if ,global-mode (,turn-on) (when ,mode (,mode -1))))))

Why not just this?

(dolist (buf (buffer-list))
  (with-current-buffer buf
    (if ,global-mode (,mode 1) (when ,mode (,mode -1))))))

There is another bit of code later on, but it seems similar - same question: why
not just (,mode 1) instead of (,turn-on)?  The (local) minor-mode function is
already defined, and it does a fine job of turning on the mode in a single
buffer - why the need for another, no-args function to do that?

There is no doubt a reason, otherwise we wouldn't have introduced this extra
TURN-ON hoop as a mandatory arg to `define-globalized-minor-mode'.  (I could
understand an optional arg, I guess, for the cases where such a turn-on function
already exists and might differ for some reason from what the minor-mode
function does with a positive arg.)

What am I missing?  Thx.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: `define-globalized-minor-mode': why the need for a separate TURN-ON function?
  2012-04-05 15:44 `define-globalized-minor-mode': why the need for a separate TURN-ON function? Drew Adams
@ 2012-04-07  3:56 ` Stefan Monnier
  2012-04-07 14:45   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2012-04-07  3:56 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

> I've only looked briefly at this, and am no doubt not noticing
> something.  Anyway, why for `define-globalized-minor-mode' must one
> define a separate TURN-ON function to turn the mode on, but using the
> (local) minor-mode function suffices to turn it off?

As the docstring says: "try to turn MODE on if applicable for that
buffer".  That's different to MODE itself which should turn it in if at
all possible.


        Stefan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: `define-globalized-minor-mode': why the need for a separate TURN-ON function?
  2012-04-07  3:56 ` Stefan Monnier
@ 2012-04-07 14:45   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2012-04-07 14:45 UTC (permalink / raw)
  To: 'Stefan Monnier'; +Cc: emacs-devel

> > why for `define-globalized-minor-mode' must one
> > define a separate TURN-ON function to turn the mode on, but 
> > using the (local) minor-mode function suffices to turn it off?
> 
> As the docstring says: "try to turn MODE on if applicable for that
> buffer".  That's different to MODE itself which should turn 
> it in if at all possible.

I see; thanks.  The "for that buffer" qualification did not jump out at me,
especially since the local mode already presumably does its thing for the
specific buffer where it is turned on.  The difference is that in the local case
it is the user who decides whether the mode makes sense and can be turned "for
that buffer".  In the global case it is the command that must decide separately,
for each buffer.

I understand now, but this was not at all obvious (to me) from just that 3-word
qualification.  You might want to make this distinction a bit more obvious in
the doc.  Perhaps say what you just said here, or add a brief example where the
distinction makes sense.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-07 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-05 15:44 `define-globalized-minor-mode': why the need for a separate TURN-ON function? Drew Adams
2012-04-07  3:56 ` Stefan Monnier
2012-04-07 14:45   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.