diff options
author | Case Duckworth | 2021-08-14 12:38:30 -0500 |
---|---|---|
committer | Case Duckworth | 2021-08-14 12:38:30 -0500 |
commit | 3fcbf3a238336621b159f1ffc0e99052315222ff (patch) | |
tree | 373707b366231db660739a6b799d58b277ee7db4 | |
parent | Don't error on bad drawers (diff) | |
download | emacs-3fcbf3a238336621b159f1ffc0e99052315222ff.tar.gz emacs-3fcbf3a238336621b159f1ffc0e99052315222ff.zip |
Merge two functions doing basically the same thing
for Custom buffers
-rw-r--r-- | init.el | 44 |
1 files 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 @@ | |||
174 | custom-unlispify-tag-names nil | 174 | custom-unlispify-tag-names nil |
175 | custom-variable-default-form 'lisp) | 175 | custom-variable-default-form 'lisp) |
176 | 176 | ||
177 | (defun unpackaged/custom-toggle-all-more-hide (&rest _) | 177 | ;; `Custom-mode-hook' fires /before/ the widgets are built, so I have to |
178 | "Toggle all \"More/Hide\" widgets in current buffer." | 178 | ;; install advice after the widgets are made. |
179 | (interactive) | 179 | (advice-add |
180 | (widget-map-buttons (lambda (widget _) | 180 | 'custom-buffer-create :after |
181 | (pcase (widget-get widget :off) | 181 | (defun custom-buffer@expand-widgets (&rest _) |
182 | ("More" (widget-apply-action widget))) | 182 | "Expand descriptions and values of variables in `Custom-mode' buffers." |
183 | nil))) | 183 | (interactive) |
184 | (advice-add 'custom-buffer-create | 184 | ;; "More/Hide" widgets (thanks alphapapa!) |
185 | :after #'unpackaged/custom-toggle-all-more-hide) | 185 | (widget-map-buttons (lambda (widget _) |
186 | 186 | (pcase (widget-get widget :off) | |
187 | (defun acdw/custom-toggle-showing-all-values (&rest _) | 187 | ("More" (widget-apply-action widget))) |
188 | "Toggle all \"Show Value\" widgets in current buffer." | 188 | nil)) |
189 | (interactive) | 189 | ;; "Show Value" widgets (the little triangles) |
190 | (widget-map-buttons (lambda (widget _) | 190 | (widget-map-buttons (lambda (widget _) |
191 | (pcase (widget-get widget :off) | 191 | (pcase (widget-get widget :off) |
192 | ("Show Value" (widget-apply-action widget))) | 192 | ("Show Value" (widget-apply-action widget))) |
193 | nil))) | 193 | nil)))) |
194 | (advice-add 'custom-buffer-create | 194 | |
195 | :after #'acdw/custom-toggle-showing-all-values)) | 195 | (add-hook ; thanks u/oantolin! |
196 | 'Custom-mode-hook | ||
197 | (defun custom-mode@imenu () | ||
198 | "Build `imenu' for `Custom-mode'." | ||
199 | (setq imenu-generic-expression | ||
200 | '(("Faces" "^\\(?:Show\\|Hide\\) \\(.*\\) face: \\[sample\\]" 1) | ||
201 | ("Variables" "^\\(?:Show Value\\|Hide\\) \\([^:\n]*\\)" 1)))))) | ||
196 | 202 | ||
197 | (setup debugger | 203 | (setup debugger |
198 | (:hook visual-line-mode) | 204 | (:hook visual-line-mode) |