all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: A programming puzzle with buffer-local hooks
Date: Thu, 18 May 2017 12:51:01 -0400	[thread overview]
Message-ID: <jwvlgpuhzz6.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 9bb8a8be-2cc6-f7cb-b164-13ffb77b8488@gmail.com

> The usual trick is to make the hook buffer local.

Can't work because the focus events don't care about the current-buffer.

> I can think of two other tricks: reference counting (every time the
> mode is disabled, check whether it's enabled anywhere else), and never
> removing the hook.

Before removing the hook, check if there's still a buffer where the mode
is activated.


        Stefan




  parent reply	other threads:[~2017-05-18 16:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 15:10 A programming puzzle with buffer-local hooks Clément Pit-Claudel
2017-05-18 15:16 ` Phillip Lord
2017-05-18 15:45   ` Clément Pit-Claudel
2017-05-18 16:51 ` Stefan Monnier [this message]
2017-05-18 18:38   ` Clément Pit-Claudel
2017-05-19  6:30 ` martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2017-05-18 15:54 Phillip Lord
2017-05-18 15:56 ` Clément Pit-Claudel
2017-05-18 18:46   ` Phillip Lord
2017-05-18 19:03     ` Clément Pit-Claudel

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=jwvlgpuhzz6.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@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.