help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make a command ask "You *really* want to do this?"


From: Jesper Harder
Subject: Re: How to make a command ask "You *really* want to do this?"
Date: Tue, 29 Apr 2003 04:17:50 +0200
User-agent: Gnus/5.09002 (Oort Gnus v0.20) Emacs/21.3.50 (gnu/linux)

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 <return> 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".


reply via email to

[Prev in Thread] Current Thread [Next in Thread]