XDG Base Directory Compliance (#431)
This uses xdg to load files in the right place.
This commit is contained in:
parent
21439f537e
commit
972996374a
|
@ -1,6 +1,9 @@
|
||||||
2.13.0 (unreleased)
|
2.13.0 (unreleased)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* Load files from XDG directories (the legacy paths still work). (#431,
|
||||||
|
@Skyb0rg007)
|
||||||
|
|
||||||
* Remove deprecated values `prompt_continue`, `prompt_comment`, `smart_accept`,
|
* Remove deprecated values `prompt_continue`, `prompt_comment`, `smart_accept`,
|
||||||
`new_prompt_hooks`, `at_new_prompt` (#..., @emillon)
|
`new_prompt_hooks`, `at_new_prompt` (#..., @emillon)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ Customization
|
||||||
### Colors
|
### Colors
|
||||||
|
|
||||||
To add colors to utop, copy one of the files `utoprc-dark` or
|
To add colors to utop, copy one of the files `utoprc-dark` or
|
||||||
`utoprc-light` to `~/.utoprc`. `utoprc-dark` is for terminals with
|
`utoprc-light` to `~/.config/utop/utoprc`. `utoprc-dark` is for terminals with
|
||||||
dark colors (such as white on black) and `utoprc-light` is for
|
dark colors (such as white on black) and `utoprc-light` is for
|
||||||
terminals with light colors (such as black on white).
|
terminals with light colors (such as black on white).
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,5 @@
|
||||||
(zed (>= 3.2.0))
|
(zed (>= 3.2.0))
|
||||||
(react (>= 1.0.0))
|
(react (>= 1.0.0))
|
||||||
(cppo (>= 1.1.2))
|
(cppo (>= 1.1.2))
|
||||||
(alcotest :with-test)))
|
(alcotest :with-test)
|
||||||
|
(xdg (>= 3.9.0))))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
(wrapped false)
|
(wrapped false)
|
||||||
(modes byte)
|
(modes byte)
|
||||||
(libraries compiler-libs.toplevel findlib.top lambda-term logs.lwt threads
|
(libraries compiler-libs.toplevel findlib.top lambda-term logs.lwt threads
|
||||||
zed)
|
xdg zed)
|
||||||
(preprocess
|
(preprocess
|
||||||
(action
|
(action
|
||||||
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file}))))
|
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file}))))
|
||||||
|
|
|
@ -23,9 +23,10 @@ let version = "%%VERSION%%"
|
||||||
(* +-----------------------------------------------------------------+
|
(* +-----------------------------------------------------------------+
|
||||||
| History |
|
| History |
|
||||||
+-----------------------------------------------------------------+ *)
|
+-----------------------------------------------------------------+ *)
|
||||||
|
module Default_paths = UTop_private.Default_paths
|
||||||
|
|
||||||
let history = LTerm_history.create []
|
let history = LTerm_history.create []
|
||||||
let history_file_name = ref (Some (Filename.concat LTerm_resources.home ".utop-history"))
|
let history_file_name = ref (Some (Default_paths.history_file_name))
|
||||||
let history_file_max_size = ref None
|
let history_file_max_size = ref None
|
||||||
let history_file_max_entries = ref None
|
let history_file_max_entries = ref None
|
||||||
let stashable_session_history = UTop_history.create ()
|
let stashable_session_history = UTop_history.create ()
|
||||||
|
|
|
@ -9,6 +9,27 @@
|
||||||
|
|
||||||
open Lwt_react
|
open Lwt_react
|
||||||
|
|
||||||
|
module Default_paths = struct
|
||||||
|
let ( / ) = Filename.concat
|
||||||
|
let xdg = Xdg.create ~env:Sys.getenv_opt ()
|
||||||
|
|
||||||
|
let resolve ~legacy ~filename =
|
||||||
|
if Sys.file_exists legacy then
|
||||||
|
legacy
|
||||||
|
else
|
||||||
|
filename
|
||||||
|
|
||||||
|
let history_file_name =
|
||||||
|
resolve
|
||||||
|
~legacy:(LTerm_resources.home / ".utop-history")
|
||||||
|
~filename:(Xdg.state_dir xdg / "utop-history")
|
||||||
|
|
||||||
|
let config_file_name =
|
||||||
|
resolve
|
||||||
|
~legacy:(LTerm_resources.home / ".utoprc")
|
||||||
|
~filename:(Xdg.config_dir xdg / "utoprc")
|
||||||
|
end
|
||||||
|
|
||||||
let size, set_size =
|
let size, set_size =
|
||||||
let ev, set_size = E.create () in
|
let ev, set_size = E.create () in
|
||||||
let init = S.const { LTerm_geom.rows = 25; LTerm_geom.cols = 80 } in
|
let init = S.const { LTerm_geom.rows = 25; LTerm_geom.cols = 80 } in
|
||||||
|
@ -27,7 +48,7 @@ let ui, set_ui = S.create Console
|
||||||
|
|
||||||
let error_style = ref LTerm_style.none
|
let error_style = ref LTerm_style.none
|
||||||
|
|
||||||
(* Config from ~/.utoprc *)
|
(* Config from $XDG_CONFIG_HOME/utop/utoprc *)
|
||||||
let autoload = ref true
|
let autoload = ref true
|
||||||
|
|
||||||
let margin_function, set_margin_function =
|
let margin_function, set_margin_function =
|
||||||
|
|
|
@ -12,6 +12,7 @@ open UTop_token
|
||||||
let return, (>>=) = Lwt.return, Lwt.(>>=)
|
let return, (>>=) = Lwt.return, Lwt.(>>=)
|
||||||
|
|
||||||
module String_set = Set.Make (String)
|
module String_set = Set.Make (String)
|
||||||
|
module Default_paths = UTop_private.Default_paths
|
||||||
|
|
||||||
type styles = {
|
type styles = {
|
||||||
mutable style_keyword : LTerm_style.t;
|
mutable style_keyword : LTerm_style.t;
|
||||||
|
@ -56,7 +57,7 @@ let styles = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let load () =
|
let load () =
|
||||||
let fn = Filename.concat LTerm_resources.home ".utoprc" in
|
let fn = Default_paths.config_file_name in
|
||||||
Lwt.catch
|
Lwt.catch
|
||||||
(fun () ->
|
(fun () ->
|
||||||
LTerm_resources.load fn >>= fun res ->
|
LTerm_resources.load fn >>= fun res ->
|
||||||
|
|
|
@ -23,6 +23,7 @@ depends: [
|
||||||
"react" {>= "1.0.0"}
|
"react" {>= "1.0.0"}
|
||||||
"cppo" {>= "1.1.2"}
|
"cppo" {>= "1.1.2"}
|
||||||
"alcotest" {with-test}
|
"alcotest" {with-test}
|
||||||
|
"xdg" {>= "3.9.0"}
|
||||||
]
|
]
|
||||||
build: [
|
build: [
|
||||||
["dune" "subst"] {pinned}
|
["dune" "subst"] {pinned}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! -*- conf-xdefaults -*-
|
! -*- conf-xdefaults -*-
|
||||||
|
|
||||||
! Copy this file to ~/.utoprc
|
! Copy this file to $XDG_CONFIG_HOME/utoprc (~/.config/utoprc)
|
||||||
|
|
||||||
! Common resources
|
! Common resources
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! -*- conf-xdefaults -*-
|
! -*- conf-xdefaults -*-
|
||||||
|
|
||||||
! Copy this file to ~/.utoprc
|
! Copy this file to $XDG_CONFIG_HOME/utoprc (~/.config/utoprc)
|
||||||
|
|
||||||
! Common resources
|
! Common resources
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue