aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/done.ml5
-rw-r--r--lib/grep.ml122
-rw-r--r--lib/headlines.ml5
-rw-r--r--lib/todos.ml5
4 files changed, 82 insertions, 55 deletions
diff --git a/lib/done.ml b/lib/done.ml
index 2c97dd3..8a69601 100644
--- a/lib/done.ml
+++ b/lib/done.ml
@@ -40,7 +40,10 @@ let rec render
let x, y = pos in
let content_position = y - content_start in
let img =
- let dot = I.string A.(st bold) ">" |> I.pad ~l:0 ~t:(y - scroll)
+ let dot =
+ if Array.length content_pretty = 0
+ then I.empty
+ else I.string A.(st bold) ">" |> I.pad ~l:0 ~t:(y - scroll)
and elements =
Array.mapi
(fun i el ->
diff --git a/lib/grep.ml b/lib/grep.ml
index 3140347..7ec4c95 100644
--- a/lib/grep.ml
+++ b/lib/grep.ml
@@ -54,7 +54,8 @@ let done_get_args = [ grep_cmd; done_pattern_regexp; "-H"; "-r"; "-n"; "--no-mes
let get_done () =
let open Shexp_process in
let open Shexp_process.Infix in
- run_calls (call done_get_args |- call [ "sort"; "-n"; "-r" ])
+ try run_calls (call done_get_args |- call [ "sort"; "-n"; "-r" ]) with
+ | _ -> ""
let todo_get_args = [ grep_cmd; todo_pattern_regexp; "-H"; "-r"; "-n"; "--no-messages" ]
@@ -62,7 +63,8 @@ let todo_get_args = [ grep_cmd; todo_pattern_regexp; "-H"; "-r"; "-n"; "--no-mes
let get_todos () =
let open Shexp_process in
let open Shexp_process.Infix in
- run_calls (call todo_get_args |- call [ "sort"; "-n"; "-r" ])
+ try run_calls (call todo_get_args |- call [ "sort"; "-n"; "-r" ]) with
+ | _ -> ""
let parse_todo_files files =
@@ -99,25 +101,31 @@ let pretty_format_todo parsed_headlines =
let get_tagged_done tag () =
let open Shexp_process in
let open Shexp_process.Infix in
- eval
- (chdir
- execution_directory
- (call done_get_args
- |- call [ grep_cmd; "--no-messages"; "-E"; tag ]
- |- call [ "sort"; "-n"; "-r" ]
- |- read_all))
+ try
+ eval
+ (chdir
+ execution_directory
+ (call done_get_args
+ |- call [ grep_cmd; "--no-messages"; "-E"; tag ]
+ |- call [ "sort"; "-n"; "-r" ]
+ |- read_all))
+ with
+ | _ -> ""
let get_tagged_todo tag () =
let open Shexp_process in
let open Shexp_process.Infix in
- eval
- (chdir
- execution_directory
- (call todo_get_args
- |- call [ grep_cmd; "--no-messages"; "-E"; tag ]
- |- call [ "sort"; "-n"; "-r" ]
- |- read_all))
+ try
+ eval
+ (chdir
+ execution_directory
+ (call todo_get_args
+ |- call [ grep_cmd; "--no-messages"; "-E"; tag ]
+ |- call [ "sort"; "-n"; "-r" ]
+ |- read_all))
+ with
+ | _ -> ""
let toggle_done file_name =
@@ -167,30 +175,36 @@ let headline_args =
let get_headlines () =
let open Shexp_process in
let open Shexp_process.Infix in
- eval
- (chdir
- execution_directory
- (find_sort_name ()
- |- call headline_args
- |- call filter_todos_args
- |- call filter_done_args
- |- call [ "sort"; "-n"; "-r" ]
- |- read_all))
+ try
+ eval
+ (chdir
+ execution_directory
+ (find_sort_name ()
+ |- call headline_args
+ |- call filter_todos_args
+ |- call filter_done_args
+ |- call [ "sort"; "-n"; "-r" ]
+ |- read_all))
+ with
+ | _ -> ""
let get_tagged_headlines tag () =
let open Shexp_process in
let open Shexp_process.Infix in
- eval
- (chdir
- execution_directory
- (find_sort_name ()
- |- call headline_args
- |- call [ grep_cmd; "--no-messages"; "-E"; tag ]
- |- call filter_todos_args
- |- call filter_done_args
- |- call [ "sort"; "-n"; "-r" ]
- |- read_all))
+ try
+ eval
+ (chdir
+ execution_directory
+ (find_sort_name ()
+ |- call headline_args
+ |- call [ grep_cmd; "--no-messages"; "-E"; tag ]
+ |- call filter_todos_args
+ |- call filter_done_args
+ |- call [ "sort"; "-n"; "-r" ]
+ |- read_all))
+ with
+ | _ -> ""
let get_tags () =
@@ -228,14 +242,15 @@ let pretty_format parsed_headlines =
(** Full body parsing *)
-let get_full_content_command file = [ "cat"; file ]
-
let read_whole_file filename =
(* open_in_bin works correctly on Unix and Windows *)
- let ch = open_in_bin filename in
- let s = really_input_string ch (in_channel_length ch) in
- close_in ch;
- s
+ try
+ let ch = open_in_bin filename in
+ let s = really_input_string ch (in_channel_length ch) in
+ close_in ch;
+ s
+ with
+ | _ -> ""
let get_full_file_content_content file =
@@ -254,17 +269,20 @@ let parse_full_content files =
let get_file_names tag =
- let cmd =
- let open Shexp_process in
- let open Shexp_process.Infix in
- find_sort_name ()
- |- call [ "xargs"; grep_cmd; "-H"; "-r"; "-l"; "--no-messages"; "-E"; tag ]
- |- call [ "sort"; "-n"; "-r" ]
- |- read_all
- in
- Shexp_process.eval (Shexp_process.chdir execution_directory cmd)
- |> String.split_on_char '\n'
- |> List.filter (fun s -> not (String.equal "" s))
+ try
+ let cmd =
+ let open Shexp_process in
+ let open Shexp_process.Infix in
+ find_sort_name ()
+ |- call [ "xargs"; grep_cmd; "-H"; "-r"; "-l"; "--no-messages"; "-E"; tag ]
+ |- call [ "sort"; "-n"; "-r" ]
+ |- read_all
+ in
+ Shexp_process.eval (Shexp_process.chdir execution_directory cmd)
+ |> String.split_on_char '\n'
+ |> List.filter (fun s -> not (String.equal "" s))
+ with
+ | _ -> []
type display_type =
diff --git a/lib/headlines.ml b/lib/headlines.ml
index 31be26c..04b4267 100644
--- a/lib/headlines.ml
+++ b/lib/headlines.ml
@@ -41,7 +41,10 @@ let rec render
let x, y = pos in
let content_position = y - content_start in
let img =
- let dot = I.string A.(st bold) ">" |> I.pad ~l:0 ~t:(y - scroll)
+ let dot =
+ if Array.length content_pretty = 0
+ then I.empty
+ else I.string A.(st bold) ">" |> I.pad ~l:0 ~t:(y - scroll)
and elements =
Array.mapi
(fun i el ->
diff --git a/lib/todos.ml b/lib/todos.ml
index 08c9a34..5d16740 100644
--- a/lib/todos.ml
+++ b/lib/todos.ml
@@ -40,7 +40,10 @@ let rec render
let x, y = pos in
let content_position = y - content_start in
let img =
- let dot = I.string A.(st bold) ">" |> I.pad ~l:0 ~t:(y - scroll)
+ let dot =
+ if Array.length content_pretty = 0
+ then I.empty
+ else I.string A.(st bold) ">" |> I.pad ~l:0 ~t:(y - scroll)
and elements =
Array.mapi
(fun i el ->