]> git.eshelyaron.com Git - emacs.git/commitdiff
let :diminish "string" guess correct mode symbol
authorNoam Postavsky <npostavs@gmail.com>
Sun, 14 Apr 2013 19:01:37 +0000 (15:01 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Sun, 14 Apr 2013 19:01:37 +0000 (15:01 -0400)
lisp/use-package/use-package.el

index 68216c6a7a971a5c281d3df7b7ae431127da721c..17f7309cf55a04dc6222ecc4519c32e77a373f69 100644 (file)
 ;; 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)))