From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Jesper Harder Newsgroups: gmane.emacs.help Subject: Re: How to make a command ask "You *really* want to do this?" Date: Tue, 29 Apr 2003 04:17:50 +0200 Organization: http://purl.org/harder/ Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1051582769 29066 80.91.224.249 (29 Apr 2003 02:19:29 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 29 Apr 2003 02:19:29 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 29 04:19:26 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19AKiL-0007YX-00 for ; Tue, 29 Apr 2003 04:19:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19AKjB-0002io-09 for gnu-help-gnu-emacs@m.gmane.org; Mon, 28 Apr 2003 22:20:17 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!news.tele.dk!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: (David Combs's message of "28 Apr 2003 21:51:11 -0400") X-Face: ^RrvqCr7c,P$zTR:QED"@h9+BTm-"fjZJJ-3=OU7.)i/K]<.J88}s>'Z_$r; List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:8976 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:8976 dkcombs@panix.com (David Combs) writes: > Especially when it's late late at night, eg 4am, and I'm dead tired, > and don't want some knee-jerk or "y", etc, to result in a > sometimes very-unpleasant surprise. > > (Especially since (1) I tend to keep emacs "up" for days at a time, > and (2) I often keep various things *scratch*.) > > What methods do *you* use for installing such > protections-from-oneself? Yeah, I like to protect *scratch*, too. I have this in my .emacs to make Emacs query before killing *scratch*: (defun jh-setup-scratch () (with-current-buffer "*scratch*" (setq buffer-offer-save t) (make-local-variable 'kill-buffer-query-functions) (setq kill-buffer-query-functions (list (lambda () (if (buffer-modified-p) (y-or-n-p "Really kill buffer? ") t)))))) (add-hook 'emacs-startup-hook 'jh-setup-scratch) Change `y-or-n-p' to `yes-or-no-p' if you'd prefer to answer "yes"/"no".