emacs-devel
[Top][All Lists]
Advanced

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

Re: turn-on-*-mode


From: David Kastrup
Subject: Re: turn-on-*-mode
Date: Tue, 16 May 2006 17:31:58 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Sam Steingold <address@hidden> writes:

>> * Kim F. Storm <address@hidden> [2006-05-16 16:52:51 +0200]:
>>
>> And for non-interactive use, doing (*-mode 1) and (*-mode -1) is the
>> preferred interface.
>> There are also a number of "toggle-" functions, which IMO is a much
>> better interface (just one function, with a simple common prefix).
>
> I think I should have been more clear about the background.
> Yes, in a program, (*-mode *) is better.
> Yes, interactively, M-x *-mode is better.
>
> The only situation where the turn-on-*-mode functions are really needed
> is hooks:
>    (add-hook 'text-mode-hook 'turn-on-auto-fill)
> is much better than
>    (add-hook 'text-mode-hook (lambda () (auto-fill-mode 1)))
>
> Maybe minor modes that are commonly enabled from hooks should have their
> turn-on-* versions?

Or maybe we should have something like

(defun add-hook-turn-on (hook mode)
  (add-hook hook `(lambda nil (,mode 1))))

So that one can write
(add-hook-turn-on 'text-mode-hook 'auto-fill-mode)

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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