History

Replace %p with a page number when invoking path launcher

for details see: https://github.com/moosotc/llpp/issues/45#issuecomment-1028683741

malc committed 4 years ago

Commit a51c29b1 parent e656df14 files · +18 −6Browse files

Unified · Split

4 files
  1. help.ml +1 −1
  2. main.ml +13 −3
  3. utils.ml +2 −1
  4. utils.mli +2 −1
help.ml+1−1
@@ -172,7 +172,7 @@ o Text searching is very naive|} · 171 unmodified lines
172172 open Utils
173173
174174 let gotourl launcher url =
175− let command = Str.global_replace Utils.Re.percent url launcher in
175+ let command = Str.global_replace Utils.Re.percents url launcher in
176176 try ignore @@ spawn command []
177177 with exn -> dolog "failed to execute `%s': %s" command @@ exntos exn
178178
main.ml+13−3
@@ -61,7 +61,17 @@ let launchpath () = · 60 unmodified lines
6161 if emptystr conf.pathlauncher
6262 then adderrmsg "path launcher" "command set"
6363 else
64− let cmd = Str.global_replace Re.percent !S.path conf.pathlauncher in
64+ let n =
65+ match !S.layout with
66+ | l :: _ -> string_of_int l.pageno
67+ | _ -> E.s
68+ in
69+ let cmd = Str.global_replace Re.percents !S.path conf.pathlauncher in
70+ let cmd =
71+ if nonemptystr n
72+ then Str.global_replace Re.percentp n cmd
73+ else cmd
74+ in
6575 match spawn cmd [] with
6676 | exception exn ->
6777 adderrfmt "spawn" "failed to execute `%s': %s" cmd @@ exntos exn
@@ -2790,7 +2800,7 @@ let gotounder = function · 2722 unmodified lines
27902800 "don't know where to save attachment"
27912801 else
27922802 let filename = Ffi.getfileannot opaque slinkindex in
2793− let savecmd = Str.global_replace Re.percent filename conf.savecmd in
2803+ let savecmd = Str.global_replace Re.percents filename conf.savecmd in
27942804 let path =
27952805 getcmdoutput
27962806 (adderrfmt savecmd
@@ -3118,7 +3128,7 @@ let save () = · 321 unmodified lines
31183128 then adderrmsg "savepath-command is empty"
31193129 "don't know where to save modified document"
31203130 else
3121− let savecmd = Str.global_replace Re.percent !S.path conf.savecmd in
3131+ let savecmd = Str.global_replace Re.percents !S.path conf.savecmd in
31223132 let path =
31233133 getcmdoutput
31243134 (adderrfmt savecmd "failed to obtain path to the saved copy: %s")
utils.ml+2−1
@@ -113,7 +113,8 @@ let getenvdef name def = · 112 unmodified lines
113113
114114 module Re = struct
115115 let crlf = Str.regexp "[\r\n]"
116− let percent = Str.regexp "%s"
116+ let percents = Str.regexp "%s"
117+ let percentp = Str.regexp "%p"
117118 let whitespace = Str.regexp "[ \t]"
118119 end
119120
utils.mli+2−1
@@ -41,7 +41,8 @@ val getenvdef : string -> string -> string · 40 unmodified lines
4141 module Re :
4242 sig
4343 val crlf : Str.regexp
44− val percent : Str.regexp
44+ val percents : Str.regexp
45+ val percentp : Str.regexp
4546 val whitespace : Str.regexp
4647 end
4748 val addchar : string -> char -> string

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t