0

Is it possible for emacs to give me a unique name for a buffer? I am making some new buffers and want to automatically name it without asking the user for a name.

Have started with the following

(defun workspace ()
  "todo"
  (interactive)
  (switch-to-buffer-other-window name)
  (with-current-buffer buffer
    (lisp-interaction-mode)) )

(defun new-buffer ()
  "Open a new empty buffer."
  (interactive)
  (let ( ($buf (generate-new-buffer "untitled")) )
    ;; switch to buffer
    (switch-to-buffer $buf)
    (funcall (and lisp-interaction-mode))))

I want the user to either accept the unique name or write one himself.

Dilna
  • 1,173
  • 3
  • 10
  • I think if you had searched for other questions about unique buffer names then you would have found the answer already. – db48x Jun 26 '22 at 17:51
  • There are some descriptions but not many implementation examples – Dilna Jun 26 '22 at 18:20
  • Here is a link to an example that uses a hard-coded specific name and then concatenates an integer to create a unique buffer name: https://emacs.stackexchange.com/a/16493/2287 – lawlist Jun 26 '22 at 19:23
  • Each of them has documentation that you can access with `C-h f`. Read them, decide which function does what you want, and proceed. – db48x Jun 26 '22 at 20:46
  • I shall proceed with `generate-new-buffer` because it always creates a new buffer and gives it a unique name. – Dilna Jun 26 '22 at 20:57
  • Then you have found your solution as was foretold by the ancient prophecies. – db48x Jun 26 '22 at 21:13
  • Indeed. My life is spared. – Dilna Jun 26 '22 at 21:30

0 Answers0