Open bufordrat opened 6 months ago
When
process-connection-type
is set tot
,utop
becomes unusable when run bytuareg-run-ocaml
. For more information, please see the OCaml Discuss thread that uncovered this issue: https://discuss.ocaml.org/t/comint-version-of-utop-in-emacs/14466
Apparently utop by default checks whether it's connected to a PTY to decide whether to use the "dumb" UI or the fancy UI that relies on ANSI escape sequences.
I don't like the idea of changing process-connection-type
for that.
I see two other solutions:
utop
an option that requests the
"dumb" UI.These are good points, and I would definitely be interested in working on a PR to the utop
project that recommends one of these changes. However, I wonder whether you would be willing to consider the code in the PR associated with this issue as a short-term solution, for the following reasons:
process-connection-type
was in fact hardcoded to nil
with no problems that I know of, other than the inability to display the output of ctypes
functions In other words, this customization solution seems very low-cost, and will help Tuareg users waiting for an upstream utop
fix. If future Tuareg users of future REPLs have a similar problem, they will also avoid having a similar wait-time till solution.
These are good points, and I would definitely be interested in working on a PR to the
utop
project that recommends one of these changes. However, I wonder whether you would be willing to consider the code in the PR associated with this issue as a short-term solution, for the following reasons:
I think rather add a specific workaround in tuareg.el
and ask users to
(setq tuareg-process-connection-type nil)
in their init file, I'd rather tell them they don't need to upgrade Tuareg and can use
;; Workaround problem where UTop assumes it's running in an
;; ANSI-compatible terminal (issue #314 of Tuareg).
(advice-add 'make-comint :around #'my-utop-workaround)
(defun my-utop-workaround (orig-fun name &rest args)
(if (not (equal name "OCaml"))
(apply orig-fun name args)
(let ((process-connection-type nil))
(apply orig-fun name args))))
Wowie zowie, I just tried pasting that exact code into my init file and it worked like a charm outta the box. Ok, this solution works for me; thanks! Will get going on a PR to utop
.
Summary
The proposal in this issue is to make
process-connection-type
customizable.Background
In commit
cd5229e
, in order to address #83,process-connection-type
was changed fromnil
tot
. This allowed Tuareg-Interactive mode to display the output ofctypes
functions when they wrote tostdout
. However, a (presumably unintended) consequence of this change was that it became impossible to runutop
under Tuareg-Interactive mode, which previously worked smoothly. Whenprocess-connection-type
is set tot
,utop
becomes unusable when run bytuareg-run-ocaml
.For more information, please see the OCaml Discuss thread that uncovered this issue: https://discuss.ocaml.org/t/comint-version-of-utop-in-emacs/14466
Proposal
A forthcoming PR will make the value of
process-connnection-type
configurable via Emacs'customize
facility. The default value will bet
, which means that this change will have no discernible effect for most Tuareg users. But the Emacs user will be able to setprocess-connection-type
tonil
if they would like to usetuareg-run-ocaml
withutop
. Having this ability will be incredibly valuable, especially to those of us at the UChicago Library who runutop
under Tuareg.