From mboxrd@z Thu Jan 1 00:00:00 1970 From: Narendra Joshi Subject: Re: Searching all attachments in org-files Date: Tue, 26 Dec 2017 19:26:28 +0530 Message-ID: <87d131a8z7.fsf@gmail.com> References: <87vagua8vm.fsf@gmail.com> <877eta2vzl.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eTpiv-0005ae-8u for emacs-orgmode@gnu.org; Tue, 26 Dec 2017 08:57:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eTpid-0001nu-82 for emacs-orgmode@gnu.org; Tue, 26 Dec 2017 08:56:53 -0500 Received: from mail-pl0-x22a.google.com ([2607:f8b0:400e:c01::22a]:36853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eTpic-0001mp-QX for emacs-orgmode@gnu.org; Tue, 26 Dec 2017 08:56:34 -0500 Received: by mail-pl0-x22a.google.com with SMTP id b12so17891312plm.3 for ; Tue, 26 Dec 2017 05:56:34 -0800 (PST) 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") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Ihor Radchenko Cc: emacs-orgmode Ihor Radchenko 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