[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: define-derived-mode runs parent mode hook after evaluating body
From: |
martin rudalics |
Subject: |
Re: define-derived-mode runs parent mode hook after evaluating body |
Date: |
Sat, 21 Jul 2007 11:21:02 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
>>(define-derived-mode change-log-mode text-mode "Change Log"
>> "..."
>> (setq left-margin 8
>> fill-column 74
>> ...
>
>
>>...but in my .emacs I have:
>
>
>>(add-hook
>> 'text-mode-hook
>> '(lambda () (setq fill-column 72)))
>
>
> The problem here is that we use text-mode both as a parent and as a real
> major-mode, so you can't change "text-mode" without changing all
> its derivatives.
>
> Maybe the real text-mode should be renamed to plain-text-mode (and derive
>>from text-mode, of course).
Which would solve this special case. In general, however, I want to add
something to a parent-mode hook and pass it on to its derivatives unless
the derivatives have their own opinion about that. Well, I could do
(add-hook
'text-mode-hook
'(lambda ()
(unless (and (local-variable-p 'fill-column)
(not (equal fill-column
(default-value 'fill-column))))
(setq fill-column 72))))
but this strikes me as inconvenient, ugly, and maybe faulty.