all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* New minor mode toggling in V24
@ 2012-01-20  0:49 Frozenlock
  2012-01-20 13:55 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Frozenlock @ 2012-01-20  0:49 UTC (permalink / raw)
  To: emacs-devel

Dear GNU Emacs developers,

I've noticed that I can no longer use the form (some-minor-mode) to
toggle a minor mode on and off in a function. The function's
documentation now says "If called from Lisp, enable the mode if ARG is
omitted or nil."

My understanding of Lisp would have led me into thinking that a mode
is on when true and off when nil. Of course, I'm sure there's a good
reason for this, such as the "toggling" behavior.

However, that a function could behave differently when called
interactively violates the principle of least astonishment.
_Especially_ for functions used as often as modes.

If only it was that...

Now to toggle a mode inside a function, I do something like this:
(some-minor-mode (when some-minor-mode-variable) -1)
Yet, some modes do not name the some-minor-mode-variable the same as
the mode itself, making the action of toggling a mode a one of a kind,
built only for this mode.

Could minor-modes function behave the same when called by a function
as they would if called interactively? I believe The toggling would be
easier to understand for everyone (at least for myself).

ARG nil --> toggle
ARG 1   --> on
ARG -1  --> off


Thank you for your time,

Christian Fortin



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

* Re: New minor mode toggling in V24
  2012-01-20  0:49 New minor mode toggling in V24 Frozenlock
@ 2012-01-20 13:55 ` Stefan Monnier
  2012-01-20 18:01   ` Frozenlock
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2012-01-20 13:55 UTC (permalink / raw)
  To: Frozenlock; +Cc: emacs-devel

> ARG nil --> toggle
> ARG 1   --> on
> ARG -1  --> off

That's what happened in the past and we changed it, so clearly we're not
going back there.
Toggling non-interactively is a very rare need.  But you can do it with
(foo-mode 'toggle) if you don't like (foo-mode (if foo-mode -1 1)).


        Stefan


PS: In case you wonder about the reason for the change, it's for
(add-hook 'foo-mode-hook 'bar-mode), eliminating the "need" for those
otherwise redundant turn-on-foo-mode.



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

* Re: New minor mode toggling in V24
  2012-01-20 13:55 ` Stefan Monnier
@ 2012-01-20 18:01   ` Frozenlock
  0 siblings, 0 replies; 3+ messages in thread
From: Frozenlock @ 2012-01-20 18:01 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Thank you for the answer.

I do prefer to use (foo-mode 'toggle), thanks for the suggestion!
Alas, this precious info isn't in the foo-mode documentation (C-h f).
Unless it's somewhere else and I simply missed it, could it be added
in the mode documentation?

Christian

On Fri, Jan 20, 2012 at 8:55 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> ARG nil --> toggle
>> ARG 1   --> on
>> ARG -1  --> off
>
> That's what happened in the past and we changed it, so clearly we're not
> going back there.
> Toggling non-interactively is a very rare need.  But you can do it with
> (foo-mode 'toggle) if you don't like (foo-mode (if foo-mode -1 1)).
>
>
>        Stefan
>
>
> PS: In case you wonder about the reason for the change, it's for
> (add-hook 'foo-mode-hook 'bar-mode), eliminating the "need" for those
> otherwise redundant turn-on-foo-mode.



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

end of thread, other threads:[~2012-01-20 18:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20  0:49 New minor mode toggling in V24 Frozenlock
2012-01-20 13:55 ` Stefan Monnier
2012-01-20 18:01   ` Frozenlock

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.