unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Juri Linkov <juri@jurta.org>,
	ams@gnu.org, emacs-devel@gnu.org, Miles Bader <miles@gnu.org>
Subject: Re: C-x C-b and C-x C-f bugging about confirmation
Date: Mon, 24 Nov 2008 00:21:00 -0500	[thread overview]
Message-ID: <87y6z9k8cj.fsf@cyd.mit.edu> (raw)
In-Reply-To: <jwv1vx1izjf.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 23 Nov 2008 22:18:10 -0500")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Alan Mackenzie's tweak to the [Confirm] prompt seems like an excellent
>> solution to this problem though.
>
> Indeed, it would cover 99% of my cases.

See attached patch (necessary doc changes not included).  Any
objections?

*** trunk/lisp/files.el.~1.1018.~	2008-11-22 16:48:15.000000000 -0500
--- trunk/lisp/files.el	2008-11-24 00:09:39.000000000 -0500
***************
*** 1104,1114 ****
--- 1104,1124 ----
  \f
  (defcustom confirm-nonexistent-file-or-buffer nil
    "If non-nil, confirmation is requested before visiting a new file or buffer.
+ If the value is `after-completion', confirmation is only
+ requested if the user calls `minibuffer-complete-and-exit'
+ immediately after `minibuffer-complete'.
  This affects commands like `switch-to-buffer' and `find-file'."
    :group 'find-file
    :version "23.1"
    :type 'boolean)
  
+ (defun confirm-nonexistent-file-or-buffer ()
+   (cond ((eq confirm-nonexistent-file-or-buffer 'after-completion)
+ 	 'confirm-after-completion)
+ 	(confirm-nonexistent-file-or-buffer
+ 	 'confirm)
+ 	(t nil)))
+ 
  (defun read-buffer-to-switch (prompt)
    "Read the name of a buffer to switch to and return as a string.
  It is intended for `switch-to-buffer' family of commands since they
***************
*** 1118,1124 ****
      (minibuffer-with-setup-hook
          (lambda () (setq minibuffer-completion-table rbts-completion-table))
        (read-buffer prompt (other-buffer (current-buffer))
!                    (if confirm-nonexistent-file-or-buffer 'confirm-only)))))
  
  (defun switch-to-buffer-other-window (buffer-or-name &optional norecord)
    "Select the buffer specified by BUFFER-OR-NAME in another window.
--- 1128,1134 ----
      (minibuffer-with-setup-hook
          (lambda () (setq minibuffer-completion-table rbts-completion-table))
        (read-buffer prompt (other-buffer (current-buffer))
!                    (confirm-nonexistent-file-or-buffer)))))
  
  (defun switch-to-buffer-other-window (buffer-or-name &optional norecord)
    "Select the buffer specified by BUFFER-OR-NAME in another window.
***************
*** 1241,1247 ****
  automatically choosing a major mode, use \\[find-file-literally]."
    (interactive
     (find-file-read-args "Find file: "
!                         (if confirm-nonexistent-file-or-buffer 'confirm-only)))
    (let ((value (find-file-noselect filename nil nil wildcards)))
      (if (listp value)
  	(mapcar 'switch-to-buffer (nreverse value))
--- 1251,1257 ----
  automatically choosing a major mode, use \\[find-file-literally]."
    (interactive
     (find-file-read-args "Find file: "
!                         (confirm-nonexistent-file-or-buffer)))
    (let ((value (find-file-noselect filename nil nil wildcards)))
      (if (listp value)
  	(mapcar 'switch-to-buffer (nreverse value))
***************
*** 1261,1267 ****
  expand wildcards (if any) and visit multiple files."
    (interactive
     (find-file-read-args "Find file in other window: "
!                         (if confirm-nonexistent-file-or-buffer 'confirm-only)))
    (let ((value (find-file-noselect filename nil nil wildcards)))
      (if (listp value)
  	(progn
--- 1271,1277 ----
  expand wildcards (if any) and visit multiple files."
    (interactive
     (find-file-read-args "Find file in other window: "
!                         (confirm-nonexistent-file-or-buffer)))
    (let ((value (find-file-noselect filename nil nil wildcards)))
      (if (listp value)
  	(progn
***************
*** 1284,1290 ****
  expand wildcards (if any) and visit multiple files."
    (interactive
     (find-file-read-args "Find file in other frame: "
!                         (if confirm-nonexistent-file-or-buffer 'confirm-only)))
    (let ((value (find-file-noselect filename nil nil wildcards)))
      (if (listp value)
  	(progn
--- 1294,1300 ----
  expand wildcards (if any) and visit multiple files."
    (interactive
     (find-file-read-args "Find file in other frame: "
!                         (confirm-nonexistent-file-or-buffer)))
    (let ((value (find-file-noselect filename nil nil wildcards)))
      (if (listp value)
  	(progn
***************
*** 1309,1315 ****
  Use \\[toggle-read-only] to permit editing."
    (interactive
     (find-file-read-args "Find file read-only: "
!                         (if confirm-nonexistent-file-or-buffer 'confirm-only)))
    (unless (or (and wildcards find-file-wildcards
  		   (not (string-match "\\`/:" filename))
  		   (string-match "[[*?]" filename))
--- 1319,1325 ----
  Use \\[toggle-read-only] to permit editing."
    (interactive
     (find-file-read-args "Find file read-only: "
!                         (confirm-nonexistent-file-or-buffer)))
    (unless (or (and wildcards find-file-wildcards
  		   (not (string-match "\\`/:" filename))
  		   (string-match "[[*?]" filename))
***************
*** 1326,1332 ****
  Use \\[toggle-read-only] to permit editing."
    (interactive
     (find-file-read-args "Find file read-only other window: "
!                         (if confirm-nonexistent-file-or-buffer 'confirm-only)))
    (unless (or (and wildcards find-file-wildcards
  		   (not (string-match "\\`/:" filename))
  		   (string-match "[[*?]" filename))
--- 1336,1342 ----
  Use \\[toggle-read-only] to permit editing."
    (interactive
     (find-file-read-args "Find file read-only other window: "
! 			(confirm-nonexistent-file-or-buffer)))
    (unless (or (and wildcards find-file-wildcards
  		   (not (string-match "\\`/:" filename))
  		   (string-match "[[*?]" filename))
***************
*** 1343,1349 ****
  Use \\[toggle-read-only] to permit editing."
    (interactive
     (find-file-read-args "Find file read-only other frame: "
!                         (if confirm-nonexistent-file-or-buffer 'confirm-only)))
    (unless (or (and wildcards find-file-wildcards
  		   (not (string-match "\\`/:" filename))
  		   (string-match "[[*?]" filename))
--- 1353,1359 ----
  Use \\[toggle-read-only] to permit editing."
    (interactive
     (find-file-read-args "Find file read-only other frame: "
!                         (confirm-nonexistent-file-or-buffer)))
    (unless (or (and wildcards find-file-wildcards
  		   (not (string-match "\\`/:" filename))
  		   (string-match "[[*?]" filename))
*** trunk/lisp/minibuffer.el.~1.60.~	2008-11-08 11:52:55.000000000 -0500
--- trunk/lisp/minibuffer.el	2008-11-24 00:15:57.000000000 -0500
***************
*** 578,584 ****
              (delete-region beg end))))
        (exit-minibuffer))
  
!      ((eq minibuffer-completion-confirm 'confirm-only)
        ;; The user is permitted to exit with an input that's rejected
        ;; by test-completion, but at the condition to confirm her choice.
        (if (eq last-command this-command)
--- 578,584 ----
              (delete-region beg end))))
        (exit-minibuffer))
  
!      ((eq minibuffer-completion-confirm 'confirm)
        ;; The user is permitted to exit with an input that's rejected
        ;; by test-completion, but at the condition to confirm her choice.
        (if (eq last-command this-command)
***************
*** 586,591 ****
--- 586,597 ----
          (minibuffer-message "Confirm")
          nil))
  
+      ((eq minibuffer-completion-confirm 'confirm-after-completion)
+       (if (eq last-command 'minibuffer-complete)
+ 	  (progn (minibuffer-message "Confirm")
+ 		 nil)
+ 	(exit-minibuffer)))
+ 
       (t
        ;; Call do-completion, but ignore errors.
        (case (condition-case nil




  reply	other threads:[~2008-11-24  5:21 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-21 13:33 C-x C-b and C-x C-f bugging about confirmation Alfred M. Szmidt
2008-11-21 14:35 ` Stefan Monnier
2008-11-21 15:46   ` Chong Yidong
2008-11-21 15:51     ` Chong Yidong
2008-11-21 16:08     ` Sam Steingold
2008-11-21 17:07       ` Chong Yidong
2008-11-21 21:23         ` Alan Mackenzie
2008-11-22 16:12           ` Miles Bader
2008-11-21 18:40       ` Eli Zaretskii
2008-11-22  3:23         ` Stefan Monnier
2008-11-22 10:13           ` Eli Zaretskii
2008-11-23  3:39             ` Stefan Monnier
2008-11-23 11:25               ` Eli Zaretskii
2008-11-24  3:08                 ` Stefan Monnier
2008-11-24  7:24                   ` Stephen J. Turnbull
2008-11-24 15:50                     ` Stefan Monnier
2008-11-22 12:18           ` Alfred M. Szmidt
2008-11-22 13:51           ` Ulrich Mueller
2008-11-23  3:50             ` Stefan Monnier
2008-11-22 11:35       ` Alfred M. Szmidt
2008-11-21 18:03     ` Stefan Monnier
2008-11-21 18:51       ` Eli Zaretskii
2008-11-21 19:29       ` Chong Yidong
2008-11-21 23:58         ` Tassilo Horn
2008-11-22  3:30         ` Stefan Monnier
2008-11-22 10:13           ` Eli Zaretskii
2008-11-22  1:54       ` Miles Bader
2008-11-22  7:08       ` mail
2008-11-22  8:24         ` Miles Bader
2008-11-21 18:37   ` Ted Zlatanov
2008-11-22 11:26   ` Alfred M. Szmidt
2008-11-23  3:49     ` Stefan Monnier
2008-11-23  4:44       ` Chong Yidong
2008-11-23 11:24         ` Romain Francoise
2008-11-23 12:45       ` Juri Linkov
2008-11-23 13:45         ` Miles Bader
2008-11-23 15:27           ` Juri Linkov
2008-11-23 22:17           ` Chong Yidong
2008-11-24  3:18           ` Stefan Monnier
2008-11-24  5:21             ` Chong Yidong [this message]
2008-11-24 15:52               ` Stefan Monnier
2008-11-24 19:58                 ` mail
2008-11-25  4:03               ` Miles Bader
2008-11-25 15:21                 ` Stefan Monnier
2008-11-25 20:09                 ` Eli Zaretskii
2008-11-24 11:24       ` Alfred M. Szmidt
2008-11-24 15:56         ` Stefan Monnier
2008-11-24 17:52           ` Alfred M. Szmidt
2008-11-28 18:52             ` Romain Francoise
2008-11-28 19:12               ` Chong Yidong
2008-11-28 21:06               ` Stefan Monnier
2008-11-28 22:27                 ` partial-completion-mode (was: C-x C-b and C-x C-f bugging about confirmation) Romain Francoise
2008-11-29  2:48                   ` partial-completion-mode Stefan Monnier
2008-11-29 19:44                     ` partial-completion-mode Romain Francoise
2008-11-29 20:42                       ` partial-completion-mode Stefan Monnier
2008-12-02 12:39                 ` C-x C-b and C-x C-f bugging about confirmation Klaus Zeitler
2008-12-02 13:05                   ` Tassilo Horn
2008-12-03 12:22                     ` Klaus Zeitler
2008-11-22 11:16 ` Gilaras Drakeson

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=87y6z9k8cj.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=ams@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=miles@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

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