15

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?

Eric.Q
  • 703
  • 1
  • 9
  • 21

2 Answers2

14

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.

ayman
  • 1,341
  • 12
  • 22
huaiyuan
  • 26,129
  • 5
  • 57
  • 63
2

You are looking at "clickable text"

Read this for more explanation.

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

Sujoy
  • 8,041
  • 3
  • 30
  • 36