emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Jan Böcker" <lists.jan@jboecker.de>
To: emacs-orgmode@gnu.org
Subject: [ANN] org-docview.el - Link to PDF files from org-mode
Date: Wed, 12 Aug 2009 20:25:10 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.0908122019590.9803@localhost.localdomain> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1003 bytes --]

Hello,

the new doc-view-mode in emacs 23 can be used to view DVI, PDF and 
PostScript files. I have written a custom link type for org-mode to allow 
linking to those files from org-mode.

This is the first thing besides .emacs customization that I have written 
in elisp; as such, any feedback would be much appreciated.
I have only tested it with PDF files so far, but it should work with 
anything doc-view-mode can display.

The attached file adds support for org-store-link inside doc-view-mode 
buffers. The link syntax is:
 	docview:/path/to/file.pdf:<page>
where <page> is the page number to visit.

To use it, copy it to your load path as org-docview.el and add

 	(require 'org-docview)

to your .emacs file.

I'd also like to suggest to integrate this functionality into the 
standard org-mode distribution, as emacs 23 includes doc-view-mode by default.

I am releasing the code under the terms of the GNU General Public License, 
Version 3 or later.

Jan Böcker

[-- Attachment #2: Type: TEXT/PLAIN, Size: 969 bytes --]

;;; org-docview.el --- support for links to doc-view-mode buffers

(require 'org)

(org-add-link-type "docview" 'org-docview-open)
(add-hook 'org-store-link-functions 'org-docview-store-link)

(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)
      ;; so that org-link-frame-setup is respected
      (doc-view-goto-page page)
      )))

(defun org-docview-store-link ()
  "Store a link to a docview buffer"
  (when (eq major-mode 'doc-view-mode)
    ;; This buffer is in doc-view-mode
    (let* ((path buffer-file-name)
	   (page (doc-view-current-page))
	   (link (concat "docview:" path ":" (number-to-string page)))
	   (description ""))
      (org-store-link-props
       :type "docview"
       :link link))))

(provide 'org-docview)

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

             reply	other threads:[~2009-08-12 18:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-12 18:25 Jan Böcker [this message]
2009-08-12 18:45 ` [ANN] org-docview.el - Link to PDF files from org-mode Leo
2009-08-12 19:30   ` doc-view-mode (was: Re: [ANN] org-docview.el - Link to PDF files from org-mode) Óscar Fuentes
2009-08-12 19:45     ` Leo
2009-08-12 20:28       ` doc-view-mode Óscar Fuentes
2009-08-12 21:19     ` doc-view-mode Tassilo Horn
2009-08-12 22:26       ` doc-view-mode Óscar Fuentes
2009-08-13 11:11         ` doc-view-mode Tassilo Horn
2009-08-12 21:33   ` Re: [ANN] org-docview.el - Link to PDF files from org-mode Carsten Dominik
2009-08-12 23:50     ` Leo

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.orgmode.org/

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

  git send-email \
    --in-reply-to=alpine.LNX.2.00.0908122019590.9803@localhost.localdomain \
    --to=lists.jan@jboecker.de \
    --cc=emacs-orgmode@gnu.org \
    /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/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).