Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call and recenter option under ivy-hydra 'calling' #2945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ivy-hydra.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
(defhydra hydra-ivy (:hint nil :color pink)
"
^ ^ ^ ^ ^ ^ | ^Call^ ^ ^ | ^Cancel^ | ^Options^ | Action _w_/_s_/_a_: %-14s(ivy-action-name)
^-^-^-^-^-^-+-^-^---------^-^--+-^-^------+-^-^-------+-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------
^ ^ _k_ ^ ^ | _f_ollow occ_U_r | _i_nsert | _c_: calling %-5s(if ivy-calling \"on\" \"off\") _C_ase-fold: %-10`ivy-case-fold-search
_h_ ^+^ _l_ | _d_one ^ ^ | _o_ops | _M_: matcher %-5s(ivy--matcher-desc)^^^^^^^^^^^^ _T_runcate: %-11`truncate-lines
^ ^ _j_ ^ ^ | _g_o ^ ^ | ^ ^ | _<_/_>_: shrink/grow^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _D_efinition of this menu
^-^-^-^-^-^-+-^-^---------^-^--+-^-^------+-^-^-------+-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------
^ ^ _k_ ^ ^ | _f_ollow occ_U_r | _i_nsert | _c_: calling %-5s(pcase ivy-calling ('rc \"rc\") ('on \"on\") (t \"off\")) _C_ase-fold: %-10`ivy-case-fold-search
_h_ ^+^ _l_ | _d_one ^ ^ | _o_ops | _M_: matcher %-5s(ivy--matcher-desc)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _T_runcate: %-11`truncate-lines
^ ^ _j_ ^ ^ | _g_o ^ ^ | ^ ^ | _<_/_>_: shrink/grow^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _D_efinition of this menu
"
;; arrows
("h" ivy-beginning-of-buffer)
Expand Down
12 changes: 8 additions & 4 deletions ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,9 @@ if one exists."
(setq ivy--index index)
(when ivy-calling
(ivy--exhibit)
(ivy-call)))
(pcase ivy-calling
('rc (ivy-call-and-recenter))
(_ (ivy-call)))))

(defun ivy-beginning-of-buffer ()
"Select the first completion candidate."
Expand Down Expand Up @@ -1330,8 +1332,10 @@ If the input is empty, select the previous history element instead."
(defun ivy-toggle-calling ()
"Flip `ivy-calling'."
(interactive)
(when (setq ivy-calling (not ivy-calling))
(ivy-call)))
(setq ivy-calling (pcase ivy-calling
('on 'rc)
('rc nil)
(_ 'on))))

(defun ivy-toggle-ignore ()
"Toggle user-configured candidate filtering."
Expand Down Expand Up @@ -1515,7 +1519,7 @@ See variable `ivy-recursive-restore' for further information."
(interactive)
(ivy-call)
(with-ivy-window
(recenter-top-bottom)))
Copy link
Author

@dalanicolai dalanicolai Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function does not recenter exclusively but, in the simplest case, alternates between top, center,
and bottom (which is not consistent with its docstring, I think)

(recenter)))

(defun ivy-next-line-and-call (&optional arg)
"Move cursor vertically down ARG candidates.
Expand Down