diff options
-rw-r--r-- | README.org | 2 | ||||
-rw-r--r-- | lib/grep.ml | 18 | ||||
-rw-r--r-- | lib/headlines.ml | 2 |
3 files changed, 7 insertions, 15 deletions
@@ -31,7 +31,7 @@ Set the environment variables: STICH_DIRECTORY STICH_GREP_CMD (default "grep") STITCH_HEADLINE_PATTERN (default "^\\* ") -STITCH_TAG_PATTERN (default ":[a-z_-]+:") +STITCH_TAG_PATTERN (default ":[a-z-]+:", matches :a-tag:) ** SPEED UP 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 diff --git a/lib/headlines.ml b/lib/headlines.ml index f32b6ef..aec8567 100644 --- a/lib/headlines.ml +++ b/lib/headlines.ml @@ -36,7 +36,7 @@ let rec headline_screen t ({ tag; pos; scroll; content; content_pretty } as stat in let scroll_down () = let scroll = if y - scroll >= size_y - 1 then scroll + 1 else scroll in - headline_screen t @@ { state with pos = x, min (y + 1) content_length; scroll } + headline_screen t @@ { state with pos = x, min (y + 1) (content_length - 1); scroll } in match Common.Term.event t with | `End | `Key (`Escape, []) | `Key (`ASCII 'q', []) | `Key (`ASCII 'C', [ `Ctrl ]) -> () |