0

This function makes a new named buffer that can run shell commands. But it only works properly when no argument is passed. When an argument is passed or set through the interactive clause, I would like that the buffer name takes the argument value for the name rather than the current (generate-new-buffer-name "foo").

(defun galaxy-shell (&optional bufrnm)
  "TODO"

(interactive "s Buffer_name: ")

(let ( (bufrnm (generate-new-buffer-name "foo")) ) (shell bufrnm)))

Dilna
  • 1
  • 3
  • 11

1 Answers1

0
(generate-new-buffer-name (or bufrnm "foo"))
db48x
  • 17,977
  • 1
  • 22
  • 28
  • How does the or part work? – Dilna Jul 24 '22 at 04:31
  • What does the documentation for or say? – db48x Jul 24 '22 at 13:25
  • Returns bufrnm if it is non-nill, else return foo. Not much resemblance to a logical or. – Dilna Jul 24 '22 at 14:16
  • 1
    Logical or bitwise or is a much more niche operator. A programmer can go their whole lives without needing it, but boolean or is much more widely used. Elisp does have logor should you ever need it. If you pay attention, you will notice that most languages make the same choice to separate them. C has || for boolean or and | for bitwise or, for example, but the one you use most often has more characters to type. – db48x Jul 24 '22 at 15:28