Skip to content

Commit

Permalink
Make ivy-completing-read handle history as cons
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Konubinix authored and abo-abo committed Nov 18, 2015
1 parent 85bd44b commit adac116
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ivy.el
Expand Up @@ -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)

This comment has been minimized.

Copy link
@Konubinix

Konubinix Nov 18, 2015

Author Contributor

According to the documentation of completing-read: "Positions are counted starting from 1 at the beginning of the list". However, the documentation of nth states that: "N counts from zero"

Then, you should use (1- (nth ...)) here or the initial-input will not be correct.

This comment has been minimized.

Copy link
@abo-abo

abo-abo Nov 18, 2015

Owner

Thanks, fixed. I missed that part somehow. I think it's strange that it counts from 1.

(symbol-value (car history)))))
(setq history (car history)))
(ivy-read (replace-regexp-in-string "%" "%%" prompt)
collection
:predicate predicate
Expand Down

0 comments on commit adac116

Please sign in to comment.