helpful icon indicating copy to clipboard operation
helpful copied to clipboard

Key to copy variable value as lisp setting

Open codecoll opened this issue 5 years ago • 1 comments

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"))))

codecoll avatar Jul 30 '19 15:07 codecoll

With a better function name, of course, it's just the one I use.

codecoll avatar Jul 30 '19 15:07 codecoll