emacs-devel
[Top][All Lists]
Advanced

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

Re: turning on minor modes from hooks


From: Miles Bader
Subject: Re: turning on minor modes from hooks
Date: Sun, 30 Aug 2009 11:11:41 +0900

"Drew Adams" <address@hidden> writes:
>> Stephen has long advocated that non-interactive invocation of mode
>> commands should always turn on the mode instead of toggling.
>
> So interactively a nil arg will toggle, but in Lisp a nil arg will turn it on?
> And just why is that a great idea?

Er, because it works the command work "as expected" in all contexts,
instead of in just one.

>> I agree with that:  I think the vast majority of uses in code 
>> do not use the toggling anyway, and while there probably are
>> a few uses which would be broken by such a change, I think
>> there would be far _more_ currently-incorrect uses
>
> In libraries or in user init files?

Mostly in user init files -- uses in libraries mostly won't be affected,
as they tend to explicitly specify the argument, and explicitly
set or reset the mode, not toggle it.

> The latter, maybe, at least until they
> discover that it doesn't do what they thought. That doesn't take long...

That's exactly the problem -- it _does_ take long for a user to
discover, because the default state for most modes is "off", and so
toggling _usually_ does the right thing.  Inadvertent use of the
toggling behavior tends to result in obscure and hard to locate bugs
(because it "usually" works right, and only fails in the rare case where
the mode happens to be already turned on for some reason).

>> that would be _fixed_ by such a change (where someone uses
>> (add-hook 'foo-hook 'ack-mode) not realizing that it really
>> toggles instead of turning on).
>
> "Not realizing" is the key phrase. This is not about being unable to 
> understand,
> I think. It's about ordinary ignorance. It's about things not being the way 
> some
> newbies expect, without reading the doc.

Yes.  Of course the doc should be good, but it's pretty clear that in
practice, it's not enough -- people don't always read the doc, or don't
read it carefully enough, or aren't experienced enough to understand all
the ramifications of what they're reading (the latter can be addressed
to some extent by careful wording, but it's almost impossible to do
reach all users).

Thus it's really really useful if we can have _both_ good docs _and_
commands that work intuitively.  Belt and braces, etc, etc.

> This is a YAGNI feature, at best, and a bug-producer and code
> complexifier, at worst.

I think you're wrong.  It will cause some bugs, but it will fix far more.

-Miles

-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff




reply via email to

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