[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b9edbae: * lisp/image-mode.el: Use one timer and lock for slow re
From: |
Juri Linkov |
Subject: |
master b9edbae: * lisp/image-mode.el: Use one timer and lock for slow remote calls (bug#45256) |
Date: |
Sat, 19 Dec 2020 15:19:32 -0500 (EST) |
branch: master
commit b9edbaed01a91d5fc6235fc679d8e0cd827f6fa9
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/image-mode.el: Use one timer and lock for slow remote calls
(bug#45256)
* lisp/image-mode.el (image-auto-resize-timer): New variable.
(image--window-state-change): Cancel previous timer and
remember new timer in image-auto-resize-timer.
(image--window-state-change): New variable.
(image-fit-to-window): When image-fit-to-window-lock is nil,
call image-toggle-display-image ignoring 'remote-file-error'.
---
lisp/image-mode.el | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 032ebf3..465bf86 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -942,6 +942,9 @@ Otherwise, display the image by calling `image-mode'."
(get-buffer-window-list (current-buffer) 'nomini 'visible))
(image-toggle-display-image)))
+(defvar image-auto-resize-timer nil
+ "Timer for `image-auto-resize-on-window-resize' option.")
+
(defun image--window-state-change (window)
;; Wait for a bit of idle-time before actually performing the change,
;; so as to batch together sequences of closely consecutive size changes.
@@ -950,8 +953,14 @@ Otherwise, display the image by calling `image-mode'."
;; consecutive calls happen without any redisplay between them,
;; the costly operation of image resizing should happen only once.
(when (numberp image-auto-resize-on-window-resize)
- (run-with-idle-timer image-auto-resize-on-window-resize nil
- #'image-fit-to-window window)))
+ (when image-auto-resize-timer
+ (cancel-timer image-auto-resize-timer))
+ (setq image-auto-resize-timer
+ (run-with-idle-timer image-auto-resize-on-window-resize nil
+ #'image-fit-to-window window))))
+
+(defvar image-fit-to-window-lock nil
+ "Lock for `image-fit-to-window' timer function.")
(defun image-fit-to-window (window)
"Adjust size of image to display it exactly in WINDOW boundaries."
@@ -968,7 +977,13 @@ Otherwise, display the image by calling `image-mode'."
(when (and image-width image-height
(or (not (= image-width window-width))
(not (= image-height window-height))))
- (image-toggle-display-image)))))))))
+ (unless image-fit-to-window-lock
+ (unwind-protect
+ (progn
+ (setq-local image-fit-to-window-lock t)
+ (ignore-error 'remote-file-error
+ (image-toggle-display-image)))
+ (setq image-fit-to-window-lock nil)))))))))))
;;; Animated images
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b9edbae: * lisp/image-mode.el: Use one timer and lock for slow remote calls (bug#45256),
Juri Linkov <=