Mercurial > emacs
annotate lisp/org/org-docview.el @ 111454:6ed4594cb91b
* src/emacs.c (syms_of_emacs) <system-type>: Doc fix.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 09 Nov 2010 19:45:29 -0800 |
parents | 6452d50492bb |
children | 5cb272c831e8 |
rev | line source |
---|---|
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
1 ;;; org-docview.el --- support for links to doc-view-mode buffers |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
2 |
108582
59b9cdd38d70
* lisp/org/org-docview.el: Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents:
107863
diff
changeset
|
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
4 |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
5 ;; Author: Jan Böcker <jan.boecker at jboecker dot de> |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
6 ;; Keywords: outlines, hypermedia, calendar, wp |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
7 ;; Homepage: http://orgmode.org |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
8 ;; Version: 7.01 |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
9 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
11 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
15 ;; (at your option) any later version. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
16 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
21 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
25 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
26 ;;; Commentary: |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
27 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
28 ;; This file implements links to open files in doc-view-mode. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
29 ;; Org-mode loads this module by default - if this is not what you want, |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
30 ;; configure the variable `org-modules'. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
31 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
32 ;; The links take the form |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
33 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
34 ;; docview:<file path>::<page number> |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
35 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
36 ;; for example: [[docview:~/.elisp/org/doc/org.pdf::1][Org-Mode Manual]] |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
37 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
38 ;; Autocompletion for inserting links is supported; you will be |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
39 ;; prompted for a file and a page number. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
40 ;; |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
41 ;; If you use org-store-link in a doc-view mode buffer, the stored |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
42 ;; link will point to the current page. |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
43 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
44 ;;; Code: |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
45 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
46 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
47 (require 'org) |
109823
6452d50492bb
Fix some more Org `check-declare' issues.
Glenn Morris <rgm@gnu.org>
parents:
109462
diff
changeset
|
48 (eval-when-compile (require 'doc-view)) ; doc-view-current-page macro |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
49 |
109823
6452d50492bb
Fix some more Org `check-declare' issues.
Glenn Morris <rgm@gnu.org>
parents:
109462
diff
changeset
|
50 (autoload 'doc-view-goto-page "doc-view") |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
51 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
52 (org-add-link-type "docview" 'org-docview-open) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
53 (add-hook 'org-store-link-functions 'org-docview-store-link) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
54 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
55 (defun org-docview-open (link) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
56 (when (string-match "\\(.*\\)::\\([0-9]+\\)$" link) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
57 (let* ((path (match-string 1 link)) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
58 (page (string-to-number (match-string 2 link)))) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
59 (org-open-file path 1) ;; let org-mode open the file (in-emacs = 1) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
60 ;; to ensure org-link-frame-setup is respected |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
61 (doc-view-goto-page page) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
62 ))) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
63 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
64 (defun org-docview-store-link () |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
65 "Store a link to a docview buffer." |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
66 (when (eq major-mode 'doc-view-mode) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
67 ;; This buffer is in doc-view-mode |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
68 (let* ((path buffer-file-name) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
69 (page (doc-view-current-page)) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
70 (link (concat "docview:" path "::" (number-to-string page))) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
71 (description "")) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
72 (org-store-link-props |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
73 :type "docview" |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
74 :link link |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
75 :description path)))) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
76 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
77 (defun org-docview-complete-link () |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
78 "Use the existing file name completion for file. |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
79 Links to get the file name, then ask the user for the page number |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
80 and append it." |
107863
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
81 (concat (replace-regexp-in-string "^file:" "docview:" (org-file-complete-link)) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
82 "::" |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
83 (read-from-minibuffer "Page:" "1"))) |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
84 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
85 |
594e81986a75
2010-04-10 Carsten Dominik <carsten.dominik@gmail.com>
Carsten Dominik <carsten.dominik@gmail.com>
parents:
diff
changeset
|
86 (provide 'org-docview) |
109462
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
87 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
88 ;; arch-tag: dd147a78-cce1-481b-b40a-15869417debe |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
89 |
a150e8a14679
Install version 7.01 of Org-mode
Carsten Dominik <carsten.dominik@gmail.com>
parents:
108582
diff
changeset
|
90 ;;; org-docview.el ends here |