Skip to content

Instantly share code, notes, and snippets.

@magnars
Created October 12, 2012 10:27
Show Gist options
  • Save magnars/3878594 to your computer and use it in GitHub Desktop.
Save magnars/3878594 to your computer and use it in GitHub Desktop.
create-scratch-buffer
(defun create-scratch-buffer nil
"create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
(interactive)
(let ((n 0)
bufname)
(while (progn
(setq bufname (concat "*scratch"
(if (= n 0) "" (int-to-string n))
"*"))
(setq n (1+ n))
(get-buffer bufname)))
(switch-to-buffer (get-buffer-create bufname))
(emacs-lisp-mode)
))
@skeeto
Copy link

skeeto commented Oct 12, 2012

How about this, letting Emacs uniquely name the buffer for you?

(defun create-scratch-buffer ()
  (interactive)
  (switch-to-buffer (generate-new-buffer "*scratch*"))
  (emacs-lisp-mode))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment