Skip to content

qingshuizheng/setvarval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SetVarVal (rename to instant-setup?)==> (Setq Var Val)

Why

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.

Examples

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...
  )

Installation

(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
  )

Customizations

  1. setvarval-extract-type: variable type to collect defcustom defvar defconst defface.
  2. setvarval-group-style: the way output organize itself.
    1. simple: (setter var1 val1) (setter var2 val2) (setter var3 val3) ...
    2. one-setter: (setter var1 val1 var2 val2 var3 val3 ...)
    3. custom-set-*: (custom-set-variables/faces '(var1 val1) '(var2 val2) '(var3 val3) ...)
    4. use-package:custom: :custom (var1 val1) (var2 val2) (var3 val3) ...
    5. use-package:custom-face: :custom (var1 unquoted-val1) (var2 unquoted-val2) (var3 unquoted-val3) ...
    6. leaf:custom: :custom (var1 . val1) (var2 val2) (var3 val3) ...
    7. leaf:custom-face: same as ‘leaf:custom
    8. leaf:custom*: :custom '((var1 val1) (var2 val2) (var3 val3) ...)
    9. setup:option: (:option var1 val1 var2 val2 var3 val3 ...)
  3. setvarval-group-setter:
    1. setq / setopt
    2. custom-set-variables / custom-set-faces
    3. defface

Usage

  1. (optional) M-x setvarval-config RET to config variables.
    1. How config works: first select variable type to extract, then filter group style that are suitable for type, finally select reasonable setter to match type and style.
  2. M-x setvarval-extract-current-buffer RET to collect configs from current buffer.
  3. M-x setvarval-extract-current-package RET to collect configs from package name if cursor is wrapped in a package manager like use-package/leaf/setup.
  4. M-x setvarval-extract-current-package-insert RET act like above, but insert configs depending on the vaule of setvarval-group-style.
  5. M-x setvarval-extract-from-library to collect configs from selected loaded feature.
    1. Features not yet loaded are currently not supported.
  6. Only command names with “insert” will insert configs, otherwise save to kill-ring.
  7. Prefix any command with C-u to preconfig type style setter before collecting.

Features (no ETA)

  • 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 and defface
    • [ ] 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

Inspirations

rubikitch/auto-document

About

Config Emacs packages one step easier.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published