-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Disable vertico-insert for tramp #240
Comments
There is no simpler way than replacing/rebinding the command in the Instead of building the regexp, you could use Having Tramp-specific insertion functionality in Vertico out of the box is out of scope. In principle Please feel free to add your command and configuration to the Vertico wiki! |
Thanks 🙏🏻 that makes sense! I'll be using (defun my-vertico-insert-unless-tramp ()
"Insert current candidate in minibuffer, except for tramp."
(interactive)
(if (vertico--remote-p (vertico--candidate))
(minibuffer-complete)
(vertico-insert))) for a few days and if it works I'll try to remember to add it to the wiki.
I don't really want to use M-TAB for this instead of TAB because I'll only ever think of using it after I tried to TAB complete and got annoyed that tramp opened the connection to the wrong machine, but that might work for other people.
Yes I don't think there is anything wrong with vertico itself, nor that it should have anything tramp-specific. I was just wondering if overriding the binding or advising the function is the way to go, which you confirm. I think that ultimately the fix would be to make tramp support other completion styles, which would make orderless work. I don't have the courage to fix this unfortunately 😅 so I was looking for a way to disable vertico temporarily as a workaround. |
Tramp should support all completion styles. The file completion backend should be agnostic to the completion styles in use. For example when I enter For example, |
We are probably talking past each other then. Do note that the function above is good enough for me so feel free to just drop the discussion 😉 I'll try to explain in detail the problem I was having. I'm trying to have completion for host names, not remote files, so "Probably it is just that the server is too slow?" does not apply here; the annoying behavior happens before I even hit the server, when completing the host names that tramps gathers from my machine. Which brings us to...
This is not true in all contexts unfortunately (emphasis mine):
from https://www.gnu.org/software/emacs/manual/html_node/tramp/File-name-completion.html for tramp 2.5.2.28.1 This is acknowledged in the orderless readme
Here's an example, I want to access
If I call find-file and type
but I can't to narrow it down so that
presumably because tramp supports providing several paths to open multiple files in one go. Which is fine! I don't think vertico or orderless need to add tramp-specific support, the problem comes from tramp only supporting If I were to just type
so instead what I want was a way to revert, temporarily, to the old TAB-calls-minibuffer-complete behavior. (defun my-vertico-insert-unless-tramp ()
"Insert current candidate in minibuffer, except for tramp."
(interactive)
(if (vertico--remote-p (vertico--candidate))
(minibuffer-complete)
(vertico-insert))) does just that. But then I wondered if this was the best way to do it, if I was missing something, etc. Hence the question, but I'm satisfied with the answer to just rebind TAB in vertico-map to a custom function. Hopefully that makes the context clearer 😅 |
Okay, I am aware that Orderless does not work for all programmable completion tables, in particular not the
For I see your point now that for Unfortunately I don't see how we could integrate this command in Vertico out of the box - usually I prefer to have uniform behavior across all contexts. We would need some means to detect if we are in a |
I just tried to go down the Orderless style dispatcher rabbit hole to improve the host name completion. Unfortunately it turns out that the hostname completion table ignores Just for reference, this is what I tried: (defun +orderless-dispatch (word index _total)
(cond
;; Treat first word as prefix completion for remote files.
((and (= index 0)
(string-match-p ":" word)
(string-match-p "\\`/[^/|:]+:"
(substitute-in-file-name
(minibuffer-contents-no-properties))))
;; Orderless will interpret this regexp as prefix
;; and pass it directly to the table. This special treatment
;; of ^literal regexps is an optimization and has also been
;; added to support tables which require a prefix.
`(orderless-regexp . ,(concat "^" (regexp-quote word))))
...)) If the table would respect the regexp filtering in addition to the prefix filtering, input like (For more background regarding the style dispatcher, see the Orderless README and https://github.com/minad/consult/wiki#minads-orderless-configuration.) |
That makes sense, thanks for looking into this! 🙏 |
Hi! 👋🏻
I'm using vertico+orderless, which is an awesome combo unless trying to autocomplete tramp paths. I don't have a full understanding of the interactions between vertico, orderless and tramp, so I might be missing something obvious 😅
Tramp hostname completion isn't sufficient in my case because hitting TAB still picks the "selected"/first candidate which is not helpful when you can't narrow down the list to something manageable.
Instead of waiting for tramp to support more completion styles, I'm looking at the problem the other way: I need a way to tweak
vertico-insert
to preempt it from doing it's job, but only when dealing with tramp paths.I've got this naive implementation bound to TAB in
vertico-map
and it works OK, if hackish. I could not find any other way to disable
vertico-insert
temporarily, is there a better way to do this? I haven't found knobs to configure the behavior ofvertico-insert
other than advising it or defining a new function. I'm especially interested in improvements along the lines ofhello-/ssh:-world
out there, hopefully)vertico--candidate
if it is an internal function that may changevertico-insert
does it's job?This might very well be outside of the scope of vertico to support such customizations, if so then anybody reading this feel free to steal this dumb function for your own config
Have a nice day 😄
The text was updated successfully, but these errors were encountered: