* lisp/image-mode.el (image-mode-winprops): Add winprops to

image-mode-winprops-alist before running image-mode-new-window-functions.
* lisp/doc-view.el (doc-view-new-window-function): Don't delay
doc-view-goto-page via timers.

Fixes: debbugs:14435
This commit is contained in:
Stefan Monnier 2013-05-24 13:42:23 -04:00
parent a4f59c0fb9
commit 5010583555
3 changed files with 32 additions and 26 deletions

View file

@ -1,10 +1,18 @@
2013-05-24 Stefan Monnier <monnier@iro.umontreal.ca>
* image-mode.el (image-mode-winprops): Add winprops to
image-mode-winprops-alist before running
image-mode-new-window-functions.
* doc-view.el (doc-view-new-window-function): Don't delay
doc-view-goto-page via timers (bug#14435).
2013-05-24 Tassilo Horn <tsdh@gnu.org> 2013-05-24 Tassilo Horn <tsdh@gnu.org>
* doc-view.el: Integrate with desktop.el. (Bug#14435) * doc-view.el: Integrate with desktop.el. (Bug#14435)
(doc-view-desktop-save-buffer): New function. (doc-view-desktop-save-buffer): New function.
(doc-view-restore-desktop-buffer): New function. (doc-view-restore-desktop-buffer): New function.
(desktop-buffer-mode-handlers): Add (desktop-buffer-mode-handlers):
`doc-view-restore-desktop-buffer' as desktop.el buffer mode Add `doc-view-restore-desktop-buffer' as desktop.el buffer mode
handler. handler.
(doc-view-mode): Set `doc-view-desktop-save-buffer' as custom (doc-view-mode): Set `doc-view-desktop-save-buffer' as custom
`desktop-save-buffer' function. `desktop-save-buffer' function.

View file

@ -328,24 +328,15 @@ of the page moves to the previous page."
(cl-assert (eq t (car winprops))) (cl-assert (eq t (car winprops)))
(delete-overlay ol)) (delete-overlay ol))
(image-mode-window-put 'overlay ol winprops) (image-mode-window-put 'overlay ol winprops)
(when (windowp (car winprops)) (when (and (windowp (car winprops))
(if (stringp (overlay-get ol 'display)) (stringp (overlay-get ol 'display))
;; We're not already displaying an image, so this is the (null doc-view-current-converter-processes))
;; initial window showing the document. ;; We're not displaying an image yet, so let's do so. This happens when
(run-with-timer nil nil ;; the buffer is displayed for the first time.
(lambda () ;; Don't do it if there's a conversion is running, since in that case, it
;; In case a conversion is running, the ;; will be done later.
;; refresh will happen as defined by (with-selected-window (car winprops)
;; `doc-view-conversion-refresh-interval'. (doc-view-goto-page 1)))))
(unless doc-view-current-converter-processes
(with-selected-window (car winprops)
(doc-view-goto-page 1)))))
;; We've split the window showing the document. All we need
;; to do is selecting the new window to cause a redisplay to
;; make the image appear there, too.
(run-with-timer nil nil
(lambda ()
(with-selected-window (car winprops))))))))
(defvar doc-view-current-files nil (defvar doc-view-current-files nil
"Only used internally.") "Only used internally.")
@ -1651,14 +1642,17 @@ If BACKWARD is non-nil, jump to the previous match."
;; desktop.el integration ;; desktop.el integration
(defun doc-view-desktop-save-buffer (desktop-dirname) (defun doc-view-desktop-save-buffer (_desktop-dirname)
`((page . ,(doc-view-current-page)) `((page . ,(doc-view-current-page))
(slice . ,(doc-view-current-slice)))) (slice . ,(doc-view-current-slice))))
(declare-function desktop-restore-file-buffer "desktop"
(buffer-filename buffer-name buffer-misc))
(defun doc-view-restore-desktop-buffer (file name misc) (defun doc-view-restore-desktop-buffer (file name misc)
(let ((page (cdr (assq 'page misc))) (let ((page (cdr (assq 'page misc)))
(slice (cdr (assq 'slice misc)))) (slice (cdr (assq 'slice misc))))
(prog1 (desktop-restore-file-buffer file name misc)) (desktop-restore-file-buffer file name misc)
(with-selected-window (or (get-buffer-window (current-buffer) 0) (with-selected-window (or (get-buffer-window (current-buffer) 0)
(selected-window)) (selected-window))
(doc-view-goto-page page) (doc-view-goto-page page)

View file

@ -69,13 +69,17 @@ otherwise it defaults to t, used for times when the buffer is not displayed."
image-mode-winprops-alist)))) image-mode-winprops-alist))))
(let ((winprops (assq window image-mode-winprops-alist))) (let ((winprops (assq window image-mode-winprops-alist)))
;; For new windows, set defaults from the latest. ;; For new windows, set defaults from the latest.
(unless winprops (if winprops
;; Move window to front.
(setq image-mode-winprops-alist
(cons winprops (delq winprops image-mode-winprops-alist)))
(setq winprops (cons window (setq winprops (cons window
(copy-alist (cdar image-mode-winprops-alist)))) (copy-alist (cdar image-mode-winprops-alist))))
;; Add winprops before running the hook, to avoid inf-loops if the hook
;; triggers window-configuration-change-hook.
(setq image-mode-winprops-alist
(cons winprops image-mode-winprops-alist))
(run-hook-with-args 'image-mode-new-window-functions winprops)) (run-hook-with-args 'image-mode-new-window-functions winprops))
;; Move window to front.
(setq image-mode-winprops-alist
(cons winprops (delq winprops image-mode-winprops-alist)))
winprops)) winprops))
(defun image-mode-window-get (prop &optional winprops) (defun image-mode-window-get (prop &optional winprops)