From: Tassilo Horn <tsdh@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: martin rudalics <rudalics@gmx.at>, emacs-devel@gnu.org
Subject: Re: cl-assertion error in doc-view
Date: Fri, 21 Sep 2012 09:14:05 +0200 [thread overview]
Message-ID: <87ipb76e6a.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: <jwvr4pww573.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 20 Sep 2012 21:12:33 -0400")
Stefan Monnier <monnier@iro.umontreal.ca> 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
next prev parent reply other threads:[~2012-09-21 7:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-19 17:55 cl-assertion error in doc-view Tassilo Horn
2012-09-20 17:25 ` martin rudalics
2012-09-20 19:54 ` Tassilo Horn
2012-09-20 21:10 ` Stefan Monnier
2012-09-20 22:24 ` martin rudalics
2012-09-21 1:12 ` Stefan Monnier
2012-09-21 7:14 ` Tassilo Horn [this message]
2012-09-21 12:59 ` Stefan Monnier
2012-09-27 3:17 ` Stefan Monnier
2012-09-27 18:17 ` Tassilo Horn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ipb76e6a.fsf@thinkpad.tsdh.de \
--to=tsdh@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.