From mboxrd@z Thu Jan 1 00:00:00 1970 From: Giovanni Ridolfi Subject: Re: [PATCH] org-insert-link: allow ido usage when inserting links Date: Fri, 14 Sep 2012 10:39:40 +0100 (BST) Message-ID: <1347615580.74656.YahooMailNeo@web29802.mail.ird.yahoo.com> References: <5CE03302-7C87-44BE-B4AF-A6A92C96C803@gmail.com> Reply-To: Giovanni Ridolfi Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCSNI-0005J3-Nt for emacs-orgmode@gnu.org; Fri, 14 Sep 2012 05:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCSNC-0001Aj-Hp for emacs-orgmode@gnu.org; Fri, 14 Sep 2012 05:39:48 -0400 Received: from nm21-vm6.bullet.mail.ird.yahoo.com ([212.82.109.246]:47997) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TCSNC-0001Ab-3O for emacs-orgmode@gnu.org; Fri, 14 Sep 2012 05:39:42 -0400 In-Reply-To: <5CE03302-7C87-44BE-B4AF-A6A92C96C803@gmail.com> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: tony day , "emacs-orgmode@gnu.org" Cc: Bastien Hi, Tony,=0A=0Athanks for submitting the patch,=0A=0A=0Ahowever I suspect i= t is longer than 20 lines. =0ATherefore it could be applied only if you've = =0Aassigned the copyright to the FSF. For more infos please refer to:=0A=0A= http://orgmode.org/worg/org-contribute.html=0A=0AWould it be possible for y= ou?=0A=0AThanks,=0A=0AGiovanni=0A=0A=0A----- Messaggio originale -----=0ADa= : tony day =0AA: emacs-orgmode@gnu.org=0ACc: =0AInviato= : Venerd=EC 14 Settembre 2012 11:21=0AOggetto: [O] [PATCH] org-insert-link:= allow ido usage when inserting links=0A=0AThis time with patch inlined.=0A= =0AI had a look through and couldn't see an obvious reason why you can't us= e ido with org-insert-link, so here's a patch to enable it.=0A=0AI haven't = looked at using ido for editing links yet, but I figure org-capture would b= e a good pattern to do this.=A0 The other thought here is to add an 'org:' = link type so you can fire up ido just like org-capture (not sure what non-i= do org-capture looks like).=0A=0AThis is my first patch, so please let me k= now if I'm not doing things right.=0A=0ATony=0A=0A[PATCH] org-insert-link: = allow ido usage when inserting links=0A=0A* lisp/org.el (org-insert-link): = added all-links to cleanly create prefix+stored links for use in ido=0A(org= -i-read-file-name): new defun to allow ido to read a file: link if allowed= =0A=0ATINYCHANGE=0A---=0Alisp/org.el | 39 +++++++++++++++++++++++++--------= ------=0A1 file changed, 25 insertions(+), 14 deletions(-)=0A=0Adiff --git = a/lisp/org.el b/lisp/org.el=0Aindex 1c18d70..a918cfc 100644=0A--- a/lisp/or= g.el=0A+++ b/lisp/org.el=0A@@ -9397,7 +9397,7 @@ be used as the default des= cription."=0A=A0=A0=A0 tmphist ; byte-compile incorrectly complains about = this=0A=A0=A0=A0 (link link-location)=0A=A0=A0=A0 (abbrevs org-link-abbre= v-alist-local)=0A-=A0=A0=A0 entry file all-prefixes auto-desc)=0A+=A0=A0= =A0 entry file all-links all-prefixes auto-desc)=0A=A0 =A0 (cond=0A=A0 = =A0 =A0 (link-location) ; specified by arg, just use it.=0A=A0 =A0 =A0 ((or= g-in-regexp org-bracket-link-regexp 1)=0A@@ -9443,19 +9443,19 @@ Use TAB to= complete link prefixes, then RET for type-specific completion support=0A= =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 org-link-types))=0A=A0 =A0 =A0 (u= nwind-protect=0A=A0=A0=A0 =A0 (progn=0A+=A0=A0=A0 =A0 =A0 (setq all-links (= append=0A+=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0 (mapcar 'car org-stored-li= nks)=0A+=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0 (mapcar 'cadr org-stored-lin= ks)=0A+=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0 (mapcar (lambda (x) (concat x= ":"))=0A+=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0 all-prefixes)))= =0A+=A0=A0=A0 =A0 =A0 (setq all-links (delete nil all-links))=0A=A0=A0=A0 = =A0 =A0 (setq link=0A-=A0=A0=A0 =A0=A0=A0 =A0 (let ((org-completion-use-ido= nil)=0A-=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 (org-completion-use-iswitchb nil))= =0A-=A0=A0=A0 =A0=A0=A0 =A0 =A0 (org-completing-read=0A-=A0=A0=A0 =A0=A0=A0= =A0 =A0 "Link: "=0A-=A0=A0=A0 =A0=A0=A0 =A0 =A0 (append=0A-=A0=A0=A0 =A0= =A0=A0 =A0 =A0 =A0 (mapcar (lambda (x) (list (concat x ":")))=0A-=A0=A0=A0 = =A0=A0=A0 =A0=A0=A0 =A0 =A0 =A0 all-prefixes)=0A-=A0=A0=A0 =A0=A0=A0 =A0 = =A0 =A0 (mapcar 'car org-stored-links)=0A-=A0=A0=A0 =A0=A0=A0 =A0 =A0 =A0 (= mapcar 'cadr org-stored-links))=0A-=A0=A0=A0 =A0=A0=A0 =A0 =A0 nil nil nil= =0A-=A0=A0=A0 =A0=A0=A0 =A0 =A0 'tmphist=0A-=A0=A0=A0 =A0=A0=A0 =A0 =A0 (= caar org-stored-links))))=0A+=A0=A0=A0 =A0=A0=A0 =A0 (org-completing-read= =0A+=A0=A0=A0 =A0=A0=A0 =A0 "Link: "=0A+=A0=A0=A0 =A0=A0=A0 =A0 all-links= =0A+=A0=A0=A0 =A0=A0=A0 =A0 nil nil nil=0A+=A0=A0=A0 =A0=A0=A0 =A0 'tmphi= st=0A+=A0=A0=A0 =A0=A0=A0 =A0 (caar org-stored-links)))=0A=A0=A0=A0 =A0 = =A0 (if (not (string-match "\\S-" link))=0A=A0=A0=A0 =A0=A0=A0 (error "No l= ink selected"))=0A=A0=A0=A0 =A0 =A0 (mapc (lambda(l)=0A@@ -9542,7 +9542,7 @= @ Use TAB to complete link prefixes, then RET for type-specific completion = support=0A(defun org-file-complete-link (&optional arg)=0A=A0 "Create a fi= le link using completion."=0A=A0 (let (file link)=0A-=A0 =A0 (setq file (r= ead-file-name "File: "))=0A+=A0 =A0 (setq file (org-i-read-file-name "File:= "))=0A=A0 =A0 (let ((pwd (file-name-as-directory (expand-file-name ".")))= =0A=A0=A0=A0 =A0 (pwd1 (file-name-as-directory (abbreviate-file-name=0A=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 (expand-file-name ".")))))= =0A@@ -9560,6 +9560,17 @@ Use TAB to complete link prefixes, then RET for t= ype-specific completion support=0A=A0 =A0 =A0 =A0 (t (setq link (concat "fi= le:" file)))))=0A=A0 =A0 link))=0A=0A+(defun org-i-read-file-name (&rest a= rgs)=0A+=A0 "Read-file-name using `ido-mode' speedup if available."=0A+=A0 = (org-without-partial-completion=0A+=A0 (if (and org-completion-use-ido=0A+= =A0 =A0 =A0 =A0 =A0 =A0 (fboundp 'ido-read-file-name)=0A+=A0 =A0 =A0 =A0 = =A0 =A0 (boundp 'ido-mode) ido-mode=0A+=A0 =A0 =A0 =A0 =A0 =A0 (listp (seco= nd args)))=0A+=A0 =A0 =A0 (let ((ido-enter-matching-directory nil))=0A+=A0= =A0 =A0 =A0 (apply 'ido-read-file-name args))=0A+=A0 =A0 (apply 'read-fi= le-name args))))=0A+=0A(defun org-completing-read (&rest args)=0A=A0 "Comp= leting-read with SPACE being a normal character."=0A=A0 (let ((enable-recu= rsive-minibuffers t)=0A-- =0A1.7.12