Convert from a plain Elisp to an expression using a leaf
.
This is accomplished by not just converting use-package
’s keywords, but by converting them once they have been expanded to a plain Elisp.
This may result in a simpler leaf
expression, but if there is no corresponding keyword, most of it will be converted to a :config
section.
Since the source is Elisp, it is possible to convert the leaf
to Elisp once and then convert it to leaf
again.
This can be used to convert miscellaneous settings in the :config
section into leaf
expressions with appropriate keywords.
It is also possible to optimize settings that are not needed.
Currently, the following leaf
keywords are supported for automatic conversion.
(leaf-available-keywords)
;;=> (:disabled
;; :leaf-protect ; <leaf system keyword>
;; :load-path ; supported!!
;; :load-path* ; supported!!
;; :leaf-autoload ; <leaf system keyword>
;; :doc ; <leaf doc keyword>
;; :req ; <leaf doc keyword>
;; :tag ; <leaf doc keyword>
;; :file ; <leaf doc keyword>
;; :url ; <leaf doc keyword>
;; :added ; <leaf doc keyword>
;; :defun ; supported!!
;; :defvar ; supported!!
;; :leaf-defun ; <leaf system keyword>
;; :leaf-defvar ; <leaf system keyword>
;; :preface ; supported!!
;; :when ; supported!!
;; :unless ; supported!!
;; :if ; <convert to :when or :unless>
;; :emacs<
;; :emacs<=
;; :emacs=
;; :emacs>
;; :emacs>=
;; :package ; <converted to :ensure>
;; :ensure ; supported!!
;; :feather ; <no corresponding sexp>
;; :straight
;; :el-get
;; :after ; supported!!
;; :commands ; supported!!
;; :bind ; supported!!
;; :bind* ; supported!!
;; :mode ; supported!!
;; :interpreter ; supported!!
;; :magic ; supported!!
;; :magic-fallback ; supported!!
;; :hook ; supported!!
;; :advice
;; :advice-remove
;; :init ; supported!!
;; :pre-setq
;; :pl-pre-setq
;; :auth-pre-setq
;; :custom ; supported!!
;; :custom* ; supported!!
;; :pl-custom
;; :auth-custom
;; :custom-face ; supported!!
;; :require ; supported!!
;; :hydra
;; :transient
;; :combop
;; :combo*
;; :smartrep
;; :smartrep*
;; :chord ; supported!!
;; :chord* ; supported!!
;; :mode-hook
;; :leaf-defer
;; :config ; supported!!
;; :global-minor-mode
;; :diminish ; supported!!
;; :delight ; supported!!
;; :setq ; supported!!
;; :setq-default ; supoorted!!
;; :pl-setq
;; :auth-setq
;; :pl-setq-default
;; :auth-setq-default)
leaf-convert
is available via el-get
.
(leaf leaf-convert :ensure t)
Pass any S-exps to leaf-convert
to get a leaf
expression.
(leaf-convert
(defvar leaf-covert-variable)
(bind-key "C-c x" 'my-ctrl-c-x-command)
(bind-key "C-c x" 'my-ctrl-c-x-command some-other-mode-map)
(bind-keys :map dired-mode-map
("o" . dired-omit-mode)
("a" . some-custom-dired-function)))
;;=> (leaf leaf-convert
;; :defvar leaf-covert-variable
;; :bind (("C-c x" . my-ctrl-c-x-command)
;; (some-other-mode-map
;; ("C-c x" . my-ctrl-c-x-command))
;; (dired-mode-map
;; ("o" . dired-omit-mode)
;; ("a" . some-custom-dired-function))))
(leaf-convert
(use-package edit-server
:if window-system
:init
(add-hook 'after-init-hook 'server-start t)
(add-hook 'after-init-hook 'edit-server-start t)))
;;=> (leaf edit-server
;; :when window-system
;; :hook ((after-init-hook . server-start)
;; (after-init-hook . edit-server-start))
;; :require t)
(leaf-convert
(leaf markdown-mode
;;:mode ("\\.md\\'" . commonmark-gfm-mode)
:config
(with-eval-after-load 'markdown-mode
(require 'org-table)
(add-hook 'markdown-mode-hook 'orgtbl-mode)
(unbind-key "`" gfm-mode-map)
(visual-line-mode nil))))
;;=> (leaf markdown-mode
;; :after t
;; :hook ((markdown-mode-hook . orgtbl-mode))
;; :require org-table
;; :config
;; (unbind-key "`" gfm-mode-map)
;; (visual-line-mode nil))
All feedback and suggestions are welcome!
You can use github issues, but you can also use Slack if you want a more casual conversation.
We welcome PR!
- cask
- install via brew
brew install cask
- manual install
cd ~/ hub clone cask/cask export PATH="$HOME/.cask/bin:$PATH"
- install via brew
Below operation flow is recommended.
make # Install git-hooks in local .git
git branch [feature-branch] # Create branch named [feature-branch]
git checkout [feature-branch] # Checkout branch named [feature-branch]
# <edit loop>
emacs leaf-convert.el # Edit something you want
make test # Test leaf-convert via multi version Emacs
git commit -am "brabra" # Commit (auto-run test before commit)
# </edit loop>
hub fork # Create fork at GitHub
git push [user] [feature-branch] # Push feature-branch to your fork
hub pull-request # Create pull-request
General Public License Version 3 (GPLv3) Copyright (c) Naoya Yamashita - https://conao3.com https://github.com/conao3/leaf-convert.el/blob/master/LICENSE
- Naoya Yamashita (conao3)