Browse Source

Properly handle list of defaults.

The "def" argument to "completing-read" can be a single string or a
list of strings, and my code only handled the singl-string case. Now
it behaves properly with a list of strings.
Ryan C. Thompson 12 years ago
parent
commit
35319b80b9
1 changed files with 5 additions and 0 deletions
  1. 5 0
      ido-ubiquitous.el

+ 5 - 0
ido-ubiquitous.el

@@ -196,6 +196,11 @@ be used as the value of `completing-read-function'."
   (let* ((ido-this-call-replaces-completing-read ido-next-call-replaces-completing-read)
          (ido-next-call-replaces-completing-read nil))
     (when ido-this-call-replaces-completing-read
+      ;; If DEF is a list, prepend it to CHOICES and set DEF to just the
+      ;; car of the default list.
+      (when (and def (listp def))
+        (setq choices (delete-dups (append def choices))
+              def (car def)))    ;; Work around a bug in ido when both INITIAL-INPUT and DEF are provided
       ;; More info: https://github.com/technomancy/ido-ubiquitous/issues/18
       (let ((initial (cond ((null initial-input) "")
                            ((stringp initial-input) initial-input)