From d2f04c99a741de44341838e7b865a14fe1762d2e Mon Sep 17 00:00:00 2001 From: malc Date: Sun, 18 Jan 2015 02:47:29 +0300 Subject: [PATCH] Support %s in savecmd %s = same path in this context. (Original idea/implementation by ghennequin) --- main.ml | 9 ++++----- utils.ml | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main.ml b/main.ml index 32b003d..bb6b090 100644 --- a/main.ml +++ b/main.ml @@ -133,13 +133,11 @@ let vlog fmt = let addpid pid = if pid > 0 then incr pidcount;; -let launchpath = - let re = Str.regexp "%s" in - fun () -> +let launchpath () = if emptystr conf.pathlauncher then print_endline state.path else ( - let command = Str.global_replace re state.path conf.pathlauncher in + let command = Str.global_replace percentsre state.path conf.pathlauncher in try addpid @@ popen command [] with exn -> Printf.eprintf "failed to execute `%s': %s\n" command (exntos exn); @@ -4835,7 +4833,8 @@ let save () = if emptystr conf.savecmd then error "don't know where to save modified document" else - match Unix.open_process_in conf.savecmd with + let command = Str.global_replace percentsre state.path conf.savecmd in + match Unix.open_process_in command with | (exception exn) -> showtext '!' (Printf.sprintf "savecmd open_process_in failed: %s" diff --git a/utils.ml b/utils.ml index bdf627a..79f1b74 100644 --- a/utils.ml +++ b/utils.ml @@ -151,3 +151,4 @@ let getenvwithdef name def = ;; let newlinere = Str.regexp "[\r\n]";; +let percentsre = Str.regexp "%s";; -- 2.11.4.GIT