GNU bug report logs - #16541
23.3; doc-view-open-text should grab place in current doc

Previous Next

Package: emacs;

Reported by: Suhail Shergill <suhailshergill <at> gmail.com>

Date: Fri, 24 Jan 2014 20:40:03 UTC

Severity: wishlist

Tags: fixed, patch

Found in version 23.3

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Tassilo Horn <tsdh <at> gnu.org>
To: Suhail Shergill <suhailshergill <at> gmail.com>
Cc: 16541 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: bug#16541: 23.3; doc-view-open-text should grab place in current doc
Date: Mon, 27 Jan 2014 11:25:09 +0100
Suhail Shergill <suhailshergill <at> gmail.com> 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




This bug report was last modified 5 years and 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.