[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C-x C-b and C-x C-f bugging about confirmation
From: |
Chong Yidong |
Subject: |
Re: C-x C-b and C-x C-f bugging about confirmation |
Date: |
Mon, 24 Nov 2008 00:21:00 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Stefan Monnier <address@hidden> 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 ----
(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
- Re: C-x C-b and C-x C-f bugging about confirmation, (continued)
- Re: C-x C-b and C-x C-f bugging about confirmation, Ted Zlatanov, 2008/11/21
- Re: C-x C-b and C-x C-f bugging about confirmation, Alfred M\. Szmidt, 2008/11/22
- Re: C-x C-b and C-x C-f bugging about confirmation, Juri Linkov, 2008/11/23
- Re: C-x C-b and C-x C-f bugging about confirmation, Miles Bader, 2008/11/23
- Re: C-x C-b and C-x C-f bugging about confirmation, Juri Linkov, 2008/11/23
- Re: C-x C-b and C-x C-f bugging about confirmation, Chong Yidong, 2008/11/23
- Re: C-x C-b and C-x C-f bugging about confirmation, Stefan Monnier, 2008/11/23
- Re: C-x C-b and C-x C-f bugging about confirmation,
Chong Yidong <=
- Re: C-x C-b and C-x C-f bugging about confirmation, Stefan Monnier, 2008/11/24
- Re: C-x C-b and C-x C-f bugging about confirmation, mail, 2008/11/24
- Re: C-x C-b and C-x C-f bugging about confirmation, Miles Bader, 2008/11/24
- Re: C-x C-b and C-x C-f bugging about confirmation, Stefan Monnier, 2008/11/25
- Re: C-x C-b and C-x C-f bugging about confirmation, Eli Zaretskii, 2008/11/25
- Re: C-x C-b and C-x C-f bugging about confirmation, Alfred M\. Szmidt, 2008/11/24
- Re: C-x C-b and C-x C-f bugging about confirmation, Stefan Monnier, 2008/11/24
- Re: C-x C-b and C-x C-f bugging about confirmation, Alfred M\. Szmidt, 2008/11/24
- Re: C-x C-b and C-x C-f bugging about confirmation, Romain Francoise, 2008/11/28
- Re: C-x C-b and C-x C-f bugging about confirmation, Chong Yidong, 2008/11/28