[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-hydra ff59888 136/395: ivy.el (ivy-read-action-form
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-hydra ff59888 136/395: ivy.el (ivy-read-action-format-columns): Add |
Date: |
Thu, 25 Feb 2021 08:31:48 -0500 (EST) |
branch: externals/ivy-hydra
commit ff59888eacd1beef91e0c8d52b33fd5a82b142f2
Author: Eric Danan <ricouilletaff@gmail.com>
Commit: Eric Danan <ricouilletaff@gmail.com>
ivy.el (ivy-read-action-format-columns): Add
Add a new function to format the action list, using several columns if
needed to preserve `ivy-height`.
---
ivy.el | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/ivy.el b/ivy.el
index 500b0a1..d230c4e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -878,6 +878,45 @@ key (a string), cmd and doc (a string)."
actions
"\n")))
+(defun ivy-read-action-format-columns (actions)
+ "Create a docstring from ACTIONS, using several columns if needed to
preserve `ivy-height'.
+
+ACTIONS is a list. Each list item is a list of 3 items: key (a
+string), cmd and doc (a string)."
+ (let ((length (length actions))
+ (i 0)
+ (max-rows (- ivy-height 1))
+ rows cols col lwidth rwidth)
+ (while (< i length)
+ (setq col (cl-subseq actions i (min length (cl-incf i max-rows))))
+ (setq lwidth (apply 'max (mapcar (lambda (x)
+ (length (nth 0 x)))
+ col)))
+ (setq rwidth (apply 'max (mapcar (lambda (x)
+ (length (nth 2 x)))
+ col)))
+ (setq col (mapcar (lambda (x)
+ (format (format "%%%ds: %%-%ds" lwidth rwidth)
+ (propertize (car x) 'face 'ivy-action)
+ (nth 2 x)))
+ col))
+ (cond
+ ((null rows)
+ (setq rows (length col)))
+ ((< (length col) rows)
+ (setq col (append col (make-list (- rows (length col)) "")))))
+ (push col cols))
+ (format "%s\n%s\n"
+ (if (eq this-command 'ivy-read-action)
+ "Select action: "
+ (ivy-state-current ivy-last))
+ (mapconcat 'identity
+ (apply 'cl-mapcar
+ (lambda (&rest args)
+ (mapconcat 'identity args " | "))
+ (nreverse cols))
+ "\n"))))
+
(defcustom ivy-read-action-function #'ivy-read-action-by-key
"Function used to read an action."
:type '(radio
- [elpa] externals/ivy-hydra 4875c7b 101/395: ivy.el (ivy-current-match): Add :extend t, (continued)
- [elpa] externals/ivy-hydra 4875c7b 101/395: ivy.el (ivy-current-match): Add :extend t, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 5430e11 107/395: ivy.el (ivy-regex): Add, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra f40a465 117/395: ivy.el (ivy-avy-style): New defcustom, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra eb83a3c 110/395: ivy.el (ivy--update-minibuffer): Extract, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 5974f06 124/395: counsel.el (counsel-evil-marks): Improve, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra b8dd986 112/395: swiper.el (swiper-isearch-format-function): Fix for ivy-prescient, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 526c7aa 113/395: counsel-org-tag-action: message when a tag has been removed., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 3fa1677 118/395: counsel.el (counsel--imenu-candidates): Use "Functions" only for Elisp, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra baddac7 129/395: counsel-kmacro: Handle potential error from `edmacro-fix-menu-commands`., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 03be27a 127/395: counsel-kmacro: Small corrections in a few doc strings., Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra ff59888 136/395: ivy.el (ivy-read-action-format-columns): Add,
Basil L. Contovounesios <=
- [elpa] externals/ivy-hydra 4d497e2 132/395: Add support for adding additional multi-actions, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 27b2ae5 141/395: Don't hardcode C-s and C-r, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 6a902b5 145/395: counsel.el (string-trim-left): Add declare-function, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 98a29b6 148/395: Fix C-<backspace> not working in counsel-file-jump, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 19bc4ed 149/395: ivy.el (ivy-ignore-buffers): Ignore *tramp/ buffers, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 982a5ac 150/395: ivy.el (ivy--tramp-candidates): The initial directory on remote should be "/", Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 554c178 158/395: ivy.el (ivy-set-actions): Allow to override the default action using "o", Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 0cff3e1 157/395: swiper.el (swiper): Add isearch-clean-overlays, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 35d015b 166/395: ivy.el (ivy-avy): Configure no-counsel-M-x, Basil L. Contovounesios, 2021/02/25
- [elpa] externals/ivy-hydra 18d7ff9 168/395: ivy.el (ivy--set-candidates): Delete duplicates, Basil L. Contovounesios, 2021/02/25