]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve error handling in 'image-dired-thumbnail-set-image-description'.
authorEli Zaretskii <eliz@gnu.org>
Sat, 1 Jun 2024 17:50:40 +0000 (20:50 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 2 Jun 2024 06:33:59 +0000 (08:33 +0200)
* 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)

lisp/image/image-dired-external.el

index 1fa94e06e02b4c539140c346bf38bc836df7b6c6..8a270bb93881c7f24643322271ea9599be73d00b 100644 (file)
@@ -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))))