summary refs log tree commit diff stats
path: root/lisp/+cus-edit.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+cus-edit.el')
-rw-r--r--lisp/+cus-edit.el80
1 files changed, 0 insertions, 80 deletions
diff --git a/lisp/+cus-edit.el b/lisp/+cus-edit.el deleted file mode 100644 index a67279c..0000000 --- a/lisp/+cus-edit.el +++ /dev/null
@@ -1,80 +0,0 @@
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(defcustom +custom-after-load-hook nil
37 "Functions to run after loading the custom file.")
38
39(defun +custom-load-ignoring-most-customizations (&optional
40 error
41 nomessage
42 nosuffix
43 must-suffix)
44 "Load `custom-file', ignoring most customizations.
45Ignore all faces, and only load variables in
46`+customize-variable-allowlist'. All the optional
47variables---ERROR, NOMESSAGE, NOSUFFIX, MUST-SUFFIX---are
48passed on to `load'.
49
50NOTE: ERROR is the opposite of its value in `load' -- meaning
51that this function by default does /not/ error, but will if you
52pass t to it."
53 (cl-letf (((symbol-function 'custom-set-faces) 'ignore)
54 ((symbol-function 'custom-set-variables)
55 (lambda (&rest args)
56 (apply #'custom-theme-set-variables 'user
57 (seq-filter (lambda (el)
58 (memq (car el)
59 +custom-variable-allowlist))
60 args)))))
61 (load custom-file (not error) nomessage nosuffix must-suffix))
62 (run-hooks '+custom-after-load-hook))
63
64(defun +cus-edit-expand-widgets (&rest _)
65 "Expand descriptions in `Custom-mode' buffers."
66 (interactive)
67 ;; "More/Hide" widgets (thanks alphapapa!)
68 (widget-map-buttons (lambda (widget _)
69 (pcase (widget-get widget :off)
70 ("More" (widget-apply-action widget)))
71 nil))
72 ;; "Show Value" widgets (the little triangles)
73 (widget-map-buttons (lambda (widget _)
74 (pcase (widget-get widget :off)
75 ("Show Value"
76 (widget-apply-action widget)))
77 nil)))
78
79(provide '+cus-edit)
80;;; +cus-edit.el ends here