Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,12 @@ time it will configure itself from all of the information that it
has available at that time. It will examine the following information
in order to configure itself:

* The file `$HOME/.zprintrc` or if that file does not exist, the file
`$HOME/.zprint.edn` for an options map in EDN format.
* If the file found above or the options map on the command line has
* The first file found among:
* `$HOME/.zprintrc`
* `$HOME/.zprint.edn` (for an options map in EDN format)
* `$XDG_CONFIG_HOME/zprint/zprintrc`
* `$XDG_CONFIG_HOME/zprint/zprint.edn` (for an options map in EDN format)
* If the file found above or the options map on the command line has
`:search-config?` true, it will look
in the current directory for a file `.zprintrc` and if it doesn't find
one, it will look for `.zprint.edn`.l If it doesn't find either of them,
Expand Down
25 changes: 20 additions & 5 deletions src/zprint/config.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

(def zprintrc ".zprintrc")
(def zprintedn ".zprint.edn")
(def xdg-zprintrc "zprintrc")
(def xdg-zprintedn "zprint.edn")

(declare merge-deep)

Expand Down Expand Up @@ -2859,22 +2861,35 @@
op-options (select-op-options op-options)
#_(println "op-options:" op-options)
;
; $HOME/.zprintrc
; $HOME/.zprintrc $HOME/.zprint.edn
;
; $XDG_CONFIG_HOME/zprint/zprintrc
; $XDG_CONFIG_HOME/zprint/zprint.edn
;
home #?(:clj (System/getenv "HOME")
:cljs nil)
file-separator #?(:clj (System/getProperty "file.separator")
:cljs nil)
zprintrc-file (str home file-separator zprintrc)
xdg-config-home #?(:clj (or (System/getenv "XDG_CONFIG_HOME")
(when (and home file-separator)
(str home file-separator ".config")))
:cljs nil)
[opts-rcfile errors-rcfile rc-filename :as home-config]
(when (and home file-separator)
(get-config-from-path [zprintrc zprintedn] file-separator [home]))
(or (when (and home file-separator)
(get-config-from-path [zprintrc zprintedn]
file-separator
[home]))
(when (and xdg-config-home file-separator)
(get-config-from-path [xdg-zprintrc xdg-zprintedn]
file-separator
[xdg-config-home])))
_ (dbg-s (merge op-options opts-rcfile)
#{:zprintrc}
"~/.zprintrc:"
home-config)
[updated-map new-doc-map rc-errors]
(config-and-validate (str "Home directory file: " rc-filename)
(config-and-validate (str "$HOME/$XDG_CONFIG_HOME directory file: "
rc-filename)
default-doc-map
default-map
opts-rcfile)
Expand Down