branch: master
commit 0f10b82bf4417bd168240a646e9775366e3240c6
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy-hydra.el (ivy-dispatching-done-hydra): Break hint into columns
In case the hint is longer than `window-width'.
Fixes #953
---
ivy-hydra.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/ivy-hydra.el b/ivy-hydra.el
index 369372a..decd896 100644
--- a/ivy-hydra.el
+++ b/ivy-hydra.el
@@ -77,15 +77,25 @@ _h_ ^+^ _l_ | _d_one ^ ^ | _o_ops | _m_: matcher
%-5s(ivy--matcher-desc)
(lambda (_) (find-function 'hydra-ivy/body)))
:exit t))
+(defvar ivy-dispatching-done-columns 2
+ "Number of columns to use if the hint does not fit on one line.")
+
(defun ivy-dispatching-done-hydra ()
"Select one of the available actions and call `ivy-done'."
(interactive)
- (let ((actions (ivy-state-action ivy-last)))
+ (let* ((actions (ivy-state-action ivy-last))
+ (estimated-len (+ 25 (length
+ (mapconcat
+ (lambda (x) (format "[%s] %s" (nth 0 x) (nth 2
x)))
+ (cdr actions) ", "))))
+ (n-columns (if (> estimated-len (window-width))
+ ivy-dispatching-done-columns
+ nil)))
(if (null (ivy--actionp actions))
(ivy-done)
(funcall
(eval
- `(defhydra ivy-read-action (:color teal)
+ `(defhydra ivy-read-action (:color teal :columns ,n-columns)
"action"
,@(mapcar (lambda (x)
(list (nth 0 x)