Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs

This commit is contained in:
Michael Albinus 2023-07-27 16:52:38 +02:00
commit e055c635b0
4 changed files with 82 additions and 36 deletions

View file

@ -577,6 +577,11 @@ without specifying a file, like this:
(notifications-notify
:title "I am playing music" :app-icon 'multimedia-player)
** Image Dired
*** New user option 'image-dired-thumb-naming'.
You can now configure how a thumbnail is named using this option.
* New Modes and Packages in Emacs 30.1

View file

@ -30,6 +30,7 @@
(eval-when-compile (require 'cl-lib))
(defvar image-dired-dir)
(defvar image-dired-thumb-naming)
(defvar image-dired-thumbnail-storage)
(defconst image-dired--thumbnail-standard-sizes
@ -57,42 +58,59 @@ Create the thumbnail directory if it does not exist."
(message "Thumbnail directory created: %s" image-dired-dir))
image-dired-dir))
(defun image-dired-contents-sha1 (filename)
"Compute the SHA-1 of the first 4KiB of FILENAME's contents."
(with-temp-buffer
(insert-file-contents-literally filename nil 0 4096)
(sha1 (current-buffer))))
(defun image-dired-thumb-name (file)
"Return absolute file name for thumbnail FILE.
Depending on the value of `image-dired-thumbnail-storage', the
file name of the thumbnail will vary:
- For `use-image-dired-dir', make a SHA1-hash of the image file's
directory name and add that to make the thumbnail file name
unique.
- For `per-directory' storage, just add a subdirectory.
- For `standard' storage, produce the file name according to the
Thumbnail Managing Standard. Among other things, an MD5-hash
of the image file's directory name will be added to the
filename.
See also `image-dired-thumbnail-storage'."
Depending on the value of `image-dired-thumbnail-storage' and
`image-dired-thumb-naming', the file name of the thumbnail will
vary:
- If `image-dired-thumbnail-storage' is set to one of the value
of `image-dired--thumbnail-standard-sizes', produce the file
name according to the Thumbnail Managing Standard. Among other
things, an MD5-hash of the image file's directory name will be
added to the file name.
- Otherwise `image-dired-thumbnail-storage' is used to set the
directory where to store the thumbnail. In this latter case
the name given to the thumbnail depends on the value of
`image-dired-thumb-naming'.
See also `image-dired-thumbnail-storage' and
`image-dired-thumb-naming'."
(let ((file (expand-file-name file)))
(cond ((memq image-dired-thumbnail-storage
image-dired--thumbnail-standard-sizes)
(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://" file)) ".png")
(expand-file-name thumbdir (xdg-cache-home)))))
((or (eq 'image-dired image-dired-thumbnail-storage)
;; Maintained for backwards compatibility:
(eq 'use-image-dired-dir image-dired-thumbnail-storage))
(expand-file-name (format "%s.jpg" (sha1 file))
(image-dired-dir)))
((eq 'per-directory image-dired-thumbnail-storage)
(expand-file-name (format "%s.thumb.jpg"
(file-name-nondirectory file))
(expand-file-name
".image-dired"
(file-name-directory file)))))))
(if (memq image-dired-thumbnail-storage
image-dired--thumbnail-standard-sizes)
(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 and PNG is mandated by the Thumbnail Managing
;; Standard.
(concat (md5 (concat "file://" file)) ".png")
(expand-file-name thumbdir (xdg-cache-home))))
(let ((name (if (eq 'sha1-contents image-dired-thumb-naming)
(image-dired-contents-sha1 file)
;; Defaults to SHA-1 of file name
(if (eq 'per-directory image-dired-thumbnail-storage)
(sha1 (file-name-nondirectory file))
(sha1 file)))))
(cond ((or (eq 'image-dired image-dired-thumbnail-storage)
;; Maintained for backwards compatibility:
(eq 'use-image-dired-dir image-dired-thumbnail-storage))
(expand-file-name (format "%s.jpg" name) (image-dired-dir)))
((eq 'per-directory image-dired-thumbnail-storage)
(expand-file-name (format "%s.jpg" name)
(expand-file-name
".image-dired"
(file-name-directory file)))))))))
(defvar image-dired-thumbnail-buffer "*image-dired*"
"Image-Dired's thumbnail buffer.")

View file

@ -162,8 +162,27 @@ to use the Thumbnail Managing Standard; they will be saved in
`image-dired-thumbnail-storage'."
:type 'directory)
(defcustom image-dired-thumb-naming 'sha1-filename
"How `image-dired' names thumbnail files.
When set to `sha1-filename' the name of thumbnail is built by
computing the SHA-1 of the full file name of the image.
When set to `sha1-contents' the name of thumbnail is built by
computing the SHA-1 of first 4KiB of the image contents (See
`image-dired-contents-sha1').
In both case, a \"jpg\" extension is appended to save as JPEG.
The value of this option is ignored if Image-Dired is customized
to use the Thumbnail Managing Standard. See
`image-dired-thumbnail-storage'."
:type '(choice :tag "How to name thumbnail files"
(const :tag "SHA-1 of the image file name" sha1-filename)
(const :tag "SHA-1 of the image contents" sha1-contents))
:version "30.1")
(defcustom image-dired-thumbnail-storage 'image-dired
"How `image-dired' stores thumbnail files.
"Where `image-dired' stores thumbnail files.
There are three ways that Image-Dired can store and generate
thumbnails:
@ -189,6 +208,9 @@ thumbnails:
Set this user option to `per-directory'.
To control the naming of thumbnails for alternatives (2) and (3)
above, customize the value of `image-dired-thumb-naming'.
To control the default size of thumbnails for alternatives (2)
and (3) above, customize the value of `image-dired-thumb-size'.
@ -197,7 +219,7 @@ format, as mandated by that standard; otherwise save them as JPEG.
For more information on the Thumbnail Managing Standard, see:
https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html"
:type '(choice :tag "How to store thumbnail files"
:type '(choice :tag "Where to store thumbnail files"
(const :tag "Use image-dired-dir" image-dired)
(const :tag "Thumbnail Managing Standard (normal 128x128)"
standard)

View file

@ -17644,6 +17644,7 @@ redisplay_window_error (Lisp_Object error_data)
if (max_redisplay_ticks > 0
&& CONSP (error_data)
&& EQ (XCAR (error_data), Qerror)
&& CONSP (XCDR (error_data))
&& STRINGP (XCAR (XCDR (error_data))))
Vdelayed_warnings_list = Fcons (list2 (XCAR (error_data),
XCAR (XCDR (error_data))),
@ -27179,7 +27180,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
oprops = Fcopy_sequence (oprops);
tem = props;
while (CONSP (tem))
while (CONSP (tem) && CONSP (XCDR (tem)))
{
oprops = plist_put (oprops, XCAR (tem),
XCAR (XCDR (tem)));