branch: master
commit cd8a570d70c157e50e38dd0e8a5a5b43dc110077
Author: Kaushal Modi <[email protected]>
Commit: Kaushal Modi <[email protected]>
Escape `%` chars if present in the symbol value
* counsel-set-variable: The current value of the variable to be modified
is displayed in the ivy prompt. If the symbol value has literal '%'
characters they need to be escaped to '%%' so that they are not
processed by `ivy--reset-state`.
---
counsel.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/counsel.el b/counsel.el
index 3d09b37..200e136 100644
--- a/counsel.el
+++ b/counsel.el
@@ -541,9 +541,11 @@ input corresponding to the chosen variable."
(setq cands '(("nil" . nil) ("t" . t))))
(t nil)))
(let* ((sym-val (symbol-value sym))
- (res (ivy-read (format "Set (%S <%s>): " sym sym-val)
- cands
- :preselect (prin1-to-string sym-val))))
+ ;; Escape '%' chars if present
+ (sym-val-str (replace-regexp-in-string "%" "%%" (format "%s"
sym-val)))
+ (res (ivy-read (format "Set (%S <%s>): " sym sym-val-str)
+ cands
+ :preselect (prin1-to-string sym-val))))
(when res
(setq res
(if (assoc res cands)