all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Reacting to local var changes in mode-hooks and file-local vars
Date: Thu, 16 Dec 2010 02:39:12 +0100	[thread overview]
Message-ID: <AANLkTimPuwoy3Kz1as4a4wJ284z3L-+dn-7L1aMO1Cyn@mail.gmail.com> (raw)
In-Reply-To: <jwvmxod5qo9.fsf-monnier+emacs@gnu.org>

On Fri, Dec 10, 2010 at 9:31 PM, Stefan Monnier
<monnier@iro.umontreal.ca> 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 () ...)
  )



      parent reply	other threads:[~2010-12-16  1:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-10 20:31 Reacting to local var changes in mode-hooks and file-local vars Stefan Monnier
2010-12-16  1:24 ` Chong Yidong
2010-12-17  4:34   ` Stefan Monnier
2010-12-16  1:39 ` Lennart Borgman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimPuwoy3Kz1as4a4wJ284z3L-+dn-7L1aMO1Cyn@mail.gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.