12
votes

I maintain a diary (internal blog containing thoughts to remember) in org-mode, and sometimes, as i study Emacs, i store learned skills and tricks with references to info files.

Currently i do the following. I open the needed info file, press c to copy current node name, press < s TAB - that is an easy template which unwraps into a src-block. Then i add lisp expression and paste node name and finally the link looks like this:

#+begin_src emacs-lisp
(info "(org) Properties and Columns")
#+end_src

When i need to view the info file, i put cursor after lisp sexp and press C-x C-e (eval-last-sexp).

This process is tedious and inelegant. What is the best way to embed links to info files in org-mode?

Edit: I've found how one can add links to info nodes. Org-mode manual on External links describes these equivalent methods using links:

[[info:org#Tags]]
[[elisp:(info "(org) Tags")]]

With the first variant i'm not sure how to automatically transform (org) Tags in org#Tags. How can i further simplify this process?

3

3 Answers

12
votes

You do it as in any of the supported link types (see the "Handling links" section in the manual). In the info file, you say M-x org-store-link, (bind it to C-c l as suggested in the manual) and then in your org file, you insert the link with C-c C-l. There you just have to select the link to your info file from the list of stored links.

1
votes

org-store-link says "Cannot link to a buffer which is not visiting a file" when visiting an Info page because Info sets the buffer-name to *info* and the buffer-file-name to nil. To work around this, the community contributed example of how to add linking to man pages (http://orgmode.org/manual/Adding-hyperlink-types.html) can be modified slightly:

;; Modified version of contrib/lisp/org-man.el; see
;; (http://orgmode.org/manual/Adding-hyperlink-types.html#Adding-hyperlink-types)
(require 'org)

(org-add-link-type "info" 'org-info-open)
(add-hook 'org-store-link-functions 'org-info-store-link)

(defcustom org-info-command 'info
  "The Emacs command to be used to display an info page."
  :group 'org-link
  :type '(choice (const info)))

(defun org-info-open (path)
  "Visit the infopage on PATH.
   PATH should be a topic that can be thrown at the info command."
  (funcall org-info-command path))

(defun org-info-store-link ()
  "Store a link to an info page."
  (when (memq major-mode '(Info-mode))
    ;; This is a info page, we do make this link
    (let* ((page (org-info-get-page-name))
           (link (concat "info:" page))
           (description (format "Infopage for %s" page)))
      (org-store-link-props
       :type "info"
       :link link
       :description description))))

(defun org-info-get-page-name ()
  "Extract the page name from Info in a hackish way."
  ;; This works for `Info-mode'.
  ;; Hackity-hack: copy the node name into the kill ring.
  (Info-copy-current-node-name)
  ;; Just return the kill.
  (current-kill 0))

(provide 'org-info)

The important bit is near the end: since the info node name is not directly accessible (not that I could easily find), we can work around it by calling Info-copy-current-node-name to put it in the kill-ring, then return the first entry in the kill-ring (which should be the just inserted node name).

1
votes

The step that should work - go to info node you need then press just 'c' (node-name will be entry to kill ring) - on your org source-file go to point you need to insert the link press C-c,C-l - press Tab then select elisp: from prompted buffer shown (or any kind of link you need).Now your prompt in mini-buffer say elisp: - entry this context after that ':' (info "^") ,let ^ be your node-name yank back by C-y - press Ret ,then you'll be ask for some description just fill it with your own. Now you are done with it ,but still don't know what happen really. - M-x,visibility-mode,And there how to write that content manually and we are now came to conclusion that "%20" must be replace every occurence of space in the context. eg.==> do it yourself ,see it yourself - switch back your visibility-mode GoodLuck