From 8a88fcde819252ae5e6fc48f485f77f7cbc00ef6 Mon Sep 17 00:00:00 2001 From: duli Date: Wed, 14 Jan 2026 22:14:39 +0800 Subject: [PATCH] Fix denote--define-retrieve-front-matter not reusing opened buffer In earlier commits, `denote-rename-buffer' could open the same file multiple times when retrieving front matter, as described in https://github.com/protesilaos/denote/issues/652 . This occurred because the subroutine `denote--file-with-temp-buffer-subr', used in the definition of `denote--define-retrieve-front-matter', contained incorrect conditional logic. As a result, files were reopened instead of reusing already opened buffers. Fixes: https://github.com/protesilaos/denote/issues/652 * (denote--file-with-temp-buffer-subr): --- denote.el | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/denote.el b/denote.el index 4e12f4c..15bfdcd 100644 --- a/denote.el +++ b/denote.el @@ -2645,14 +2645,13 @@ Subroutine of `denote--file-with-temp-buffer'." (file-exists (file-exists-p file)) (buffer-modified (buffer-modified-p buffer))) (cond - ((or (and file-exists - buffer - (not buffer-modified) - (not (eq buffer-modified 'autosaved))) - (and file-exists (not buffer))) - (cons #'insert-file-contents file)) - (buffer + ((and file-exists + buffer + (not buffer-modified)) (cons #'insert-buffer buffer)) + ((and file-exists + (or (null buffer) buffer-modified)) + (cons #'insert-file-contents file)) ;; (t ;; (error "Cannot find anything about file `%s'" file)) )))