branch: master commit 99698e68f02ddcc400fca63a282a099317e42b0a Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy-dispatching-call): Add and bind to "C-M-o" * ivy.el (ivy-minibuffer-map): Update. (ivy-read-action): New command. (ivy-dispatching-done): Update. * ivy-hydra.el (hydra-ivy): Bind `ivy-read-action' to "a". Re #254 --- ivy-hydra.el | 3 ++- ivy.el | 32 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ivy-hydra.el b/ivy-hydra.el index 152812b..84b592d 100644 --- a/ivy-hydra.el +++ b/ivy-hydra.el @@ -49,7 +49,7 @@ " ^^^^^^ ^Yes^ ^No^ ^Maybe^ ^Action^ ^^^^^^^^^^^^^^--------------------------------------------------- -^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %s(if ivy-calling \"on\" \"off\") _w_/_s_: %s(ivy-action-name) +^ ^ _k_ ^ ^ _f_ollow _i_nsert _c_: calling %s(if ivy-calling \"on\" \"off\") _w_/_s_/_a_: %s(ivy-action-name) _h_ ^+^ _l_ _d_one _o_ops _m_: matcher %s(if (eq ivy--regex-function 'ivy--regex-fuzzy) \"fuzzy\" \"ivy\") ^ ^ _j_ ^ ^ _g_o ^ ^ _<_/_>_: shrink/grow _t_runcate: %`truncate-lines " @@ -74,6 +74,7 @@ _h_ ^+^ _l_ _d_one _o_ops _m_: matcher %s(if (eq ivy--regex-function 'i ("<" ivy-minibuffer-shrink) ("w" ivy-prev-action) ("s" ivy-next-action) + ("a" ivy-read-action) ("t" (setq truncate-lines (not truncate-lines)))) (provide 'ivy-hydra) diff --git a/ivy.el b/ivy.el index e06c3dd..a841a4b 100644 --- a/ivy.el +++ b/ivy.el @@ -157,6 +157,7 @@ Only \"./\" and \"../\" apply here. They appear in reverse order." (define-key map (kbd "M-i") 'ivy-insert-current) (define-key map (kbd "C-o") 'hydra-ivy/body) (define-key map (kbd "M-o") 'ivy-dispatching-done) + (define-key map (kbd "C-M-o") 'ivy-dispatching-call) (define-key map (kbd "C-k") 'ivy-kill-line) (define-key map (kbd "S-SPC") 'ivy-restrict-to-matches) (define-key map (kbd "M-w") 'ivy-kill-ring-save) @@ -302,12 +303,11 @@ When non-nil, it should contain one %d.") (insert ivy-text) (ivy--exhibit)))) -(defun ivy-dispatching-done () - "Select one of the available actions and call `ivy-done'." +(defun ivy-read-action () + "Change the action to one of the available ones." (interactive) (let ((actions (ivy-state-action ivy-last))) - (if (null (ivy--actionp actions)) - (ivy-done) + (unless (null (ivy--actionp actions)) (let* ((hint (concat ivy--current "\n" (mapconcat @@ -321,14 +321,30 @@ When non-nil, it should contain one %d.") "\n") "\n")) (key (string (read-key hint))) - (action (assoc key (cdr actions)))) + (action-idx (cl-position-if + (lambda (x) (equal (car x) key)) + (cdr actions)))) (cond ((string= key "")) - ((null action) + ((null action-idx) (error "%s is not bound" key)) (t (message "") - (ivy-set-action (nth 1 action)) - (ivy-done))))))) + (setcar actions (1+ action-idx)) + (ivy-set-action actions))))))) + +(defun ivy-dispatching-done () + "Select one of the available actions and call `ivy-done'." + (interactive) + (ivy-read-action) + (ivy-done)) + +(defun ivy-dispatching-call () + "Select one of the available actions and call `ivy-call'." + (interactive) + (let ((actions (copy-sequence (ivy-state-action ivy-last)))) + (ivy-read-action) + (ivy-call) + (ivy-set-action actions))) (defun ivy-build-tramp-name (x) "Reconstruct X into a path.