unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Suhail Shergill <suhailshergill@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 16541@debbugs.gnu.org, Suhail Shergill <suhailshergill@gmail.com>
Subject: bug#16541: 23.3; doc-view-open-text should grab place in current doc
Date: Sat, 25 Jan 2014 02:10:47 +0000	[thread overview]
Message-ID: <8738kc3lzm.fsf@chaos.shergill.su> (raw)
In-Reply-To: <jwvlhy5xer7.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Fri, 24 Jan 2014 16:17:38 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> 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.

digging deeper, it seems doc-view-search-internal uses occurrences of \f as page
markers. in fact, with a little bit of tinkering the following advice does the
trick: 

(defadvice doc-view-open-text (around
                               su/advice/doc-view/doc-view-open-text/around/goto-page
                               last a c pre)
  "grab the page when in doc-view mode and ensure that doc-view-open-text
   opens the correct page"
  (let ((su/dv/page (doc-view-current-page))
        (su/dv/text-buffer-name (concat "Text contents of " (buffer-name))))
    ad-do-it
    (with-current-buffer su/dv/text-buffer-name
     (re-search-forward "\f" nil t (1- su/dv/page))
     (recenter-top-bottom 0))))

-- 
Suhail





  reply	other threads:[~2014-01-25  2:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24 20:18 bug#16541: 23.3; doc-view-open-text should grab place in current doc Suhail Shergill
2014-01-24 21:17 ` Stefan Monnier
2014-01-25  2:10   ` Suhail Shergill [this message]
2014-01-27 10:25     ` Tassilo Horn
2019-09-29 13:09       ` Lars Ingebrigtsen
2019-10-03  9:05         ` Tassilo Horn
2019-10-03 14:55           ` Lars Ingebrigtsen
2019-10-03 17:06             ` 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738kc3lzm.fsf@chaos.shergill.su \
    --to=suhailshergill@gmail.com \
    --cc=16541@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 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).