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

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

[elpa] externals/embark ca00f6cfb1 1/3: Add embark-selection-indicator (


From: ELPA Syncer
Subject: [elpa] externals/embark ca00f6cfb1 1/3: Add embark-selection-indicator (See #629)
Date: Wed, 17 May 2023 22:58:20 -0400 (EDT)

branch: externals/embark
commit ca00f6cfb1c41a92bac07c3cc85154aed2b69b42
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add embark-selection-indicator (See #629)
---
 embark.el | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/embark.el b/embark.el
index 536572cb8e..d60ce08123 100644
--- a/embark.el
+++ b/embark.el
@@ -3312,11 +3312,26 @@ PRED is a predicate function used to filter the items."
 (defface embark-selected '((t (:inherit match)))
   "Face for selected candidates.")
 
+(defcustom embark-selection-indicator
+  #("  Embark:%s " 1 12 (face (embark-selected bold)))
+  "Mode line indicator used for selected candidates."
+  :type '(choice string nil))
+
 (defvar-local embark--selection nil
   "Buffer local list of selected targets.
 Add or remove elements to this list using the `embark-select'
 action.")
 
+(defun embark--selection-indicator ()
+  "Mode line indicator showing number of selected items."
+  (when-let ((sel
+              (buffer-local-value
+               'embark--selection
+               (or (when-let ((win (active-minibuffer-window)))
+                     (window-buffer win))
+                   (current-buffer)))))
+    (format embark-selection-indicator (length sel))))
+
 (cl-defun embark--select
     (&key orig-target orig-type bounds &allow-other-keys)
   "Add or remove ORIG-TARGET of given ORIG-TYPE to the selection.
@@ -3343,7 +3358,10 @@ If BOUNDS are given, also highlight the target when 
selecting it."
         (add-text-properties 0 (length orig-target)
                              `(multi-category ,(cons orig-type orig-target))
                              target)
-        (push (cons target overlay) embark--selection)))))
+        (push (cons target overlay) embark--selection))))
+  (when embark-selection-indicator
+    (add-to-list 'mode-line-misc-info '(:eval (embark--selection-indicator)))
+    (force-mode-line-update t)))
 
 (defalias 'embark-select #'ignore
   "Add or remove the target from the current buffer's selection.



reply via email to

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