Skip to content

Commit

Permalink
lein.sh: honor XDG_CACHE_HOME
Browse files Browse the repository at this point in the history
Closes #3572
  • Loading branch information
vemv committed Nov 6, 2023
1 parent 20d8542 commit 1c1ef92
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): display Java class/method/field info when available.
- This info is available when [enrich-classpath](https://docs.cider.mx/cider/config/basic_config.html#use-enrich-classpath) is active.
- `cider-popup-buffer-display`: honor `special-display-buffer-names` if customized for a given CIDER buffer name (e.g. `*cider-inspect*`), avoiding the double-rendering of the given buffer.
- [#3572](https://github.com/clojure-emacs/cider/issues/3572): `lein.sh`: honor `XDG_CACHE_HOME`.
- Bump the injected `cider-nrepl` to [0.43.0](https://github.com/clojure-emacs/cider-nrepl/blob/v0.43.0/CHANGELOG.md#0430-2023-11-04).
- Improves performance for exception handling and other use cases.

Expand Down
18 changes: 16 additions & 2 deletions lein.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@ shift
output=$(2>&1 "$lein" "$@")
cmd=$(grep "\s-cp\s"<<< "$output")

function cache_root() {
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
cache_dir="${cache_dir/#\~/$HOME}"
mkdir -p "$cache_dir" 2>/dev/null
if [[ -w "$cache_dir" ]]; then
echo "${cache_dir%/}"
else
return 1
fi
}

if grep --silent "\s-cp\s"<<< "$cmd"; then
eval "$cmd"
else
# Print errors:
mkdir -p ~/.emacs.d
echo "$output" >> ~/.emacs.d/cider-error.log
if cache_dir=$(cache_root); then
logfile="$cache_dir"/cider-enrich-classpath-error.log
echo "$output" >> "$logfile"
echo "Could not activate enrich-classpath. Error report available at $logfile"
fi
no_enrich=()
for arg in "$@"; do
if [ "$arg" == "cider.enrich-classpath.plugin-v2/middleware" ]; then
Expand Down

0 comments on commit 1c1ef92

Please sign in to comment.