emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [ANN] org-docview.el - Link to PDF files from org-mode
@ 2009-08-12 18:25 Jan Böcker
  2009-08-12 18:45 ` Leo
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Böcker @ 2009-08-12 18:25 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-08-13 11:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-12 18:25 [ANN] org-docview.el - Link to PDF files from org-mode Jan Böcker
2009-08-12 18:45 ` 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

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