helpful
helpful copied to clipboard
Key to copy variable value as lisp setting
Could you add the key 'c' to copy a variable as a lisp expression setting? It could make it convenient to quickly copy a setting (especially for more complex variables with nested lists) to edit in the scratch buffer.
Here's the function, it's just needed to bound to the key c in Helpful:
(defun my-help-mode-copy-variable-setting-as-lisp ()
(interactive)
(save-excursion
(goto-char (point-min))
(if (not (looking-at ".*variable"))
(message "not a variable")
(looking-at "[^ ]+")
(let ((var (match-string 0)))
(kill-new (concat "(setq "
var
" '"
(pp (symbol-value (intern var)))
")")))
(message "copied"))))
With a better function name, of course, it's just the one I use.