emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 76fff20 114/184: counsel-M-x: Propertize names of active m


From: Oleh Krehel
Subject: [elpa] master 76fff20 114/184: counsel-M-x: Propertize names of active modes.
Date: Wed, 16 Oct 2019 13:15:02 -0400 (EDT)

branch: master
commit 76fff20e6774f777787902030e9dcb528682078a
Author: Nathan Moreau <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel-M-x: Propertize names of active modes.
    
    * counsel.el (counsel-active-mode): new face.
    (counsel-M-x-transformer): propertize names of active modes.
    
    Fixes #2189
    Fixes #2258
---
 counsel.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/counsel.el b/counsel.el
index 1ee165b..67ff54f 100644
--- a/counsel.el
+++ b/counsel.el
@@ -799,6 +799,11 @@ With prefix arg MODE a query for the symbol help mode is 
offered."
   "Face used by `counsel-M-x' for key bindings."
   :group 'ivy-faces)
 
+(defface counsel-active-mode
+  '((t :inherit font-lock-builtin-face))
+  "Face used by `counsel-M-x' for activated modes."
+  :group 'ivy-faces)
+
 (defcustom counsel-alias-expand t
   "When non-nil, show the expansion of aliases in `counsel-M-x'."
   :type 'boolean
@@ -806,8 +811,15 @@ With prefix arg MODE a query for the symbol help mode is 
offered."
 
 (defun counsel-M-x-transformer (cmd)
   "Return CMD annotated with its active key binding, if any."
-  (let ((alias (symbol-function (intern cmd)))
-        (key (where-is-internal (intern cmd) nil t)))
+  (let* ((sym (intern cmd))
+         (alias (symbol-function sym))
+         (key (where-is-internal sym nil t)))
+    (when (or (eq sym major-mode)
+              (and
+               (memq sym minor-mode-list)
+               (boundp sym)
+               (buffer-local-value sym (ivy-state-buffer ivy-last))))
+      (put-text-property 0 (length cmd) 'face 'counsel-active-mode cmd))
     (concat cmd
             (when (and (symbolp alias) counsel-alias-expand)
               (format " (%s)" alias))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]