[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Specifying mode in file variables trouble
From: |
Lennart Borgman (gmail) |
Subject: |
Re: Specifying mode in file variables trouble |
Date: |
Tue, 23 Sep 2008 19:22:50 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 |
Stefan Monnier wrote:
>> set to nil (see the sources for `run-mode-hooks'). I have no idea what
>> delayed-mode-hooks is used for so I do not know if setting
>
> It is used so that the parent mode hook is run at the end of the (child)
> major mode, so that the user's hook functions (placed on the parent
> hook) can take into account the variable values set by the child.
Thanks. I might be beginning to understand. From what you wrote above
and the somewhat scarse documentation I draw the conclusion that in
normal case the child major modes mode hook is run before the parent
major modes mode hook.
So the order of running the hooks is
childs local mode hook
which also include running childs global hook (at the `t')
parents' mode hooks
If this is correct then I think that adding the call to
mumamo-restore-most-buffer-locals first in the childs local mode hook
would be the best.
The values thus restored can then be changed by things coming later in
the mode hooks.
Since it looks like delay-mode-hook is something that we should not
touch in case we are not the macro delay-mode-hook this is nothing we
have to care about.
So this is what I have got now:
;; Save local variables before switching major
(mumamo-save-most-buffer-locals major-mode)
;; Restore local variables after switching, but do it in the mode
;; hook:
(let ((mode-hook (intern-soft (concat (symbol-name major) "-hook")))
(restore-fun (lambda ()
(mumamo-restore-most-buffer-locals major))))
(when mode-hook
;; Put first in local hook to run it first:
(add-hook mode-hook restore-fun nil t))
(funcall major) ;; <------- This is the major mode change
(if (not mode-hook)
(mumamo-restore-most-buffer-locals major)
(remove-hook mode-hook restore-fun t)))
- Re: Specifying mode in file variables trouble, (continued)
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/27
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/23
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/23
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/24
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/24
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/25
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/24
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/23
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/23
- Re: Specifying mode in file variables trouble, Stefan Monnier, 2008/09/23
- Re: Specifying mode in file variables trouble,
Lennart Borgman (gmail) <=
- Re: Specifying mode in file variables trouble, Stefan Monnier, 2008/09/23
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/23
- Re: Specifying mode in file variables trouble, Stefan Monnier, 2008/09/23
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/23
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/24
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/24
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/25
- Re: Specifying mode in file variables trouble, Lennart Borgman (gmail), 2008/09/25
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/26
- Re: Specifying mode in file variables trouble, Richard M. Stallman, 2008/09/26