aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2017-12-14 23:42:12 +0000
committerWilfred Hughes <me@wilfred.me.uk>2017-12-14 23:42:12 +0000
commitc53fc352fcbf633285bbb85faed1a5b8ceab2fde (patch)
tree4757f94b55dda0ced9ea3da588c90831cd63baf1
parent5922370d79516d36a43f68b51643c8fc7aa5aa26 (diff)
Emulate eval-expression more closely when reading new values
Put point at the beginning of the new value, and run eval-expression-minibuffer-setup-hook so things like paredit get enabled.
-rw-r--r--helpful.el22
1 files changed, 15 insertions, 7 deletions
diff --git a/helpful.el b/helpful.el
index 91a3913..7b536c8 100644
--- a/helpful.el
+++ b/helpful.el
@@ -283,14 +283,22 @@ or disable if already enabled."
(let* ((sym (button-get button 'symbol))
(sym-value (symbol-value sym))
(buf (button-get button 'buffer))
- ;; Inspired by `counsel-set-variable'.
+ ;; Inspired by `counsel-read-setq-expression'.
(expr
- (read-from-minibuffer
- "Eval: "
- (format
- (if (consp sym-value) "(setq %s '%S)" "(setq %s %S)")
- sym sym-value)
- read-expression-map t)))
+ (minibuffer-with-setup-hook
+ (lambda ()
+ (add-function :before-until (local 'eldoc-documentation-function)
+ #'elisp-eldoc-documentation-function)
+ (run-hooks 'eval-expression-minibuffer-setup-hook)
+ (goto-char (minibuffer-prompt-end))
+ (forward-char (length (format "(setq %S " sym))))
+ (read-from-minibuffer
+ "Eval: "
+ (format
+ (if (consp sym-value) "(setq %s '%S)" "(setq %s %S)")
+ sym sym-value)
+ read-expression-map t
+ 'read-expression-history))))
(save-current-buffer
;; If this is a buffer-local variable, ensure we're in the right
;; buffer.