Git Product home page Git Product logo

Comments (27)

oantolin avatar oantolin commented on June 14, 2024 2

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.

minad avatar minad commented on June 14, 2024 2

@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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024 1

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024 1

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024 1

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

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.

minad avatar minad commented on June 14, 2024

@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.

minad avatar minad commented on June 14, 2024

@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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

Also, can consult-line search for regexp as isearch can?

from consult.

minad avatar minad commented on June 14, 2024

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

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 avatar s-kostyaev commented on June 14, 2024

@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.

minad avatar minad commented on June 14, 2024

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.

minad avatar minad commented on June 14, 2024

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.

oantolin avatar oantolin commented on June 14, 2024

Yep, using setq-local on orderless-matching-styles should work.

from consult.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

Yep, using setq-local on orderless-matching-styles should work.

Should I set it inside some hook?

from consult.

oantolin avatar oantolin commented on June 14, 2024

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.

oantolin avatar oantolin commented on June 14, 2024

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

Yep, using setq-local on orderless-matching-styles should work.

There is the better solution - orderless-transient-matching-styles

from consult.

minad avatar minad commented on June 14, 2024

@oantolin

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.

s-kostyaev avatar s-kostyaev commented on June 14, 2024

I think I can now achieve the behavior I need. Maybe consult-line-frome-isearch is enough.

from consult.

oantolin avatar oantolin commented on June 14, 2024

Out of curiosity, @s-kostyaev: what styles do you normally use?

from consult.

oantolin avatar oantolin commented on June 14, 2024

I see, that makes sense.

from consult.

WorldsEndless avatar WorldsEndless commented on June 14, 2024

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.

minad avatar minad commented on June 14, 2024

@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.

minad avatar minad commented on June 14, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.