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

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

[elpa] externals/org 8b18fc5817 3/3: org-attach-dir-from-id: Detect atta


From: ELPA Syncer
Subject: [elpa] externals/org 8b18fc5817 3/3: org-attach-dir-from-id: Detect attachments under default `org-attach-id-dir'
Date: Wed, 20 Sep 2023 06:58:29 -0400 (EDT)

branch: externals/org
commit 8b18fc581751e8525e97a1676657c586fb9f5e54
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-attach-dir-from-id: Detect attachments under default `org-attach-id-dir'
    
    * lisp/org-attach.el (org-attach-dir-from-id): When searching for an
    existing attachment directory, consider the default value of of
    `org-attach-id-dir', if it is changed.  This way, if user used the
    default value in the past (or accidentally via emacs -Q), we can still
    find the existing attachment dir.
---
 lisp/org-attach.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index a2ff955241..a3f8652fed 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -437,17 +437,26 @@ ignoring nils.  If EXISTING is non-nil, then return the 
first path
 found in the filesystem.  Otherwise return the first non-nil value."
   (let ((fun-list org-attach-id-to-path-function-list)
         (base-dir (expand-file-name org-attach-id-dir))
+        (default-base-dir (expand-file-name "data/"))
         preferred first)
     (while (and fun-list
                 (not preferred))
       (let* ((name (funcall (car fun-list) id))
-             (candidate (and name (expand-file-name name base-dir))))
+             (candidate (and name (expand-file-name name base-dir)))
+             ;; Try the default value `org-attach-id-dir' as a fallback.
+             (candidate2 (and name (not (equal base-dir default-base-dir))
+                              (expand-file-name name default-base-dir))))
         (setq fun-list (cdr fun-list))
         (when candidate
           (if (or (not existing) (file-directory-p candidate))
               (setq preferred candidate)
             (unless first
-              (setq first candidate))))))
+              (setq first candidate)))
+          (when (and existing
+                     candidate2
+                     (not (file-directory-p candidate))
+                     (file-directory-p candidate2))
+            (setq preferred candidate2)))))
     (or preferred first)))
 
 (defun org-attach-check-absolute-path (dir)



reply via email to

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