3

Would like to use two scratch buffers on two side-by-side windows. How can I do this thing? Can only also ask for more than two scratch buffers that can be named?

2 Answers 2

3

In the first scratch buffer, do C-x 4 b (switch-to-buffer-other-window) and supply second-scratch (or whatever) as argument. In your new buffer, do M-x lisp-interaction-mode and that's it.

Doing this from elisp is an exercise for the reader.

The point is that there is nothing magic about a scratch buffer: it is simply a buffer with major-mode lisp-interaction-mode.

1
  • Would still need some help for a solution.
    – Dilna
    Jun 26, 2022 at 15:32
3

I whipped this up based off of the other answer.

(defun mw::make-scratch-buffer (name)
  (interactive "sNew scratch buffer's name (don't include asterisks): " name)
  (progn (switch-to-buffer-other-window (format "*%s*" name))
         (lisp-interaction-mode)))

Some people might think that automagically adding asterisks like that is annoying. Others might prefer to use switch-to-buffer instead of switch-to-buffer-other-window. But hopefully this is something you and other people can adapt and build on.

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.