Created
May 11, 2015 14:37
-
-
Save hcarty/b2dab5324d0d4344d771 to your computer and use it in GitHub Desktop.
Snippet to toggle requiring/not requiring ;; in utop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Put this in ~/.ocamlinit to be able to toggle requiring ;; on and off *) | |
let toggle_semi = | |
let original = !UTop.parse_toplevel_phrase in | |
let no_semi str eos_is_error = original (str ^ ";;") eos_is_error in | |
let semi = ref true in | |
fun () -> | |
UTop.parse_toplevel_phrase := if !semi then no_semi else original; | |
semi := not !semi | |
;; | |
(* Include this line to not require ;; by default *) | |
toggle_semi ();; |
We can then hook up a single key e.g. F5 to use your toggle function!
#require "lambda-term"
let () =
LTerm_read_line.bind
[{control = false; meta = false; shift = false; code = F5}]
[LTerm_read_line.Edit (Custom toggle_semi)]
Ah, not bad!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The method and idea is originally from ocaml-community/utop#131