[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Searching all attachments in org-files
From: |
Narendra Joshi |
Subject: |
Re: [O] Searching all attachments in org-files |
Date: |
Tue, 26 Dec 2017 19:26:28 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) |
Ihor Radchenko <address@hidden> writes:
> Dear Narendra,
>
> Here is what I am using:
>
> (defun org-att-complete-link (&optional arg)
> "Completion dispatcher for att: links (rewritten from org-attach-open)"
> (let* ((attach-dir (org-attach-dir t))
> (files (org-attach-file-list attach-dir))
> (file (if (= (length files) 1)
> (car files)
> (completing-read "att: "
> (mapcar #'list files) nil t)))
> (path (expand-file-name file attach-dir)))
> (concat "att:" file)))
> (add-to-list 'org-link-abbrev-alist '("att" . org-attach-expand-link))
> (org-link-set-parameters
> "att"
> :complete 'org-att-complete-link)
#+begin_src emacs-lisp
(defun org-att-complete-link (&optional arg)
"Completion dispatcher for att: links (rewritten from org-attach-open)"
(let* ((attach-dir (expand-file-name org-attach-directory org-directory))
(file-paths (directory-files-recursively attach-dir ".*"))
(completions (mapcar (lambda (f)
(cons (file-name-base f) f))
file-paths))
(file-name (completing-read "att: " completions nil t))
(path (assoc-default file-name completions)))
(concat "att:" path)))
#+end_src
This worked for me. I had to change it a bit for my use case. Thanks a
lot for the help! :)
--
Narendra Joshi