Comments (12)
Thank you for your answers @minad and @manuel-uberti. I just gave you 2 use cases but there are many more: starting an isearch with the thing at point, starting a project-wide string replacement with the thing at point... Ivy provides just one binding (M-n
) that works for all these use cases and I think it makes a lot of sense.
from vertico.
@DamienCassou Maybe you are looking for a function which adds things from point in a dwim fashion to the future history. See https://github.com/raxod502/selectrum/wiki/Additional-Configuration#minibuffer-default-add-function
(autoload 'ffap-guesser "ffap")
(setq minibuffer-default-add-function
(defun minibuffer-default-add-function+ ()
(with-selected-window (minibuffer-selected-window)
(delete-dups
(delq nil
(list (thing-at-point 'symbol)
(thing-at-point 'list)
(ffap-guesser)
(thing-at-point-url-at-point)))))))
I consider this code wiki quality at best. I don't think such a thing should be part of a completion UI (neither Selectrum nor Vertico).
from vertico.
@DamienCassou It's not clear to me if you tried these use cases or are just asking if it works before you tried. I loaded just vertico, not other "related" packages and tried the following:
- I tried what you described with
projectile-find-file
and vertico andM-n
did not insert the filename-at-point, but it choose another filename from the project, I assume pulling it from the candidate list in some order. I tried the same thing usingfind-file
andM-n
inserted the filename at point, just like you want. - I did exactly what you described in 2. and it worked fine with vertico. Though I'd rather just hit
M-.
here to go directly to the definition usingxref-find-definitions
without usingimenu
.
As mentioned above, emacs generically calls this "future history" and individual commands implement it in different ways. Those that want a symbol pull in a symbol, others pull in filenames, urls or words or other things. I think most commands I'd want to use in this position already use symbol-at-point
, imenu seems to, if not it's probably a bug with them.
FWIW, projectile-find-file
with selectrum also didn't pull in filename-at-point
(it behaved the same as with vertico) but project-find-file
did do what you want. I tried your example 1. with ivy and counsel and M-n
did do what you describe. I think this is a function of counsel-projectile-find-file
which AFAICT counsel-projectile replaces projectile-find-file
with and it's not a generic function of ivy-next-history-element
. As near as I can tell ivy-next-history-element
is just defaulting the future history to symbol-at-point
when in a prog-mode
derivative and it's not on a file, url or other thing.
from vertico.
Thank you very much @hmelman for your detailed investigation. I will use that as a base to learn new ways of doing things.
from vertico.
You can use yank to insert text into the minibuffer obviously. Then you can use the ffap-
functions which give you find file at point. Then the usual minibuffer history commands are still there, take a look at the vertico-map
. I hope this answers your question. I am not sure if I understood all the points you made above since some seem ivy specific.
from vertico.
@DamienCassou doesn't M-n
do what you're after already?
EDIT: no, now that I see what you mean.
from vertico.
One possible solution is using embark
and embark-consult
:
- on the thing at point, use
embark-act
(I suggest to bind it to a quick key binding) - press
C
(as in capitalc
) and thenf
from vertico.
For the imenu+ivy
flow, isn't it enough to use xref-find-definitions
?
from vertico.
I see your point, but I think it's also kind of related to your personal usage, isn't it? I mean, I have use cases for your new examples that don't require M-n
:
- isearch with the thing at point:
M-s .
(there is alsoM-s M-.
on Emacs master as well) - project-wide string replacement: I use
consult-ripgrep
on the thing at point,embark-export
and edit that buffer accordingly
Not that I don't see your point, of course. It's up to @minad understanding whether it is a complexity worth adding.
from vertico.
Sorry, no such complexity is worth adding here. Vertico provides what default completion provides, if this is insufficient, you can add your own small commands and bind them in vertico-map
. My problem here is also a bit that I don't clearly understand what kind of command you would like to see here (some kind of dwim insert something from point?). Maybe if you provide a code snippet it becomes more clear to me. But such additions are so or so out of the question to be added here. If you are looking for a full featured solution, I recommend Selectrum.
I consider Vertico to be mostly feature complete, so you will generally have a very hard time of convincing me to add something here. The better approach for more features and commands is to maintain them separately. This works well as long as the additions don't require modifications to Vertico itself. If some external feature cannot be implemented (for example because the display code is too rigid), one could discuss adding hooks or splitting up some functions to make it easier for advices to do their job.
Closing.
from vertico.
I'm sorry I didn't managed to express myself clearly so you understand what I need. I also understand you don't want to add features to vertico.
I will try to explain myself again anyway: When in the minibuffer with vertico completion system, I would like to be able to press a shortcut and get the text at point in the main buffer copy-pasted into the vertico's prompt. It should work regardless of the command that triggered the completion system. Without this, I have to start by copying the text at point, then call the command that triggers completion and finally yank the text I've just copied.
from vertico.
Yes, this is exactly what the Emacs built-in future history is supposed to do (accessible via next-history-element
). See above, the minibuffer-default-add-function
adds things at point to the future history according to your preferences.
(Alternatively you can also write a small command bound to vertico-map
which switches to the original buffer, takes the thing at point, goes back to the minibuffer and inserts. But I recommend the future history for this.)
from vertico.
Related Issues (20)
- Error in post-command-hook (vertico--exhibit): (void-function compat--string-width) HOT 1
- File name column takes to much space (even truncated with custom code).)
- Error in `execute extended command` minibuffer
- Refresh on `backward-kill-word`
- The alternative to M-RET doesn't work or is poorly described
- Emacs 30 freezes if there isn't enough room due to window-size-fixed HOT 1
- Lagging cursor movement in Wayland
- Vertico distorts email attachments
- reject completions?
- Problematic completion Org mode commands
- Performance issues
- Pull request: don't delete right side of minibuffer after TAB HOT 1
- vertico-flat-mode with vertico-flat-max-lines > 1 does not respect (setq vertico-resize 'grow-only) HOT 5
- Query Regarding Functionality Similar to ivy-restrict-to-matches
- How to achieve fuzzy completion HOT 1
- Use a different sort strategy per command
- Error in post-command-hook (vertico--exhibit): (cyclic-function-indirection ConTeXt-mode)
- Keyboard macro and default M-x command selection
- Blank line among function completions with llama installed
- Odd issue with read-file-name and vertico
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vertico.