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?
Asked
Active
Viewed 238 times
4
-
3[28.7 Bug Reference](https://www.gnu.org/software/emacs/manual/html_node/emacs/Bug-Reference.html): “*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 https://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 Jun 19 '23 at 05: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. – dalanicolai Jun 19 '23 at 08:50
-
I'd never thought of using bug-reference-mode for this. That's a neat idea. – phils Jun 19 '23 at 09:37
-
https://emacs.stackexchange.com/tags/elisp/info – Drew Jun 19 '23 at 14:39
2 Answers
3
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.

phils
- 48,657
- 3
- 76
- 115
-
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. – dalanicolai Jun 19 '23 at 08:13
-
@dalanicolai : You can bind, say, `C-
` 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 Jun 19 '23 at 11:26 -
I find that this is also [how Emacs maintainers do](https://git.savannah.gnu.org/cgit/emacs.git/tree/.dir-locals.el#n2). – shynur Jun 30 '23 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")
.

shynur
- 4,065
- 1
- 3
- 23
-
1This is just a clickable version of @phils' answer. If you want, you can implement it like `info#elisp"Invisible Text"`. – shynur Jun 19 '23 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 press `c` in the info buffer to get the correct 'link format'. Thanks for this very good suggestion... – dalanicolai Jun 19 '23 at 11:55