From 3fcbf3a238336621b159f1ffc0e99052315222ff Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 12:38:30 -0500 Subject: Merge two functions doing basically the same thing for Custom buffers --- init.el | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/init.el b/init.el index 69aafac..3fba01e 100644 --- a/init.el +++ b/init.el @@ -174,25 +174,31 @@ custom-unlispify-tag-names nil custom-variable-default-form 'lisp) - (defun unpackaged/custom-toggle-all-more-hide (&rest _) - "Toggle all \"More/Hide\" widgets in current buffer." - (interactive) - (widget-map-buttons (lambda (widget _) - (pcase (widget-get widget :off) - ("More" (widget-apply-action widget))) - nil))) - (advice-add 'custom-buffer-create - :after #'unpackaged/custom-toggle-all-more-hide) - - (defun acdw/custom-toggle-showing-all-values (&rest _) - "Toggle all \"Show Value\" widgets in current buffer." - (interactive) - (widget-map-buttons (lambda (widget _) - (pcase (widget-get widget :off) - ("Show Value" (widget-apply-action widget))) - nil))) - (advice-add 'custom-buffer-create - :after #'acdw/custom-toggle-showing-all-values)) + ;; `Custom-mode-hook' fires /before/ the widgets are built, so I have to + ;; install advice after the widgets are made. + (advice-add + 'custom-buffer-create :after + (defun custom-buffer@expand-widgets (&rest _) + "Expand descriptions and values of variables in `Custom-mode' buffers." + (interactive) + ;; "More/Hide" widgets (thanks alphapapa!) + (widget-map-buttons (lambda (widget _) + (pcase (widget-get widget :off) + ("More" (widget-apply-action widget))) + nil)) + ;; "Show Value" widgets (the little triangles) + (widget-map-buttons (lambda (widget _) + (pcase (widget-get widget :off) + ("Show Value" (widget-apply-action widget))) + nil)))) + + (add-hook ; thanks u/oantolin! + 'Custom-mode-hook + (defun custom-mode@imenu () + "Build `imenu' for `Custom-mode'." + (setq imenu-generic-expression + '(("Faces" "^\\(?:Show\\|Hide\\) \\(.*\\) face: \\[sample\\]" 1) + ("Variables" "^\\(?:Show Value\\|Hide\\) \\([^:\n]*\\)" 1)))))) (setup debugger (:hook visual-line-mode) -- cgit 1.4.1-21-gabe81