Commit | Line | Data |
---|---|---|
20908596 CD |
1 | ;;; org-info.el --- Support for links to Info nodes from within Org-Mode |
2 | ||
114f9c96 | 3 | ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
1e4f816a | 4 | ;; Free Software Foundation, Inc. |
20908596 CD |
5 | |
6 | ;; Author: Carsten Dominik <carsten at orgmode dot org> | |
7 | ;; Keywords: outlines, hypermedia, calendar, wp | |
8 | ;; Homepage: http://orgmode.org | |
ed21c5c8 | 9 | ;; Version: 6.35i |
20908596 CD |
10 | ;; |
11 | ;; This file is part of GNU Emacs. | |
12 | ;; | |
b1fc2b50 | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
20908596 | 14 | ;; it under the terms of the GNU General Public License as published by |
b1fc2b50 GM |
15 | ;; the Free Software Foundation, either version 3 of the License, or |
16 | ;; (at your option) any later version. | |
20908596 CD |
17 | |
18 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;; GNU General Public License for more details. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
b1fc2b50 | 24 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
20908596 CD |
25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
26 | ;; | |
27 | ;;; Commentary: | |
28 | ||
29 | ;; This file implements links to Info nodes from within Org-mode. | |
30 | ;; Org-mode loads this module by default - if this is not what you want, | |
31 | ;; configure the variable `org-modules'. | |
32 | ||
33 | ;;; Code: | |
34 | ||
35 | (require 'org) | |
36 | ||
37 | ;; Declare external functions and variables | |
38 | ||
39 | (declare-function Info-find-node "info" (filename nodename | |
40 | &optional no-going-back)) | |
41 | (defvar Info-current-file) | |
42 | (defvar Info-current-node) | |
43 | ||
44 | ;; Install the link type | |
45 | (org-add-link-type "info" 'org-info-open) | |
46 | (add-hook 'org-store-link-functions 'org-info-store-link) | |
47 | ||
48 | ;; Implementation | |
49 | (defun org-info-store-link () | |
50 | "Store a link to an Info file and node." | |
20908596 CD |
51 | (when (eq major-mode 'Info-mode) |
52 | (let (link desc) | |
53 | (setq link (org-make-link "info:" | |
54 | (file-name-nondirectory Info-current-file) | |
55 | ":" Info-current-node)) | |
56 | (setq desc (concat (file-name-nondirectory Info-current-file) | |
57 | ":" Info-current-node)) | |
58 | (org-store-link-props :type "info" :file Info-current-file | |
59 | :node Info-current-node | |
60 | :link link :desc desc) | |
61 | link))) | |
62 | ||
63 | (defun org-info-open (path) | |
64 | "Follow an Info file and node link specified by PATH." | |
65 | (org-info-follow-link path)) | |
66 | ||
67 | ||
68 | (defun org-info-follow-link (name) | |
69 | "Follow an Info file and node link specified by NAME." | |
70 | (if (or (string-match "\\(.*\\)::?\\(.*\\)" name) | |
71 | (string-match "\\(.*\\)" name)) | |
72 | (progn | |
73 | (require 'info) | |
74 | (if (match-string 2 name) ; If there isn't a node, choose "Top" | |
75 | (Info-find-node (match-string 1 name) (match-string 2 name)) | |
76 | (Info-find-node (match-string 1 name) "Top"))) | |
77 | (message "Could not open: %s" name))) | |
78 | ||
79 | (provide 'org-info) | |
80 | ||
88ac7b50 | 81 | ;; arch-tag: 1e289f54-7176-487f-b575-dd4854bab15e |
b349f79f | 82 | |
20908596 | 83 | ;;; org-info.el ends here |