]> code.delx.au - gnu-emacs-elpa/commitdiff
Make ivy-completing-read handle history as cons
authorSamuel Loury <konubinixweb@gmail.com>
Wed, 18 Nov 2015 10:31:48 +0000 (11:31 +0100)
committerOleh Krehel <ohwoeowho@gmail.com>
Wed, 18 Nov 2015 11:08:57 +0000 (12:08 +0100)
The ivy-read function assumes that history is a symbol, hence
ivy-completing-read now makes sure that a symbol is given to
ivy-read.

Moreover, it makes sure that the value of initial-input is
coherent with the value of the HISTPOS part of the history
variable if it exists.

Fixes #295

ivy.el

diff --git a/ivy.el b/ivy.el
index 92b87fd0527c54495c8db8e603a020a85e8f294f..fe2d125568327266c6ff2fbb15e6bd1d7df0ed97 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -1238,6 +1238,12 @@ DEF is the default value.
 _INHERIT-INPUT-METHOD is ignored for now.
 
 The history, defaults and input-method arguments are ignored for now."
+  ;; See the doc of `completing-read'.
+  (when (consp history)
+    (when (numberp (cdr history))
+      (setq initial-input (nth (cdr history)
+                               (symbol-value (car history)))))
+    (setq history (car history)))
   (ivy-read (replace-regexp-in-string "%" "%%" prompt)
             collection
             :predicate predicate