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)))

1 Answer 1

0
(generate-new-buffer-name (or bufrnm "foo"))
4
  • How does the or part work?
    – Dilna
    Jul 24, 2022 at 4:31
  • What does the documentation for or say?
    – db48x
    Jul 24, 2022 at 13:25
  • Returns bufrnm if it is non-nill, else return foo. Not much resemblance to a logical or.
    – Dilna
    Jul 24, 2022 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, 2022 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.