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?
2 Answers
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.
-
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.– shynurCommented Jun 19, 2023 at 11:26 -
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")
.
-
1This is just a clickable version of @phils' answer. If you want, you can implement it like
info#elisp"Invisible Text"
.– shynurCommented Jun 19, 2023 at 11:18 -
1Changing 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 pressc
in the info buffer to get the correct 'link format'. Thanks for this very good suggestion... Commented Jun 19, 2023 at 11:55
M-:
variant of @phils answer.