branch: master
commit d63ce8fa96103e9f3be422d7b9d48de13fde34ea
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Ensure that inserted candidates don't have read-only property
* ivy.el (ivy-completions): Update.
Fixes #28.
The issue was that the whole text of erc buffer has (read-only t)
property. That means if I copy some of those strings and insert them
into the minibuffer, I can't delete them unless I set
`inhibit-read-only' to t. Instead, I set the read-only to nil for the
string that I insert. It doesn't affect the original buffer string.
---
ivy.el | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/ivy.el b/ivy.el
index 4d307f3..a06b50c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -401,12 +401,14 @@ CANDIDATES is a list of strings."
(setq ivy--current (copy-sequence (nth index cands)))
(setf (nth index cands)
(ivy--add-face ivy--current 'ivy-current-match))
- (concat "\n" (mapconcat
- (lambda (s)
- (if (> (length s) ww)
- (concat (substring s 0 (- ww 3)) "...")
- s))
- cands "\n"))))))
+ (let ((res (concat "\n" (mapconcat
+ (lambda (s)
+ (if (> (length s) ww)
+ (concat (substring s 0 (- ww 3)) "...")
+ s))
+ cands "\n"))))
+ (put-text-property 0 (length res) 'read-only nil res)
+ res)))))
(provide 'ivy)