aboutsummaryrefslogtreecommitdiff
path: root/lib/grep.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-14 12:47:36 -0500
committerMarc Coquand <marc@mccd.space>2024-05-14 12:47:36 -0500
commit20aa8079b40ee794bc84ead7283622c78f49afb5 (patch)
treea1331aa492c350dd15ff653532ddfa7b69437b00 /lib/grep.ml
parent89817d53ec7dbf5cff9c873afe9b7bc939dbe8c3 (diff)
downloadstitch-20aa8079b40ee794bc84ead7283622c78f49afb5.tar.gz
stitch-20aa8079b40ee794bc84ead7283622c78f49afb5.tar.bz2
stitch-20aa8079b40ee794bc84ead7283622c78f49afb5.zip
Resolve a few bugs
Diffstat (limited to 'lib/grep.ml')
-rw-r--r--lib/grep.ml18
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/grep.ml b/lib/grep.ml
index 0d79c57..9638c37 100644
--- a/lib/grep.ml
+++ b/lib/grep.ml
@@ -3,10 +3,7 @@ let execution_directory =
let grep_cmd = Sys.getenv_opt "STICH_GREP_CMD" |> Option.value ~default:"ugrep"
-
-let tag_pattern =
- Sys.getenv_opt "STITCH_TAG_PATTERN" |> Option.value ~default:":[a-z_-]+:"
-
+let tag_pattern = Sys.getenv_opt "STITCH_TAG_PATTERN" |> Option.value ~default:":[a-z-]+:"
let headline_pattern =
Sys.getenv_opt "STITCH_HEADLINE_PATTERN" |> Option.value ~default:"^\\* "
@@ -33,9 +30,7 @@ let run_print ~dir args =
eval (chdir dir (call args |- read_all))
-let headline_args =
- [ "xargs"; grep_cmd; "^\\*"; "-H"; "-r"; "-n"; "--separator=|"; "--no-messages" ]
-
+let headline_args = [ "xargs"; grep_cmd; "^\\*"; "-H"; "-r"; "-n"; "--no-messages" ]
(* type sort = *)
(* | Name *)
@@ -48,10 +43,7 @@ let headline_args =
let get_headlines () =
let open Shexp_process in
let open Shexp_process.Infix in
- eval
- (chdir
- execution_directory
- (find_sort_modification () |- call headline_args |- read_all))
+ eval (chdir execution_directory (find_sort_name () |- call headline_args |- read_all))
let get_tagged_headlines tag () =
@@ -85,10 +77,10 @@ let parse_headlines s =
if String.equal message ""
then None
else (
- let split = Str.bounded_split (Str.regexp "|") message 3 in
+ let split = Str.bounded_split (Str.regexp ":[0-9]+:") message 2 in
match split with
(* file, line, content *)
- | [ file_name; _; content ] -> Some (file_name, content)
+ | [ file_name; content ] -> Some (file_name, content)
| _ -> raise (Not_A_Tuple (String.concat " SPLIT " split, message))))
|> Array.of_list