summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKarl Fogel <kfogel@red-bean.com>2009-09-05 16:25:27 +0000
committerKarl Fogel <kfogel@red-bean.com>2009-09-05 16:25:27 +0000
commit049a231b91bfb3b6f59b478d512829d35ad701b9 (patch)
tree04888c4d79cb36a82000f6cbb3ebd54e07c9eabc /lisp
parentef7ef2a01693469788f72fdaa554b88f1b961e0f (diff)
downloademacs-049a231b91bfb3b6f59b478d512829d35ad701b9.tar.gz
* lisp/files.el (find-alternate-file): Run `kill-buffer-hook' manually
before killing the old buffer, since by the time `kill-buffer' is run so many buffer variables have been set to nil that it may not behave as expected. (Bug#4061)
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/files.el15
2 files changed, 20 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9356b66552d..8d5200e5ddf 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
2009-09-05 Karl Fogel <kfogel@red-bean.com>
+ * files.el (find-alternate-file): Run `kill-buffer-hook' manually
+ before killing the old buffer, since by the time `kill-buffer' is
+ run so many buffer variables have been set to nil that it may not
+ behave as expected. (Bug#4061)
+
+2009-09-05 Karl Fogel <kfogel@red-bean.com>
+
* files.el (find-alternate-file): If the old buffer is modified
and visiting a file, behave similarly to `kill-buffer' when
killing it, thus reverting to the pre-1.878 behavior; see
diff --git a/lisp/files.el b/lisp/files.el
index 773740214b7..e20f4695b49 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1493,6 +1493,17 @@ killed."
(odir dired-directory)
(otrue buffer-file-truename)
(oname (buffer-name)))
+ ;; Run `kill-buffer-hook' here. It needs to happen before
+ ;; variables like `buffer-file-name' etc are set to nil below,
+ ;; because some of the hooks that could be invoked
+ ;; (e.g., `save-place-to-alist') depend on those variables.
+ ;;
+ ;; Note that `kill-buffer-hook' is not what queries whether to
+ ;; save a modified buffer visiting a file. Rather, `kill-buffer'
+ ;; asks that itself. Thus, there's no need to temporarily do
+ ;; `(set-buffer-modified-p nil)' before running this hook.
+ (run-hooks 'kill-buffer-hook)
+ ;; Okay, now we can end-of-life the old buffer.
(if (get-buffer " **lose**")
(kill-buffer " **lose**"))
(rename-buffer " **lose**")
@@ -1520,8 +1531,8 @@ killed."
(rename-buffer oname)))
(unless (eq (current-buffer) obuf)
(with-current-buffer obuf
- ;; We already asked; don't ask again.
- (let ((kill-buffer-query-functions))
+ ;; We already ran these; don't run them again.
+ (let (kill-buffer-query-functions kill-buffer-hook)
(kill-buffer obuf))))))
(defun create-file-buffer (filename)