From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Jan_B=F6cker?= Subject: Re: Specify page number in hyperlink [to pdf] Date: Thu, 29 Apr 2010 21:22:24 +0200 Message-ID: <4BD9DC70.3090006@jboecker.de> References: <4BD87ED7.5030907@san.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7ZJm-00021Y-DY for emacs-orgmode@gnu.org; Thu, 29 Apr 2010 15:22:38 -0400 Received: from [140.186.70.92] (port=39913 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7ZJl-00021Q-60 for emacs-orgmode@gnu.org; Thu, 29 Apr 2010 15:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7ZJj-00061K-JH for emacs-orgmode@gnu.org; Thu, 29 Apr 2010 15:22:36 -0400 Received: from mail7.worldserver.net ([217.13.200.27]:51988) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7ZJj-000615-9w for emacs-orgmode@gnu.org; Thu, 29 Apr 2010 15:22:35 -0400 In-Reply-To: <4BD87ED7.5030907@san.rr.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Joe Riel Cc: emacs-orgmode@gnu.org On 28.04.2010 20:30, Joe Riel wrote: > The hyperlink syntax allows specifying a line number, however, > that doesn't do anything (other than force the document to > be opened inside of emacs) with a non-text file (say a pdf). > > Is therea an extension to allow specifying a page number > so that a link to a pdf is opened at the specified page? There is in the current git version, its not yet documented though. Add an entry to the variable org-file-apps like this: ("\\.pdf::\\([0-9]+\\)\\'" . "evince \"%s\" -p %1") Or as seen in the customize interface: Extension: \.pdf::\([0-9]+\)\' Command: evince "%s" -p %1 The subexpression \([0-9]+\) in the regex captures the page number, which replaces the %1 in the command string. (This example assumes you want to open your PDFs with evince, which accepts a page number after the -p option.) You can then reference a specific page of a PDF like this: [[file:/path/to/document.pdf::42]] I had planned to document this yesterday, but unfortunately spent the better part of the day recovering from a cold. I will send a patch describing how this works, when exactly the new behaviour kicks in and the implications for backwards compatibility as soon as I find time to describe it compactly enough to fit into the docstring. HTH, Jan PS: Here is my first draft of the change to the docstring; it does not mention custom lisp forms yet, and still makes the docstring too long for my taste. I guess I'll write a separate tutorial on worg which I'll reference in the docstring, and include in the docstring only one example of the extended feature and information on backwards compatibility. \"regex\" Regular expression matched against the file name. For backward compatibility, this can also be a string with only alphanumeric characters, which is then interpreted as an extension. + + If this regular expression captures parts of the + match using groups (subexpressions), it is matched + against the whole link instead; \"%n\" in a + command string will be replaced by the n-th + subexpression match, just like \"%s\" is replaced + with the file name. + + For backwards compatibility, this behaviour is not + triggered if the command string does not contain + any \"%n\", i.e. in that case the regexp is still + matched against the file name. + + If you want to use groups in your regexp but do not want + it matched against the whole link, use shy groups like this: + \"\\(?:txt|html\\)\"