Subject: bug#16541: 23.3; doc-view-open-text should grab place in current doc

From: Tassilo Horn <[email-masked]>
Date: Mon, 27 Jan 2014 11:25:09 +0100

Suhail Shergill <[email-masked]> writes:

Hi!

>> Currently doc-view has pretty much no idea about the format in use,
>> so it doesn't know how to go from one page to another.
>
> except results shown by doc-view-search and doc-view-search-next-match
> are associated with the correct page number as seen in docview mode
> (even though it seems the search is conducted on the extracted
> text). so, clearly that information is available to doc-view in some
> sense.

Suhail is correct.  We could easily make C-c C-t switch to the current
page using this patch:

--8<---------------cut here---------------start------------->8---
=== modified file 'lisp/doc-view.el'
--- lisp/doc-view.el	2014-01-01 07:43:34 +0000
+++ lisp/doc-view.el	2014-01-27 10:22:11 +0000
@@ -1400,6 +1400,7 @@
 (defun doc-view-open-text ()
   "Open a buffer with the current doc's contents as text."
   (interactive)
+  (let ((page (doc-view-current-page)))
   (if doc-view--current-converter-processes
       (message "DocView: please wait till conversion finished.")
     (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir))))
@@ -1409,8 +1410,11 @@
 		(dir (file-name-directory buffer-file-name)))
 	    (with-current-buffer (find-file txt)
 	      (rename-buffer name)
-	      (setq default-directory dir)))
-	(doc-view-doc->txt txt 'doc-view-open-text)))))
+		(setq default-directory dir)
+		;; Jump to the current page
+		(goto-char (point-min))
+		(search-forward "
                                 " nil t (1- page))))
+	  (doc-view-doc->txt txt 'doc-view-open-text))))))
 
 ;;;;; Toggle between editing and viewing
--8<---------------cut here---------------end--------------->8---

Should I install it?

Bye,
Tassilo