unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jesper Harder <harder@myrealbox.com>
Subject: Re: How to make a command ask "You *really* want to do this?"
Date: Tue, 29 Apr 2003 04:17:50 +0200	[thread overview]
Message-ID: <m3llxu9hdd.fsf@defun.localdomain> (raw)
In-Reply-To: <b8klqf$s2e$1@panix1.panix.com> (David Combs's message of "28 Apr 2003 21:51:11 -0400")

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	other threads:[~2003-04-29  2:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-29  1:51 How to make a command ask "You *really* want to do this?" David Combs
2003-04-29  2:17 ` Jesper Harder [this message]
2003-04-29  8:47 ` Heinz Rommerskirchen
2003-04-30 22:50   ` Stefan Monnier
2003-04-30 23:10     ` Henrik Enberg
2003-04-29 17:27 ` Eric Hanchrow
2003-04-29 17:41   ` Chris McMahan
2003-05-13  9:56 ` Per Abrahamsen
2003-05-23  6:31   ` David Combs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3llxu9hdd.fsf@defun.localdomain \
    --to=harder@myrealbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).