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):
This commit is contained in:
duli 2026-01-14 22:14:39 +08:00
parent 47207e9cb2
commit 8a88fcde81
No known key found for this signature in database
GPG key ID: 0C378F00219F31FD

View file

@ -2645,14 +2645,13 @@ Subroutine of `denote--file-with-temp-buffer'."
(file-exists (file-exists-p file)) (file-exists (file-exists-p file))
(buffer-modified (buffer-modified-p buffer))) (buffer-modified (buffer-modified-p buffer)))
(cond (cond
((or (and file-exists ((and file-exists
buffer buffer
(not buffer-modified) (not buffer-modified))
(not (eq buffer-modified 'autosaved)))
(and file-exists (not buffer)))
(cons #'insert-file-contents file))
(buffer
(cons #'insert-buffer buffer)) (cons #'insert-buffer buffer))
((and file-exists
(or (null buffer) buffer-modified))
(cons #'insert-file-contents file))
;; (t ;; (t
;; (error "Cannot find anything about file `%s'" file)) ;; (error "Cannot find anything about file `%s'" file))
))) )))