branch: master
commit 7ab66ed08268fd75657d21e370ee1e673c153b22
Author: Ryan C. Thompson <[email protected]>
Commit: Ryan C. Thompson <[email protected]>
Make DEF default to the empty string in ivy-completing-read
This maintains compatibility with completing-read-default, which
effectively treats a nil DEF as the empty string.
Since this may not always be desired, there is also a variable to
allow suppression of this behavior named
ivy-completing-read-default-is-empty-string.
---
ivy.el | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/ivy.el b/ivy.el
index a2fc22c..0640cef 100644
--- a/ivy.el
+++ b/ivy.el
@@ -273,6 +273,14 @@ Example:
This is a global variable that is set by ivy functions for use in
action functions.")
+(defvar ivy-completing-read-default-is-empty-string t
+ "If non-nil, emulate default arg handling of `completing-read-default'.
+
+Specifically, if `ivy-completing-read' is called with DEF nil, it
+will be treated as equivalent to specifying the empty string for
+DEF, since that is what `completing-read-default' does. If this
+is nil, then a nil DEF will really mean no default.")
+
;;* Keymap
(require 'delsel)
(defvar ivy-minibuffer-map
@@ -1856,6 +1864,8 @@ INHERIT-INPUT-METHOD is currently ignored."
(setq initial-input (nth (1- (cdr history))
(symbol-value (car history)))))
(setq history (car history)))
+ (when (and (null def) ivy-completing-read-default-is-empty-string)
+ (setq def ""))
(ivy-read (replace-regexp-in-string "%" "%%" prompt)
collection
:predicate predicate