[Top][All Lists]

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

bug#6454: 24.0.50; kill-buffer switches current-buffer

From: Stefan Monnier
Subject: bug#6454: 24.0.50; kill-buffer switches current-buffer
Date: Fri, 25 Jun 2010 01:07:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> Actually, I think there is a small bug there: if kill-buffer-hook is a
> list of functions, the first function could potentially switch buffer
> and the second function would be called in the wrong buffer.

This is true of many hooks, yes, and we have generally taken the point
of view that if a hook function changes the current buffer, there can be
the following cases:
- it's OK the hook expects this anyway (e.g. write-region-annotate-functions)
- it breaks the code that runs the hook (e.g. kill-buffer): if the
  breakage is serious, it's a bug in the code that runs the hook that
  should protect itself from such changes.  If the breakage is not too
  serious and/or the performance is considered a serious issue you may
  just say "don't do that" in the docstring of the hook.
- it doesn't break the code that runs the hook, but it can break
  subsequent functions on that hook: we say that the bug is in the hook
  function, which simply should not change the current buffer.  We may
  add a note in the hook's docstring telling coders no to do that.

I think kill-buffer-hook is in the third category.

-- Stefan

reply via email to

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