summaryrefslogtreecommitdiff
path: root/lisp/image-mode.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2008-05-22 21:27:42 +0000
committerChong Yidong <cyd@stupidchicken.com>2008-05-22 21:27:42 +0000
commitb81f0babbdd62eedfed4e701b5c776aedcaf1fe7 (patch)
tree77ea18d289c8f2a577345ebf0ed66bbd753c229d /lisp/image-mode.el
parentbe26add72fe46af66ad85d2fec969f5f79108ad1 (diff)
downloademacs-b81f0babbdd62eedfed4e701b5c776aedcaf1fe7.tar.gz
(image-mode-winprops): Add argument CLEANUP to prune
image-mode-winprops-alist, preventing it from growing indefinitely. (image-mode-reapply-winprops): Use it.
Diffstat (limited to 'lisp/image-mode.el')
-rw-r--r--lisp/image-mode.el18
1 files changed, 14 insertions, 4 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index a331064ecf3..9cfc734daab 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -56,10 +56,19 @@
"Special hook run when image data is requested in a new window.
It is called with one argument, the initial WINPROPS.")
-(defun image-mode-winprops (&optional window)
+(defun image-mode-winprops (&optional window cleanup)
"Return winprops of WINDOW.
A winprops object has the shape (WINDOW . ALIST)."
- (unless window (setq window (selected-window)))
+ (cond ((null window)
+ (setq window (selected-window)))
+ ((not (windowp window))
+ (error "Not a window: %s" window)))
+ (when cleanup
+ (setq image-mode-winprops-alist
+ (delq nil (mapcar (lambda (winprop)
+ (if (window-live-p (car-safe winprop))
+ winprop))
+ image-mode-winprops-alist))))
(let ((winprops (assq window image-mode-winprops-alist)))
;; For new windows, set defaults from the latest.
(unless winprops
@@ -94,8 +103,9 @@ A winprops object has the shape (WINDOW . ALIST)."
(defun image-mode-reapply-winprops ()
;; When set-window-buffer, set hscroll and vscroll to what they were
;; last time the image was displayed in this window.
- (when (listp image-mode-winprops-alist)
- (let* ((winprops (image-mode-winprops))
+ (when (and (image-get-display-property)
+ (listp image-mode-winprops-alist))
+ (let* ((winprops (image-mode-winprops nil t))
(hscroll (image-mode-window-get 'hscroll winprops))
(vscroll (image-mode-window-get 'vscroll winprops)))
(if hscroll (set-window-hscroll (selected-window) hscroll))