Skip to content
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

Improve back-slash handling to reduce confusion #41

Closed
xbot opened this issue Feb 19, 2017 · 6 comments
Closed

Improve back-slash handling to reduce confusion #41

xbot opened this issue Feb 19, 2017 · 6 comments

Comments

@xbot
Copy link

xbot commented Feb 19, 2017

Either :Ack App\\\Link or :Ack App\\\\Link will find App\Link.

Why ? Won't it be easier to be understood with :Ack App\\Link ?

@wincent
Copy link
Owner

wincent commented Feb 28, 2017

You should be confused because it is confusing. There are multiple levels of escaping happening here, I think:

  • The shell in which the ack/ag command performs escaping.
  • The ack/ag performs Perl-Compatible Regular Expression escaping too.

I think the shell in particular makes this tricky to understand, as evidenced by this Stack Exchange post.

@xbot
Copy link
Author

xbot commented Mar 1, 2017

@wincent Thanks. Now I understand what happened. The other question is, won't it be more readable for the inputed regular expression if Ferret do the extra escaping ?

@wincent
Copy link
Owner

wincent commented Mar 2, 2017

That's an interesting idea. If it could be done reliably, that would be great. Having to be aware of the complicated escaping rules definitely makes the current set-up a leaky abstraction.

The only "gotcha" I can think of here is that depending on which mode Ferret is running in (using modern vim "async" primitives, using the vim-dispatch plug-in, or falling back to the legacy code path), the exact method used to launch the underlying tool may vary, so the escaping requirements may be different. We'd want to look into that to be sure that all the cases are correctly handled.

@wincent wincent changed the title I'm confused about the back slashes Improve back-slash handling to reduce confusion Mar 2, 2017
@xbot
Copy link
Author

xbot commented Mar 2, 2017

@wincent Yeah, I'm looking forward to that.

@wincent
Copy link
Owner

wincent commented Jun 9, 2017

I think I have this working fairly nicely now on the "next" branch. Have tested with async Neovim, async Vim 8, and vanilla (non-async) Vim-8. Haven't bothered to test with vim-dispatch, yet, but I will. If I haven't run into any issues with this in a few days, will merge to master.

@xbot
Copy link
Author

xbot commented Mar 15, 2022

Currently, I use ferret with rg to search for patterns. If the pattern is complicated, it is likely that it's not compatible with :Acks , so I have to escape some characters manually since I'm using the very magic option \v with :Acks.

I think it would be better if there is an option with which I can hook a customized function to escape characters when :Acks is executed, that would be a big boost to efficiency!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants