Comments (14)
@raxod502 Thanks for the explanation!
from consult.
Thank you! There is the default
input. However the initial-argument
seems deprecated by the completing-read
api, so I am intentionally not supporting the argument here. Could you please describe a bit more in detail what these functions are supposed to do, since I am not very familiar with all the ivy/swiper details?
from consult.
If you call isearch
insert some search input and call consult-line-from-isearch
it behaves like you call consult-line
and insert exact same input. consult-line-from-isearch
begin search for symbol at point.
from consult.
I have tried to use default
to implement it and I can't.
from consult.
Thank you. I think this is indeed not possible without using the initial input argument. I wonder about the motivation for the deprecation, e.g. it needs a bit of digging through the mailing list and git blame. Then we can think of an alternative solution and ask for example the selectrum developers what they are proposing to use instead. I would like to make this project work well with both icomplete and selectrum.
from consult.
@s-kostyaev I decided to implement support for initial input since I think it can be useful in the special cases you mentioned f5ef8ba. Please let me know if it works for you. Note however that consult--read is private API, therefore and also since it benefits others, I would encourage you to make PRs if you have useful commands lying around :) If you don't have time for that, please add the command to the wishlist #6 such that we can at least keep it in mind!
from consult.
Thanks. I will provide PR as soon as I have free time. Also, why do you think selectrum has no support for initial input
? It has:
https://github.com/raxod502/selectrum/blob/945f8fe18933a53b2012a1d179587d90a70bb536/selectrum.el#L1514
from consult.
@s-kostyaev Yes, it has. However the initial-input argument of completing-read is for some reason not passed through to selectrum-read (https://github.com/raxod502/selectrum/blob/945f8fe18933a53b2012a1d179587d90a70bb536/selectrum.el#L1616). I guess the reason is that commands using completing-read
should generally not use initial-input and selectrum wants to make sure that only commands which are explicitly designed to work well with selectrum are allowed to use it. Maybe @clemera can tell us more. My implementation of consult--read is using the selectrum initial-argument option if selectrum is used, for icomplete the initial argument is simply passed to completing-read.
Lines 327 to 335 in c880adb
Maybe I should add that if consult uses initial input it is probably ok, since we make sure that it works well with selectrum. So I think we are good, but I hope maybe the selectrum developers change their mind since I don't like jumping through such hoops to achieve what I am looking for. Also note that consult--selectrum-options
is a hack of mine which allows passing options to selectrum despite using completing-read. But I hope this can be added to the public selectrum api at some point, see radian-software/selectrum#244. The story is unnecessarily complicated as of now imho.
from consult.
I don't know more about this, I believe it was there from the start so @raxod502 may have more information. I also wondered about this a few times (why it is officially deprecated). Note you could also do something like:
(minibuffer-with-setup-hook
(lambda () (insert "initial input"))
(completing-read "Test: " #'help--symbol-completion-table))
But I just noticed this doesn't currently work correctly with selectrum.
from consult.
@clemera Thank you for chiming in. Yes I had this before using a minibuffer-with-setup-hook, erase-minibuffer-contents, insert etc. But the solution I use now is more robust.
Edit: How I read the upstream deprecation - It is deprecated for "most use-cases". But I guess it will continue to work forever and I don't see how they will get rid of this argument. Well they could also do the selectrum move and simply ignore the argument, but I don't think this is a great solution. In particular since selectrum itself supports initial input. The concept itself is therefore not deprecated. Maybe upstream should undeprecate this argument again. I think it is enough if one says that initial arguments are generally discouraged because they are intrusive etc. But as far as I see it from this issue, there are some special valid uses cases.
from consult.
I don't know more about this, I believe it was there from the start so @raxod502 may have more information. I also wondered about this a few times (why it is officially deprecated). Note you could also do something like:
(minibuffer-with-setup-hook (lambda () (insert "initial input")) (completing-read "Test: " #'help--symbol-completion-table))But I just noticed this doesn't currently work correctly with selectrum.
Selectrum currently use exactly the same solution:
https://github.com/raxod502/selectrum/blob/945f8fe18933a53b2012a1d179587d90a70bb536/selectrum.el#L1229
from consult.
@s-kostyaev Sure. But there are many things happening before and after. Therefore it is not a good idea to write my own hook which crashes this party.
from consult.
The concept itself is therefore not deprecated. Maybe upstream should undeprecate this argument again. I think it is enough if one says that initial arguments are generally discouraged because they are intrusive etc. But as far as I see it from this issue, there are some special valid uses cases.
+1
from consult.
Yeah, I think this may be an artifact of external packages having a lot more creativity with how to use the completing-read
API than was anticipated upstream. Perhaps none of the built-in commands need something like this, and all the uses of initial-input
upstream have been hacks that would have been better served by default
. And so the argument was deprecated, despite the fact that there are also other use cases that are not hacks.
I was not thinking about these use cases when I developed Selectrum, so I read the docstring of completing-read
(which says initial-input
is deprecated) and thought of it as one more wart I could do away with. But in light of the discussion in this thread I think it would make a lot of sense to pass through initial-input
from completing-read
into selectrum-read
.
from consult.
Related Issues (20)
- `consult--jump-ensure-buffer` does not take partial previews into account
- I can't get consult-ripgrep to show only matching files, as with the "-l" command line option
- consult-line warning in non-org-mode buffer HOT 1
- consult-buffer does not show default candidate in minibuffer HOT 2
- Builing an easy consult-bbdb
- consult--global-mark-candidates only stores the location in places that are stripped HOT 6
- Consult-buffer "not "remembers" open buffers from previous sessions. HOT 1
- Sometimes `consult-line` throws a "Regular expression too big" error HOT 1
- Does consult-fd support directory abbreviation?
- consult hangs with find-file at emacs startup
- Pre-select nearest heading arguments
- consult-register not working anymore
- How to add advice to achieve for org buffer like to collapse all the headings after executing 'consult-org-heading'?
- How do I use `consult-line` (with live previews) with `ivy`?
- [Q] How do I hide the line numbers in, e.g., `consult-outline`?
- [Q/Bug] consult-grep (with ripgrep or ugrep) is slower than counsel-rg
- consult preview: "PDF document is damaged" but no problem viewing it directly from pdf-tools HOT 4
- [FR] Add the ability to change the initial query in `consult-completion-in-region` HOT 1
- how to use consult-fd on a list of files? HOT 6
- additional set of buffers in consult-buffer-sources
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 consult.