[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dumb question #143 -- How do I get the *scratch* window back ??
From: |
Amy Templeton |
Subject: |
Re: Dumb question #143 -- How do I get the *scratch* window back ?? |
Date: |
Wed, 02 May 2007 02:15:41 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
William Case wrote:
> I have been inadvertently deleting my "scratch* window.
> How do I get it back?
You can add the following code to your .emacs file (taken
from either the emacs wiki or from some useful person's
website...apologies to whomever is going uncredited here).
The effect of this is to grant you an immortal scratch
buffer. Once killed, it rise from the ashes, albeit empty.
Enjoy!
Code:
_________________________________________________________________
;;; Immortal scratch buffer
(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 ()
;; 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.
nil)
_________________________________________________________________
Amy
P.S.: You do need to include both the defun and the first
stanza; the part before the defun adds a hook to your
current scratch buffer's kill-buffer-query-functions
which will call the program defined in the defun if
the buffer is killed, which creates a new scratch
buffer and adds a hook to your new scratch buffer's
kill-buffer-query-functions which will call the
program defined in the defun, which...
- Dumb question #143 -- How do I get the *scratch* window back ??, William Case, 2007/05/02
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, Thien-Thi Nguyen, 2007/05/02
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, William Case, 2007/05/02
- Message not available
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, Thien-Thi Nguyen, 2007/05/02
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, weber, 2007/05/02
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, William Case, 2007/05/02
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, Mark Elston, 2007/05/03
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, William Case, 2007/05/03
- Message not available
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, weber, 2007/05/03
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, William Case, 2007/05/04
- Message not available
- Re: Dumb question #143 -- How do I get the *scratch* window back ??, Mark Elston, 2007/05/04