helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit c53fc352fcbf633285bbb85faed1a5b8ceab2fde
parent 5922370d79516d36a43f68b51643c8fc7aa5aa26
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Thu, 14 Dec 2017 23:42:12 +0000

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.

Diffstat:
Mhelpful.el | 22+++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)

diff --git 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.