From edca64d2cc5fffc49510741b17c0cdc5edebd73f Mon Sep 17 00:00:00 2001 From: Garth Tuohy Date: Wed, 3 Apr 2024 04:45:33 -0400 Subject: [PATCH 1/2] Correct paths for utop-history, utoprc: in utop subdirs of XDG base dirs --- src/lib/uTop_private.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/uTop_private.ml b/src/lib/uTop_private.ml index a694a9ad..9bbe0dee 100644 --- a/src/lib/uTop_private.ml +++ b/src/lib/uTop_private.ml @@ -22,12 +22,12 @@ module Default_paths = struct let history_file_name = resolve ~legacy:(LTerm_resources.home / ".utop-history") - ~filename:(Xdg.state_dir xdg / "utop-history") + ~filename:(Xdg.state_dir xdg / "utop" / "utop-history") let config_file_name = resolve ~legacy:(LTerm_resources.home / ".utoprc") - ~filename:(Xdg.config_dir xdg / "utoprc") + ~filename:(Xdg.config_dir xdg / "utop" / "utoprc") end let size, set_size = From 4654b228d7b9058e0eb633ce90bcf6cae4c321fb Mon Sep 17 00:00:00 2001 From: Garth Tuohy Date: Wed, 3 Apr 2024 20:37:43 -0400 Subject: [PATCH 2/2] Create directory for history file if directory does not exist --- src/lib/uTop_main.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/uTop_main.ml b/src/lib/uTop_main.ml index 3018681f..baaf856b 100644 --- a/src/lib/uTop_main.ml +++ b/src/lib/uTop_main.ml @@ -53,7 +53,10 @@ let init_history () = return () | Some fn -> Lwt.catch - (fun () -> LTerm_history.load UTop.history fn) + (fun () -> + let dn = Filename.dirname fn in + if not (Sys.file_exists dn) then Unix.mkdir dn 0o700; + LTerm_history.load UTop.history fn) (function | Unix.Unix_error (error, func, arg) -> Logs_lwt.err (fun m -> m "cannot load history from %S: %s: %s"