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