4

It is easy to find how to create links to info nodes from elisp docstrings and from org-mode files. Is there also a standard way to link to an info node section from elisp comments?

4
  • 3
    28.7 Bug Reference: “For example, let’s assume in our project, we usually write references to bug reports as bug#1234, or Bug-1234 and that this bug’s page on the issue tracker is project.org/issues/1234, then these local variables section would do. ... Note that bug-reference-url-format may also be a function in order to cater for more complex scenarios, e.g., when different parts of the bug reference have to be used to distinguish between issues and merge requests resulting in different URLs.” may help.
    – shynur
    Commented Jun 19, 2023 at 5:50
  • Nice, I did not know about bug-reference mode. Indeed, it should be possible to use it by adding an appropriate 'browse url handler'. However, then it would probably be nicer to create a separate 'info-reference-mode', or buttonize some 'info url' by default in emacs-lisp-mode directly. For now, I will simply go with the M-: variant of @phils answer. Commented Jun 19, 2023 at 8:50
  • I'd never thought of using bug-reference-mode for this. That's a neat idea.
    – phils
    Commented Jun 19, 2023 at 9:37
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Commented Jun 19, 2023 at 14:39

2 Answers 2

4

In comments I just write this:

;; See (info "(elisp) Invisible Text")

And then I just evaluate that with C-xC-e if I want to view that node.

3
  • Thanks! Indeed, I am using See 'M-: (info "(elisp) Invisible Text")'. I wondered if there was a 'clickable' version, and this answer more or less 'confirms' that there isn't. Commented Jun 19, 2023 at 8:13
  • @dalanicolai : You can bind, say, C-<down-mouse-1> to a function which will evaluate (info "(elisp) Invisible Text") in this example. This is also clickable to some extent. |||| Or you can see my answer, although it's a bit of a hassle.
    – shynur
    Commented Jun 19, 2023 at 11:26
  • I find that this is also how Emacs maintainers do.
    – shynur
    Commented Jun 30, 2023 at 23:22
3

Need a bit of dirty work: modify the definition of one function in bug-reference.el. (I'm just making a demonstration here. You should modify it according to your needs.) (BTW, this is one of the benefits of open source -- modify the code as you wish.)

(defun bug-reference-push-button (&optional pos _use-mouse-action)
  ;; ... ...
  (when url ; The following is what you need to modify:
    (if (string-match-p "^(info \".+?\")$" url)
        (eval (read url))
      (browse-url url))))))) ; (defun ...) ends here

Then eval:

(setq-local bug-reference-bug-regexp "\\(\\((info \".+?\")\\)\\)"
            bug-reference-url-format "%s")
(bug-reference-mode)

in your working buffer. (Of course, you can use file local variables, which are more elegant.)

Now you can click what @phils wrote down in his answer: ;; See (info "(elisp) Invisible Text").

2
  • 1
    This is just a clickable version of @phils' answer. If you want, you can implement it like info#elisp"Invisible Text".
    – shynur
    Commented Jun 19, 2023 at 11:18
  • 1
    Changing the bug-reference-push-button also is a nice solution indeed (although maybe a little less 'consistent' than adding a url-handler), also because one can just press c in the info buffer to get the correct 'link format'. Thanks for this very good suggestion... Commented Jun 19, 2023 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.