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

"tuareg-eval-phrase" and the double-semicolon ;; #259

Closed
Fourchaux opened this issue Jul 16, 2021 · 5 comments
Closed

"tuareg-eval-phrase" and the double-semicolon ;; #259

Fourchaux opened this issue Jul 16, 2021 · 5 comments

Comments

@Fourchaux
Copy link

Fourchaux commented Jul 16, 2021

(* tuareg 20210709.321 - OCaml 4.12.0 - Emacs 28.0.50 *)

e.g.

let _ = 1 ;;
let _ = 2

After a "tuareg-eval-phrase" the cursor jumps to the beginning of the next phrase. OK.

- Exception 1:

let _ = 1
;;
let _ = 2

The cursor jumps to ;; and stays there.

- Exception 2:

let _ = 1 (* comment *) ;;
let _ = 2

Idem.

Note:

let _ = 1 ;; (* comment *)
let _ = 2

This is OK. The cursor jumps to the second line.

Do you think it would be possible to correct these movements?

@mattiase
Copy link
Contributor

Yes, I noticed that too and agree it's a bit annoying when evaluating several phrases in a row with C-M-x and suddenly getting stuck because of a ;; on a line of its own.

From looking at the source it might be intentional – see tuareg--skip-backward-comments-semicolon and tuareg--skip-forward-comments-semicolon for example. There could be subtleties involved. Let's hear what the maintainers have to say about it.

@monnier
Copy link
Contributor

monnier commented Aug 3, 2021

I doubt these subtleties in those functions are meant to provide the behavior under discussion.

But FWIW, I'm probably not the right person to answer since I consider double-semi-colons in files to be non-kosher.

@mattiase
Copy link
Contributor

mattiase commented Aug 4, 2021

I think most people avoid ;;, but they often remain when they do get inserted for whatever reason – as when the compiler throws a seemingly nonsensical error that needs to be narrowed down. They are also very common in test suites, which can be quite useful to run piecemeal using C-M-x.

Double-semis are also used a lot by students learning the language and we should be nice to them once in a while.

@monnier
Copy link
Contributor

monnier commented Aug 4, 2021 via email

@Fourchaux
Copy link
Author

Fourchaux commented Aug 4, 2021

@mattiase
Skipping lines that only contain ;; would already be a very big improvement.

BTW, this "style" is used by some big guns:
X. Leroy: https://github.com/ocaml/ocaml/blob/trunk/parsing/location.ml
or D.Doligez: https://github.com/ocaml/ocaml/blob/trunk/driver/main_args.ml
(for the first reason you give - improving the error messages - I suppose).

mattiase added a commit to mattiase/tuareg that referenced this issue Aug 8, 2021
This allows repeated `tuareg-eval-phrase` to execute phrases in
sequence without the user needing to do anything in-between.
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

No branches or pull requests

3 participants