org-info.el 2.7 KB

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