unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Miles Bader'" <miles@gnu.org>, "'Dan Nicolaescu'" <dann@ics.uci.edu>
Cc: emacs-devel@gnu.org
Subject: RE: turning on minor modes from hooks
Date: Sat, 29 Aug 2009 17:14:53 -0700	[thread overview]
Message-ID: <9CA8B839B73049A6A7B1AD1C4D92BFC3@us.oracle.com> (raw)
In-Reply-To: <87eiqui4yx.fsf@catnip.gol.com>

> > (add-hook 'text-mode-hook   'auto-fill-mode)
> >
> > This avoids defining extra functions just for the purpose 
> > of being able to call them from hooks.

There's never been a need to define an "extra function" for use on a hook.

(add-hook 'text-mode-hook (lambda () (auto-fill-mode 1)))

> > Not sure how feasible is to have a clean implementation of 
> > such a feature...
> 
> 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?

> 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? The latter, maybe, at least until they
discover that it doesn't do what they thought. That doesn't take long...

> 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.

There are lots of such Emacs-Lisp gotchas that new users learn about soon
enough. What's so special about this one? This one they learn about as soon as
they try it the first time.

Or, barring simple trial and error, they can actually read the doc (quelle
horreur !) to find out that a nil arg toggles. It's the same thing for learning
about quoting or list structure or hooks or anything else: things might not be
what you expect if you don't read a little. Emacs puts the info at your
fingertips with doc strings and such - really not a biggee.

It's not as if this is something complex and difficult for users to understand -
some people just don't bother to check a doc string or Info.

You seem to contrast ignorance about the arg, on the one hand, with the entire
body of existing Lisp code that uses mode functions, on the other. Granted, most
mode-function calls do not toggle the mode, but I don't think toggling is that
rare.

Not to mention code that might specifically test the arg, treating nil
differently from a positive integer - oops, guess what, starting with Emacs 23.2
they act the same...

I'd rather not expect library authors to have to adjust their existing code that
toggles the mode, to make it call (foo-mode (not foo-mode)) instead of
(foo-mode). I'd rather they not need to adjust code that examines the arg and
acts accordingly, changing the logic for Emacs post-23.1.

I'd rather that new users just read the doc and learn this FAQ, like so many
other FAQs. Not a biggee, and neither is using `lambda' in a hook. This is a
YAGNI feature, at best, and a bug-producer and code complexifier, at worst.

No, I don't feel very strongly about this, but I do not think it's a great idea.





  reply	other threads:[~2009-08-30  0:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-29 21:25 turning on minor modes from hooks Dan Nicolaescu
2009-08-29 23:18 ` Miles Bader
2009-08-30  0:14   ` Drew Adams [this message]
2009-08-30  2:11     ` Miles Bader
2009-08-30  3:01       ` Drew Adams
2009-08-30  3:58         ` Miles Bader
2009-08-30  3:59     ` Stefan Monnier
2009-08-30  4:00       ` Miles Bader
2009-08-31  3:33   ` Richard Stallman
2009-08-31 14:36     ` Stefan Monnier
2009-08-31 22:15       ` Miles Bader
2009-08-31 23:32         ` Stefan Monnier
2009-09-01  0:17           ` Miles Bader
2009-09-01 12:16       ` Richard Stallman
2009-09-01 16:19         ` Stefan Monnier
2009-09-01 21:20           ` Richard Stallman
2009-09-01 23:23             ` Stefan Monnier
2009-09-03 13:47               ` Richard Stallman
2009-09-04 21:23                 ` Geoff Gole
2009-08-31 15:30     ` Daniel Colascione
2009-08-31 18:54       ` Tassilo Horn
2009-09-01 12:16         ` Richard Stallman
2009-08-31 23:43       ` Stefan Monnier
2009-09-01  2:07       ` Stephen J. Turnbull

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9CA8B839B73049A6A7B1AD1C4D92BFC3@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).