Parcourir la source

Enable "ido-fallback-command" in ido-ubiquitous

This means that you can now fall back to non-ido completion if ido
completion has already been started by calling "ido-fallback-command".
However, it needs to be bound to a key to be practical, because it can't
be activated through any mechanism that also uses the minibuffer (e.g.
M-x).
Ryan C. Thompson il y a 10 ans
Parent
commit
70d177f1da
1 fichiers modifiés avec 20 ajouts et 8 suppressions
  1. 20 8
      ido-ubiquitous.el

+ 20 - 8
ido-ubiquitous.el

@@ -525,7 +525,12 @@ This function is a wrapper for `ido-completing-read' designed to
 be used as the value of `completing-read-function'. Importantly,
 it detects edge cases that ido cannot handle and uses normal
 completion for them."
-  (let* (;; Set the active override and clear the "next" one so it
+  (let* (;; Save the original arguments in case we need to do the
+         ;; fallback
+         (orig-args
+          (list prompt collection predicate require-match
+          initial-input hist def inherit-input-method))
+         ;; Set the active override and clear the "next" one so it
          ;; doesn't apply to nested calls.
          (ido-ubiquitous-active-override ido-ubiquitous-next-override)
          (ido-ubiquitous-next-override nil)
@@ -565,14 +570,21 @@ completion for them."
                    (<= (length collection) ido-ubiquitous-max-items))))
          ;; Final check for everything
          (ido-allowed (and ido-allowed collection-ok))
-         (comp-read-fun
+         (result
           (if ido-allowed
-              'ido-ubiquitous-completing-read
-            ido-ubiquitous-fallback-completing-read-function)))
-    (funcall comp-read-fun
-	     prompt collection predicate
-	     require-match initial-input
-	     hist def inherit-input-method)))
+              (ido-ubiquitous-completing-read prompt collection
+               predicate require-match initial-input hist def
+               inherit-input-method)
+            (setq ido-exit 'fallback))))
+    ;; (message "Result: %S" result)
+    ;; (message "ido-exit: %S" ido-exit)
+    ;; Do the fallback if necessary. This could either be because ido
+    ;; can't handle the arguments, or the user indicated during
+    ;; completion that they wanted to fall back to non-ido completion.
+    (if (memq 'fallback (list ido-exit result))
+        (apply ido-ubiquitous-fallback-completing-read-function
+               orig-args)
+      result)))
 
 ;;; Old-style default support