emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/image-dired f069b2cc88 3/4: image-dired: Minor cleanups


From: Stefan Kangas
Subject: scratch/image-dired f069b2cc88 3/4: image-dired: Minor cleanups
Date: Sat, 20 Aug 2022 20:39:03 -0400 (EDT)

branch: scratch/image-dired
commit f069b2cc885b0798692682a6cd1ecdfc7b1b2499
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    image-dired: Minor cleanups
    
    * lisp/image-dired/image-dired-dired.el
    (image-dired-dired-after-readin-hook, image-dired-minor-mode):
    Minor doc fixes.
    * lisp/image-dired/image-dired-util.el
    (image-dired-file-name-at-point): Use when-let.
    * lisp/image-dired/image-dired-util.el
    (image-dired-window-width-pixels): Move from here...
    * lisp/image-dired/image-dired-compat.el
    (image-dired-window-width-pixels): ...to here.  Make obsolete in
    favor of window-body-width.  Update callers.
---
 lisp/image-dired/image-dired-compat.el   | 9 +++++++--
 lisp/image-dired/image-dired-dired.el    | 5 +++--
 lisp/image-dired/image-dired-external.el | 9 +++------
 lisp/image-dired/image-dired-util.el     | 9 ++-------
 lisp/image-dired/image-dired.el          | 2 +-
 5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/lisp/image-dired/image-dired-compat.el 
b/lisp/image-dired/image-dired-compat.el
index d037f71d35..17568bff52 100644
--- a/lisp/image-dired/image-dired-compat.el
+++ b/lisp/image-dired/image-dired-compat.el
@@ -99,6 +99,11 @@ completely fit)."
 (make-obsolete-variable 'image-dired-display-window-height-correction
                         "no longer used." "29.1")
 
+(defun image-dired-window-width-pixels (window)
+  "Calculate WINDOW width in pixels."
+  (declare (obsolete window-body-width "29.1"))
+  (window-body-width window t))
+
 (defun image-dired-display-window-width (window)
   "Return width, in pixels, of WINDOW."
   (declare (obsolete nil "29.1"))
@@ -115,7 +120,7 @@ completely fit)."
   "Calculate WINDOW height in pixels."
   (declare (obsolete nil "29.1"))
   ;; Note: The mode-line consumes one line
-    (* (- (window-height window) 1) (frame-char-height)))
+  (* (- (window-height window) 1) (frame-char-height)))
 
 (defcustom image-dired-cmd-read-exif-data-program "exiftool"
   "Program used to read EXIF data to image.
@@ -223,7 +228,7 @@ Dired."
         (dired-buf (image-dired-associated-dired-buffer)))
     (if (not (and dired-buf file-name))
         (message "No image, or image with correct properties, at point")
-    (with-current-buffer dired-buf
+      (with-current-buffer dired-buf
         (message "%s" file-name)
         (when (dired-goto-file file-name)
           (cond ((eq command 'mark) (dired-mark 1))
diff --git a/lisp/image-dired/image-dired-dired.el 
b/lisp/image-dired/image-dired-dired.el
index f74e45c44c..d2c13e334a 100644
--- a/lisp/image-dired/image-dired-dired.el
+++ b/lisp/image-dired/image-dired-dired.el
@@ -61,7 +61,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))
@@ -229,7 +230,7 @@ With prefix argument, move ARG lines."
 ;;;###autoload
 (define-minor-mode image-dired-minor-mode
   "Setup easy-to-use keybindings for the commands to be used in Dired mode.
-Note that n, p and <down> and <up> will be hijacked and bound to
+Note that \\`n', \\`p' and \\`<down>' and \\`<up>' will be hijacked and bound 
to
 `image-dired-dired-next-line' and `image-dired-dired-previous-line'."
   :keymap image-dired-minor-mode-map)
 
diff --git a/lisp/image-dired/image-dired-external.el 
b/lisp/image-dired/image-dired-external.el
index a115dbb350..b54d7cb74b 100644
--- a/lisp/image-dired/image-dired-external.el
+++ b/lisp/image-dired/image-dired-external.el
@@ -144,8 +144,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'."
   :group 'image-dired
@@ -178,15 +177,13 @@ original file with `image-dired-temp-rotate-image-file'."
   :group 'image-dired
   :type 'boolean)
 
-(defcustom image-dired-cmd-write-exif-data-program
-  "exiftool"
+(defcustom image-dired-cmd-write-exif-data-program "exiftool"
   "Program used to write EXIF data to image.
 Used together with `image-dired-cmd-write-exif-data-options'."
   :group 'image-dired
   :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-dired/image-dired-util.el 
b/lisp/image-dired/image-dired-util.el
index 7e591eb2ee..67ac52a2e6 100644
--- a/lisp/image-dired/image-dired-util.el
+++ b/lisp/image-dired/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
diff --git a/lisp/image-dired/image-dired.el b/lisp/image-dired/image-dired.el
index b60df1cd8b..844ab23cd5 100644
--- a/lisp/image-dired/image-dired.el
+++ b/lisp/image-dired/image-dired.el
@@ -1102,7 +1102,7 @@ See also `image-dired-line-up-dynamic'."
 Calculate how many thumbnails fit."
   (interactive)
   (let* ((char-width (frame-char-width))
-        (width (image-dired-window-width-pixels 
(image-dired-thumbnail-window)))
+        (width (window-body-width (image-dired-thumbnail-window) t))
         (image-dired-thumbs-per-row
          (/ width
             (+ (* 2 image-dired-thumb-relief)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]