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?

Dilna
  • 1,173
  • 3
  • 10

2 Answers2

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.

Fran Burstall
  • 3,665
  • 10
  • 18
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.

Michael Wolf
  • 131
  • 4