GNU bug report logs - #75949
kill-buffer-quit-windows breaks kill-buffer-hook

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Thu, 30 Jan 2025 17:14:02 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 75949 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Juri Linkov <juri <at> linkov.net>
Cc: 75949 <at> debbugs.gnu.org
Subject: Re: bug#75949: kill-buffer-quit-windows breaks kill-buffer-hook
Date: Sun, 2 Feb 2025 09:52:49 +0100
> Since a new argument can't be added, another variant would be at least
> to set the current buffer before every call of the hook functions.
> I.e. instead of
>
>    (run-hooks 'kill-buffer-hook)
>
> to do something like
>
>    (run-hook-wrapped 'kill-buffer-hook
>                      (lambda (fun)
>                        (with-current-buffer current-buffer
>                          (funcall fun))
>                        nil))
>
> But this won't help when buffers are switched inside hook functions.

The problem is that we run hooks completely in C so wrapping is at least
not that simple.  Whatever it is, nesting 'kill-buffer-hook' as in

 (add-hook 'kill-buffer-hook (lambda () (kill-buffer (get-buffer "bar")))
	    nil t)

is not really recommended.

martin




This bug report was last modified 111 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.