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