Closed humanfactors closed 4 years ago
Ivy has a variable ivy-read-action-format-function
allowing to customize the function used to format the list of actions. I have the same problem as you with the default function, so I defined the following one to have them spread over multiple columns:
(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"))))
(setq ivy-read-action-format-function 'ivy-read-action-format-columns)
@abo-abo: Would you be interested in a PR to include such a function in Ivy?
@ericdanan Sure, please PR.
@humanfactors The function ivy-read-action-format-columns
is now part of ivy, so you only need to customize the variable ivy-read-action-format-function
.
When pressing
M-o
over a project in the list, I can't actually read the entire set of candidate hints. I can't figure out how to either expand this view (strokes result in[bind] not found
). Of course, I can look these up incounsel-projectile--defcustom-action
but that's not exactly very useful every single time.The resulting selections appear as in screenshot below for me:
Is there any method whereby I can view all the candidates in a larger view? Forgive me if this isn't an issue directly with this package, I'm relatively new to Ivy.