emacs-devel
[Top][All Lists]
Advanced

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

Re: Reacting to local var changes in mode-hooks and file-local vars


From: Lennart Borgman
Subject: Re: Reacting to local var changes in mode-hooks and file-local vars
Date: Thu, 16 Dec 2010 02:39:12 +0100

On Fri, Dec 10, 2010 at 9:31 PM, Stefan Monnier
<address@hidden> wrote:
> Some major modes currently do things like
>
>   (defun my-mode ()
>     ...
>     (kill-all-local-variables)
>     ...
>     (run-mode-hooks 'my-mode-hook)
>     ...set up some more vars...)
>
> The "set up some more vars" code is there because those vars may depend
> on some other vars that are likely to be changed by the user in the
> my-mode-hook.
> This is actually a hack.  It works in some cases but has several
> downsides, such as:
> - can't use define-derived-mode to define such a mode.
> - can't derive from this mode since the "set up some more vars" would
>  then be run before the child mode hook.
> - does not react properly to file-local variable settings.
>
> Currently, the best fix I know is to do:
>
>  (define-derived-mode my-mode nil "My"
>    ...
>    (add-hook 'hack-local-variables-hook
>              (lambda () ...set up some more vars...)
>              nil t))
>
> but this also has some downsides:
> - hack-local-variables-hook is not run if enable-local-variables is nil.
> - hack-local-variables-hook is not run for non-file-modes
>  (e.g. comint modes) or when the user does M-x my-mode RET

Maybe something like

(define-derived-mode my-mode nil "Your"
  ...
  :after-local-variables-setup (lambda () ...)
  )



reply via email to

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