zsh completion last_prompt behaviour for long lists - zsh-completion

I currently configure my zsh tab completion with:
autoload -U compinit && compinit
zstyle ':completion:*:default' menu select=0
zstyle ':completion:*:default' select-scroll 0
What I like about this is:
unambiguous completions get completed immediately
ambiguous completions get expanded as far as possible (first strike of tab) and ambiguities get listed to me (second strike)
hitting tab further (one more tab stroke after the list appeared) I go through the menu-select'ions, i.e. the prompt stays above the list of ambiguities, one of them gets highlighted and it is inserted in the prompt, and hitting tab further, I go to the next item. Even in case the list of ambiguities cannot be displayed, then the list below the prompt scrolls.
What I don't like:
if the list is too long to be displayed, it gets first printed completely and the prompt ends up below the list, and only with the next stroke, I end up at the top of the terminal again for the menu-select mode.
So I'd like to change the behaviour to:
unambiguous completions get completed immediately
ambiguous completions get expanded as far as possible (first strike of tab) and ambiguities get listed to me, ALWAYS below the prompt, even if the list is too long to be shown completely (doesn't matter if first or second stroke)
hitting tab further (one more tab stroke after the list appeared) I go through the menu-select'ions, i.e. the prompt stays above the list of ambiguities, one of them gets highlighted and it is inserted in the prompt, and hitting tab further, I go to the next item. Even in case the list of ambiguities cannot be displayed, then the list below the prompt scrolls.
A crucial aspect is that the list of ambiguities gets shown before the first one is inserted into the prompt. Otherwise I could already use
zstyle ':completion:*:default' menu select=0 yes=0

Related

Auto-insert and cycle through completions in Emacs company mode

I want to implement the following behavior:
I type the beginning of a word, say "pr"
I press TAB
It autocompletes to the first available completion, say "print" - without any popups
I don't move my caret and I press TAB again, and it selects the second completion on "pr" - not on "print", which is already present on my current caret position
Basically, I want to be able to cycle through completions for a symbol with immediate insertion of the completion - without the popup. How would you do that with company-mode?
Try enabling company-tng-mode and removing company-pseudo-tooltip-unless-just-one-frontend from company-frontends, at the same time.

prevent auto-complete expansion in emacs except for explicit binding

I want auto-complete menu to show automatically while typing but never expand except if explicitly requested (return or M-tab or such). I type very fast and I only want to potentially expand if I don't know what I want or there's a very long completion. I cannot seem to be able to prevent expansion when a single option is available in the menu and this causes big problems when there are already characters on the line right of the cursor.
Auto-complete menu shows fine. With each character the options get more narrow. Problem shows when a single option is left - the menu disappears and the overlay expansion shows (obscuring existing characters to the right of the cursor). When I type one more character the expansion takes effect but it is broken up with the remaining characters of the expansion as a suffix to the existing line. If the one more character I typed was NOT the one in the suggested expansion things still break but without the rest of the suggestion.
This is very inconvenient as I usually type very fast and trigger broken completions. I would like to have the menu always show automatically but expansions NEVER take effect except explicitly (I slow down my typing when I'm unsure what I want to type.
I tried all the options I found in the documentation but I just cannot prevent expansions from taking effect. I want to completely disable expansions (except for explicit expansion).

How can I search through fish completions?

I've noticed that sometimes, when there are multiple completion options, I get something like an input field, beneath the command line, where I can type and filter the completions. I'm not sure how I triggered it. Is there a key combination that I can press so that I have it available on demand?
To enter search mode directly, you can press shift-tab. You can also press tab until the highlight is in the pager, and then just start typing: that triggers searching too.
Update March 2020: This changed in fish 3.0 here. There's now two ways to reveal the completion search:
Press ctrl s to toggle the search field while the pager is active
Press shift tab instead of tab to trigger completions with the search field shown immediately
These correspond to pager-toggle-search and complete-and-search key bindings.

How to make "up"key complete the already typed command from history, not pick any that contains the already typed part?

Until recently, when I typed
x=1;
2*x;
x
into the command window (without pressing enter after x) and pressed the arrow up key, the line was completed with the last command in the history that started with the already typed part, here the first line. Recently, the behavior changed to replacing it with the last command that contains the already typed part, i.e. the second line in the example, without me knowingly changing any setting.
How do I get the old behaviour back? In "Perferences->Keyboard->Shortcuts" (as per this question) the up key is associated with "Cursor up" and "Previous History Command", but the description of the latter is ambiguous regarding the expected behaviour when something is already typed into the command line.
First, make sure that the command history window is docked (If you have a floating window every time you press up then it is not docked. There is a drop-down menu - little circle with a triangle inside. Open the menu and select "Dock").
Once\if the window is docked, open the menu again and make sure that "Match Beginning" is selected and not "Match Anywhere".

Tab in Emacs-helm (anything) does not autocomplete with current best match

While trying to autocomplete a file (e.g. to open a file with C-x C-f) Emacs-helm shows a list of possible candidates.
If I then press Tab (which I would hope it would help me choose the first/closest match), I get the following in the minibuffer:
It looks like the minibuffer gets confused with escape characters, and it does not choose the file that I actually want to open (the top choice).
Helm requires this conceptual jump from the default Emacs completion, which is not so obvious:
You don't need to press a key to complete. The completion buffer refreshes
with new results after every input.
This is called "incremental" completion.
The normal tab functionality is not needed in "incremental"
completion. So tab was rebound to helm-select-action, which allows you to
choose an alternative action with the selection. But there is only one action
in read-file-name.
The error you're seeing could be clearer though, I've filed this issue on github.
Additionally, note Helm treats each space separated term as a filtering
regular expression. So, pressing space foo will filter
the current list down to those that contain foo in the name.