Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs lisp how to insert-button into a temporary buffer without switching to it

Tags:

emacs

elisp

I'm new to Elisp. Was trying out the following code to insert clickable buttons into a temporary buffer

(with-output-to-temp-buffer "*tmp*"
  (insert-button "My Button"))

It doesn't work this way, the button got created in current buffer instead of tmp. Then I tried modifying code to following

(with-output-to-temp-buffer "*tmp*"
  (toggle-read-only)
  (insert-button "My Button"))

Unfortunately "toggle-read-only" seems only to toggle read-only for current buffer NOT tmp.

Is there any way I could achieve this - to insert button directly into a temporary buffer without actually switching the cursor focus to it?

like image 220
Shawn Avatar asked Sep 12 '25 13:09

Shawn


1 Answers

Here's the code:

(with-current-buffer (get-buffer-create "*tmp*")
  (insert-button "My Button"))
like image 143
abo-abo Avatar answered Sep 14 '25 06:09

abo-abo