all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using helm only for org refiling
@ 2013-04-18 15:20 Alan Schmitt
  2013-04-19 10:28 ` Sylvain Rousseau
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Schmitt @ 2013-04-18 15:20 UTC (permalink / raw)
  To: Org-mode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using helm only for org refiling
  2013-04-18 15:20 Using helm only for org refiling Alan Schmitt
@ 2013-04-19 10:28 ` Sylvain Rousseau
  2013-04-22  8:09   ` Alan Schmitt
  0 siblings, 1 reply; 4+ messages in thread
From: Sylvain Rousseau @ 2013-04-19 10:28 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Org-mode


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

Hello,

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)))
 	   (t
-	    (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
-`org-outline-path-complete-in-steps'.
-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
-`org-outline-path-complete-in-steps'.
-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
       (unwind-protect
 	  (progn
 	    (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."
   (org-without-partial-completion
-   (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
     (apply
      '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))))
 	       (t
-		(let (org-completion-use-ido org-completion-use-iswitchb)
+		(let (org-completion-handler)
 		  (org-completing-read
 		   (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-pop-to-buffer-same-window
      (org-icompleting-read "Org buffer: "
 			   (mapcar 'list (mapcar 'buffer-name blist))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Using helm only for org refiling
  2013-04-19 10:28 ` Sylvain Rousseau
@ 2013-04-22  8:09   ` Alan Schmitt
  2013-04-22  9:45     ` Sylvain Rousseau
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Schmitt @ 2013-04-22  8:09 UTC (permalink / raw)
  To: Sylvain Rousseau; +Cc: Org-mode

Sylvain Rousseau writes:

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

Thanks a lot, this is very nice!

Any chance this patch may be applied in the official repository?

Alan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using helm only for org refiling
  2013-04-22  8:09   ` Alan Schmitt
@ 2013-04-22  9:45     ` Sylvain Rousseau
  0 siblings, 0 replies; 4+ messages in thread
From: Sylvain Rousseau @ 2013-04-22  9:45 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Org-mode

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

Glad to be of some help!

I doubt this will be applied since helm is not bundled in emacs but we
could definitely use a more general completion handler that may take a
function and write that function outside of org's code.


Sylvain.

[-- Attachment #2: Type: text/html, Size: 377 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-22  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18 15:20 Using helm only for org refiling Alan Schmitt
2013-04-19 10:28 ` Sylvain Rousseau
2013-04-22  8:09   ` Alan Schmitt
2013-04-22  9:45     ` Sylvain Rousseau

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.