From 46a93aa7b0753e7e1ba7c557709b2680ebb24fde Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 30 Dec 2023 11:31:51 +0100 Subject: [PATCH] find-buffer-visiting: Fix test breakage introduced in b7a737ef49 * lisp/files.el (find-buffer-visiting): Fix code branch checking for buffers referring to the same file number. We should check the found buffer with the file number, not current. Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66117#412 --- lisp/files.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 315ba831e8c..78e2bca3cff 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2220,15 +2220,17 @@ If there is no such live buffer, return nil." (number (file-attribute-file-identifier attributes))) (and buffer-file-numbers-unique (car-safe number) ;Make sure the inode is not just nil. - (let ((buf (find-buffer 'buffer-file-number number))) - (when (and buf (buffer-local-value 'buffer-file-name buf) + (let* ((buf (find-buffer 'buffer-file-number number)) + (buf-file-name (and buf (buffer-local-value 'buffer-file-name buf)))) + (when (and buf-file-name ;; Verify this buffer's file number ;; still belongs to its file. - (file-exists-p buffer-file-name) - (equal (file-attributes buffer-file-truename) - attributes) + (file-exists-p buf-file-name) + (equal + (file-attributes (buffer-local-value 'buffer-file-truename buf)) + attributes) (or (not predicate) - (funcall predicate (current-buffer)))) + (funcall predicate buf))) buf)))))))) -- 2.39.5