Subject: Re: mode-specific and file-regexp-specific settings

From: Didier Verna <[email-masked]>
Date: Thu, 07 Feb 2013 18:25:37 +0100

Stefan Monnier <[email-masked]> wrote:

> Also, we should introduce a way to set variables to a value that is
> mode-dependent.  Maybe something like
>
>   (setq-modes whitespace-style
>      (foo-mode 'face)
>      (bar-mode 'trailing)
>      (t 'tab-mark))
>
> Which could turn into something akin to
>
>   (setq-default whitespace-style 'tab-mark)
>   (add-hook 'bar-mode-hook (lambda () (setq-local whitespace-style 'trailing)))
>   (add-hook 'foo-mode-hook (lambda () (setq-local whitespace-style 'face)))

  Oh, and BTW this is not gonna work. What you're doing here is
  instantiating buffer-local values once and for all. If later on the
  user changes his mode-specific settings, they won't be propagated to
  the already existing buffers.

  On the contrary, what I do in whitespace.el (and I think what should
  be done in a general solution) is to dynamically retreive the
  file/mode-specific value everytime it's needed, so that user changes
  are visible everywhere immediately (this is what specifiers do in
  XEmacs in fact).

-- 
ELS 2013, June 3/4, Madrid, Spain:  http://els2013.european-lisp-symposium.org

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com