EDIT in response to your 'extended/edited' question
I think you should think about how to simplify this yourself. But let me show you two options, then you can come up with, arguably, the most straightforward simplification, using if
i.c.w. or
(shell
(generate-new-buffer-name
(pcase buffer-name
((or "" (pred null)) "galaxy")
(name name))))
or
(when (string-blank-p buffer-name)
(setq buffer-name nil))
(shell
(generate-new-buffer-name
(or buffer-name "galaxy")))
You can clean it up a little more by making the buffer-name
argument mandatory, so that you do not have to check for the argument being nil.
END EDIT
I would suggest that you experiment a little using the scratch buffer
(defun galaxy-shell (&optional buffer-name)
(interactive "sEnter buffer name: ")
(print buffer-name))
Try calling it interactively and non-interactively (as making the argument optional suggests that you would like to support non-interactive calls also).
Now that you have checked the 'empty' value(s) of buffer-name
, have a look at string-empty-p
(and null
).