emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sylvain Rousseau <thisirs@gmail.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: Using helm only for org refiling
Date: Fri, 19 Apr 2013 12:28:48 +0200	[thread overview]
Message-ID: <CAJ8n832jHsrNPNOHUQtMT-fThjE4ckwRxmtMO4hme5JBCBM7+A@mail.gmail.com> (raw)
In-Reply-To: <m2mwsv7tn6.fsf@top.irisa.fr>

[-- Attachment #1.1: Type: text/plain, Size: 758 bytes --]


I use the following patch (against release_8.0) to refile with helm. Just
set org-completion-handler to 'helm.

2013/4/18 Alan Schmitt <alan.schmitt@polytechnique.org>

> Hello,
> I tried using helm (the successor to anything) for everything, and it
> was a bit too much. However, I really appreciated how it integrated with
> org refiling.
> I've been trying to figure out how to enable helm only for refiling, by
> binding "C-c C-w" in the org-mode-map to something, but I'm getting lost
> in helm's source code. I guess it's calling "helm-org-headlines" at some
> point, but I cannot find how it interacts with the usual refiling
> approach.
> If someone is using helm with refiling, I'd gladly use some help here.
> Thanks,
> Alan

[-- Attachment #1.2: Type: text/html, Size: 1193 bytes --]

[-- Attachment #2: helm.patch --]
[-- Type: application/octet-stream, Size: 8120 bytes --]

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 936883a..198f699 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1691,7 +1691,7 @@ The template may still contain \"%?\" for cursor positioning."
 				   (member char '("u" "U"))
 				   nil nil (list org-end-time-was-given)))
-	    (let (org-completion-use-ido)
+	    (let (org-completion-handler)
 	      (push (org-completing-read-no-i
 		     (concat (if prompt prompt "Enter string")
 			     (if default (concat " [" default "]"))
diff --git a/lisp/org.el b/lisp/org.el
index b41185e..6062a81 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4115,23 +4115,16 @@ This is needed for font-lock setup.")
   :tag "Org Completion"
   :group 'org)
-(defcustom org-completion-use-ido nil
-  "Non-nil means use ido completion wherever possible.
-Note that `ido-mode' must be active for this variable to be relevant.
-If you decide to turn this variable on, you might well want to turn off
-See also `org-completion-use-iswitchb'."
+(defcustom org-completion-handler nil
+  "Non-nil means use other completion handler wherever possible.
+If you decide to turn this variable on, you might well want to
+turn off `org-outline-path-complete-in-steps'."
   :group 'org-completion
-  :type 'boolean)
-(defcustom org-completion-use-iswitchb nil
-  "Non-nil means use iswitchb completion wherever possible.
-Note that `iswitchb-mode' must be active for this variable to be relevant.
-If you decide to turn this variable on, you might well want to turn off
-Note that this variable has only an effect if `org-completion-use-ido' is nil."
-  :group 'org-completion
-  :type 'boolean)
+  :type '(choice
+	  (const :tag "Default" nil)
+	  (const :tag "Ido" ido)
+	  (const :tag "Iswitchb" iswitchb)
+	  (const :tag "Helm" helm)))
 (defcustom org-completion-fallback-command 'hippie-expand
   "The expansion command called by \\[pcomplete] in normal context.
@@ -9927,15 +9920,16 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
 	    (setq link
-		  (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)))
+		  (let (org-completion-handler)
+		    (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))
 		(user-error "No link selected"))
 	    (mapc (lambda(l)
@@ -10072,7 +10066,7 @@ See `read-file-name' for a description of parameters."
     (apply 'org-icompleting-read args)))
 (defun org-completing-read-no-i (&rest args)
-  (let (org-completion-use-ido org-completion-use-iswitchb)
+  (let (org-completion-handler)
     (apply 'org-completing-read args)))
 (defun org-iswitchb-completing-read (prompt choices &rest args)
@@ -10086,27 +10080,41 @@ from."
     (iswitchb-read-buffer prompt)))
 (defun org-icompleting-read (&rest args)
-  "Completing-read using `ido-mode' or `iswitchb' speedups if available."
+  "Completing-read using `ido-mode', `iswitchb' or `helm'
+speedups if available."
-   (if (and org-completion-use-ido
-	    (fboundp 'ido-completing-read)
-	    (boundp 'ido-mode) ido-mode
-	    (listp (second args)))
-       (let ((ido-enter-matching-directory nil))
-	 (apply 'ido-completing-read (concat (car args))
-		(if (consp (car (nth 1 args)))
-		    (mapcar 'car (nth 1 args))
-		  (nth 1 args))
-		(cddr args)))
-     (if (and org-completion-use-iswitchb
-	      (boundp 'iswitchb-mode) iswitchb-mode
-	      (listp (second args)))
-	 (apply 'org-iswitchb-completing-read (concat (car args))
-		(if (consp (car (nth 1 args)))
-		    (mapcar 'car (nth 1 args))
-		  (nth 1 args))
-		(cddr args))
-       (apply 'completing-read args)))))
+   (cond
+    ((and (eq org-completion-handler 'ido)
+	  (fboundp 'ido-completing-read)
+	  (boundp 'ido-mode) ido-mode
+	  (listp (second args)))
+     (let ((ido-enter-matching-directory nil))
+       (apply 'ido-completing-read (concat (car args))
+	      (if (consp (car (nth 1 args)))
+		  (mapcar 'car (nth 1 args))
+		(nth 1 args))
+	      (cddr args))))
+    ((and (eq org-completion-handler 'iswitchb)
+	  (boundp 'iswitchb-mode) iswitchb-mode
+	  (listp (second args)))
+     (apply 'org-iswitchb-completing-read (concat (car args))
+	    (if (consp (car (nth 1 args)))
+		(mapcar 'car (nth 1 args))
+	      (nth 1 args))
+	    (cddr args)))
+    ((and (eq org-completion-handler 'helm)
+	  (require 'helm-mode nil t)
+	  (listp (second args)))
+     (helm-comp-read (car args)
+		     (if (consp (car (nth 1 args)))
+			 (mapcar 'substring-no-properties
+				 (mapcar 'car (nth 1 args)))
+		       (nth 1 args))
+		     :test (nth 2 args)
+		     :must-match (nth 3 args)
+		     :initial-input (nth 4 args)
+		     :name "Refile completions"))
+    (t (apply 'completing-read args)))))
 (defun org-extract-attributes (s)
   "Extract the attributes cookie from a string and set as text property."
@@ -11432,7 +11440,7 @@ RFLOC can be a refile location obtained in a different way.
 MSG is a string to replace \"Refile\" in the default prompt with
 another verb.  E.g. `org-copy' sets this parameter to \"Copy\".
-See also `org-refile-use-outline-path' and `org-completion-use-ido'.
+See also `org-refile-use-outline-path' and `org-completion-use-handler'.
 If you are using target caching (see `org-refile-use-cache'),
 you have to clear the target cache in order to find new targets.
@@ -11705,8 +11713,7 @@ this is used for the GOTO interface."
 (defun org-olpath-completing-read (prompt collection &rest args)
   "Read an outline path like a file name."
   (let ((thetable collection)
-	(org-completion-use-ido nil)	   ; does not work with ido.
-	(org-completion-use-iswitchb nil)) ; or iswitchb
+	org-completion-handler)	   ; not work with other completion handler
      'org-icompleting-read prompt
      (lambda (string predicate &optional flag)
@@ -15041,7 +15048,7 @@ When INCREMENT is non-nil, set the property to the next allowed value."
 		      (car (nth (1- rpl) allowed))
 		    (org-completing-read "Effort: " allowed nil))))
-		(let (org-completion-use-ido org-completion-use-iswitchb)
+		(let (org-completion-handler)
 		   (concat "Effort " (if (and cur (string-match "\\S-" cur))
 					 (concat "[" cur "]") "")
@@ -15640,7 +15647,7 @@ This is computed according to `org-property-set-functions-alist'."
 		  (funcall set-function prompt allowed nil
 			   (not (get-text-property 0 'org-unrestricted
 						   (caar allowed))))
-		(let (org-completion-use-ido org-completion-use-iswitchb)
+		(let (org-completion-handler)
 		  (funcall set-function prompt
 			   (mapcar 'list (org-property-values property))
 			   nil nil "" nil cur)))))
@@ -17676,15 +17683,12 @@ With one prefix argument, restrict available buffers to files.
 With two prefix arguments, restrict available buffers to agenda files.
 Defaults to `iswitchb' for buffer name completion.
-Set `org-completion-use-ido' to make it use ido instead."
+Set `org-completion-handler' to make it use ido or helm instead."
   (interactive "P")
   (let ((blist (cond ((equal arg '(4))  (org-buffer-list 'files))
                      ((equal arg '(16)) (org-buffer-list 'agenda))
                      (t                 (org-buffer-list))))
-	(org-completion-use-iswitchb org-completion-use-iswitchb)
-	(org-completion-use-ido org-completion-use-ido))
-    (unless (or org-completion-use-ido org-completion-use-iswitchb)
-      (setq org-completion-use-iswitchb t))
+	(org-completion-handler (or org-completion-handler 'iswitchb)))
      (org-icompleting-read "Org buffer: "
 			   (mapcar 'list (mapcar 'buffer-name blist))

  reply	other threads:[~2013-04-19 10:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18 15:20 Alan Schmitt
2013-04-19 10:28 ` Sylvain Rousseau [this message]
2013-04-22  8:09   ` Alan Schmitt
2013-04-22  9:45     ` Sylvain Rousseau

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:

  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=CAJ8n832jHsrNPNOHUQtMT-fThjE4ckwRxmtMO4hme5JBCBM7+A@mail.gmail.com \
    --to=thisirs@gmail.com \
    --cc=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: Using helm only for org refiling' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:


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).