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

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

[elpa] master 891be1d 199/399: counsel.el (counsel-org-file): Handle ATT


From: Oleh Krehel
Subject: [elpa] master 891be1d 199/399: counsel.el (counsel-org-file): Handle ATTACH_DIR property
Date: Sat, 20 Jul 2019 14:57:23 -0400 (EDT)

branch: master
commit 891be1d9d1a7a2e53624db58149221b187b296fe
Author: Eric Danan <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-org-file): Handle ATTACH_DIR property
    
    Also list attachments from directories specified with the ATTACH_DIR rather
    than the ID property.
    
    Fixes #2042
---
 counsel.el | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/counsel.el b/counsel.el
index 269a19f..1355241 100644
--- a/counsel.el
+++ b/counsel.el
@@ -3311,26 +3311,23 @@ attachment directory associated with the current 
buffer, all
 contained files are listed, so the return value could conceivably
 include attachments of other Org buffers."
   (require 'org-attach)
-  (let* ((ids (let (res)
-                (save-excursion
-                  (goto-char (point-min))
-                  (while (re-search-forward "^:ID:[\t ]+\\(.*\\)$" nil t)
-                    (push (match-string-no-properties 1) res))
-                  (nreverse res))))
-         (files
-          (cl-remove-if-not
-           #'file-exists-p
-           (mapcar (lambda (id)
-                     (expand-file-name
-                      (concat (substring id 0 2) "/" (substring id 2))
-                      org-attach-directory))
-                   ids))))
+  (let (dirs)
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward "^:\\(ATTACH_DIR\\|ID\\):[\t ]+\\(.*\\)$" nil 
t)
+        (let ((dir (match-string-no-properties 2)))
+          (when (string= "ID" (match-string-no-properties 1))
+            (setq dir (expand-file-name
+                       (concat (substring dir 0 2) "/" (substring dir 2))
+                       org-attach-directory)))
+          (when (file-exists-p dir)
+            (push dir dirs)))))
     (cl-mapcan
      (lambda (dir)
        (mapcar (lambda (file)
                  (file-relative-name (expand-file-name file dir)))
                (org-attach-file-list dir)))
-     files)))
+     (nreverse dirs))))
 
 ;;;###autoload
 (defun counsel-org-file ()



reply via email to

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