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

Restore location when case split #465

Closed
wants to merge 1 commit into from

Conversation

bixuanzju
Copy link

I always find it annoying every time I do case split on a variable or hole, the cursor would be put on the last of the clause, and I need to move backward several lines to do some editing.

Copy link
Member

@david-christiansen david-christiansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the desired behavior is an improvement, but I don't think that the use of setq here is the right way to do it. Did save-excursion not work? And if not, why not let-bind the variable rather than conjuring it up with setq?

@@ -576,8 +576,10 @@ KILLFLAG is set if N was explicitly specified."
(let ((result (car (idris-eval `(:case-split ,(cdr what) ,(car what))))))
(if (<= (length result) 2)
(message "Can't case split %s" (car what))
(setq final-point (point))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is lexically scoped, so final-point isn't around right now. Why not let-bind it here, rather than using setq?

@@ -588,8 +590,10 @@ KILLFLAG is set if N was explicitly specified."
(let ((result (car (idris-eval `(:make-case ,(cdr what) ,(car what))))))
(if (<= (length result) 2)
(message "Can't make cases from %s" (car what))
(setq final-point (point))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is lexically scoped, so final-point isn't around right now. Why not let-bind it here, rather than using setq?

Also, did you test save-excursion rather than using goto-char like this?

@bixuanzju
Copy link
Author

Thanks! I'm a newbie to elisp. I will see if save-excursion works

@david-christiansen
Copy link
Member

I'm happy to give feedback - sorry it took so long.

keram added a commit to keram/idris-mode that referenced this pull request Dec 7, 2022
Addresses feedback on idris-hackers#465 with
small improvement for making case from hole where the point is moved
back to position of `_` in `case _ of` as that is place user
may most likely edit next.

Closes idris-hackers#465
@jfdm jfdm closed this in #583 Dec 8, 2022
keram added a commit to keram/idris-mode that referenced this pull request Dec 8, 2022
Addresses feedback on idris-hackers#465 with
small improvement for making case from hole where the point is moved
back to position of `_` in `case _ of` as that is place user
may most likely edit next.

Closes idris-hackers#465
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