Browse Source

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
Ihor Radchenko 3 years ago
parent
commit
876e813334
1 changed files with 7 additions and 3 deletions
  1. 7 3
      lisp/org-persist.el

+ 7 - 3
lisp/org-persist.el

@@ -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/"))