commit dfbcae90bcca7de1428848f3397a7b0b2b663ffc
parent 15baad13e6cd09d7681565fe9e1f18b7dff8528d
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Sun, 10 Dec 2017 12:20:08 +0000
Allow users to call Customize from helpful buffers
Closes #59
Diffstat:
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -1,7 +1,7 @@
# v0.4
Variables may be set from the helpful buffer, and booleans can be
-toggled.
+toggled. If a variable is a `defcustom`, we also offer Customize.
Show the name of variables at the top of the helpful buffer.
diff --git a/helpful.el b/helpful.el
@@ -183,6 +183,16 @@ This allows us to distinguish strings from symbols."
'path path
'position pos))
+(define-button-type 'helpful-customize-button
+ 'action #'helpful--customize
+ 'symbol nil
+ 'follow-link t
+ 'help-echo "Open Customize for this symbol")
+
+(defun helpful--customize (button)
+ "Open Customize for this symbol."
+ (customize-variable (button-get button 'symbol)))
+
(define-button-type 'helpful-toggle-button
'action #'helpful--toggle
'symbol nil
@@ -647,7 +657,14 @@ state of the current symbol."
"Set variable" nil
:type 'helpful-set-button
'symbol helpful--sym
- 'buffer buf))))
+ 'buffer buf))
+ (when (custom-variable-p helpful--sym)
+ (insert
+ " "
+ (make-text-button
+ "Customize" nil
+ :type 'helpful-customize-button
+ 'symbol helpful--sym)))))
;; Show keybindings.
;; TODO: allow users to conveniently add and remove keybindings.