From: Eli Zaretskii Date: Sat, 1 Jun 2024 17:50:40 +0000 (+0300) Subject: Improve error handling in 'image-dired-thumbnail-set-image-description'. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e81f9060be8113fb5f857b6c048ab01106dce854;p=emacs.git Improve error handling in 'image-dired-thumbnail-set-image-description'. * lisp/image/image-dired-external.el (image-dired-thumbnail-set-image-description): Show more detailed error messages in case of failure. (cherry picked from commit 8ecf1a995fc318ea055cbc71f9223340feb2acd0) --- diff --git a/lisp/image/image-dired-external.el b/lisp/image/image-dired-external.el index 1fa94e06e02..8a270bb9388 100644 --- a/lisp/image/image-dired-external.el +++ b/lisp/image/image-dired-external.el @@ -609,13 +609,18 @@ default value at the prompt." (if (not (image-dired-image-at-point-p)) (message "No thumbnail at point") (let* ((file (image-dired-original-file-name)) - (old-value (or (exif-field 'description (exif-parse-file file)) ""))) - (if (eq 0 - (image-dired-set-exif-data file "ImageDescription" - (read-string "Value of ImageDescription: " - old-value))) - (message "Successfully wrote ImageDescription tag") - (error "Could not write ImageDescription tag"))))) + (old-value (or (exif-field 'description (exif-parse-file file)) "")) + (defdir default-directory)) + (with-temp-buffer + (setq default-directory defdir) + (if (eq 0 + (image-dired-set-exif-data file "ImageDescription" + (read-string + "Value of ImageDescription: " + old-value))) + (message "Successfully wrote ImageDescription tag") + (error "Could not write ImageDescription tag: %s" + (string-replace "\n" "" (buffer-string)))))))) (defun image-dired-set-exif-data (file tag-name tag-value) "In FILE, set EXIF tag TAG-NAME to value TAG-VALUE." @@ -627,7 +632,7 @@ default value at the prompt." (cons ?u (image-dired--file-URI (expand-file-name file))) (cons ?t tag-name) (cons ?v tag-value)))) - (apply #'call-process image-dired-cmd-write-exif-data-program nil nil nil + (apply #'call-process image-dired-cmd-write-exif-data-program nil t nil (mapcar (lambda (arg) (format-spec arg spec)) image-dired-cmd-write-exif-data-options))))