0

Haw can one introduce a button within a dedicated buffer? With a text area in the middle.

Dilna
  • 1,173
  • 3
  • 10
  • `C-h i g(elisp)RET m Making buttons`. – NickD Nov 15 '22 at 20:44
  • 1
    In my opinion, there is nothing simple about creating buttons and forms in Emacs. What helped launch me in the right direction was playing around with this library: https://www.emacswiki.org/emacs/widget-demo.el After you get that semi-working, go ahead and add the tree-mode to the mix which the demo looks for to see if its available. – lawlist Nov 16 '22 at 02:30
  • There are probably multiple questions here. Can you talk more about what you mean by "dedicated buffer"? Inserting a button is a completely separate question from buffer management. – zck Nov 16 '22 at 05:40
  • The button is introduced in a named buffer make by a package, so that buttons are directed to that named buffer, rather than inserted to the current buffer. – Dilna Nov 16 '22 at 07:08

1 Answers1

1

Your elisp code can switch to the buffer, then insert the button.

(let* ((buffer-name "my-buffer-name")
       (window (get-buffer-window buffer-name)))
  (if window
      (select-window window)
    (switch-to-buffer buffer-name))
  (insert-text-button "ohmy"
                      'action (lambda (button) (message "clicked the button!"))))

Note that depending what else is going on, you might have to delete text in that buffer before inserting the button.

zck
  • 8,984
  • 2
  • 31
  • 65