allow to configure the external editor
This commit is contained in:
parent
8d104762ce
commit
c41969dc62
|
@ -35,6 +35,13 @@ to disable the autoloading of files in
|
|||
.I $OCAML_TOPLEVEL_PATH/autoload
|
||||
at startup.
|
||||
|
||||
The key
|
||||
.I external-editor
|
||||
can be set to a command line. It is used to edit the input when
|
||||
pressing C-x C-e. It defaults to the contents of the
|
||||
.I EDITOR
|
||||
environment variable.
|
||||
|
||||
The key
|
||||
.I profile
|
||||
may have the value
|
||||
|
|
|
@ -75,6 +75,11 @@ let phrase_terminator, get_phrase_terminator, set_phrase_terminator = make_varia
|
|||
let auto_run_lwt, get_auto_run_lwt, set_auto_run_lwt = make_variable true
|
||||
let auto_run_async, get_auto_run_async, set_auto_run_async = make_variable true
|
||||
let topfind_verbose, get_topfind_verbose, set_topfind_verbose = make_variable false
|
||||
let external_editor, get_external_editor, set_external_editor =
|
||||
make_variable
|
||||
(match Sys.getenv "EDITOR" with
|
||||
| exception Not_found -> "vi"
|
||||
| s -> s)
|
||||
|
||||
(* Ugly hack until the action system of lambda-term is improved *)
|
||||
let end_and_accept_current_phrase : LTerm_read_line.action =
|
||||
|
|
|
@ -177,6 +177,11 @@ val end_and_accept_current_phrase : LTerm_read_line.action
|
|||
]}
|
||||
*)
|
||||
|
||||
(** External editor command. [None] for default. *)
|
||||
val external_editor : string signal
|
||||
val set_external_editor : string -> unit
|
||||
val get_external_editor : unit -> string
|
||||
|
||||
(** {6 History} *)
|
||||
|
||||
val history : LTerm_history.t
|
||||
|
|
|
@ -146,6 +146,8 @@ class read_phrase ~term = object(self)
|
|||
method create_temporary_file_for_external_editor =
|
||||
Filename.temp_file "utop" ".ml"
|
||||
|
||||
method external_editor = UTop.get_external_editor ()
|
||||
|
||||
val mutable return_value = None
|
||||
|
||||
method eval =
|
||||
|
|
|
@ -87,6 +87,9 @@ let load () =
|
|||
| str -> raise (LTerm_resources.Error (Printf.sprintf "invalid profile %S" str)));
|
||||
UTop_private.error_style := styles.style_error;
|
||||
UTop_private.autoload := LTerm_resources.get_bool "autoload" res <> Some false;
|
||||
(match LTerm_resources.get "external-editor" res with
|
||||
| "" -> ()
|
||||
| s -> UTop.set_external_editor s);
|
||||
return ())
|
||||
(function
|
||||
| Unix.Unix_error(Unix.ENOENT, _, _) ->
|
||||
|
|
Loading…
Reference in New Issue