diff options
| author | Chong Yidong | 2008-05-22 21:27:42 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-05-22 21:27:42 +0000 |
| commit | b81f0babbdd62eedfed4e701b5c776aedcaf1fe7 (patch) | |
| tree | 77ea18d289c8f2a577345ebf0ed66bbd753c229d | |
| parent | be26add72fe46af66ad85d2fec969f5f79108ad1 (diff) | |
| download | emacs-b81f0babbdd62eedfed4e701b5c776aedcaf1fe7.tar.gz emacs-b81f0babbdd62eedfed4e701b5c776aedcaf1fe7.zip | |
(image-mode-winprops): Add argument CLEANUP to prune
image-mode-winprops-alist, preventing it from growing indefinitely.
(image-mode-reapply-winprops): Use it.
| -rw-r--r-- | lisp/image-mode.el | 18 |
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 @@ | |||
| 56 | "Special hook run when image data is requested in a new window. | 56 | "Special hook run when image data is requested in a new window. |
| 57 | It is called with one argument, the initial WINPROPS.") | 57 | It is called with one argument, the initial WINPROPS.") |
| 58 | 58 | ||
| 59 | (defun image-mode-winprops (&optional window) | 59 | (defun image-mode-winprops (&optional window cleanup) |
| 60 | "Return winprops of WINDOW. | 60 | "Return winprops of WINDOW. |
| 61 | A winprops object has the shape (WINDOW . ALIST)." | 61 | A winprops object has the shape (WINDOW . ALIST)." |
| 62 | (unless window (setq window (selected-window))) | 62 | (cond ((null window) |
| 63 | (setq window (selected-window))) | ||
| 64 | ((not (windowp window)) | ||
| 65 | (error "Not a window: %s" window))) | ||
| 66 | (when cleanup | ||
| 67 | (setq image-mode-winprops-alist | ||
| 68 | (delq nil (mapcar (lambda (winprop) | ||
| 69 | (if (window-live-p (car-safe winprop)) | ||
| 70 | winprop)) | ||
| 71 | image-mode-winprops-alist)))) | ||
| 63 | (let ((winprops (assq window image-mode-winprops-alist))) | 72 | (let ((winprops (assq window image-mode-winprops-alist))) |
| 64 | ;; For new windows, set defaults from the latest. | 73 | ;; For new windows, set defaults from the latest. |
| 65 | (unless winprops | 74 | (unless winprops |
| @@ -94,8 +103,9 @@ A winprops object has the shape (WINDOW . ALIST)." | |||
| 94 | (defun image-mode-reapply-winprops () | 103 | (defun image-mode-reapply-winprops () |
| 95 | ;; When set-window-buffer, set hscroll and vscroll to what they were | 104 | ;; When set-window-buffer, set hscroll and vscroll to what they were |
| 96 | ;; last time the image was displayed in this window. | 105 | ;; last time the image was displayed in this window. |
| 97 | (when (listp image-mode-winprops-alist) | 106 | (when (and (image-get-display-property) |
| 98 | (let* ((winprops (image-mode-winprops)) | 107 | (listp image-mode-winprops-alist)) |
| 108 | (let* ((winprops (image-mode-winprops nil t)) | ||
| 99 | (hscroll (image-mode-window-get 'hscroll winprops)) | 109 | (hscroll (image-mode-window-get 'hscroll winprops)) |
| 100 | (vscroll (image-mode-window-get 'vscroll winprops))) | 110 | (vscroll (image-mode-window-get 'vscroll winprops))) |
| 101 | (if hscroll (set-window-hscroll (selected-window) hscroll)) | 111 | (if hscroll (set-window-hscroll (selected-window) hscroll)) |