* doc-view functions inside with-current-buffer do not work
@ 2014-11-03 16:16 Alexander Baier
2014-11-03 16:57 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Baier @ 2014-11-03 16:16 UTC (permalink / raw)
To: emacs-devel
Hello,
Consider the following steps:
- Define this function:
#+BEGIN_SRC emacs-lisp
(defun my-doc-view-goto-page (n)
(with-current-buffer (get-buffer "test.pdf")
(doc-view-goto-page n)))
#+END_SRC
- C-x C-f test.pdf RET
- Evaluating the following snippet:
#+BEGIN_SRC emacs-lisp
(my-doc-view-goto-page 2)
#+END_SRC
For me the buffer containing the test.pdf is still displaying the first
page of test.pdf. I expected it to show the second. Is this a bug?
Note: I waited for doc-view-mode to convert the whole pdf to png
images. At least the mode line displays "1/22" and does not change
anymore.
Regards,
--
Alexander Baier
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: doc-view functions inside with-current-buffer do not work
2014-11-03 16:16 doc-view functions inside with-current-buffer do not work Alexander Baier
@ 2014-11-03 16:57 ` Stefan Monnier
2014-11-03 17:28 ` Alexander Baier
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2014-11-03 16:57 UTC (permalink / raw)
To: Alexander Baier; +Cc: emacs-devel
> Consider the following steps:
> - Define this function:
> #+BEGIN_SRC emacs-lisp
> (defun my-doc-view-goto-page (n)
> (with-current-buffer (get-buffer "test.pdf")
> (doc-view-goto-page n)))
> #+END_SRC
Just like point and goto-char, the page displayed by doc-view can be
different in different windows, so selecting the buffer is not enough
for doc-view-goto-page to know which window should be affected.
You need with-selected-window instead of with-current-buffer.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: doc-view functions inside with-current-buffer do not work
2014-11-03 16:57 ` Stefan Monnier
@ 2014-11-03 17:28 ` Alexander Baier
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Baier @ 2014-11-03 17:28 UTC (permalink / raw)
To: emacs-devel
On 2014-11-03 17:57 Stefan Monnier wrote:
>> Consider the following steps:
>
>> - Define this function:
>> #+BEGIN_SRC emacs-lisp
>> (defun my-doc-view-goto-page (n)
>> (with-current-buffer (get-buffer "test.pdf")
>> (doc-view-goto-page n)))
>> #+END_SRC
>
> Just like point and goto-char, the page displayed by doc-view can be
> different in different windows, so selecting the buffer is not enough
> for doc-view-goto-page to know which window should be affected.
>
> You need with-selected-window instead of with-current-buffer.
This works like a charm, thank you!
Regards,
--
Alexander Baier
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-03 17:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03 16:16 doc-view functions inside with-current-buffer do not work Alexander Baier
2014-11-03 16:57 ` Stefan Monnier
2014-11-03 17:28 ` Alexander Baier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).