]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow `:diminish` with no arguments
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 14 Jun 2017 18:24:01 +0000 (20:24 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Sat, 8 Jul 2017 13:32:46 +0000 (15:32 +0200)
When given no arguments, have :diminish assume it should diminish a
mode named after the current package (the package’s name, with “-mode”
appended, if it’s not already) to an empty string.

When given only a string to diminish an implicit package name to, do
not append “-mode” to the package name if it already ends with
it.  (This is a backwards-incompatible change if someone was
diminishing a package named “foo-mode” implementing `foo-mode-mode`.)

Add test cases for `use-package-normalize-diminish`.

This addresses some of the redundancy mentioned in issue https://github.com/jwiegley/use-package/issues/288.

lisp/use-package/use-package.el
test/lisp/use-package/use-package-tests.el

index 593a680eee3ae688edefe2713a45d254ca5e9371..d397e0e4072709ed51f6e4811e12870ad9bc30de 100644 (file)
@@ -1409,10 +1409,12 @@ deferred until the prefix key sequence is pressed."
      SYMBOL
      (SYMBOL . STRING)"
   (cond
+   ((not arg)
+    (list (use-package-as-mode name)))
    ((symbolp arg)
     (list arg))
    ((stringp arg)
-    (list (cons (intern (concat (use-package-as-string name) "-mode")) arg)))
+    (list (cons (use-package-as-mode name) arg)))
    ((and (consp arg) (stringp (cdr arg)))
     (list arg))
    ((and (not recursed) (listp arg) (listp (cdr arg)))
index 625e95ca5877d38eeeac33cca2162a933c2dc813..c52c3810439c960a634b769021170c7f9c06d878 100644 (file)
 
   )
 
+(ert-deftest use-package-normalize-diminish ()
+  (should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
+                 '(foopkg-mode)))
+  (should (equal (use-package-normalize-diminish 'foopkg :diminish 'bar)
+                 '(bar)))
+  (should (equal (use-package-normalize-diminish 'foopkg :diminish "bar")
+                 '((foopkg-mode . "bar"))))
+  (should (equal (use-package-normalize-diminish 'foopkg :diminish 'foo-mode)
+                 '(foo-mode)))
+  (should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar"))
+                 '((foo . "bar")))))
+
 ;; Local Variables:
 ;; indent-tabs-mode: nil
 ;; no-byte-compile: t