aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2023-07-27 16:52:38 +0200
committerMichael Albinus2023-07-27 16:52:38 +0200
commite055c635b0d73efe3826e418690a3d91eee69647 (patch)
treea6a85dd77d0139cdd2103543b7fd42c2440428cc
parent42a911c61e67caa807750cd40887b729f09aaf52 (diff)
parent83b6a8a514727ebba0c05e161f90d17270ddeccd (diff)
downloademacs-e055c635b0d73efe3826e418690a3d91eee69647.tar.gz
emacs-e055c635b0d73efe3826e418690a3d91eee69647.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/image/image-dired-util.el84
-rw-r--r--lisp/image/image-dired.el26
-rw-r--r--src/xdisp.c3
4 files changed, 82 insertions, 36 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 44ffbaf78f2..39b4a35930a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -577,6 +577,11 @@ without specifying a file, like this:
577 (notifications-notify 577 (notifications-notify
578 :title "I am playing music" :app-icon 'multimedia-player) 578 :title "I am playing music" :app-icon 'multimedia-player)
579 579
580** Image Dired
581
582*** New user option 'image-dired-thumb-naming'.
583You can now configure how a thumbnail is named using this option.
584
580 585
581* New Modes and Packages in Emacs 30.1 586* New Modes and Packages in Emacs 30.1
582 587
diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el
index a80b3afc0f3..3f6880fc807 100644
--- a/lisp/image/image-dired-util.el
+++ b/lisp/image/image-dired-util.el
@@ -30,6 +30,7 @@
30(eval-when-compile (require 'cl-lib)) 30(eval-when-compile (require 'cl-lib))
31 31
32(defvar image-dired-dir) 32(defvar image-dired-dir)
33(defvar image-dired-thumb-naming)
33(defvar image-dired-thumbnail-storage) 34(defvar image-dired-thumbnail-storage)
34 35
35(defconst image-dired--thumbnail-standard-sizes 36(defconst image-dired--thumbnail-standard-sizes
@@ -57,42 +58,59 @@ Create the thumbnail directory if it does not exist."
57 (message "Thumbnail directory created: %s" image-dired-dir)) 58 (message "Thumbnail directory created: %s" image-dired-dir))
58 image-dired-dir)) 59 image-dired-dir))
59 60
61(defun image-dired-contents-sha1 (filename)
62 "Compute the SHA-1 of the first 4KiB of FILENAME's contents."
63 (with-temp-buffer
64 (insert-file-contents-literally filename nil 0 4096)
65 (sha1 (current-buffer))))
66
60(defun image-dired-thumb-name (file) 67(defun image-dired-thumb-name (file)
61 "Return absolute file name for thumbnail FILE. 68 "Return absolute file name for thumbnail FILE.
62Depending on the value of `image-dired-thumbnail-storage', the 69Depending on the value of `image-dired-thumbnail-storage' and
63file name of the thumbnail will vary: 70`image-dired-thumb-naming', the file name of the thumbnail will
64- For `use-image-dired-dir', make a SHA1-hash of the image file's 71vary:
65 directory name and add that to make the thumbnail file name 72
66 unique. 73- If `image-dired-thumbnail-storage' is set to one of the value
67- For `per-directory' storage, just add a subdirectory. 74 of `image-dired--thumbnail-standard-sizes', produce the file
68- For `standard' storage, produce the file name according to the 75 name according to the Thumbnail Managing Standard. Among other
69 Thumbnail Managing Standard. Among other things, an MD5-hash 76 things, an MD5-hash of the image file's directory name will be
70 of the image file's directory name will be added to the 77 added to the file name.
71 filename. 78
72See also `image-dired-thumbnail-storage'." 79- Otherwise `image-dired-thumbnail-storage' is used to set the
80 directory where to store the thumbnail. In this latter case
81 the name given to the thumbnail depends on the value of
82 `image-dired-thumb-naming'.
83
84See also `image-dired-thumbnail-storage' and
85`image-dired-thumb-naming'."
73 (let ((file (expand-file-name file))) 86 (let ((file (expand-file-name file)))
74 (cond ((memq image-dired-thumbnail-storage 87 (if (memq image-dired-thumbnail-storage
75 image-dired--thumbnail-standard-sizes) 88 image-dired--thumbnail-standard-sizes)
76 (let ((thumbdir (cl-case image-dired-thumbnail-storage 89 (let ((thumbdir (cl-case image-dired-thumbnail-storage
77 (standard "thumbnails/normal") 90 (standard "thumbnails/normal")
78 (standard-large "thumbnails/large") 91 (standard-large "thumbnails/large")
79 (standard-x-large "thumbnails/x-large") 92 (standard-x-large "thumbnails/x-large")
80 (standard-xx-large "thumbnails/xx-large")))) 93 (standard-xx-large "thumbnails/xx-large"))))
81 (expand-file-name 94 (expand-file-name
82 ;; MD5 is mandated by the Thumbnail Managing Standard. 95 ;; MD5 and PNG is mandated by the Thumbnail Managing
83 (concat (md5 (concat "file://" file)) ".png") 96 ;; Standard.
84 (expand-file-name thumbdir (xdg-cache-home))))) 97 (concat (md5 (concat "file://" file)) ".png")
85 ((or (eq 'image-dired image-dired-thumbnail-storage) 98 (expand-file-name thumbdir (xdg-cache-home))))
86 ;; Maintained for backwards compatibility: 99 (let ((name (if (eq 'sha1-contents image-dired-thumb-naming)
87 (eq 'use-image-dired-dir image-dired-thumbnail-storage)) 100 (image-dired-contents-sha1 file)
88 (expand-file-name (format "%s.jpg" (sha1 file)) 101 ;; Defaults to SHA-1 of file name
89 (image-dired-dir))) 102 (if (eq 'per-directory image-dired-thumbnail-storage)
90 ((eq 'per-directory image-dired-thumbnail-storage) 103 (sha1 (file-name-nondirectory file))
91 (expand-file-name (format "%s.thumb.jpg" 104 (sha1 file)))))
92 (file-name-nondirectory file)) 105 (cond ((or (eq 'image-dired image-dired-thumbnail-storage)
93 (expand-file-name 106 ;; Maintained for backwards compatibility:
94 ".image-dired" 107 (eq 'use-image-dired-dir image-dired-thumbnail-storage))
95 (file-name-directory file))))))) 108 (expand-file-name (format "%s.jpg" name) (image-dired-dir)))
109 ((eq 'per-directory image-dired-thumbnail-storage)
110 (expand-file-name (format "%s.jpg" name)
111 (expand-file-name
112 ".image-dired"
113 (file-name-directory file)))))))))
96 114
97(defvar image-dired-thumbnail-buffer "*image-dired*" 115(defvar image-dired-thumbnail-buffer "*image-dired*"
98 "Image-Dired's thumbnail buffer.") 116 "Image-Dired's thumbnail buffer.")
diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index b13b3e08ce2..96a0c2ef9bc 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -162,8 +162,27 @@ to use the Thumbnail Managing Standard; they will be saved in
162`image-dired-thumbnail-storage'." 162`image-dired-thumbnail-storage'."
163 :type 'directory) 163 :type 'directory)
164 164
165(defcustom image-dired-thumb-naming 'sha1-filename
166 "How `image-dired' names thumbnail files.
167When set to `sha1-filename' the name of thumbnail is built by
168computing the SHA-1 of the full file name of the image.
169
170When set to `sha1-contents' the name of thumbnail is built by
171computing the SHA-1 of first 4KiB of the image contents (See
172`image-dired-contents-sha1').
173
174In both case, a \"jpg\" extension is appended to save as JPEG.
175
176The value of this option is ignored if Image-Dired is customized
177to use the Thumbnail Managing Standard. See
178`image-dired-thumbnail-storage'."
179 :type '(choice :tag "How to name thumbnail files"
180 (const :tag "SHA-1 of the image file name" sha1-filename)
181 (const :tag "SHA-1 of the image contents" sha1-contents))
182 :version "30.1")
183
165(defcustom image-dired-thumbnail-storage 'image-dired 184(defcustom image-dired-thumbnail-storage 'image-dired
166 "How `image-dired' stores thumbnail files. 185 "Where `image-dired' stores thumbnail files.
167There are three ways that Image-Dired can store and generate 186There are three ways that Image-Dired can store and generate
168thumbnails: 187thumbnails:
169 188
@@ -189,6 +208,9 @@ thumbnails:
189 208
190 Set this user option to `per-directory'. 209 Set this user option to `per-directory'.
191 210
211To control the naming of thumbnails for alternatives (2) and (3)
212above, customize the value of `image-dired-thumb-naming'.
213
192To control the default size of thumbnails for alternatives (2) 214To control the default size of thumbnails for alternatives (2)
193and (3) above, customize the value of `image-dired-thumb-size'. 215and (3) above, customize the value of `image-dired-thumb-size'.
194 216
@@ -197,7 +219,7 @@ format, as mandated by that standard; otherwise save them as JPEG.
197 219
198For more information on the Thumbnail Managing Standard, see: 220For more information on the Thumbnail Managing Standard, see:
199https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html" 221https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html"
200 :type '(choice :tag "How to store thumbnail files" 222 :type '(choice :tag "Where to store thumbnail files"
201 (const :tag "Use image-dired-dir" image-dired) 223 (const :tag "Use image-dired-dir" image-dired)
202 (const :tag "Thumbnail Managing Standard (normal 128x128)" 224 (const :tag "Thumbnail Managing Standard (normal 128x128)"
203 standard) 225 standard)
diff --git a/src/xdisp.c b/src/xdisp.c
index e061b602e0d..aa49749edf9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -17644,6 +17644,7 @@ redisplay_window_error (Lisp_Object error_data)
17644 if (max_redisplay_ticks > 0 17644 if (max_redisplay_ticks > 0
17645 && CONSP (error_data) 17645 && CONSP (error_data)
17646 && EQ (XCAR (error_data), Qerror) 17646 && EQ (XCAR (error_data), Qerror)
17647 && CONSP (XCDR (error_data))
17647 && STRINGP (XCAR (XCDR (error_data)))) 17648 && STRINGP (XCAR (XCDR (error_data))))
17648 Vdelayed_warnings_list = Fcons (list2 (XCAR (error_data), 17649 Vdelayed_warnings_list = Fcons (list2 (XCAR (error_data),
17649 XCAR (XCDR (error_data))), 17650 XCAR (XCDR (error_data))),
@@ -27179,7 +27180,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
27179 27180
27180 oprops = Fcopy_sequence (oprops); 27181 oprops = Fcopy_sequence (oprops);
27181 tem = props; 27182 tem = props;
27182 while (CONSP (tem)) 27183 while (CONSP (tem) && CONSP (XCDR (tem)))
27183 { 27184 {
27184 oprops = plist_put (oprops, XCAR (tem), 27185 oprops = plist_put (oprops, XCAR (tem),
27185 XCAR (XCDR (tem))); 27186 XCAR (XCDR (tem)));