Comments (27)
There is the better solution -
orderless-transient-matching-styles
Oh, that's right! I completely forgot. Thank goodness there is at least one expert on orderless in this conversation. 😛
from consult.
@oantolin @s-kostyaev As far as I see, we don't have to do anything here? If you disagree, please reopen or ping me!
from consult.
I think if we will provide consult-isearch
it should be aware of other isearch options like search-whitespace-regexp
, isearch-lax-whitespace
, isearch-regexp-lax-whitespace
, etc. Also, it should use the same completion style as isearch
. That's why I've created #40 to be able to overwrite default completion style for consult-line
only.
from consult.
This one works for me:
(defun my-consult-line-from-isearch ()
(interactive)
(minibuffer-with-setup-hook
(lambda ()
(setq orderless-transient-matching-styles '(orderless-prefixes)))
(consult-line-from-isearch)))
from consult.
Out of curiosity, @s-kostyaev: what styles do you normally use?
(orderless-matching-styles '(orderless-regexp orderless-initialism orderless-flex))
And for me flex breaks in-file search.
from consult.
I think consult-line
should not overwrite isearch-string
at all. It should have their own history (I mean consult-line
). This command consult-line-from-isearch
is great for add it to isearch-mode-map
like this:
(leaf isearch
:bind ((isearch-mode-map
("M-i" . consult-line-from-isearch))))
or to use it with ace-isearch
. But switching back and forward sounds neat. Name convention also from ace-isearch
.
from consult.
@s-kostyaev I think overwriting would be okay since it would only happen for consult-isearch
, thus being triggered explicitly by the user. I tried this. But so far the experiment did not go well. If you would like to play around with this a bit it could be cool, but we don't have to do this. It was just an idea. Thanks for the isearch-mode-map example. I agree, that makes sense. Maybe this should be added to the readme.
from consult.
@s-kostyaev Here is what I tried for now. As I said, does not work yet unfortunately.
;;;###autoload
(defun consult-isearch ()
"Search by lines, using and updating the `isearch-string'."
(interactive)
(minibuffer-with-setup-hook
(lambda ()
(add-hook 'post-command-hook
(lambda ()
(setq
isearch-regexp nil
isearch-string (minibuffer-contents-no-properties))
nil t)))
(consult-line isearch-string)))
from consult.
Also, can consult-line
search for regexp as isearch
can?
from consult.
Also, can consult-line search for regexp as isearch can?
Depends on the completion style. If the completion style recognizes regexps, I think yes. But this is all a bit fuzzy. I am not deep into this. I am using orderless.
from consult.
I am using orderless.
Same as me. But looks like orderless
has its own completion styles. And, AFAIK, that styles are global.
UPD. Yep. orderless
has orderless-matching-styles
. And it is a global custom variable.
from consult.
@s-kostyaev Here is what I tried for now. As I said, does not work yet unfortunately.
;;;###autoload (defun consult-isearch () "Search by lines, using and updating the `isearch-string'." (interactive) (minibuffer-with-setup-hook (lambda () (add-hook 'post-command-hook (lambda () (setq isearch-regexp nil isearch-string (minibuffer-contents-no-properties)) nil t))) (consult-line isearch-string)))
This is a bad idea to use hook with lambda. You will add this lambda to that hook every time you call this command. Use named function instead.
from consult.
It is okay to do it like this here, but this is a matter of taste. And no, it is not added every time. The hook is added locally.
from consult.
Same as me. But looks like orderless has its own completion styles. And, AFAIK, that styles are global.
Probably you can overwrite them locally, like the hooks. But I would have to look into this.
from consult.
Yep, using setq-local
on orderless-matching-styles
should work.
from consult.
Yep, using
setq-local
onorderless-matching-styles
should work.
Should I set it inside some hook?
from consult.
Well, you should set it when the minibuffer is the current buffer. So if you are already using minibuffer-with-setup-hook
, do it in the function you pass to it.
from consult.
But, I for one don't like people messing with my matching styles, maybe others feel the same way.
I think a better solution is education: just explain clearly in the docstrings that consult-line uses whatever kind of completion you have and is not the same thing as isearch, regexp isearch or lax whitespace isearch.
from consult.
I prefer different completion styles for in file search and commands for example. I like Emacs because I can make it my own tool with my own rules. So why should I learn the tool instead of configure it for exact my purpose? Kind of philosophical question.
from consult.
Yep, using
setq-local
onorderless-matching-styles
should work.
There is the better solution - orderless-transient-matching-styles
from consult.
But, I for one don't like people messing with my matching styles, maybe others feel the same way.
I think a better solution is education: just explain clearly in the docstrings that consult-line uses whatever kind of completion you have and is not the same thing as isearch, regexp isearch or lax whitespace isearch.
I agree with this sentiment, but such behavior could be made configurable and it could be restricted to only few commands for which this is an explicitly stated feature. But I am not sure if something like consult-isearch
can be made or makes much sense. As I said it was just an idea based on the simpler command we already have consult-line-from-isearch
.
from consult.
I think I can now achieve the behavior I need. Maybe consult-line-frome-isearch
is enough.
from consult.
Out of curiosity, @s-kostyaev: what styles do you normally use?
from consult.
I see, that makes sense.
from consult.
I'm new to Consult, but I don't see the solution -- how to I connect consult to my isearch results when I press M-i
if I'm not using orderless?
from consult.
@WorldsEndless What do you want to achieve exactly? You can access the last isearch input in the future history of consult-line
. This is pretty much it, very limited. But there is also the proposal to make the isearch history accessible, see #171. But with #171, the isearch history would not connect to consult-line
, but would only allow to restart an old isearch session.
from consult.
@WorldsEndless For reference, regarding ace-isearch I answered here - https://www.reddit.com/r/emacs/comments/l2sata/finding_replacements_for_switching_to_selectrum/gk80veh?utm_source=share&utm_medium=web2x&context=3
from consult.
Related Issues (20)
- Transform yanks before listing/previewing in consult-yank HOT 1
- Consult previews don't have any font highlighting
- consult-grep family integrates badly with literally-visited files
- consult--each-line not unquoted `end` symbol
- Sorting when buffer switching
- consult-buffer only showing the active buffer HOT 4
- Usage of :history in consult--read?
- consult-xref broken in emacs 30 HOT 1
- consult-xref assumes xref-file-location in consult-xref--candidates
- `call-interactively` does not use `consult-customize` HOT 1
- Consult (asynchronous) doesn't respect completion-styles with orderless?
- Should preview change the current region?
- `consult-yank-from-kill-ring` appends the text, instead of inserting it
- Match not found with consult-ripgrep and consult-grep
- `void-function internal--without-restriction` under Emacs 30 HOT 1
- how do i use consult to live preview a given list of files + line number
- consult-buffer with `display-buffer-alist` HOT 1
- Error running timer: (wrong-type-argument sequencep #<marker in no buffer>) HOT 2
- Is there a way to remember the last search and Change the result layout?
- Possible to grep in other window
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.