all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Damien Cassou <damien.cassou@gmail.com>
To: emacs-devel@gnu.org
Subject: 2 annoying questions for `find-alternate-file`
Date: Thu, 19 Jul 2012 18:29:34 +0200	[thread overview]
Message-ID: <CA+y5ggibVZgdd0i-Fj76ZU0KcQJhQMGdEKnuuntaBc_qc4Xxqw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]

Hi,

`find-alternate-file` currently asks 2 questions when the current buffer
contains unsaved changes. If you really want what you asked for, you
have to first answer no and then yes:

"Buffer %s is modified; save it first? "           -> no
"Kill and replace the buffer without saving it? "  -> yes

This is annoying. These two questions have already been changed multiple
times and there have already been discussions about it, for
example:

http://lists.gnu.org/archive/html/emacs-devel/2009-09/msg00101.html

I think that's a sign things are too complex.

I propose to replace these 2 questions by just 1 which could be along the
lines of "Do you really want to do what you asked for?". When the user
confirms, his changes are lost. When the user does not confirm, the
process is aborted, giving him a chance to save and try again.

I attach a possible patch.

-- 
Damien Cassou
http://damiencassou.seasidehosting.st

"Lambdas are relegated to relative obscurity until Java makes them
popular by not having them." James Iry

[-- Attachment #2: one-question-for-find-alternate-file.patch --]
[-- Type: application/octet-stream, Size: 808 bytes --]

diff -u /tmp/files-old.el /tmp/files.el
--- /tmp/files-old.el	2012-07-19 18:15:18.181231878 +0200
+++ /tmp/files.el	2012-07-19 18:14:48.653232742 +0200
@@ -1559,11 +1559,9 @@
   (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions)
     (error "Aborted"))
   (when (and (buffer-modified-p) buffer-file-name)
-    (if (yes-or-no-p (format "Buffer %s is modified; save it first? "
+    (unless (yes-or-no-p (format "Buffer %s is modified; are you sure you want to continue? "
 			     (buffer-name)))
-        (save-buffer)
-      (unless (yes-or-no-p "Kill and replace the buffer without saving it? ")
-        (error "Aborted"))))
+        (error "Aborted")))
   (let ((obuf (current-buffer))
 	(ofile buffer-file-name)
 	(onum buffer-file-number)

Diff finished.  Thu Jul 19 18:15:31 2012

             reply	other threads:[~2012-07-19 16:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 16:29 Damien Cassou [this message]
2012-07-19 18:12 ` 2 annoying questions for `find-alternate-file` Thien-Thi Nguyen
2012-07-20 10:09 ` Juri Linkov
2012-10-29  1:27 ` Drew Adams

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

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

  git send-email \
    --in-reply-to=CA+y5ggibVZgdd0i-Fj76ZU0KcQJhQMGdEKnuuntaBc_qc4Xxqw@mail.gmail.com \
    --to=damien.cassou@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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.
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.