Last active
August 29, 2015 14:17
-
-
Save darkfeline/f615f8ccb4cc104ca6a6 to your computer and use it in GitHub Desktop.
Delight plugin for use-package.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package delight) | |
(add-to-list 'use-package-keywords :delight t) | |
(defun use-package-normalize/:delight (name-symbol keyword args) | |
"Normalize arguments to delight." | |
(cond | |
((and (= (length args) 1) | |
(symbolp (car args))) | |
(list (car args) nil name-symbol)) | |
((and (= (length args) 2) | |
(symbolp (car args))) | |
(list (car args) (cadr args) name-symbol)) | |
((and (= (length args) 3) | |
(symbolp (car args))) | |
args) | |
(t | |
(use-package-error ":delight expects same args as delight function")))) | |
(defun use-package-handler/:delight (name-symbol keyword args rest state) | |
(let ((body (use-package-process-keywords name-symbol rest state))) | |
(use-package-concat | |
body | |
`((delight | |
(quote ,(nth 0 args)) | |
,(nth 1 args) | |
(quote ,(nth 2 args))) | |
t)))) | |
(provide 'use-package-delight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jwiegley You're right, my inexperience with Elisp is showing. It should be checking (car args), not (cdr args). The restriction on delight is that the first argument is a symbol.