Browse Source

org.el: Fix 7ec8ced

* org.el (org-icompleting-read): Correct bug introduced previously.
Rasmus 10 years ago
parent
commit
797023b84c
1 changed files with 27 additions and 21 deletions
  1. 27 21
      lisp/org.el

+ 27 - 21
lisp/org.el

@@ -10498,27 +10498,33 @@ from."
     (iswitchb-read-buffer prompt)))
 
 (defun org-icompleting-read (&rest args)
-  "Completing-read using `ido-mode' or `iswitchb' speedups if available."
-  (org-without-partial-completion
-   (let ((ido-enter-matching-directory nil))
-     (apply
-      (cond ((and org-completion-use-ido
-		  (fboundp 'ido-completing-read)
-		  (boundp 'ido-mode) ido-mode
-		  (listp (second args)))
-	     'ido-completing-read)
-	    ((and org-completion-use-iswitchb
-		  (boundp 'iswitchb-mode) iswitchb-mode
-		  (listp (second args)))
-	     'org-iswitchb-completing-read)
-	    (t (or (and (boundp 'completing-read-function)
-			completing-read-function)
-		   'completing-read)))
-      (concat (car args))
-      (if (consp (car (nth 1 args)))
-	  (mapcar 'car (nth 1 args))
-	(nth 1 args))
-      (cddr args)))))
+  "Completing-read using `ido-mode' or `iswitchb' speedups if available.
+
+Should be called like `completing-read'."
+  (let ((default-completion (or completing-read-function
+				completion-read)))
+    (org-without-partial-completion
+     (if (not (listp (second args)))
+	 ;; Ido only supports lists as the COLLECTION argument.  Use
+	 ;; default completion function when second argument is not a
+	 ;; list.
+	 (apply default-completion args)
+       (let ((ido-enter-matching-directory nil))
+	 (apply (cond ((and org-completion-use-ido
+			    (fboundp 'ido-completing-read)
+			    (boundp 'ido-mode)
+			    ido-mode)
+		       'ido-completing-read)
+		      ((and org-completion-use-iswitchb
+			    (boundp 'iswitchb-mode)
+			    iswitchb-mode)
+		       'org-iswitchb-completing-read)
+		      (t default-completion))
+		(pop args)
+		(if (org-some 'consp (car args))
+		    (mapcar 'car (pop args))
+		  (pop args))
+		args))))))
 
 (defun org-extract-attributes (s)
   "Extract the attributes cookie from a string and set as text property."