[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 77ab9837ca 3/3: Merge pull request #636 from min
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 77ab9837ca 3/3: Merge pull request #636 from minad/select-indicator |
Date: |
Wed, 17 May 2023 22:58:20 -0400 (EDT) |
branch: externals/embark
commit 77ab9837cab271f8d8ef24eb59405429ee60d104
Merge: ab920eaadf 33bec9395e
Author: Omar AntolĂn Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #636 from minad/select-indicator
Add embark-selection-indicator (See #629)
---
CHANGELOG.org | 4 ++++
README.org | 7 ++++++-
embark.el | 20 +++++++++++++++++++-
embark.texi | 11 +++++++++--
4 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 475121e1d7..1b5f5fd422 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -1,4 +1,8 @@
#+title: Embark changelog
+
+* Development version
+- Added a mode line indicator showing the number of selected targets in
+ the current buffer (contributed by @minad, thanks!)
* Version 0.22.1 (2023-04-20)
** New feature: selections
Now users can select several targets to make an ad hoc collection. The
diff --git a/README.org b/README.org
index 483da47e5c..8d4d641fec 100644
--- a/README.org
+++ b/README.org
@@ -245,7 +245,12 @@ member of the current selection. Similarly if no targets
are selected
and you are in a minibuffer completion session, running =embark-select=
from =embark-act-all= will select all the current completion candidates.
-This functionality is supported everywhere:
+By default, whenever some targets are selected in the current buffer,
+a count of selected targets appears in the mode line. This can be
+turned off or customized through the =embark-selection-indicator= user
+option.
+
+The selection functionality is supported in every buffer:
- In the minibuffer this gives a convenient way to act on several
completion candidates that don't follow any simple pattern: just go
diff --git a/embark.el b/embark.el
index ede4d3c80a..1c69f8cfac 100644
--- a/embark.el
+++ b/embark.el
@@ -3317,11 +3317,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.
@@ -3348,7 +3363,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.
diff --git a/embark.texi b/embark.texi
index 89a4e5f128..7c2891b526 100644
--- a/embark.texi
+++ b/embark.texi
@@ -356,7 +356,12 @@ member of the current selection. Similarly if no targets
are selected
and you are in a minibuffer completion session, running @samp{embark-select}
from @samp{embark-act-all} will select all the current completion candidates.
-This functionality is supported everywhere:
+By default, whenever some targets are selected in the current buffer,
+a count of selected targets appears in the mode line. This can be
+turned off or customized through the @samp{embark-selection-indicator} user
+option.
+
+The selection functionality is supported in every buffer:
@itemize
@item
@@ -992,15 +997,18 @@ without confirmation is dangerous? You have a couple of
options:
@item
You can keep using the @samp{tab-bar-close-tab-by-name} command, but have
Embark ask you for confirmation:
+@end enumerate
@lisp
(push #'embark--confirm
(alist-get 'tab-bar-close-tab-by-name
embark-pre-action-hooks))
@end lisp
+@enumerate
@item
You can write your own command that prompts for confirmation and
use that instead of @samp{tab-bar-close-tab-by-name} in the above keymap:
+@end enumerate
@lisp
(defun my-confirm-close-tab-by-name (tab)
(interactive "sTab to close: ")
@@ -1013,7 +1021,6 @@ independently of Embark. Using it from @samp{M-x} leaves
something to be
desired, though, since you don't get completion for the tab names.
You can fix this if you wish as described in the previous section.
@end enumerate
-@end enumerate
@node New target example in regular buffers - short Wikipedia links
@subsection New target example in regular buffers - short Wikipedia links