emacs lisp: how to add to link/hyperlink to another file just like that in *H e l p*

Tag: emacs , elisp Author: sunegar Date: 2011-09-22

we can get help with "C-h ..." and emacs show a Help buffer,and jump to other place with the link . How can I make something like that with elisp, link to another buffer or show something else?

thanks for "button" and "clickable text"
If you're saying that your question has been answered, then accept one of the answers.

Best Answer

The builtin Button package provides a convenient way. For example,

(require 'button)
(insert-button "foo" 'action (lambda (x) (find-file user-init-file)))

will insert a button/link labeled "foo" that when activated (by pressing Enter while point is over the label or middle clicking) will bring up the init file.

Here is another example that mimics a www link,

(insert-button "fsf"
               'action (lambda (x) (browse-url (button-get x 'url)))
               'url "http://www.fsf.org")

See Elisp Reference Manual 38.17 Buttons.

Other Answer1

You are looking at "clickable text"

Read this for more explanation.

Or this if you are going to be using org-mode.