org-info.el 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.02b
  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. "Store a link to an INFO folder or message."
  40. (when (eq major-mode 'Info-mode)
  41. (let (link desc)
  42. (setq link (org-make-link "info:"
  43. (file-name-nondirectory Info-current-file)
  44. ":" Info-current-node))
  45. (setq desc (concat (file-name-nondirectory Info-current-file)
  46. ":" Info-current-node))
  47. (org-store-link-props :type "info" :file Info-current-file
  48. :node Info-current-node
  49. :link link :desc desc)
  50. link)))
  51. (defun org-info-open (path)
  52. "Follow an Info file and node link specified by PATH."
  53. (org-info-follow-link path))
  54. (defun org-info-follow-link (name)
  55. "Follow an Info file and node link specified by NAME."
  56. (if (or (string-match "\\(.*\\)::?\\(.*\\)" name)
  57. (string-match "\\(.*\\)" name))
  58. (progn
  59. (require 'info)
  60. (if (match-string 2 name) ; If there isn't a node, choose "Top"
  61. (Info-find-node (match-string 1 name) (match-string 2 name))
  62. (Info-find-node (match-string 1 name) "Top")))
  63. (message "Could not open: %s" name)))
  64. (provide 'org-info)
  65. ;; arch-tag: 1e289f54-7176-487f-b575-dd4854bab15e
  66. ;;; org-info.el ends here