Closed Fourchaux closed 3 years ago
This is squarely my fault, thanks for noticing! Very sorry about that. Would pull request #251 help?
Oups, I don't know how to apply your PR...
Trying
$ opam pin add tuareg --dev
Or
$ opam pin add tuareg https://github.com/mattiase/tuareg.git
gives
...
The following actions will be performed:
∗ install conf-emacs 1 [required by tuareg]
∗ install tuareg 2.2.0*
↻ recompile user-setup 0.7 [uses tuareg]
===== ∗ 2 ↻ 1 =====
Do you want to continue? [Y/n] y
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved user-setup.0.7 (cached)
[ERROR] The compilation of conf-emacs.1 failed at "emacs --version".
⬇ retrieved tuareg.2.2.0 (no changes)
...
╶─ No changes have been performed
The pull request is on a separate branch and according to the Opam docs you would say something like
opam pin add tuareg https://github.com/mattiase/tuareg.git#defun-separator
but I haven't tested it myself.
You could also work outside Opam, cloning the branch directly:
$ git clone https://github.com/mattiase/tuareg.git
$ cd tuareg
$ git checkout defun-separator
and then tell your Emacs to use files from that directory. Do say if you need more directions.
Note: I also try opam pin add tuareg https://github.com/mattiase/tuareg.git#defun-separator but the install pb is still present.
Now, working and testing outside opam seems OK. Great. :+1:
Thanks for testing! Let's see if we can receive assistance in the merge of #251 then. @monnier?
Found something else (with 'and'). Damn...
e.g.:
let a = 1 and b = 2 in a + b
'tuareg-eval-phrase' gives:
# let a = 1;;
val a : int = 1
with the cursor jumping to the beginning of 'and'.
A second 'tuareg-eval-phrase' gives a Parse error:
# and b = 2;;
Toplevel input:
# and b = 2;;
^^^
Parse error: illegal begin of top_phrase
Do you have the same problem?
Thank you, and confirmed. This calls for some more careful testing.
Even though a declarative let... and...
now consists of two separate defuns, it should as you noted be a single phrase since that is the smallest unit that can be evaluated.
There is more to it than meets the eye. I shall prepare an improved patch as soon as time permits.
The pull request has been updated; do take a look. (And sorry about the delay.)
This patch solves the 'and' problem. Very good.
Now, I have tried the first examples from the OCaml manual and, unfortunately, several problems exist. e.g.: https://www.ocaml.org/manual/coreexamples.html#s:datatypes
(1 < 2) = false;;
'a';;
"Hello" ^ " " ^ "world";;
{|This is a quoted string, here, neither \ nor " are special characters|};;
{|"\\"|}="\"\\\\\"";;
In all these examples, if the cursor is on the first character, a 'tuareg-eval-phrase' does not evaluate the phrase.
Could having a non-alphanumeric first character be a problem?
Good catch, thank you! This time, for sure...
This time, for sure... YES. Thank you. :+1:
Quick note: if you have free time, could you give a look at: https://github.com/ocaml/tuareg/issues/239 (yet another one, sorry !)
https://www.ocaml.org/manual/objectexamples.html#s:class-interfaces (Error with tuareg-eval-phrase)
type restricted_point_type =
object
method get_x : int
method bump : unit
end;;
Line 1, characters 5-7:
1 | class;;
^^
Error: Syntax error
OK with tuareg-eval-region :
class type restricted_point_type =
object method bump : unit method get_x : int end
It looks like this bug has been fixed; close it if you agree.
OK. Done.
Emacs 28.0.50 - Tuareg 20210605.1629 - OCaml 4.12.0
e.g.
After a 'tuareg-eval-phrase' of the phrase 1, the cursor moves to the beginning of the phrase 2 but all subsequent 'tuareg-eval-phrase' return the evaluation of the phrase 1. Moving the cursor to the right (at least 1 character) allows the evaluation of the phrase 2.
(No need to move the cursor before).