Function: tuareg-interactive-mode

tuareg-interactive-mode is an interactive and natively compiled function defined in tuareg.el.

Signature

(tuareg-interactive-mode)

Documentation

Major mode for interacting with an OCaml process.

Runs an OCaml REPL as a subprocess of Emacs, with I/O through an Emacs buffer. A history of input phrases is maintained. Phrases can be sent from another buffer in tuareg mode.

Short cuts for interactions with the REPL:
<delete> delete-forward-char
<kp-delete> delete-forward-char
<kp-enter> tuareg-interactive-send-input-end-of-phrase
<mouse-2> comint-insert-input
C-<down> comint-next-input
C-<return> tuareg-interactive-send-input-end-of-phrase
C-<up> comint-previous-input
C-M-l comint-show-output
C-c . comint-insert-previous-argument
C-c C-\ comint-quit-subjob
C-c C-a comint-bol-or-process-mark
C-c C-c comint-interrupt-subjob
C-c C-d comint-send-eof
C-c C-e comint-show-maximum-output
C-c C-k tuareg-kill-ocaml
C-c C-l comint-dynamic-list-input-ring
C-c C-n comint-next-prompt
C-c C-o comint-delete-output
C-c C-p comint-previous-prompt
C-c C-r comint-show-output
C-c C-s comint-write-output
C-c C-u comint-kill-input
C-c C-w backward-kill-word
C-c C-x comint-get-next-from-history
C-c C-z tuareg-switch-to-recent-buffer
C-c M-o comint-clear-buffer
C-c M-r comint-previous-matching-input-from-input
C-c M-s comint-next-matching-input-from-input
C-c RET comint-copy-old-input
C-c SPC comint-accumulate
C-c TAB tuareg-interrupt-ocaml
C-c ` tuareg-interactive-next-error-repl
C-d comint-delchar-or-maybe-eof
C-x <up> comint-complete-input-ring
M-n comint-next-input
M-p comint-previous-input
M-r comint-history-isearch-backward-regexp
RET tuareg-interactive-send-input
S-<return> tuareg-interactive-send-input-end-of-phrase

In addition to any hooks its parent mode comint-mode might have run, this mode runs the hook tuareg-interactive-mode-hook, as the final or penultimate step during initialization.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(define-derived-mode tuareg-interactive-mode comint-mode "Tuareg-Interactive"
  "Major mode for interacting with an OCaml process.
Runs an OCaml REPL as a subprocess of Emacs, with I/O through an
Emacs buffer. A history of input phrases is maintained. Phrases can
be sent from another buffer in tuareg mode.

Short cuts for interactions with the REPL:
\\{tuareg-interactive-mode-map}"
  (add-hook 'comint-output-filter-functions #'tuareg-interactive-filter)
  (setq comint-prompt-regexp "^#  *")
  (setq comint-process-echoes nil)
  (setq comint-get-old-input 'tuareg-interactive-get-old-input)
  (setq comint-scroll-to-bottom-on-output
        tuareg-interactive-scroll-to-bottom-on-output)
  (set-syntax-table tuareg-mode-syntax-table)
  (setq-local comment-start "(* ")
  (setq-local comment-end " *)")
  (setq-local comment-start-skip "(\\*+[ \t]*")
  (setq-local comint-prompt-read-only t)

  (tuareg--common-mode-setup)
  (tuareg--install-font-lock t)
  (when (or tuareg-interactive-input-font-lock
            tuareg-interactive-output-font-lock
            tuareg-interactive-error-font-lock)
    (font-lock-mode 1))

  (tuareg-update-options-menu))