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

support mark-(next|previous)-like-this #1764

Merged
merged 7 commits into from
Feb 10, 2025
Merged

Conversation

Prikaz98
Copy link
Contributor

@Prikaz98 Prikaz98 commented Feb 2, 2025

There is a similar PR, but I didn't use isearch to find the next marks.

mark-(next|previous)-like-this aims to work like multiple-cursors.el This means that if there is nothing to select, it marks the next or previous line.
Handling offsets is a bit complex because we need to maintain the same starting or ending position of the region when calling mark-next or mark-prev.

Demo:
lem-multicursor

TODO:

  • Figure out how to write the test
  • Fix the bug where duplicate marks appear when spamming the commands add-cursors-to-(next|prev)-line (previously handled by clear-duplicate-cursors; I believe we can address this within the function that determines the next cursor position)

@Prikaz98 Prikaz98 changed the title feat: support mark-(next|previous)-like-this WIP: support mark-(next|previous)-like-this Feb 2, 2025
@Prikaz98 Prikaz98 marked this pull request as draft February 2, 2025 18:53
double C-g - means first toggle region, secong cancel multiple-cursors
spam cursors fixed
@Prikaz98
Copy link
Contributor Author

Prikaz98 commented Feb 3, 2025

Also added C-g double click behavior (first cancel mark region, second clean multicursors)
lem-multicursor-double-c-g-behavior

@Prikaz98
Copy link
Contributor Author

Prikaz98 commented Feb 4, 2025

I have a problem with test running. I read an instruction from this page
and checked rove project but unfortunately I've got the same result.
Or this

.qlot/bin/rove lem-tests.asd

Testing System lem-tests

✓ 0 tests completed

Summary:
  All 0 tests passed.

no test executed

or

.qlot/bin/rove tests/cursors.lisp

Unhandled ASDF/FIND-COMPONENT:MISSING-COMPONENT in thread #<SB-THREAD:THREAD tid=1070475 "main thread" RUNNING
                                                             {1003F80003}>:
  Component "lem-tests/cursors" not found

If someone know what is wrong, please let me know 🙏

I saw your like:) Can you help me pls @cxxxr

@cxxxr
Copy link
Member

cxxxr commented Feb 5, 2025

lem-tests is not a package-inferred-system, so it is not possible to run tests on a file-by-file basis from rove.
If you want to test individually, how about running 'run-test' from the REPL?

tests cover
 - mark prev/next like by active region
 - C-g double click behavior
   First cancel active regions in multicursors mode
   Second cancel multicursors
 - mark prev/next like in the same line
 - keep point in the same position regardless search direction
@Prikaz98 Prikaz98 changed the title WIP: support mark-(next|previous)-like-this support mark-(next|previous)-like-this Feb 5, 2025
@Prikaz98 Prikaz98 marked this pull request as ready for review February 5, 2025 23:10
@Prikaz98
Copy link
Contributor Author

Prikaz98 commented Feb 7, 2025

I think that's enough for this PR. If you see any issues in my code, feel free to leave comments :)

@cxxxr
Copy link
Member

cxxxr commented Feb 7, 2025

Thank you for the PR.
I'm checking the behavior now.
This looks similar to

(define-key *isearch-keymap* "C-M-n" 'isearch-add-cursor-to-next-match)
but is it different?

@Prikaz98
Copy link
Contributor Author

Prikaz98 commented Feb 7, 2025

Oh, yes, it is a similar function. I didn't know that this function already exists in isearch module. Let's close this PR and I just keep it in my personal build.

Also it will be great to add mention in Lem doc in multiple cursors description. Because when I read it I thought: "Oh, there is no my most useful function mc mode. I must implement this"

@cxxxr
Copy link
Member

cxxxr commented Feb 7, 2025

Yeah, I'm sorry there are no documents. That's something we need to improve.
Also, since the functions of isearch are incomplete, I would be happy if they could be integrated with this PR.

isearch-abort
 - if during the isearch mode user add any fake cursros we should stay in the same place
@Prikaz98
Copy link
Contributor Author

Prikaz98 commented Feb 7, 2025

Merged prior changes with the existing implementation in the isearch module. Hopefully, it turned out pretty nice.

lem-multicursors-isearch

@cxxxr
Copy link
Member

cxxxr commented Feb 10, 2025

Thank you so much!
it can't support the behavior of having multiple cursors on the same line that was supported before this change, but I will merge this PR itself.

@cxxxr cxxxr merged commit ea4bfe5 into lem-project:main Feb 10, 2025
@Prikaz98 Prikaz98 deleted the multicursor branch February 10, 2025 09:53
CarsonEllsworth33 pushed a commit to CarsonEllsworth33/lem that referenced this pull request Feb 28, 2025
* feat: support mark-(next|previous)-like-this

* feat: double C-g

double C-g - means first toggle region, secong cancel multiple-cursors
spam cursors fixed

* added tests:

tests cover
 - mark prev/next like by active region
 - C-g double click behavior
   First cancel active regions in multicursors mode
   Second cancel multicursors
 - mark prev/next like in the same line
 - keep point in the same position regardless search direction

* removed useless lines

* Search since last element (not loop)

* feat: isearch-add-cursors in different directions

isearch-abort
 - if during the isearch mode user add any fake cursros we should stay in the same place

* remove extra var
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.

2 participants