emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f8fed41 2/3: image-dired: Improve XDG compliance


From: Stefan Kangas
Subject: master f8fed41 2/3: image-dired: Improve XDG compliance
Date: Mon, 25 Oct 2021 01:57:40 -0400 (EDT)

branch: master
commit f8fed417a51fe4d572f4b5c6a7a591adf133e874
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    image-dired: Improve XDG compliance
    
    * lisp/image-dired.el (xdg): Require.
    (image-dired-main-image-directory): Prefer XDG_PICTURES_HOME.
    (image-dired-thumb-name): Simplify by using 'xdg-cache-home'.
---
 lisp/image-dired.el | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 210361f..77a3590 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -157,6 +157,7 @@
 (require 'exif)
 (require 'image-mode)
 (require 'widget)
+(require 'xdg)
 
 (eval-when-compile
   (require 'cl-lib)
@@ -551,10 +552,12 @@ Including parameters.  Used when displaying original 
image from
   :type '(choice string
                  (const :tag "Not Set" nil)))
 
-(defcustom image-dired-main-image-directory "~/pics/"
+(defcustom image-dired-main-image-directory
+  (or (xdg-user-dir "PICTURES") "~/pics/")
   "Name of main image directory, if any.
 Used by `image-dired-copy-with-exif-file-name'."
-  :type 'string)
+  :type 'string
+  :version "29.1")
 
 (defcustom image-dired-show-all-from-dir-max-files 100
   "Maximum number of files in directory before prompting.
@@ -647,18 +650,15 @@ file name of the thumbnail will vary:
 See also `image-dired-thumbnail-storage'."
   (cond ((memq image-dired-thumbnail-storage
                image-dired--thumbnail-standard-sizes)
-         (let* ((xdg (getenv "XDG_CACHE_HOME"))
-                (dir (if (and xdg (file-name-absolute-p xdg))
-                         xdg "~/.cache"))
-                (thumbdir (cl-case image-dired-thumbnail-storage
-                            (standard "thumbnails/normal")
-                            (standard-large "thumbnails/large")
-                            (standard-x-large "thumbnails/x-large")
-                            (standard-xx-large "thumbnails/xx-large"))))
+         (let ((thumbdir (cl-case image-dired-thumbnail-storage
+                           (standard "thumbnails/normal")
+                           (standard-large "thumbnails/large")
+                           (standard-x-large "thumbnails/x-large")
+                           (standard-xx-large "thumbnails/xx-large"))))
            (expand-file-name
             ;; MD5 is mandated by the Thumbnail Managing Standard.
             (concat (md5 (concat "file://" (expand-file-name file))) ".png")
-            (expand-file-name thumbdir dir))))
+            (expand-file-name thumbdir (xdg-cache-home)))))
         ((eq 'use-image-dired-dir image-dired-thumbnail-storage)
          (let* ((f (expand-file-name file))
                 (hash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]