[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A programming puzzle with buffer-local hooks
From: |
martin rudalics |
Subject: |
Re: A programming puzzle with buffer-local hooks |
Date: |
Fri, 19 May 2017 08:30:33 +0200 |
> 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.
I would use reference counting with an increment call when the mode is
enabled in a buffer and a decrement call run by ‘kill-buffer-hook’ and
when the mode gets disabled in a buffer. Obviously, the function on
‘kill-buffer-hook’ should be removed together with the other functions
when that count drops to zero.
martin