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

acme: Reverse search #552

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

acme: Reverse search #552

wants to merge 2 commits into from

Conversation

bd339
Copy link

@bd339 bd339 commented Apr 30, 2022

This PR does two things:

  1. Implement a new Kool command. Kool is the reverse of Look. It searches backwards from point.
  2. Clean up the search function: removed unnecessary variables and remove code that AFAICT has no performance or correctness purpose.

I know about :-/ and :? but snarfing the needle to the tag and potentially escaping it is an annoyance. It would be more convenient if there was a mouse chord or key modifier for MB3, bypassing the tag completely. Suggestions or feedback?

@bd339 bd339 changed the title Reverse search acme: Reverse search Apr 30, 2022
bd339 added 2 commits May 1, 2022 00:04
Kool is the reverse of Look. It searches backwards from point.
@mibk
Copy link

mibk commented May 2, 2022

I know about :-/ and :? but snarfing the needle to the tag and potentially escaping it is an annoyance. It would be more convenient if there was a mouse chord or key modifier for MB3, bypassing the tag completely. Suggestions or feedback?

Totally agree. The backwards search is so inconvenient (compared to the forward search), that unless I really need it, I just use forward search and cycle through the whole file. I thought about it many times that it would be nice if the shift key was changing the search direction.

@bd339
Copy link
Author

bd339 commented May 2, 2022

Since this patch is all about convenience, I agree it would be ideal if shift+MB3 searched backwards. I haven't looked enough at the code to be sure, but it looks to me like Acme uses two threads for mouse and keyboard handling. Therefore it might not be trivial to synchronise them into one event. Are there any examples of keyboard+mouse interaction in acme I can look at?

@jxy
Copy link
Contributor

jxy commented May 2, 2022

Isn't it the same as Edit ?search_term

@bd339
Copy link
Author

bd339 commented May 2, 2022

Isn't it the same as Edit ?search_term

Not really imo. The difference between Kool and Edit ?search_term is the same as the difference between Look and Edit /search_term. That means you don't have to retype search_term, you can select it and use MB2. You also don't have to escape regex chars. Just today I was searching for ^H in Acme. That query must be rewritten to Edit ?\^H to do what I want.

@mibk
Copy link

mibk commented May 3, 2022

You also don't have to escape regex chars. Just today I was searching for ^H in Acme. That query must be rewritten to Edit ?\^H to do what I want.

As a different approach to solving the problem of escaping regexp special chars I've once thought about implementing the following feature from the Plan 9 grep (see grep(1)):

An expression starting with * will treat the rest of the expression as literal characters.

I think it's a reasonable, small enough feature that would make the experience with Plan 9 tools more consistent.

@bd339
Copy link
Author

bd339 commented May 3, 2022

An expression starting with * will treat the rest of the expression as literal characters.

Interesting, I didn't know that. Wonder how many other people do :D
Or you can use Look (or Kool with this PR). That's what I did and that's what it's there for AFAIK.

In any case, I feel that belongs in a separate PR if someone implements it: I still don't feel that makes backward search sufficiently convenient compared to forward search. In fact it would be less convienient than Kool, because you still have to re-type/snarf search_term in general (and add the * which many people may not know about). Acme is the only editor I know that makes searching in reverse considerably harder.

Maybe I should rename this PR: Easy reverse search?

@mibk
Copy link

mibk commented May 3, 2022

In any case, I feel that belongs in a separate PR if someone implements it

Definitely. It's a separate, albeit related issue.

Since this patch is all about convenience, I agree it would be ideal if shift+MB3 searched backwards.

The shift+MB3 would be really nice. But your approach, as is, might be a good starting point. Just a couple observations:

  • I'd find it more convenient if the name of the reverse search command were something like Lookb. Look is already present in the window tag, so adding a single letter plus clicking on it is more convenient than typing Kool somewhere else.
  • If this pull request gets accepted, the Acme man page should probably be updated as well. See $PLAN9/man/man1/acme.1:437.

@rastagraffix
Copy link

rastagraffix commented May 4, 2022 via email

@dancrossnyc dancrossnyc requested a review from rsc May 11, 2022 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants