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
172open Utils172open Utils
173 173
174let gotourl launcher url =174let gotourl launcher url =
175 let command = Str.global_replace Utils.Re.percent url launcher in175 let command = Str.global_replace Utils.Re.percents url launcher in
176 try ignore @@ spawn command []176 try ignore @@ spawn command []
177 with exn -> dolog "failed to execute `%s': %s" command @@ exntos exn177 with exn -> dolog "failed to execute `%s': %s" command @@ exntos exn
178 178
main.ml+13−3
@@ -61,7 +61,17 @@ let launchpath () = · 60 unmodified lines
61 if emptystr conf.pathlauncher61 if emptystr conf.pathlauncher
62 then adderrmsg "path launcher" "command set"62 then adderrmsg "path launcher" "command set"
63 else63 else
64 let cmd = Str.global_replace Re.percent !S.path conf.pathlauncher in64 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
65 match spawn cmd [] with75 match spawn cmd [] with
66 | exception exn ->76 | exception exn ->
67 adderrfmt "spawn" "failed to execute `%s': %s" cmd @@ exntos exn77 adderrfmt "spawn" "failed to execute `%s': %s" cmd @@ exntos exn
@@ -2790,7 +2800,7 @@ let gotounder = function · 2722 unmodified lines
2790 "don't know where to save attachment"2800 "don't know where to save attachment"
2791 else2801 else
2792 let filename = Ffi.getfileannot opaque slinkindex in2802 let filename = Ffi.getfileannot opaque slinkindex in
2793 let savecmd = Str.global_replace Re.percent filename conf.savecmd in2803 let savecmd = Str.global_replace Re.percents filename conf.savecmd in
2794 let path =2804 let path =
2795 getcmdoutput2805 getcmdoutput
2796 (adderrfmt savecmd2806 (adderrfmt savecmd
@@ -3118,7 +3128,7 @@ let save () = · 321 unmodified lines
3118 then adderrmsg "savepath-command is empty"3128 then adderrmsg "savepath-command is empty"
3119 "don't know where to save modified document"3129 "don't know where to save modified document"
3120 else3130 else
3121 let savecmd = Str.global_replace Re.percent !S.path conf.savecmd in3131 let savecmd = Str.global_replace Re.percents !S.path conf.savecmd in
3122 let path =3132 let path =
3123 getcmdoutput3133 getcmdoutput
3124 (adderrfmt savecmd "failed to obtain path to the saved copy: %s")3134 (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
113 113
114module Re = struct114module Re = struct
115 let crlf = Str.regexp "[\r\n]"115 let crlf = Str.regexp "[\r\n]"
116 let percent = Str.regexp "%s"116 let percents = Str.regexp "%s"
117 let percentp = Str.regexp "%p"
117 let whitespace = Str.regexp "[ \t]"118 let whitespace = Str.regexp "[ \t]"
118end119end
119 120
utils.mli+2−1
@@ -41,7 +41,8 @@ val getenvdef : string -> string -> string · 40 unmodified lines
41module Re :41module Re :
42 sig42 sig
43 val crlf : Str.regexp43 val crlf : Str.regexp
44 val percent : Str.regexp44 val percents : Str.regexp
45 val percentp : Str.regexp
45 val whitespace : Str.regexp46 val whitespace : Str.regexp
46 end47 end
47val addchar : string -> char -> string48val 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