emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/denote 63621dc37b 03/13: Fix regression caused by commi


From: ELPA Syncer
Subject: [elpa] externals/denote 63621dc37b 03/13: Fix regression caused by commit c0db85d
Date: Sun, 15 Oct 2023 03:57:50 -0400 (EDT)

branch: externals/denote
commit 63621dc37ba42e59102a438db9f10ad906761239
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Fix regression caused by commit c0db85d
    
    What we ultimately want is to be able to extract data from a buffer,
    though the previous version did not handle all cases gracefully. A
    problem with that was how it would get the title of the current file
    as the description of a link, even though it would correctly point to
    the selected link target.
---
 denote.el | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/denote.el b/denote.el
index 9279ebfba9..6131fbeb0c 100644
--- a/denote.el
+++ b/denote.el
@@ -1374,9 +1374,16 @@ Run `denote-desluggify' on title if the extraction is 
sucessful."
   "Return path to FILE or its buffer together with the appropriate function.
 Subroutine of `denote--file-with-temp-buffer'."
   (when file
-    (if (file-exists-p file)
-        (cons #'insert-file-contents buffer-file-name)
-      (cons #'insert-buffer (get-file-buffer file)))))
+    (let ((buffer (get-file-buffer file))
+          (file-exists (file-exists-p file)))
+      (cond
+       ((or (and file-exists buffer (not (buffer-modified-p buffer)))
+            file-exists)
+        (cons #'insert-file-contents file))
+       (buffer
+        (cons #'insert-buffer buffer))
+       (t
+        (error "Cannot find anything about file `%s'" file))))))
 
 (defmacro denote--file-with-temp-buffer (file &rest body)
   "If FILE exists, insert its contents in a temp buffer and call BODY."



reply via email to

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