branch: externals/embark commit e6b0f8321846e9bbdaf8f9e2cab4220c0b0a58c4 Merge: 503fc31f68 d7330972aa Author: Omar Antolín Camarena <omar.anto...@gmail.com> Commit: Omar Antolín Camarena <omar.anto...@gmail.com>
Merge branch 'master' of https://github.com/oantolin/embark --- CHANGELOG.org | 4 ++++ README.org | 7 ++++++- embark-org.el | 19 ++++++++++++++++--- embark.el | 31 ++++++++++++++++++++++++------- embark.texi | 11 +++++++++-- 5 files changed, 59 insertions(+), 13 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-org.el b/embark-org.el index 8ac22345ce..5ca25c27af 100644 --- a/embark-org.el +++ b/embark-org.el @@ -145,7 +145,10 @@ ;;; Tables (dolist (motion '(org-table-move-cell-up org-table-move-cell-down - org-table-move-cell-left org-table-move-cell-right)) + org-table-move-cell-left org-table-move-cell-right + org-table-move-row org-table-move-column + org-table-move-row-up org-table-move-row-down + org-table-move-column-left org-table-move-column-right)) (add-to-list 'embark-repeat-actions motion)) (push 'embark--ignore-target @@ -154,11 +157,20 @@ (defvar-keymap embark-org-table-cell-map :doc "Keymap for actions the current cells, column or row of an Org table." :parent embark-general-map - ;; TODO: default action? + "RET" #'org-table-align ; harmless default "<up>" #'org-table-move-cell-up "<down>" #'org-table-move-cell-down "<left>" #'org-table-move-cell-left "<right>" #'org-table-move-cell-right + "d" #'org-table-kill-row + "D" #'org-table-delete-column ; capital = column + "^" #'org-table-move-row-up + "v" #'org-table-move-row-down + "<" #'org-table-move-column-left + ">" #'org-table-move-column-right + "i" #'org-table-insert-row + "I" #'org-table-insert-column ; capital = column + "h" #'org-table-insert-hline "=" #'org-table-eval-formula "e" #'org-table-edit-field "g" #'org-table-recalculate) @@ -166,7 +178,7 @@ (defvar-keymap embark-org-table-map :doc "Keymap for actions on entire Org table." :parent embark-general-map - ;; TODO: default action? + "RET" #'org-table-align ; harmless default "=" #'org-table-edit-formulas "s" #'org-table-sort-lines "t" #'org-table-transpose-table-at-point @@ -174,6 +186,7 @@ "f" #'org-table-follow-field-mode "y" #'org-table-paste-rectangle "d" #'org-table-toggle-formula-debugger + "o" #'org-table-toggle-coordinate-overlays "i" #'org-table-iterate "e" #'org-table-export) diff --git a/embark.el b/embark.el index 91a6ae2b09..1042808bb4 100644 --- a/embark.el +++ b/embark.el @@ -478,7 +478,8 @@ arguments and more details." (write-region embark--mark-target) (append-to-file embark--mark-target) (shell-command-on-region embark--mark-target) - (embark-eval-replace embark--mark-target)) + (embark-eval-replace embark--mark-target) + (delete-indentation embark--mark-target)) "Alist associating commands with post-action hooks. The hooks are run instead of the embarked upon action. The hook can decide whether or not to run the action or it can run it @@ -529,9 +530,7 @@ argument: a one element list containing the target." backward-sexp forward-sentence backward-sentence forward-paragraph backward-paragraph ;; smerge commands - smerge-refine smerge-combine-with-next smerge-keep-current - smerge-keep-upper smerge-keep-lower smerge-keep-base - smerge-keep-all smerge-resolve smerge-prev smerge-next) + smerge-refine smerge-combine-with-next smerge-prev smerge-next) "List of repeatable actions. When you use a command on this list as an Embark action from outside the minibuffer, `embark-act' does not exit but instead @@ -2385,8 +2384,8 @@ ARG is the prefix argument." ((symbol-function 'embark--confirm) #'ignore)) (let ((prefix-arg prefix)) (when-let ((bounds (plist-get candidate :bounds))) - (goto-char (car bounds)) - (embark--act action candidate)))))) + (goto-char (car bounds))) + (embark--act action candidate))))) (quit (embark--quit-p action))) (when (and (eq action (embark--default-action type)) (eq action embark--command)) @@ -3317,11 +3316,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 +3362,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