branch: externals/ivy-hydra
commit 4ba0944bec05c22d695fd5b89527160603649d62
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-set-variable): Save expr to the kill ring
---
counsel.el | 10 +++++++---
targets/plain.el | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/counsel.el b/counsel.el
index 7547aba..c5cbc9b 100644
--- a/counsel.el
+++ b/counsel.el
@@ -627,13 +627,14 @@ to `ivy-highlight-face'."
(insert (format "%S " sym)))
(read-from-minibuffer "Eval: "
(format
- (if (and sym-value (consp sym-value))
+ (if (and sym-value (or (consp
sym-value)
+ (symbolp
sym-value)))
"(setq '%S)"
"(setq %S)")
sym-value)
read-expression-map t
'read-expression-history))))
- (eval-expression expr)))
+ expr))
(defun counsel--setq-doconst (x)
"Return a cons of description and value for X.
@@ -710,12 +711,15 @@ With a prefix arg, restrict list to variables defined
using
(if (assoc res cands)
(cdr (assoc res cands))
(read res)))
+ (kill-new (format "(setq %S %S)" sym res))
(set sym (if (and (listp res) (eq (car res) 'quote))
(cadr res)
res))))
(unless (boundp sym)
(set sym nil))
- (counsel-read-setq-expression sym)))
+ (let ((expr (counsel-read-setq-expression sym)))
+ (kill-new (prin1-char expr))
+ (eval-expression expr))))
(when doc
(lv-delete-window)))))
diff --git a/targets/plain.el b/targets/plain.el
index 140db3e..7b3a27b 100644
--- a/targets/plain.el
+++ b/targets/plain.el
@@ -6,4 +6,5 @@
(global-set-key (kbd "C-s") 'swiper)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-rg)
+(global-set-key (kbd "<f2> j") 'counsel-set-variable)
(global-set-key (kbd "C-c s") 'isearch-forward-regexp)