From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Amy Templeton Newsgroups: gmane.emacs.help Subject: Re: Dumb question #143 -- How do I get the *scratch* window back ?? Date: Wed, 02 May 2007 02:15:41 -0400 Message-ID: <87lkg7hhte.fsf@gmail.com> References: <1178078755.3157.54.camel@CASE> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1178086242 15702 80.91.229.12 (2 May 2007 06:10:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 2 May 2007 06:10:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 02 08:10:39 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hj82w-0007bl-HK for geh-help-gnu-emacs@m.gmane.org; Wed, 02 May 2007 08:10:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hj89J-0002wX-EN for geh-help-gnu-emacs@m.gmane.org; Wed, 02 May 2007 02:17:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hj895-0002uo-At for help-gnu-emacs@gnu.org; Wed, 02 May 2007 02:16:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hj893-0002uK-S0 for help-gnu-emacs@gnu.org; Wed, 02 May 2007 02:16:59 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hj893-0002uH-Ml for help-gnu-emacs@gnu.org; Wed, 02 May 2007 02:16:57 -0400 Original-Received: from ag-out-0708.google.com ([72.14.246.240]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hj82f-0001RY-Jv for help-gnu-emacs@gnu.org; Wed, 02 May 2007 02:10:21 -0400 Original-Received: by ag-out-0708.google.com with SMTP id 23so57143agd for ; Tue, 01 May 2007 23:10:20 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:to:subject:references:from:x-now-playing:emacs:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=LCRrUOwT/NP2aZf3nXD6taYVL3JedaZWSiLlwXxeLC5lpDPsaDOfdMApkGg27hCrh0pvdpGKLCMuZZ2gd4ANC42rw8LLv1ogPJbiD9eRq/kH1fw1cRL/kZyPmuo3z8Zyzzmiq6sh2A4k+NL6PeJQkBYl5XCjl2C8DxI5BEhU63w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:to:subject:references:from:x-now-playing:emacs:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=S/6URQaZmOnU7xWvEDDJ2nD2KepWCwuUNgR+W+8+ugbgo7h5hAzzmzQRNjf65v68HZ2z1uqNxRkyk5J8aXCTyoHAFbZakYM5VJLEjEDWuQmvcBKcNQbz+dvk3JPlJljk0jYeYvjw0fUQvT8Gjvt2JfzIhx/eX42CJaHeqSHjR+0= Original-Received: by 10.101.68.18 with SMTP id v18mr190008ank.1178086220766; Tue, 01 May 2007 23:10:20 -0700 (PDT) Original-Received: from localhost ( [132.162.245.60]) by mx.google.com with ESMTP id c28sm770632anc.2007.05.01.23.10.19; Tue, 01 May 2007 23:10:20 -0700 (PDT) X-Now-Playing: Nothing playing right now Emacs: never had it, never will. In-Reply-To: <1178078755.3157.54.camel@CASE> (William Case's message of "Wed\, 02 May 2007 00\:05\:55 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-detected-kernel: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:43468 Archived-At: 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...