[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cl-assertion error in doc-view
From: |
Tassilo Horn |
Subject: |
Re: cl-assertion error in doc-view |
Date: |
Fri, 21 Sep 2012 09:14:05 +0200 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>>> So we need a different solution that does not rely on displaying
>>> the buffer.
>> What's the purpose of a thing called `doc-view-display' if it's not
>> to display something?
>
> It's to setup the overlays and properties so that the text is replaced
> by the page images (using the `display' property). That's orthogonal
> to whether the buffer is displayed in a window.
How about using `set-window-buffer' and `save-window-excursion' like so?
That also does the right thing, that is, not show the buffer forcefully,
with `find-file-noselect'.
--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/doc-view.el'
--- lisp/doc-view.el 2012-09-20 19:53:40 +0000
+++ lisp/doc-view.el 2012-09-21 07:05:40 +0000
@@ -1169,25 +1169,25 @@
If FORCE is non-nil, start viewing even if the document does not
have the page we want to view."
(with-current-buffer buffer
- (let ((prev-pages doc-view-current-files)
- (windows (get-buffer-window-list buffer nil t)))
+ (let ((prev-pages doc-view-current-files))
(setq doc-view-current-files
(sort (directory-files (doc-view-current-cache-dir) t
"page-[0-9]+\\.png" t)
'doc-view-sort))
- (unless windows
- (switch-to-buffer buffer)
- (setq windows (get-buffer-window-list buffer nil t)))
- (dolist (win windows)
- (let* ((page (doc-view-current-page win))
- (pagefile (expand-file-name (format "page-%d.png" page)
- (doc-view-current-cache-dir))))
- (when (or force
- (and (not (member pagefile prev-pages))
- (member pagefile doc-view-current-files)))
- (with-selected-window win
- (cl-assert (eq (current-buffer) buffer) t)
- (doc-view-goto-page page))))))))
+ (save-window-excursion
+ (dolist (win (or (get-buffer-window-list buffer nil t)
+ (let ((w (selected-window)))
+ (set-window-buffer w buffer)
+ (list w))))
+ (let* ((page (doc-view-current-page win))
+ (pagefile (expand-file-name (format "page-%d.png" page)
+ (doc-view-current-cache-dir))))
+ (when (or force
+ (and (not (member pagefile prev-pages))
+ (member pagefile doc-view-current-files)))
+ (with-selected-window win
+ (cl-assert (eq (current-buffer) buffer) t)
+ (doc-view-goto-page page)))))))))
(defun doc-view-buffer-message ()
;; Only show this message initially, not when refreshing the buffer (in which
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
Re: cl-assertion error in doc-view, Stefan Monnier, 2012/09/26