From 800669d9dac14c370b3f7d5b2966799d677f3dc8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 21 Mar 2015 23:35:58 -0500 Subject: [PATCH] Add :delight support, thanks to darkfeline on GitHub Fixes https://github.com/jwiegley/use-package/issues/189 --- lisp/use-package/use-package.el | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index 78f1281dbb3..7396677ac0a 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -128,7 +128,8 @@ the user specified." :demand :init :config - :diminish) + :diminish + :delight) "Establish which keywords are valid, and the order they are processed in. Note that `:disabled' is special, in that it causes nothing at all to happen, @@ -924,6 +925,36 @@ deferred until the prefix key sequence is pressed." arg) body))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; :delight +;; + +(defun use-package-normalize/:delight (name-symbol keyword args) + "Normalize arguments to delight." + (cond + ((and (= (length args) 1) + (symbolp (cdr args))) + (list (car args) nil name-symbol)) + ((and (= (length args) 2) + (symbolp (cdr args))) + (list (car args) (cadr args) name-symbol)) + ((and (= (length args) 3) + (symbolp (cdr 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)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; The main macro -- 2.39.2