all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to make a command ask "You *really* want to do this?"
@ 2003-04-29  1:51 David Combs
  2003-04-29  2:17 ` Jesper Harder
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: David Combs @ 2003-04-29  1:51 UTC (permalink / raw)


I just discovered, to my horror, that C-x C-c does
a save-buffers-exit-emacs (I've always exited by
doing that "by hand", ie M-x save-buff...).

It was only via C-h l (ell) and then C-h k that
I discovered this (yeah, rtfm, David).

Anyway, I do like how C-x n asks if I'm sure that
I really want to narrow; I'd like to get
eg C-x C-c to do the same thing (requiring a
fully-typed-in "yes", maybe even two of them!),

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?

Thanks

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  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
  2003-04-29  8:47 ` Heinz Rommerskirchen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Jesper Harder @ 2003-04-29  2:17 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  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
@ 2003-04-29  8:47 ` Heinz Rommerskirchen
  2003-04-30 22:50   ` Stefan Monnier
  2003-04-29 17:27 ` Eric Hanchrow
  2003-05-13  9:56 ` Per Abrahamsen
  3 siblings, 1 reply; 9+ messages in thread
From: Heinz Rommerskirchen @ 2003-04-29  8:47 UTC (permalink / raw)


dkcombs@panix.com (David Combs) writes:

 
> What methods do *you* use for installing such
> protections-from-oneself?

Years ago I copied the following from the usenet into my .emacs

(setq kill-emacs-query-functions
      (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
	    kill-emacs-query-functions))

But since 21.1 (?) there is the variable confirm-kill-emacs

-- 
Regards

Heinz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  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
  2003-04-29  8:47 ` Heinz Rommerskirchen
@ 2003-04-29 17:27 ` Eric Hanchrow
  2003-04-29 17:41   ` Chris McMahan
  2003-05-13  9:56 ` Per Abrahamsen
  3 siblings, 1 reply; 9+ messages in thread
From: Eric Hanchrow @ 2003-04-29 17:27 UTC (permalink / raw)


>>>>> "David" == David Combs <dkcombs@panix.com> writes:

    David> Anyway, I do like how C-x n asks if I'm sure that I really
    David> want to narrow; I'd like to get eg C-x C-c to do the same
    David> thing (requiring a fully-typed-in "yes", maybe even two of
    David> them!),

Simply "disable" the command, like so:

        (put 'save-buffers-kill-emacs 'disabled 
                "Nobody in their right mind would ever want to kill Emacs.\n")

-- 

      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'
    '---''(_/--'  `-'\_) fL
        -- Igor Pechtchanski

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  2003-04-29 17:27 ` Eric Hanchrow
@ 2003-04-29 17:41   ` Chris McMahan
  0 siblings, 0 replies; 9+ messages in thread
From: Chris McMahan @ 2003-04-29 17:41 UTC (permalink / raw)


Here's some code to do just that...

;;;======================================================================
;;; ask if you REALLY want to quit emacs
;;;======================================================================
(defun ask-before-quit ()
  "Ask if the user really wants to quit Emacs."
  (interactive)
  (y-or-n-p "Really quit emacs? "))

(add-hook 'kill-emacs-query-functions 'ask-before-quit)



Eric Hanchrow <offby1@blarg.net> writes:

> >>>>> "David" == David Combs <dkcombs@panix.com> writes:
> 
>     David> Anyway, I do like how C-x n asks if I'm sure that I really
>     David> want to narrow; I'd like to get eg C-x C-c to do the same
>     David> thing (requiring a fully-typed-in "yes", maybe even two of
>     David> them!),
> 
> Simply "disable" the command, like so:
> 
> (put 'save-buffers-kill-emacs 'disabled 
>         "Nobody in their right mind would ever want to kill Emacs.\n")
> 
> -- 
> 
>       |\      _,,,---,,_
> ZZZzz /,`.-'`'    -.  ;-;;,_
>      |,4-  ) )-,_. ,\ (  `'-'
>     '---''(_/--'  `-'\_) fL
>         -- Igor Pechtchanski

-- 
     (.   .)
  =ooO=(_)=Ooo========================
  Chris McMahan | cmcmahan-AT-one.net
  ====================================

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  2003-04-29  8:47 ` Heinz Rommerskirchen
@ 2003-04-30 22:50   ` Stefan Monnier
  2003-04-30 23:10     ` Henrik Enberg
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2003-04-30 22:50 UTC (permalink / raw)


>>>>> "Heinz" == Heinz Rommerskirchen <Heinrich.Rommerskirchen@siemens.com> writes:
> Years ago I copied the following from the usenet into my .emacs
> (setq kill-emacs-query-functions
>       (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
> 	    kill-emacs-query-functions))

The proper way to write it nowadays is:

  (add-hook 'kill-emacs-query-functions
            (lambda () (yes-or-no-p "Really kill Emacs? ")))


-- Stefan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  2003-04-30 22:50   ` Stefan Monnier
@ 2003-04-30 23:10     ` Henrik Enberg
  0 siblings, 0 replies; 9+ messages in thread
From: Henrik Enberg @ 2003-04-30 23:10 UTC (permalink / raw)


"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:

>>>>>> "Heinz" == Heinz Rommerskirchen <Heinrich.Rommerskirchen@siemens.com> writes:
>> Years ago I copied the following from the usenet into my .emacs
>> (setq kill-emacs-query-functions
>>       (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
>> 	    kill-emacs-query-functions))
>
> The proper way to write it nowadays is:
>
>   (add-hook 'kill-emacs-query-functions
>             (lambda () (yes-or-no-p "Really kill Emacs? ")))

Or in this particular case: 

        (setq confirm-kill-emacs 'yes-or-no-p)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  2003-04-29  1:51 How to make a command ask "You *really* want to do this?" David Combs
                   ` (2 preceding siblings ...)
  2003-04-29 17:27 ` Eric Hanchrow
@ 2003-05-13  9:56 ` Per Abrahamsen
  2003-05-23  6:31   ` David Combs
  3 siblings, 1 reply; 9+ messages in thread
From: Per Abrahamsen @ 2003-05-13  9:56 UTC (permalink / raw)


dkcombs@panix.com (David Combs) writes:

> Anyway, I do like how C-x n asks if I'm sure that
> I really want to narrow; I'd like to get
> eg C-x C-c to do the same thing (requiring a
> fully-typed-in "yes", maybe even two of them!),

M-x disable-command <ret> save-buffers-exit-emacs <ret>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to make a command ask "You *really* want to do this?"
  2003-05-13  9:56 ` Per Abrahamsen
@ 2003-05-23  6:31   ` David Combs
  0 siblings, 0 replies; 9+ messages in thread
From: David Combs @ 2003-05-23  6:31 UTC (permalink / raw)



Thanks for all the suggestions!

David

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-05-23  6:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.