Function: doc-view-goto-page
doc-view-goto-page is an interactive and byte-compiled function
defined in doc-view.el.gz.
Signature
(doc-view-goto-page PAGE)
Documentation
View the page given by PAGE.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/doc-view.el.gz
(defun doc-view-goto-page (page)
"View the page given by PAGE."
(interactive "nPage: ")
(let ((len (doc-view-last-page-number)))
(if (< page 1)
(setq page 1)
(when (and (> page len)
;; As long as the converter is running, we don't know
;; how many pages will be available.
(null doc-view--current-converter-processes))
(setq page len)))
(force-mode-line-update) ;To update `current-page'.
(setf (doc-view-current-page) page
(doc-view-current-info)
(concat
(propertize
(format "Page %d of %d." page len) 'face 'bold)
;; Tell user if converting isn't finished yet
(and doc-view--current-converter-processes
" (still converting...)")
;; Display context infos if this page matches the last search
(when (and doc-view--current-search-matches
(assq page doc-view--current-search-matches))
(concat "\n" (propertize "Search matches:" 'face 'bold)
(let ((contexts ""))
(dolist (m (cdr (assq page
doc-view--current-search-matches)))
(setq contexts (concat contexts "\n - \"" m "\"")))
contexts)))))
;; Update the buffer
;; We used to find the file name from doc-view--current-files but
;; that's not right if the pages are not generated sequentially
;; or if the page isn't in doc-view--current-files yet.
(let ((file (expand-file-name
(format doc-view--image-file-pattern page)
(doc-view--current-cache-dir))))
(doc-view-insert-image file :pointer 'arrow)
(when (and (not (file-exists-p file))
doc-view--current-converter-processes)
;; The PNG file hasn't been generated yet.
(funcall doc-view-single-page-converter-function
doc-view--buffer-file-name file page
(let ((win (selected-window)))
(lambda ()
(and (eq (current-buffer) (window-buffer win))
;; If we changed page in the mean
;; time, don't mess things up.
(eq (doc-view-current-page win) page)
;; Make sure we don't infloop.
(file-readable-p file)
(with-selected-window win
(doc-view-goto-page page))))))))
(overlay-put (doc-view-current-overlay)
'help-echo (doc-view-current-info))))