all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: Feature request: permanent-local values in hooks buffer local values
Date: Tue, 04 Dec 2007 19:13:35 +0100	[thread overview]
Message-ID: <475598CF.4050200@gmail.com> (raw)
In-Reply-To: <E1IzPpC-0008VA-Lo@fencepost.gnu.org>

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	other threads:[~2007-12-04 18:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-03 17:15 Feature request: permanent-local values in hooks buffer local values Lennart Borgman (gmail)
2007-12-03 18:22 ` Juanma Barranquero
2007-12-04  4:56 ` Richard Stallman
2007-12-04 18:13   ` Lennart Borgman (gmail) [this message]
2007-12-05  6:05     ` Richard Stallman
2007-12-05  7:21       ` Lennart Borgman (gmail)
2007-12-06  2:11         ` Richard Stallman
2007-12-07  0:25           ` Lennart Borgman (gmail)
2007-12-09 12:36             ` Richard Stallman
2007-12-09 14:21               ` Lennart Borgman (gmail)
2007-12-09 15:24                 ` Lennart Borgman (gmail)
2007-12-09 23:19                 ` Richard Stallman

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=475598CF.4050200@gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /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.