I'm trying to create *Help* buffers in Emacs, documenting functions defined in other languages.

I can create a simple help buffer easily:

(defun wh/help-hello-world ()
  (with-help-window (help-buffer)
    (princ "foo_bar is a function.\n\nIt does stuff.")))

However, I want to add a clickable link in my *Help* buffer, which Emacs seems to call a button. I can see describe-function-1 calls help-xref-button which creates a button.

However, if I call insert-text-button the same way help-xref-button creates buttons, then 'help-args seems to expect an elisp function and path.

(defun wh/help-hello-world-button ()
  (let ((buf (help-buffer)))
    (with-help-window buf
      (princ "foo_bar is a function.\n\nIt does stuff."))
    (with-current-buffer buf
      (let ((inhibit-read-only t))
         'type 'help-function-def
         'help-args '(button-type-subtype-p "/usr/share/emacs/24.5/lisp/button.el.gz"))))))

How can I create an Emacs button pointing to an arbitrary line in an arbitrary file?

1 Answer 1


You can use both make-button or make-text-button. For example

(defun button-pressed (button)
  (message (format "Button pressed!")))

(define-button-type 'custom-button
  'action 'button-pressed
  'follow-link t
  'help-echo "Click Button"
  'help-args "test")

(make-button 1 10 :type 'custom-button)

This will create a button at char 1 to 10 in the current buffer.

  • 2
    Works really well! Is the 'help-args value actually used anywhere? Commented Aug 21, 2016 at 17:09
  • 2
    Aha, it can be accessed using button-get. Commented Aug 22, 2016 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.