From: Narendra Joshi <narendraj9@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Searching all attachments in org-files
Date: Tue, 26 Dec 2017 19:26:28 +0530 [thread overview]
Message-ID: <87d131a8z7.fsf@gmail.com> (raw)
In-Reply-To: <877eta2vzl.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> (Ihor Radchenko's message of "Tue, 26 Dec 2017 08:06:38 +0800")
Ihor Radchenko <yantar92@gmail.com> 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
prev parent reply other threads:[~2017-12-26 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-25 19:46 Searching all attachments in org-files Narendra Joshi
2017-12-26 0:06 ` Ihor Radchenko
2017-12-26 13:56 ` Narendra Joshi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d131a8z7.fsf@gmail.com \
--to=narendraj9@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).