summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el18
-rw-r--r--lisp/+cus-edit.el72
2 files changed, 90 insertions, 0 deletions
diff --git a/init.el b/init.el index 45133df..835af08 100644 --- a/init.el +++ b/init.el
@@ -136,6 +136,24 @@
136 calendar-latitude _location-latitude 136 calendar-latitude _location-latitude
137 calendar-longitude _location-longitude)) 137 calendar-longitude _location-longitude))
138 138
139(setup cus-edit
140 ;; I don't use Custom to actually /make/ any customizations, but it's handy to
141 ;; (A) see what options are available and (B) persist some changes across
142 ;; restarts, for example, `safe-local-variables'.
143 (:also-load +cus-edit)
144 (:option custom-file (private/ "custom.el")
145 custom-magic-show nil
146 custom-magic-show-button t
147 custom-raised-buttons nil
148 custom-unlispify-tag-names nil
149 custom-variable-default-form 'lisp
150 +custom-variable-allowlist '(safe-local-variable-values))
151 (when (file-exists-p custom-file)
152 (+custom-load-ignoring-most-customizations t))
153 (advice-add 'custom-buffer-create-internal :after '+cus-edit-expand-widgets)
154 (:with-mode Custom-mode
155 (:local-set imenu-generic-expression +cus-edit-imenu-generic-expression)))
156
139(setup dired 157(setup dired
140 (:also-load dired-x) 158 (:also-load dired-x)
141 (:also-straight dired-subtree 159 (:also-straight dired-subtree
diff --git a/lisp/+cus-edit.el b/lisp/+cus-edit.el new file mode 100644 index 0000000..2f9769d --- /dev/null +++ b/lisp/+cus-edit.el
@@ -0,0 +1,72 @@
1;;; +cus-edit.el -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; The naming convention for this library, called "cus-edit.el" on the
6;; filesystem, is all over the damn place. Whatever.
7
8;;; Code:
9
10(require 'cl-lib)
11(require 'seq)
12
13(defgroup +customize nil
14 "Extra customize customizations."
15 :prefix "+customize-"
16 :group 'customize)
17
18(defcustom +cus-edit-imenu-generic-expression ; thanks u/oantolin!
19 `(("Faces" ,(rx (seq bol
20 (or "Show" "Hide") " "
21 (group (zero-or-more nonl))
22 " face: [sample]"))
23 1)
24 ("Variables" ,(rx (seq bol
25 (or "Show Value" "Hide") " "
26 (group (zero-or-more
27 (not (any "\n:"))))))
28 1))
29 "Show faces and variables in `imenu' in a `customize' buffer."
30 :type 'sexp ; This is .. over-simplified.
31 )
32
33(defcustom +custom-variable-allowlist nil
34 "Variables to allow changing while loading the Custom file.")
35
36(defun +custom-load-ignoring-most-customizations (&optional
37 noerror
38 nomessage
39 nosuffix
40 must-suffix)
41 "Load `custom-file', ignoring most customizations.
42Ignore all faces, and only load variables in
43`+customize-variable-allowlist'. All the optional
44variables---NOERROR, NOMESSAGE, NOSUFFIX, MUST-SUFFIX---are
45passed on to `load'."
46 (cl-letf (((symbol-function 'custom-set-faces) 'ignore)
47 ((symbol-function 'custom-set-variables)
48 (lambda (&rest args)
49 (apply 'custom-theme-set-variables 'user
50 (seq-filter (lambda (el)
51 (memq (car el)
52 +customize-variable-allowlist))
53 args)))))
54 (load custom-file noerror nomessage nosuffix must-suffix)))
55
56(defun +cus-edit-expand-widgets (&rest _)
57 "Expand descriptions in `Custom-mode' buffers."
58 (interactive)
59 ;; "More/Hide" widgets (thanks alphapapa!)
60 (widget-map-buttons (lambda (widget _)
61 (pcase (widget-get widget :off)
62 ("More" (widget-apply-action widget)))
63 nil))
64 ;; "Show Value" widgets (the little triangles)
65 (widget-map-buttons (lambda (widget _)
66 (pcase (widget-get widget :off)
67 ("Show Value"
68 (widget-apply-action widget)))
69 nil)))
70
71(provide '+cus-edit)
72;;; +cus-edit.el ends here