org-persist.el: Fix Emacs versions where xdg.el is not available

* lisp/org-persist.el (org-persist-directory): Make `xdg-cache-home'
call optional.  Prefer cache directory in `user-emacs-directory' when
the cache already exists there.

Fixes https://list.orgmode.org/CAFqubHf+WpuNEEapKcG94WjHFcRxVSF+j-7Ut3b_roMfKQchhg@mail.gmail.com/T/#m99c63439a745c07fd7c30cde0b49b3d5bd1757f0
This commit is contained in:
Ihor Radchenko 2021-11-10 09:45:16 +08:00
parent ded97b7672
commit 876e813334
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 7 additions and 3 deletions

View File

@ -29,7 +29,7 @@
(require 'org-compat)
(require 'org-id)
(require 'xdg)
(require 'xdg nil t)
(declare-function org-back-to-heading "org" (&optional invisible-ok))
(declare-function org-next-visible-heading "org" (arg))
@ -37,9 +37,13 @@
(defvar org-persist-directory (expand-file-name
(org-file-name-concat
(let ((cache-dir (xdg-cache-home)))
(let ((cache-dir (when (fboundp 'xdg-cache-home)
(xdg-cache-home))))
(if (or (seq-empty-p cache-dir)
(not (file-exists-p cache-dir)))
(not (file-exists-p cache-dir))
(file-exists-p (org-file-name-concat
user-emacs-directory
"org-persist")))
user-emacs-directory
cache-dir))
"org-persist/"))