* protocol for PDFs?
@ 2010-01-02 8:28 D M German
2010-01-02 15:16 ` Jan Böcker
2010-01-02 15:20 ` Darlan Cavalcante Moreira
0 siblings, 2 replies; 8+ messages in thread
From: D M German @ 2010-01-02 8:28 UTC (permalink / raw)
To: emacs-orgmode
hi there,
I am trying to add support in Evince and Xournal for org. I have already
implemented most of it in Xournal, but now I am hitting a roadblock.
What would the form of the URI for a link to a PDF document and a page
be?
In other words, is there support for a link to a given page in a PDF
already written in org?
If not, what would the place to add this functionality?
thanks a lot!
--daniel
--
--
Daniel M. German
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
2010-01-02 8:28 protocol for PDFs? D M German
@ 2010-01-02 15:16 ` Jan Böcker
2010-01-02 20:07 ` D M German
` (2 more replies)
2010-01-02 15:20 ` Darlan Cavalcante Moreira
1 sibling, 3 replies; 8+ messages in thread
From: Jan Böcker @ 2010-01-02 15:16 UTC (permalink / raw)
To: dmg; +Cc: emacs-orgmode
On 02.01.2010 09:28, D M German wrote:
>
> hi there,
>
> I am trying to add support in Evince and Xournal for org. I have already
> implemented most of it in Xournal, but now I am hitting a roadblock.
> What would the form of the URI for a link to a PDF document and a page
> be?
>
> In other words, is there support for a link to a given page in a PDF
> already written in org?
Hi, I am the author of org-docview.el, which adds support for links to
the doc-view-mode of Emacs 23 and is merged in the current master branch
of org-mode.
It allows you to link to any document format which doc-view-mode
supports, which includes PDF files. The syntax is:
docview:<file name>::<page number>
Example:
[[docview:/home/jan/some-file.pdf::7][Page 7]]
Of course, these links open the file by visiting it in emacs.
I would propose to modify org-docview.el to look in org-file-apps for an
entry for \.pdf\'
- If you want to use doc-view-mode to view the PDFs, specify "Visit in
Emacs"
- If you want to use an external viewer, specify that
In the case of an external viewer, org-docview.el would have to know how
to pass the page number on to that viewer, maybe replace %p by the page
number, then pass that on to org-open-file-from-string.
This reminds me again of the fact that docview: links are basically the
same as file: links, but instead of specifying a line number, they
specify a page number. org-docview.el already uses the file: link
functions to do most of the heavy lifting (e.g. to respect
org-link-file-path-type).
I wonder if this separate syntax for "link to a specific line" and "link
to a specific page" is a bad thing, but I also do not want to mess with
the core too much.
PS: I am very interested in integrating Xournal with Org. I use Xournal
for doing all my homework for university; when I have saved the file, I
manually add a file: link to my org file. It would be great to store
that link directly from Xournal!
- Jan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
2010-01-02 8:28 protocol for PDFs? D M German
2010-01-02 15:16 ` Jan Böcker
@ 2010-01-02 15:20 ` Darlan Cavalcante Moreira
2010-01-02 19:23 ` Jan Böcker
1 sibling, 1 reply; 8+ messages in thread
From: Darlan Cavalcante Moreira @ 2010-01-02 15:20 UTC (permalink / raw)
To: dmg; +Cc: emacs-orgmode
If you use docview mode to view a PDF in Emacs then the link will contain the
page you are viewing in the PDF file. I don't know how you will implement the
support in Evince, but Evince also has an option ("-p") to open the file in a
given page and this would be enough for a link to a PDF file. Since I prefer
using Evince instead of docview mode I would be very happy to test it.
- Darlan Cavalcante Moreira
At Sat, 02 Jan 2010 00:28:14 -0800,
D M German <dmg@uvic.ca> wrote:
>
>
> hi there,
>
> I am trying to add support in Evince and Xournal for org. I have already
> implemented most of it in Xournal, but now I am hitting a roadblock.
>
> What would the form of the URI for a link to a PDF document and a page
> be?
>
> In other words, is there support for a link to a given page in a PDF
> already written in org?
>
> If not, what would the place to add this functionality?
>
> thanks a lot!
>
> --daniel
>
>
> --
> --
> Daniel M. German
> http://turingmachine.org/
> http://silvernegative.com/
> dmg (at) uvic (dot) ca
> replace (at) with @ and (dot) with .
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
2010-01-02 15:20 ` Darlan Cavalcante Moreira
@ 2010-01-02 19:23 ` Jan Böcker
2010-01-02 20:17 ` D M German
0 siblings, 1 reply; 8+ messages in thread
From: Jan Böcker @ 2010-01-02 19:23 UTC (permalink / raw)
To: Darlan Cavalcante Moreira; +Cc: emacs-orgmode, dmg
On 02.01.2010 16:20, Darlan Cavalcante Moreira wrote:
> Evince also has an option ("-p") to open the file in a
> given page and this would be enough for a link to a PDF file. Since I prefer
> using Evince instead of docview mode I would be very happy to test it.
I have implemented an experimental version of org-docview.el which
allows you to specify an external PDF viewer. Check out the docview-dev
branch at
http://github.com/jboecker/org-mode
To test this, pull from there or apply the following patch, then:
M-x customize-variable org-docview-pdf-app
Set it to "evince %s -p %p" and docview: links to PDF files should now
open in evince. There may still be bugs lurking here, and I am thinking
about generalizing this to use a variable org-docview-apps which would
behave like org-file-apps.
This would duplicate functionality of file: links again, which bugs me,
but on the other hand it would be difficult to reuse org-file-apps for
this, as I suggested in my previous email -- when opening a file: link
to a PDF, the %p would not get replaced and may confuse the PDF viewer
application :(
Also, YAGNI may apply here if nobody uses docview: links to link to
non-PDF files anyway.
-----------
new experimental variable: org-docview-pdf-app
External application to open docview: links pointing to a pdf file.
Possible values:
'emacs: Visit the file with emacs using doc-view-mode.
string: An external PDF viewer application.
%s will be replaced by the file name.
%p will be replaced by the page number.
Example:
evince %s -p %p
---
lisp/org-docview.el | 39 ++++++++++++++++++++++++++++++++++-----
1 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/lisp/org-docview.el b/lisp/org-docview.el
index 98da615..f2d0bf2 100644
--- a/lisp/org-docview.el
+++ b/lisp/org-docview.el
@@ -53,14 +53,43 @@
(org-add-link-type "docview" 'org-docview-open)
(add-hook 'org-store-link-functions 'org-docview-store-link)
+(defcustom org-docview-pdf-app
+ 'emacs
+ "External application to open docview: links pointing to a pdf file.
+Possible values:
+
+ 'emacs: Visit the file with emacs using doc-view-mode.
+ string: An external PDF viewer application.
+ %s will be replaced by the file name.
+ %p will be replaced by the page number.
+
+ Example:
+ evince %s -p %p"
+ :group 'org-link-follow
+ :type '(choice (const :tag "Visit with Emacs" emacs)
+ (string :tag "Command")))
+
(defun org-docview-open (link)
(when (string-match "\\(.*\\)::\\([0-9]+\\)$" link)
(let* ((path (match-string 1 link))
- (page (string-to-number (match-string 2 link))))
- (org-open-file path 1) ;; let org-mode open the file (in-emacs = 1)
- ;; to ensure org-link-frame-setup is respected
- (doc-view-goto-page page)
- )))
+ (page-string (match-string 2 link))
+ (page (string-to-number page-string)))
+
+ (if (and (not (eq org-docview-pdf-app 'emacs))
+ (string-match "\.pdf$" path))
+ (let ((cmd (with-temp-buffer
+ (insert org-docview-pdf-app)
+ (goto-char 1)
+ (replace-string "%s" path)
+ (goto-char 1)
+ (replace-string "%p" page-string)
+ (buffer-string))))
+ (message cmd)
+ (start-process-shell-command cmd nil cmd))
+
+ (org-open-file path 1) ;; let org-mode open the file (in-emacs = 1)
+ ;; to ensure org-link-frame-setup is respected
+ (doc-view-goto-page page)))))
(defun org-docview-store-link ()
"Store a link to a docview buffer"
--
1.6.6
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
2010-01-02 15:16 ` Jan Böcker
@ 2010-01-02 20:07 ` D M German
2010-01-02 21:17 ` D M German
[not found] ` <86bphbhbmh.fsf@mn.cs.uvic.ca>
2 siblings, 0 replies; 8+ messages in thread
From: D M German @ 2010-01-02 20:07 UTC (permalink / raw)
To: Jan Böcker; +Cc: emacs-orgmode
Jan Böcker twisted the bytes to say:
Jan> Example:
Jan> [[docview:/home/jan/some-file.pdf::7][Page 7]]
Jan> Of course, these links open the file by visiting it in emacs.
Jan> I would propose to modify org-docview.el to look in org-file-apps for an
Jan> entry for \.pdf\'
thanks. This will get me going for the time being.
Also, keep in mind that some people use xournal for native .xoj files,
so it will be nice to generalize this for any extension (provide a
"handler" for the given type of document).
--dmg
--
--
Daniel M. German
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
2010-01-02 19:23 ` Jan Böcker
@ 2010-01-02 20:17 ` D M German
0 siblings, 0 replies; 8+ messages in thread
From: D M German @ 2010-01-02 20:17 UTC (permalink / raw)
To: Jan Böcker; +Cc: emacs-orgmode
Jan Böcker twisted the bytes to say:
Jan> On 02.01.2010 16:20, Darlan Cavalcante Moreira wrote:
>> Evince also has an option ("-p") to open the file in a
>> given page and this would be enough for a link to a PDF file. Since I prefer
>> using Evince instead of docview mode I would be very happy to test it.
Jan> I have implemented an experimental version of org-docview.el which
Jan> allows you to specify an external PDF viewer. Check out the docview-dev
Jan> branch at
Jan> http://github.com/jboecker/org-mode
Jan> To test this, pull from there or apply the following patch, then:
Jan> M-x customize-variable org-docview-pdf-app
Jan> Set it to "evince %s -p %p" and docview: links to PDF files should now
Jan> open in evince. There may still be bugs lurking here, and I am thinking
Jan> about generalizing this to use a variable org-docview-apps which would
Jan> behave like org-file-apps.
Great. I have now a patch for xournal that supports page numbers from
the command line:
https://sourceforge.net/tracker/?func=detail&aid=2924825&group_id=163434&atid=827735
The format is --page=%p or -p %p
It is likely to make it into xournal. I am now adding an option to use
org-protocol to create the link from xournal. more later.
--dmg
Jan> This would duplicate functionality of file: links again, which bugs me,
Jan> but on the other hand it would be difficult to reuse org-file-apps for
Jan> this, as I suggested in my previous email -- when opening a file: link
Jan> to a PDF, the %p would not get replaced and may confuse the PDF viewer
Jan> application :(
Jan> Also, YAGNI may apply here if nobody uses docview: links to link to
Jan> non-PDF files anyway.
Jan> -----------
Jan> new experimental variable: org-docview-pdf-app
Jan> External application to open docview: links pointing to a pdf file.
Jan> Possible values:
'emacs: Visit the file with emacs using doc-view-mode.
string: An external PDF viewer application.
%s will be replaced by the file name.
%p will be replaced by the page number.
Example:
evince %s -p %p
--
--
Daniel M. German
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
2010-01-02 15:16 ` Jan Böcker
2010-01-02 20:07 ` D M German
@ 2010-01-02 21:17 ` D M German
[not found] ` <86bphbhbmh.fsf@mn.cs.uvic.ca>
2 siblings, 0 replies; 8+ messages in thread
From: D M German @ 2010-01-02 21:17 UTC (permalink / raw)
To: Jan Böcker; +Cc: emacs-orgmode
I have implemented 'Remember' in xournal. I doubt this feature will ever
make into the mainstream. You can check out my fork. it contains many
features not in the current distribution, but useful, including very
rudimentary search support, ability to jump to next and previous
annotations:
http://github.com/dmgerman/xournal
or you can cherry pick my commits.
Look for Remember under the edit menu. By default it would use the name
of the PDF file (if one exits), otherwise it will use the .XOJ file. I
am curious to see if we can select text in xournal.
I don't use Link (only remember) but that would be easy to implement
too. The infrastructure is there now.
Jan> PS: I am very interested in integrating Xournal with Org. I use Xournal
Jan> for doing all my homework for university; when I have saved the file, I
Jan> manually add a file: link to my org file. It would be great to store
Jan> that link directly from Xournal!
Jan> - Jan
--
--
Daniel M. German
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: protocol for PDFs?
[not found] ` <86bphbhbmh.fsf@mn.cs.uvic.ca>
@ 2010-01-04 16:09 ` Sebastian Rose
0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Rose @ 2010-01-04 16:09 UTC (permalink / raw)
To: dmg; +Cc: emacs-orgmode
D M German <dmg@uvic.ca> writes:
> Jan> It allows you to link to any document format which doc-view-mode
> Jan> supports, which includes PDF files. The syntax is:
>
> Jan> docview:<file name>::<page number>
>
> Jan> Example:
>
> Jan> [[docview:/home/jan/some-file.pdf::7][Page 7]]
>
> I have started modifying evince. I got to the point in evince that I can
> now call emacs-client. The problem is, what do I pass to it?
>
> Will the call to emacsclient be:
>
> emascclient ort-protocol://remember://docview:/home/jan/some-file.pdf::7/TitleOfPDF/Selection
Hi Daniel,
you will have to call
emascclient ort-protocol://docview:/home/jan/some-file.pdf::7/TitleOfPDF/Selection
and define a custom handler to make this work. As docview is in the
core, you could add that handler directly in lisp/org-protocol.el if
everyone is OK with that.
I'm not online very often at the moment. I probably won't read your
answers before I tried that myself (just updated Org-mode here). I'll be
back on thursday :-/
See:
http://www.youtube.com/profile?user=Nie0815#p/u/1/h7Z2PiAcgh8
and
http://orgmode.org/worg/org-tutorials/org-protocol-custom-handler.php
for more on custom handlers.
Best wishes
Sebastian
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-01-04 16:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-02 8:28 protocol for PDFs? D M German
2010-01-02 15:16 ` Jan Böcker
2010-01-02 20:07 ` D M German
2010-01-02 21:17 ` D M German
[not found] ` <86bphbhbmh.fsf@mn.cs.uvic.ca>
2010-01-04 16:09 ` Sebastian Rose
2010-01-02 15:20 ` Darlan Cavalcante Moreira
2010-01-02 19:23 ` Jan Böcker
2010-01-02 20:17 ` D M German
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.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).