Re: [Orgmode] protocol for PDFs?

2010-01-04 Thread Sebastian Rose
D M German d...@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



___
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


Re: [Orgmode] protocol for PDFs?

2010-01-02 Thread Darlan Cavalcante Moreira

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


___
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


Re: [Orgmode] protocol for PDFs?

2010-01-02 Thread Jan Böcker
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



___
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


Re: [Orgmode] protocol for PDFs?

2010-01-02 Thread D M German

 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 .


___
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


Re: [Orgmode] protocol for PDFs?

2010-01-02 Thread D M German
 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=detailaid=2924825group_id=163434atid=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 .


___
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


Re: [Orgmode] protocol for PDFs?

2010-01-02 Thread D M German

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 .


___
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


Re: [Orgmode] protocol for PDFs?

2010-01-02 Thread D M German




 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

By the way, the way I envision it, xournal will have an option to open
evince in the same page (already implemented), and then one can select
text from the PDF and send it to org.

In xournal one can create a hyperlink to a given page using org, but no
selection is possible (no support in xournal yet).

--dmg


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