]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/image-mode.el (image-mode-winprops): Add winprops to
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 24 May 2013 17:42:23 +0000 (13:42 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 24 May 2013 17:42:23 +0000 (13:42 -0400)
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
lisp/ChangeLog
lisp/doc-view.el
lisp/image-mode.el

index 17d176989367db0f7ec817bf4c253e443d3e075b..8dd3ef277b03d416f3f1cecbcc68c69510d238eb 100644 (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>
 
        * doc-view.el: Integrate with desktop.el.  (Bug#14435)
        (doc-view-desktop-save-buffer): New function.
        (doc-view-restore-desktop-buffer): New function.
-       (desktop-buffer-mode-handlers): Add
-       `doc-view-restore-desktop-buffer' as desktop.el buffer mode
+       (desktop-buffer-mode-handlers):
+       Add `doc-view-restore-desktop-buffer' as desktop.el buffer mode
        handler.
        (doc-view-mode): Set `doc-view-desktop-save-buffer' as custom
        `desktop-save-buffer' function.
index d7476114fcb7c88740b1500fba9dc422a2b43073..3a4a8138237b109231d374c8c262fe19a0174f33 100644 (file)
@@ -328,24 +328,15 @@ of the page moves to the previous page."
       (cl-assert (eq t (car winprops)))
       (delete-overlay ol))
     (image-mode-window-put 'overlay ol winprops)
-    (when (windowp (car winprops))
-      (if (stringp (overlay-get ol 'display))
-         ;; We're not already displaying an image, so this is the
-         ;; initial window showing the document.
-         (run-with-timer nil nil
-                         (lambda ()
-                           ;; In case a conversion is running, the
-                           ;; refresh will happen as defined by
-                           ;; `doc-view-conversion-refresh-interval'.
-                           (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))))))))
+    (when (and (windowp (car winprops))
+               (stringp (overlay-get ol 'display))
+               (null doc-view-current-converter-processes))
+      ;; We're not displaying an image yet, so let's do so.  This happens when
+      ;; the buffer is displayed for the first time.
+      ;; Don't do it if there's a conversion is running, since in that case, it
+      ;; will be done later.
+      (with-selected-window (car winprops)
+        (doc-view-goto-page 1)))))
 
 (defvar doc-view-current-files nil
   "Only used internally.")
@@ -1651,14 +1642,17 @@ If BACKWARD is non-nil, jump to the previous match."
 
 ;; desktop.el integration
 
-(defun doc-view-desktop-save-buffer (desktop-dirname)
+(defun doc-view-desktop-save-buffer (_desktop-dirname)
   `((page . ,(doc-view-current-page))
     (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)
   (let ((page  (cdr (assq 'page 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)
                              (selected-window))
       (doc-view-goto-page page)
index ac090f020b3e2427c391c96c4cfad44bc9eb93ac..909e2fa247fe39cf7aa166da171616083ed4ecea 100644 (file)
@@ -69,13 +69,17 @@ otherwise it defaults to t, used for times when the buffer is not displayed."
                            image-mode-winprops-alist))))
   (let ((winprops (assq window image-mode-winprops-alist)))
     ;; 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
                            (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))
-    ;; Move window to front.
-    (setq image-mode-winprops-alist
-          (cons winprops (delq winprops image-mode-winprops-alist)))
     winprops))
 
 (defun image-mode-window-get (prop &optional winprops)