From 2abe5f9480332476e22a58ad5f83d0cfa20eb7c2 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 14 Apr 2013 15:01:37 -0400 Subject: [PATCH] let :diminish "string" guess correct mode symbol --- lisp/use-package/use-package.el | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el index 68216c6a7a9..17f7309cf55 100644 --- a/lisp/use-package/use-package.el +++ b/lisp/use-package/use-package.el @@ -212,7 +212,9 @@ ;; if you have that installed. It's purpose is to remove strings from your ;; mode-line that would otherwise always be there and provide no useful ;; information. It is invoked with the `:diminish' keyword, which is passed -;; either the minor mode symbol, or a cons of the symbol and a replacement string: +;; either the minor mode symbol, a cons of the symbol and a replacement string, +;; or just a replacement string in which case the minor mode symbol is guessed +;; to be the package name with "-mode" at the end: ;; ;; (use-package abbrev ;; :diminish abbrev-mode @@ -453,16 +455,20 @@ For full documentation. please see commentary. `(progn ,config-body (ignore-errors - ,@(if (listp diminish-var) - (if (listp (cdr diminish-var)) - (mapcar (lambda (var) - (if (listp var) - `(diminish (quote ,(car var)) ,(cdr var)) - `(diminish (quote ,var)))) - diminish-var) - `((diminish (quote ,(car diminish-var)) ,(cdr diminish-var))) - ) - `((diminish (quote ,diminish-var)))))))) + ,@(cond + ((stringp diminish-var) + `(diminish (quote ,(intern (concat name-string "-mode"))) + ,diminish-var)) + ((symbolp diminish-var) + `(diminish (quote ,diminish-var))) + ((and (consp diminish-var) (stringp (cdr diminish-var))) + `(diminish (quote ,(car diminish-var)) ,(cdr diminish-var))) + (t ; list of symbols or (symbol . "string") pairs + (mapcar (lambda (var) + (if (listp var) + `(diminish (quote ,(car var)) ,(cdr var)) + `(diminish (quote ,var)))) + diminish-var))))))) (if (and commands (symbolp commands)) (setq commands (list commands))) -- 2.39.2