emacs-devel
[Top][All Lists]
Advanced

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

Re: turn-on-*-mode


From: Miles Bader
Subject: Re: turn-on-*-mode
Date: Wed, 17 May 2006 11:18:16 +0900

Reiner Steib <address@hidden> writes:
> An advantage of turn-on-... (and turn-off-...) is that is simplifies
> adding it to a hook:
>
>   (add-hook 'text-mode-hook 'turn-on-auto-fill)
>   (add-hook 'text-mode-hook (lambda () (flyspell-mode 1)))
>
> BTW, AFAICS the `flyspell-mode' entry in the defcustom of
> `text-mode-hook' toggles `flyspell-mode' instead of turning it on:

Stefan had a (what I thought was) clever suggestion to deal with this:
Make "...-mode" functions toggle only when used interactively (just as
they only print a message when used interactively), and otherwise have
them just enable the state unconditionally.

This is not a strictly compatible change, but in practice probably would
fix more problems than it would cause -- nobody in their right mind puts
a mode-function in a hook with the intention to toggle the state, but
people _do_ put mode functions in hooks _thinking_ that they
unconditionally enable the mode.

A possible variant of this idea that might be more compatible is to have
`run-hooks' bind a global variable to t when running a hook
(e.g. `running-hook'), and have mode function unconditionally enable the
mode when that variable is non-nil.

-Miles
-- 
It wasn't the Exxon Valdez captain's driving that caused the Alaskan oil spill.
It was yours.  [Greenpeace advertisement, New York Times, 25 February 1990]




reply via email to

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