From: Stefan Kangas Date: Wed, 31 Aug 2022 03:52:11 +0000 (+0200) Subject: image-dired: Minor cleanups X-Git-Tag: emacs-29.0.90~1856^2~773 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=504d5c2da867a932f7bb43af8be114607d70a572;p=emacs.git image-dired: Minor cleanups * lisp/image/image-dired-dired.el (image-dired-dired-after-readin-hook, image-dired-minor-mode): Minor doc fixes. (image-dired-dired-display-image): Don't accept ineffectual prefix argument. * lisp/image/image-dired-util.el (image-dired-file-name-at-point): Use when-let. (image-dired-display-thumb-properties): Redefine as obsolete function alias for 'image-dired-update-header-line'. * lisp/image/image-dired-util.el (image-dired-window-width-pixels): Make obsolete in favor of window-body-width. * lisp/image/image-dired.el (image-dired-line-up-dynamic) (image-dired-display-window-width): Don't use above obsolete function. --- diff --git a/lisp/image/image-dired-dired.el b/lisp/image/image-dired-dired.el index aa9fa38751a..b15d46d1115 100644 --- a/lisp/image/image-dired-dired.el +++ b/lisp/image/image-dired-dired.el @@ -81,7 +81,8 @@ previous -ARG, if ARG<0) files." (defun image-dired-dired-after-readin-hook () "Relocate existing thumbnail overlays in Dired buffer after reverting. Move them to their corresponding files if they still exist. -Otherwise, delete overlays." +Otherwise, delete overlays. +Used by `image-dired-dired-toggle-marked-thumbs'." (mapc (lambda (overlay) (when (overlay-get overlay 'put-image) (let* ((image-file (overlay-get overlay 'image-file)) @@ -289,12 +290,12 @@ With prefix argument ARG, create thumbnails even if they already exist image-dired-external-viewer file))) ;;;###autoload -(defun image-dired-dired-display-image (&optional arg) +(defun image-dired-dired-display-image (&optional _) "Display current image file. -See documentation for `image-dired-display-image' for more information. -With prefix argument ARG, display image in its original size." - (interactive "P" dired-mode) - (image-dired-display-image (dired-get-filename) arg)) +See documentation for `image-dired-display-image' for more information." + (declare (advertised-calling-convention () "29.1")) + (interactive nil dired-mode) + (image-dired-display-image (dired-get-filename))) (defun image-dired-copy-with-exif-file-name () "Copy file with unique name to main image directory. diff --git a/lisp/image/image-dired-external.el b/lisp/image/image-dired-external.el index 893d3da843d..c26cedc9f2c 100644 --- a/lisp/image/image-dired-external.el +++ b/lisp/image/image-dired-external.el @@ -142,8 +142,7 @@ Available format specifiers are the same as in :version "26.1" :type '(repeat (string :tag "Argument"))) -(defcustom image-dired-cmd-rotate-original-program - "jpegtran" +(defcustom image-dired-cmd-rotate-original-program "jpegtran" "Executable used to rotate original image. Used together with `image-dired-cmd-rotate-original-options'." :type 'file) @@ -171,8 +170,7 @@ original image file name and %t which is replaced by Used together with `image-dired-cmd-write-exif-data-options'." :type 'file) -(defcustom image-dired-cmd-write-exif-data-options - '("-%t=%v" "%f") +(defcustom image-dired-cmd-write-exif-data-options '("-%t=%v" "%f") "Arguments of command used to write EXIF data. Used with `image-dired-cmd-write-exif-data-program'. Available format specifiers are: %f which is replaced by diff --git a/lisp/image/image-dired-util.el b/lisp/image/image-dired-util.el index 1318b25a12a..cb1632e1be4 100644 --- a/lisp/image/image-dired-util.el +++ b/lisp/image/image-dired-util.el @@ -104,9 +104,8 @@ See also `image-dired-thumbnail-storage'." (defun image-dired-file-name-at-point () "Get abbreviated file name for thumbnail or display image at point." - (let ((f (image-dired-original-file-name))) - (when f - (abbreviate-file-name f)))) + (when-let ((f (image-dired-original-file-name))) + (abbreviate-file-name f))) (defun image-dired-associated-dired-buffer () "Get associated Dired buffer at point." @@ -119,10 +118,6 @@ See also `image-dired-thumbnail-storage'." (equal (window-buffer window) buf)) nil t)) -(defun image-dired-window-width-pixels (window) - "Calculate WINDOW width in pixels." - (* (window-width window) (frame-char-width))) - (defun image-dired-display-window () "Return window where `image-dired-display-image-buffer' is visible." (get-window-with-predicate @@ -152,6 +147,11 @@ See also `image-dired-thumbnail-storage'." "Return non-nil if there is an `image-dired' thumbnail at point." (get-text-property (point) 'image-dired-thumbnail)) +(defun image-dired-window-width-pixels (window) + "Calculate WINDOW width in pixels." + (declare (obsolete window-body-width "29.1")) + (* (window-width window) (frame-char-width))) + (provide 'image-dired-util) ;; Local Variables: diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el index 87c2cd3f094..b92166c1dcc 100644 --- a/lisp/image/image-dired.el +++ b/lisp/image/image-dired.el @@ -1056,13 +1056,13 @@ See also `image-dired-line-up-dynamic'." Calculate how many thumbnails fit." (interactive nil image-dired-thumbnail-mode) (let* ((char-width (frame-char-width)) - (width (image-dired-window-width-pixels (image-dired-thumbnail-window))) - (image-dired-thumbs-per-row - (/ width - (+ (* 2 image-dired-thumb-relief) - (* 2 image-dired-thumb-margin) - (image-dired-thumb-size 'width) - char-width)))) + (width (window-body-width (image-dired-thumbnail-window) t)) + (image-dired-thumbs-per-row + (/ width + (+ (* 2 image-dired-thumb-relief) + (* 2 image-dired-thumb-margin) + (image-dired-thumb-size 'width) + char-width)))) (image-dired-line-up))) (defun image-dired-line-up-interactive () @@ -1368,7 +1368,7 @@ completely fit)." (defun image-dired-display-window-width (window) "Return width, in pixels, of WINDOW." (declare (obsolete nil "29.1")) - (- (image-dired-window-width-pixels window) + (- (window-body-width window t) image-dired-display-window-width-correction)) (defun image-dired-display-window-height (window) @@ -1535,10 +1535,8 @@ Dired." (cons (list tag file) (cdr image-dired-tag-file-list)))) (setq image-dired-tag-file-list (list (list tag file)))))) -(defun image-dired-display-thumb-properties () - "Display thumbnail properties in the echo area." - (declare (obsolete image-dired-update-header-line "29.1")) - (image-dired-update-header-line)) +(define-obsolete-function-alias 'image-dired-display-thumb-properties + #'image-dired-update-header-line "29.1") (defvar image-dired-slideshow-count 0 "Keeping track on number of images in slideshow.")