It's not clear to me exactly what you want.
If you want a command that never prompts the user, and always uses artika
as the "base" name, then I think you simply need:
(defun artika-workspace ()
(interactive)
(switch-to-buffer (generate-new-buffer "artika")))
This will produce buffers named artika
, artika<2>
, artika<3>
, and so on.
(If you dislike that standard Emacs naming convention, and you really want it to be artika-1
, artika-2
, artika-3
, and so on? Then you'll need to write your own equivalent of generate-new-buffer
and generate-new-buffer-name
.)
Otherwise, the answer by Tobias might be closer to what you want?
EDIT
Based on your comment, I think you want something like:
(defun artika-workspace (&optional base)
(interactive "sBuffer name: ")
(switch-to-buffer
(generate-new-buffer
(if (string-blank-p base) "artika" base))))
The equivalent, using more named intermediate variables, in case you prefer that style:
(defun artika-workspace (&optional base)
(interactive "sBuffer name: ")
(let* ((name (if (string-blank-p base) "artika" base))
(buffer (generate-new-buffer name)))
(switch-to-buffer buffer)))