Skip to content

Instantly share code, notes, and snippets.

@rawsyntax
Created June 28, 2011 03:50
Show Gist options
  • Save rawsyntax/1050449 to your computer and use it in GitHub Desktop.
Save rawsyntax/1050449 to your computer and use it in GitHub Desktop.
;;resurrect *scratch* buffer
;; FROM: Morten Welind
;;http://www.geocrawler.com/archives/3/338/1994/6/0/1877802/
(save-excursion
(set-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode)
(make-local-variable 'kill-buffer-query-functions)
(add-hook 'kill-buffer-query-functions 'kill-scratch-buffer))
(defun kill-scratch-buffer ()
;; The next line is just in case someone calls this manually
(set-buffer (get-buffer-create "*scratch*"))
;; Kill the current (*scratch*) buffer
(remove-hook 'kill-buffer-query-functions 'kill-scratch-buffer)
(kill-buffer (current-buffer))
;; Make a brand new *scratch* buffer
(set-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode)
(make-local-variable 'kill-buffer-query-functions)
(add-hook 'kill-buffer-query-functions 'kill-scratch-buffer)
;; Since we killed it, don't let caller do that.
(insert initial-scratch-message)
nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment