diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+cus-edit.el | 72 |
1 files changed, 72 insertions, 0 deletions
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. | ||
42 | Ignore all faces, and only load variables in | ||
43 | `+customize-variable-allowlist'. All the optional | ||
44 | variables---NOERROR, NOMESSAGE, NOSUFFIX, MUST-SUFFIX---are | ||
45 | passed 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 | ||