Too often, I explore one new package by extracting its defcustom/defface/defvar/defconst (mainly the first two), and organizing them into a new style. This package do some stuff for me.
There might be better packages for this, but this is mine.
This is what it looks like after extraction from Emacs builtin simple.el
with default settings. It is truncated due to long list.
;; This is automatically collected with setvarval, hundreds of lines:
(setq idle-update-delay 0.5)
(setq next-error-highlight 0.5)
(setq next-error-highlight-no-select 0.5)
(setq next-error-recenter nil)
(setq next-error-message-highlight nil)
(setq next-error-hook nil)
(setq next-error-verbose t)
(setq next-error-find-buffer-function #'ignore)
(setq next-error-found-function #'ignore)
;; .
;; .
;; .
;; .
;; more and more and more going on...
If cursor within use-package
, and setvarval-group-style
is set to use-package:custom
:
(use-package simple
;; This line below is automatically collected with setvarval, hundreds of lines:
:custom
(idle-update-delay 0.5)
(next-error-highlight 0.5)
(next-error-highlight-no-select 0.5)
(next-error-recenter nil)
(next-error-message-highlight nil)
(next-error-hook nil)
(next-error-verbose t)
(next-error-find-buffer-function #'ignore)
(next-error-found-function #'ignore)
;; .
;; .
;; .
;; .
;; more and more and more going on...
)
(use-package setvarval
:straight (:host "github" :repo "qingshuizheng/setvarval")
:config
(setq setvarval-extract-type 'defcustom) ; 'defvar, 'defconst, 'defface
(setq setvarval-group-style 'simple) ; 'simple, 'one-setter, 'custom-set-*, 'use-package:custom(-face), 'leaf:custom(*|-face), 'setup:option
(setq setvarval-group-setter 'setq) ; 'setopt, 'setq-local/default 'customize-set-variables/faces
)
setvarval-extract-type
: variable type to collectdefcustom
defvar
defconst
defface
.setvarval-group-style
: the way output organize itself.simple
:(setter var1 val1) (setter var2 val2) (setter var3 val3) ...
one-setter
:(setter var1 val1 var2 val2 var3 val3 ...)
custom-set-*
:(custom-set-variables/faces '(var1 val1) '(var2 val2) '(var3 val3) ...)
use-package:custom
::custom (var1 val1) (var2 val2) (var3 val3) ...
use-package:custom-face
::custom (var1 unquoted-val1) (var2 unquoted-val2) (var3 unquoted-val3) ...
leaf:custom
::custom (var1 . val1) (var2 val2) (var3 val3) ...
leaf:custom-face
: same as ‘leaf:customleaf:custom*
::custom '((var1 val1) (var2 val2) (var3 val3) ...)
setup:option
:(:option var1 val1 var2 val2 var3 val3 ...)
setvarval-group-setter
:setq
/setopt
custom-set-variables
/custom-set-faces
defface
- (optional)
M-x setvarval-config RET
to config variables.- How config works: first select variable
type
to extract, then filter groupstyle
that are suitable fortype
, finally select reasonablesetter
to matchtype
andstyle
.
- How config works: first select variable
M-x setvarval-extract-current-buffer RET
to collect configs from current buffer.M-x setvarval-extract-current-package RET
to collect configs from package name if cursor is wrapped in a package manager likeuse-package/leaf/setup
.M-x setvarval-extract-current-package-insert RET
act like above, but insert configs depending on the vaule ofsetvarval-group-style
.M-x setvarval-extract-from-library
to collect configs from selected loaded feature.- Features not yet loaded are currently not supported.
- Only command names with “insert” will insert configs, otherwise save to kill-ring.
- Prefix any command with
C-u
to preconfigtype
style
setter
before collecting.
- extract type
- [X] defcustom
- [X] defface
- [X] defvar
- [X] defconst
- group styles
- [X] simple
- [X] one-setter
- [X] custom-set-*
- [X] use-package:custom
- [X] use-package:custom-face
- [X] leaf:custom*
- [X] leaf:custom
- [X] leaf:custom-face
- [X] setup:option
- group setter
- [X] setq
- [X] setopt
- [X] customize-set-variables/faces
- [X] empty
- content-aware
- [X] use-package
- [X] setup
- [X] leaf
- [ ] (require ‘s)
- [ ] (with-eval-after-load ‘s)
- [ ] backward search library
- misc TODO list
- [X] support collecting configs from features not yet loaded.
- [ ] inhibit indent-region messages
- [ ] recursively include sub packages
- [ ] option to insert variables in a disabled state
- [ ] header comments and separators
- [ ] support default variable tyle to extract, e.g.,
defcustom
anddefface
- [ ] support custom group styles
- [ ] better data interaction between setter, var and val
- [ ] keep val as original state, e.g., ?% instead of 37
- [ ] support retrieval of deps
- [ ] diff default/user values after extraction
- [ ] support doc
- [ ] support :group in big el files for easy grouping, e.g., telega-customize.el