From mboxrd@z Thu Jan 1 00:00:00 1970 From: tony day Subject: [PATCH] * org-insert-link: use ido when inserting links Date: Sat, 13 Oct 2012 15:42:07 +1100 Message-ID: References: <04D0E787-A8A1-4246-8DD2-D607E38D61BA@gmail.com> <87a9vr3ldr.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 6.0 \(1486\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:54742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMtYE-0003s1-1O for emacs-orgmode@gnu.org; Sat, 13 Oct 2012 00:42:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMtYC-0003XE-Ha for emacs-orgmode@gnu.org; Sat, 13 Oct 2012 00:42:13 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:49693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMtYC-0003X8-80 for emacs-orgmode@gnu.org; Sat, 13 Oct 2012 00:42:12 -0400 Received: by mail-pa0-f41.google.com with SMTP id fa10so3763046pad.0 for ; Fri, 12 Oct 2012 21:42:11 -0700 (PDT) In-Reply-To: <87a9vr3ldr.fsf@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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org On 12 Oct 2012, at 23:50, Nicolas Goaziou wrote: > Thanks for considering my suggestions. So here are new ones: And a revised patch for your reviewing pleasure :) > Judging by your test case, it's the >=20 > (mapcar 'cadr org-stored-links) >=20 > part that cause problems, isn't it? I'm not sure why it should belong = to > the provided collection. Wouldn't dropping it solve the ido problem? No, but the combination of removing this and removing the list wrapper = solves the ordering issues I was trying to fix. I wasn't sure why the = cadr was there either. =20 >> Removed the hard coded iswitch and ido switches. >=20 > Just wondering: what will happen if an user wants to use iswitchb? Works for the first part and reverts to no assist on file: selection. >> Changed the order of prefixes so http came up first. >=20 > Please do not add unrelated "features" during a patch review. By the > way, I'm not sure to agree with you: it /is/ meaningful to have > user-defined link abbrevs before default types. Excellent advice (yes, even the nitpicks :) =46rom 31c9855ca6db95d10ca09611f749d74074b19b08 Mon Sep 17 00:00:00 2001 From: Tony Day Date: Fri, 12 Oct 2012 14:39:53 +1100 Subject: [PATCH] * org-insert-link: use ido when inserting links org.el (org-insert-link): remove a list within the list of link creation that causes a bug when using ido. Remove the hard coded iswitch and ido switches. (org-iread-file-name): create a function that can use ido-read-file-name if flagged as ok. (org-file-complete-link): reference org-iread-file-name. --- lisp/org.el | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index bdfc919..89acb81 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9317,18 +9317,15 @@ Use TAB to complete link prefixes, then RET for = type-specific completion support (unwind-protect (progn (setq link - (let ((org-completion-use-ido nil) - (org-completion-use-iswitchb nil)) - (org-completing-read - "Link: " - (append - (mapcar (lambda (x) (list (concat x ":"))) - all-prefixes) - (mapcar 'car org-stored-links) - (mapcar 'cadr org-stored-links)) - nil nil nil - 'tmphist - (caar org-stored-links)))) + (org-completing-read + "Link: " + (append + (mapcar (lambda (x) (concat x ":")) + all-prefixes) + (mapcar 'car org-stored-links)) + nil nil nil + 'tmphist + (caar org-stored-links))) (if (not (string-match "\\S-" link)) (error "No link selected")) (mapc (lambda(l) @@ -9422,7 +9419,7 @@ Use TAB to complete link prefixes, then RET for = type-specific completion support (defun org-file-complete-link (&optional arg) "Create a file link using completion." (let (file link) - (setq file (read-file-name "File: ")) + (setq file (org-iread-file-name "File: ")) (let ((pwd (file-name-as-directory (expand-file-name "."))) (pwd1 (file-name-as-directory (abbreviate-file-name (expand-file-name "."))))) @@ -9440,6 +9437,20 @@ Use TAB to complete link prefixes, then RET for = type-specific completion support (t (setq link (concat "file:" file))))) link)) =20 +(defun org-iread-file-name (&rest args) + "Read-file-name using `ido-mode' speedup if available. +ARGS are arguments that may be passed to `ido-read-file-name' or = `read-file-name'. +See `read-file-name' for a description of parameters. +" + (org-without-partial-completion + (if (and org-completion-use-ido + (fboundp 'ido-read-file-name) + (boundp 'ido-mode) ido-mode + (listp (second args))) + (let ((ido-enter-matching-directory nil)) + (apply 'ido-read-file-name args)) + (apply 'read-file-name args)))) + (defun org-completing-read (&rest args) "Completing-read with SPACE being a normal character." (let ((enable-recursive-minibuffers t) --=20 1.7.9.6 (Apple Git-31.1)