Parcourir la source

Don't pre-expand functional collections in ido-ubiquitous

Instead, if ido-ubiquitous decides to use ido with a functional
collection, it will set the new variable
ido-cr+-force-on-functional-collection to let ido-cr+ know it's ok,
and then pass the function on to ido-cr+ unmodified.

This change is needed for ido-describe-fns.el to work.
Ryan C. Thompson il y a 8 ans
Parent
commit
7be0f28aae
2 fichiers modifiés avec 17 ajouts et 11 suppressions
  1. 8 1
      ido-completing-read+.el
  2. 9 10
      ido-ubiquitous.el

+ 8 - 1
ido-completing-read+.el

@@ -73,6 +73,13 @@ Debug info is printed to the *Messages* buffer."
 (defvar ido-cr+-enable-this-call nil
   "If non-nil, then the current call to `ido-completing-read' is by `ido-completing-read+'")
 
+(defvar ido-cr+-force-on-functional-collection nil
+  "If non-nil, the next call to `ido-completing-read+' will operate on functional collections.
+
+This is not meant to be set permanently, but rather let-bound
+before calling `ido-completing-read+' under controlled
+circumstances.")
+
 (defvar ido-cr+-orig-completing-read-args nil
   "Original arguments passed to `ido-completing-read+'.
 
@@ -181,7 +188,7 @@ completion for them."
            ((bound-and-true-p completion-extra-properties)
             (signal 'ido-cr+-fallback
                     '("ido cannot handle non-nil `completion-extra-properties'")))
-           ((functionp collection)
+           ((and (functionp collection) (not ido-cr+-force-on-functional-collection))
             (signal 'ido-cr+-fallback
                     '("ido cannot handle COLLECTION being a function"))))
           ;; Expand all possible completions

+ 9 - 10
ido-ubiquitous.el

@@ -662,21 +662,20 @@ completion for them."
                    (ido-ubiquitous-active-state
                     (or ido-ubiquitous-active-override
                         ido-ubiquitous-default-state
-                        'enable)))
+                        'enable))
+                   (ido-cr+-force-on-functional-collection
+                    (or ido-ubiquitous-allow-on-functional-collection
+                        (memq ido-ubiquitous-active-override
+                              '(enable enable-old)))))
               ;; If ido-ubiquitous is disabled this time, fall back
               (when (eq ido-ubiquitous-active-state 'disable)
                 (signal 'ido-ubiquitous-fallback
                         '("`ido-ubiquitous-active-state' is `disable'")))
-              ;; Handle a collection that is a function: either expand
-              ;; completion list now or fall back
+              ;; Handle a collection that is a function: trigger the
+              ;; ido-ubiquitous fallback rather than waiting for
+              ;; ido-cr+ to do its own fall back.
               (when (functionp collection)
-                (if (or ido-ubiquitous-allow-on-functional-collection
-                        (memq ido-ubiquitous-active-override
-                              '(enable enable-old)))
-                    (setq collection (all-completions "" collection predicate)
-                          ;; `all-completions' will apply the predicate,
-                          ;; so it now becomes redundant.
-                          predicate nil)
+                (unless ido-cr+-force-on-functional-collection
                   (signal 'ido-ubiquitous-fallback
                           '("COLLECTION is a function and there is no override"))))
               (let ((ido-ubiquitous-enable-next-call t))