From d65d29c33493355664babbedc8d9362cd54fb2f2 Mon Sep 17 00:00:00 2001 From: malc Date: Tue, 22 May 2018 11:03:38 +0300 Subject: [PATCH] Cosmetics --- config.ml | 2 +- help.ml | 2 +- main.ml | 7 ++++--- utils.ml | 8 +++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config.ml b/config.ml index 6d5d0a7..c899f47 100644 --- a/config.ml +++ b/config.ml @@ -711,7 +711,7 @@ let keys_of_string s = in loop 0 0 0 elems in - let elems = Str.split whitere s in + let elems = Str.split Utils.Re.whitespace s in List.map (key_of_string (Str.regexp "-")) elems ;; diff --git a/help.ml b/help.ml index cb65378..afae7fd 100644 --- a/help.ml +++ b/help.ml @@ -181,7 +181,7 @@ external fz_version : unit -> string = "ml_fz_version";; external llpp_version : unit -> string = "ml_llpp_version";; let gotourl launcher url = - let command = Str.global_replace percentsre url launcher in + let command = Str.global_replace Utils.Re.percent url launcher in try ignore @@ spawn command [] with exn -> dolog "failed to execute `%s': %s" command @@ exntos exn ;; diff --git a/main.ml b/main.ml index e79cc9c..7373104 100644 --- a/main.ml +++ b/main.ml @@ -94,7 +94,8 @@ let launchpath () = if emptystr conf.pathlauncher then dolog "%s" state.path else ( - let command = Str.global_replace percentsre state.path conf.pathlauncher in + let command = + Str.global_replace Utils.Re.percent state.path conf.pathlauncher in match spawn command [] with | _pid -> () | exception exn -> @@ -2914,7 +2915,7 @@ let entermsgsmode = method reset = state.newerrmsgs <- false; - let l = Str.split newlinere (Buffer.contents state.errmsgs) in + let l = Str.split Utils.Re.crlf (Buffer.contents state.errmsgs) in m_items <- Array.of_list l initializer @@ -3482,7 +3483,7 @@ let save () = then adderrmsg "savepath-command is empty" "don't know where to save modified document" else - let savecmd = Str.global_replace percentsre state.path conf.savecmd in + let savecmd = Str.global_replace Utils.Re.percent state.path conf.savecmd in let path = getcmdoutput (fun exn -> diff --git a/utils.ml b/utils.ml index 97a197a..8dbbae7 100644 --- a/utils.ml +++ b/utils.ml @@ -166,9 +166,11 @@ let getenvwithdef name def = | exception Not_found -> def ;; -let newlinere = Str.regexp "[\r\n]";; -let percentsre = Str.regexp "%s";; -let whitere = Str.regexp "[ \t]";; +module Re = struct + let crlf = Str.regexp "[\r\n]";; + let percent = Str.regexp "%s";; + let whitespace = Str.regexp "[ \t]";; +end;; let unit () = ();; -- 2.11.4.GIT