[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra fb8804d 280/395: ivy.el (ivy--call-marked): E
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra fb8804d 280/395: ivy.el (ivy--call-marked): Extract |
Date: |
Thu, 25 Feb 2021 08:32:20 -0500 (EST) |
branch: externals/ivy-hydra
commit fb8804d3559d2b7da35e3f241f282707c6d6aac8
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
ivy.el (ivy--call-marked): Extract
---
ivy.el | 110 ++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 58 insertions(+), 52 deletions(-)
diff --git a/ivy.el b/ivy.el
index ea1870b..27f904c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1520,6 +1520,45 @@ See variable `ivy-recursive-restore' for further
information."
(defvar ivy-mark-prefix ">"
"Prefix used by `ivy-mark'.")
+(defun ivy--call-marked (action)
+ (let* ((prefix-len (length ivy-mark-prefix))
+ (marked-candidates
+ (mapcar
+ (lambda (s)
+ (let ((cand (substring s prefix-len)))
+ (if ivy--directory
+ (expand-file-name cand ivy--directory)
+ cand)))
+ ivy-marked-candidates))
+ (multi-action (ivy--get-multi-action ivy-last)))
+ (if multi-action
+ (let ((default-directory (ivy-state-directory ivy-last)))
+ (funcall multi-action marked-candidates))
+ (dolist (c marked-candidates)
+ (let ((default-directory (ivy-state-directory ivy-last)))
+ (funcall action c))))))
+
+(defun ivy--call-cand (current)
+ (let ((collection (ivy-state-collection ivy-last)))
+ (cond
+ ;; Alist type.
+ ((and (consp (car-safe collection))
+ ;; Previously, the cdr of the selected
+ ;; candidate would be returned. Now, the
+ ;; whole candidate is returned.
+ (let ((idx (get-text-property 0 'idx current)))
+ (if idx
+ (progn
+ (ivy--remove-props current 'idx)
+ (nth idx collection))
+ (assoc current collection)))))
+ (ivy--directory
+ (expand-file-name current ivy--directory))
+ ((equal current "")
+ ivy-text)
+ (t
+ current))))
+
(defun ivy-call ()
"Call the current action without exiting completion."
(interactive)
@@ -1535,61 +1574,28 @@ See variable `ivy-recursive-restore' for further
information."
ivy-inhibit-action
(and (not ivy-inhibit-action)
(ivy--get-action ivy-last))))
- (collection (ivy-state-collection ivy-last))
(current (ivy-state-current ivy-last))
- (x (cond
- ;; Alist type.
- ((and (consp (car-safe collection))
- ;; Previously, the cdr of the selected
- ;; candidate would be returned. Now, the
- ;; whole candidate is returned.
- (let ((idx (get-text-property 0 'idx current)))
- (if idx
- (progn
- (ivy--remove-props current 'idx)
- (nth idx collection))
- (assoc current collection)))))
- (ivy--directory
- (expand-file-name current ivy--directory))
- ((equal current "")
- ivy-text)
- (t
- current)))
+ (x (ivy--call-cand current))
(res
(cond
- ((null action)
- current)
- ((eq action #'identity)
- (prog1 x
- (ivy-recursive-restore)))
- (t
- (select-window (ivy--get-window ivy-last))
- (set-buffer (ivy-state-buffer ivy-last))
- (prog1 (unwind-protect
- (if ivy-marked-candidates
- (let* ((prefix-len (length ivy-mark-prefix))
- (marked-candidates
- (mapcar
- (lambda (s)
- (let ((cand (substring s prefix-len)))
- (if ivy--directory
- (expand-file-name cand
ivy--directory)
- cand)))
- ivy-marked-candidates))
- (multi-action (ivy--get-multi-action
ivy-last)))
- (if multi-action
- (let ((default-directory
(ivy-state-directory ivy-last)))
- (funcall multi-action marked-candidates))
- (dolist (c marked-candidates)
- (let ((default-directory
(ivy-state-directory ivy-last)))
- (funcall action c)))))
- (setq default-directory (ivy-state-directory
ivy-last))
- (funcall action x))
- (ivy-recursive-restore))
- (unless (or (eq ivy-exit 'done)
- (minibuffer-window-active-p (selected-window))
- (null (active-minibuffer-window)))
- (select-window (active-minibuffer-window))))))))
+ ((null action)
+ current)
+ ((eq action #'identity)
+ (prog1 x
+ (ivy-recursive-restore)))
+ (t
+ (select-window (ivy--get-window ivy-last))
+ (set-buffer (ivy-state-buffer ivy-last))
+ (prog1 (unwind-protect
+ (if ivy-marked-candidates
+ (ivy--call-marked action)
+ (setq default-directory (ivy-state-directory
ivy-last))
+ (funcall action x))
+ (ivy-recursive-restore))
+ (unless (or (eq ivy-exit 'done)
+ (minibuffer-window-active-p (selected-window))
+ (null (active-minibuffer-window)))
+ (select-window (active-minibuffer-window))))))))
(if ivy-inhibit-action
res
current)))
- [elpa] externals/ivy-hydra 781cbbc 255/395: Advertise ivy-string< over string-lessp, (continued)
- [elpa] externals/ivy-hydra 781cbbc 255/395: Advertise ivy-string< over string-lessp, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 0e4a55f 242/395: ivy.el (ivy--preselect-index): Don't return nil, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra af2a5fa 247/395: * counsel.el (counsel-pt): Fix counsel-ag usage, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 4aa8073 264/395: ivy.el (ivy-call): Make "M-x cd" work again, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra d1ba9b8 269/395: ivy.el (ivy-resume): Refresh on modified buffer for swiper-isearch, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 5e67e7c 268/395: counsel.el (counsel-rg): Split command args independent of the order, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6369139 271/395: ivy.el (ivy--update-history): Behave more like completing-read-default, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra c0dc909 277/395: ivy.el (ivy-resume): Support multiple ivy sessions, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 8989ed1 276/395: ivy.el (ivy--update-minibuffer): don't filter while there's input, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra d790e53 278/395: doc/ivy.org: Mention multiple-session ivy-resume, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra fb8804d 280/395: ivy.el (ivy--call-marked): Extract,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra 489bc57 284/395: counsel.el (counsel-rg-base-command): Make the default a list, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 7fd0662 285/395: counsel.el (counsel-grep-like-occur): Fix for marked files in dired, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra f1c57a1 292/395: counsel.el (counsel-async-command-delay): Set the default to 0.0, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra fb73bfe 288/395: counsel.el (counsel--rg-targets): Fix regression, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 2b26f83 289/395: counsel.el (counsel--sync-sentinel-on-exit): Don't reset index, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6a576cb 293/395: ivy-avy.el: Extract, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra e42e0b3 295/395: ivy-hydra.el (ivy-minibuffer-grow): Move, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 9fddf44 297/395: ivy-faces.el: Extract, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra a33af9b 356/395: Unset yank-undo-function in counsel-yank-pop, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 98c61de 299/395: ivy.el (ivy-set-display-transformer): Mark obsolete, Basil L. Contovounesios, 2021/02/25