views:

152

answers:

1

I'm trying to figure out how the "hyperlink" works in the *Help* buffer (so that I can implement something similar in the output of M-x compile). Here is a more detailed description of the behaviour I want to imitate: M-x describe-function find-file opens up a *Help* buffer. The first line of this buffer (for me) shows: find-file is an interactive Lisp function in files.el. files.el is underlined and clicking (or hitting enter when point is there) opens a new buffer with files.el and the point positioned at the definition of find-file. Doing a describe-key for says invokes push-button in button.el, which tells me Perform the action specified by a button at location pos - but how do I define a button and associate an action with that button in my own buffer?

+2  A: 

The major mode of the *Help* buffers is help-mode. In its source code (help-mode.el), you find function help-make-xrefs that "Parse[s] and hyperlink[s] documentation cross-references in the given BUFFER". You may check it how it was implemented.

Otherwise, I'd suggest using org-mode instead, which uses the simple form [[URI][caption]] to mark hyperlinks.

Török Gábor
Thank you, that helped. I debugged the code in compile mode, realised there is a way for me to specify a regexp (in compilation-error-regexp-alist) that'll allow me to add additional patterns which would be used by compile mode to create cross references.
Rohith