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

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.

Related

Powershell 7.3.0 Tab completion not working

I've recently upgraded PowerShell to version 7.3.0 version and now, when I type a command, I see its suggestions like when I'm typing pip it adds list like in this image. Or when I type start of the command it suggests its full name.
The problem is that when I press Tab it doesn't complete the command, instead it just starts listing current directories, i.e. here is an image after pressing Tab once.
Also even when I start typing the full name of the command like pip li it still shows the ending, but when pressing Tab it just does nothing.
I expected this to complete the current command with the suggestion after Tab is pressed.
I've tried to google this problem but haven't found the exact same case I have with 7.3.0 version.
Just press -> (right arrow) key
If you want to change key bindings:
source: https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/
Key Bindings for Predictions
Key bindings control cursor movement and additional features within the prediction. To support users running Predictive IntelliSense on multiple platforms, key bindings are user-settable from the command line or your profile script.
PSReadLine contains functions to navigate and accept predictions. As an example, to accept a displayed prediction, PSReadLine contains functions:
AcceptSuggestion – Accept the current inline suggestion
AcceptNextSuggestionWord – Accept the next word of the inline suggestion
AcceptSuggestion is built within ForwardChar, which by default is bound to RightArrow. Pressing RightArrow accepts an inline suggestion when the cursor is at the end of the current line.
AcceptNextSuggestionWord is built within the function ForwardWord, which can be bound with Ctrl+f by Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord. Pressing Ctrl+f accepts the next word of an inline suggestion when the cursor is at the end of current editing line.
As a user, you can bound other keys to AcceptSuggestion and AcceptNextSuggestionWord for similar functionalities. Search for ForwardCharAndAcceptNextSuggestionWord in SamplePSReadLineProfile.ps1 for an example to make RightArrow accept the next word from inline suggestion, instead of the whole suggestion line.
List of additional suggested key bindings defined in PSReadLine SamplePSReadLineProfile.ps1

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 to enable Arrow-Up (and Arrow-Down) key to show previous (or next) entered line in Emacs?

How to enable Arrow-Up (and Arrow-Down) key to show previous (or next) entered line in Emacs?
In Emacs, particular in Scheme mode, I want to use the ArrowUp and ArrowDown keys to navigate in the history or entered commmands, like I use to do in Bash.
However, pressing these keys in the Scheme interpreter (running inside Emacs) doesn't do anything except to go up or down one line in the buffer.
I guess the way to enable this history navigation applies to all modes?
I want to go the expression above i.e. '(1 2 3).
How do I enable it?
You need to get into the command buffer to get history of commands. Press M-x and then try Up /Down. When you are in a regular buffer, these are indeed navigation keys.
Also. have a look at Helm.
Edit (to sync the answer with the updated question, pulling the updated answer from the comments)
If the intention is to use history in the Lisp interpreter buffer, then C-up and C-down are the usual key bindings for that.

Is there an Emacs keyboard shortcut for selecting between ambiguous buffer names when switching buffers

In emacs I'm already using iswitchbuffer, but I would still like to be more productive with my buffer switching.
One common case which arises a lot is that I have 6 or 7 identical or near-identical file names. For example:
server.py<proj1> server.py<proj2> server.py<proj3>... foo_server.py<proj4>
The problem is that I have to type out most of the directory context when I'm switching buffers.
An existing alternative to typing the directory context is a completion window which pops up saying:e
Click on a completion to select it.
In this buffer, type RET to select the completion near point.
Possible completions are:
... ....
but this is unsatisfactory as well since I have to the switch to the window and use the mouse to pick one.
What I'd prefer is to use tab or some other key to highlight alternative buffer selections, then enter to select one. Is there a way to do this?
In iswitchb-mode (and its successor1 ido-mode) the default binding for cycling through candidates are Ctrl+s and Ctrl+r.
You should be able to limit your candidates by typing the common bit of the filename then cycle through those candidates with those bindings.
1 See the header text in iswitchb.el and ido.el.
If you use icomplete-mode (which is a bit like iswitchb-mode but applies to all completions rather than only for buffers), you can cycle to the next/previous matching candidate with C-, and
C-..
Another option, if you use the default completion system (with or without icomplete-mode), is to type serv*1 (for example) to select server.py<proj1>.

auto complete in command minibuffer of emacs

Which setting needs to be done in init.el file, which allows completing the rest of command if one hit M-x and initial letter of the command.
Infact in need something similar as ido-mode for minibuffer too
The ido-mode for the "M-x minifuffer" is called smex (smex use ido).
Available on the main package repos of Emacs. Homepage here
I think you are talking about incremental completion, i.e., having Emacs automatically complete what you type in the minibuffer, without your having to explicitly request completion (e.g., using TAB).
Incremental completion is available in Icicles, as well as Ido and IswitchB. And icomplete-mode shows you completion candidates in a similar way to Ido and IswitchB.
Icicles incremental completion has two aspects:
When buffer *Completions* is displayed and updated, showing you the candidates matching your input -- how soon that happens and what triggers updating
Whether and how much your minibuffer input is expanded (completed) to reflect the set of matching completions
Wrt *Completions* display (#1):
You can use C-# to cycle among the levels (normal, eager, off) at any time.
Normal means that *Completions* is not displayed until you ask for it, but thereafter it is automatically updated as you type/edit your input.
Eager means that *Completions* is displayed as soon as you type something that matches at least two candidates.
(There is also an option to show *Completions* from the outset, before you type anything -- useful as a kind of menu.) You can also specify how long to wait after you type or delete a character before updating *Completions*.
Wrt input expansion (#2):
Icicles is unique in expanding your input to (typically) the longest common match among all completions, even when completion uses apropos matching (that is, regexp or substring -- S-TAB), not just prefix matching (TAB).
There are 4 levels/behaviors for this expansion, plus off (no expansion):
Off -- this is like Ido and IswitchB: completions are shown, but your input is not completed
On request -- expand your input only when requested (TAB or S-TAB)
On request or sole candidate -- on request or when there is only one match
Always for TAB, on request for S-TAB -- TAB expands whenever possible; S-TAB is like previous
Always -- expand input whenever possible
C-" toggles between two of the input-expansion behaviors that you choose (a user option), and C-M-" cycles among all of the behaviors.