[Top][All Lists]

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

Re: Feature request: permanent-local values in hooks buffer local values

From: Lennart Borgman (gmail)
Subject: Re: Feature request: permanent-local values in hooks buffer local values
Date: Tue, 04 Dec 2007 19:13:35 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Richard Stallman wrote:
For buffer local values of hooks you can perhaps use that, but it probably does not do what you want. Some functions in a hook should survive changing major mode (for the same reasons that variables should do it), but other should not.

Could somehow a feature be added to hooks that fulfills the need I have sketched above?

Isn't change-major-mode-hook sufficient to take care of this need?

Perhaps you meant after-change-major-mode-hook? Yes, minor modes can add them selves to after-change-major-mode-hook to re-add their buffer local hook functions if that fits.

Perhaps that is better. It could look something like below where I have used flymake as an example. (flymake-mode is a minor mode that is buffer local, but that does not really care about major mode. It depends on the buffer file name instead.):

  (put 'flymake-mode 'permanent-local t)

  (defun flymake-add-to-local-hooks ()
    (when flymake-mode
      (add-hook 'after-change-functions 'flymake-after-change-function
                 nil t)
      (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
      (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)))

  (add-hook 'after-change-major-mode-hook 'flymake-add-to-local-hooks)

What disturbs me about a solution like this is that the global value of after-change-major-mode-hook must be used. (Am I missing something there?) It does not mean any performance penalty, of course. It just that it feels a bit strange.

Is this the way to go for such minor modes as flymake-mode? I think we need some guidelines here for minor mode authors.

The reason I am asking this is mainly because it has to be solved in some way for mumamo-mode. (For those who do not know about it see http://www.emacswiki.org/cgi-bin/wiki/MuMaMo )

reply via email to

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