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

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.