From 9aea757bb0003d0e7679cf96a726c0d58e7c4093 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Wed, 19 Jan 2011 21:55:36 -0500 Subject: [PATCH] Revert changes adding format args to yes-or-no-p and y-or-n-p. See discussion on emacs-devel at http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00388.html * src/fns.c (Fyes_or_no_p): Revert 2011-01-07 change, removing ARGS. * lisp/subr.el (y-or-n-p): Revert 2011-01-07 change, removing ARGS. * lisp/files.el (find-alternate-file, basic-save-buffer) (basic-save-buffer-2, revert-buffer, recover-file) (kill-buffer-ask, abort-if-file-too-large) (set-visited-file-name, write-file, backup-buffer) (basic-save-buffer, save-some-buffers): * lisp/dired-aux.el (dired-compress-file): Callers changed. --- etc/NEWS | 2 -- lisp/ChangeLog | 11 +++++++++ lisp/dired-aux.el | 4 ++-- lisp/dired.el | 2 +- lisp/files.el | 60 ++++++++++++++++++++++++----------------------- lisp/subr.el | 10 ++++---- src/ChangeLog | 4 ++++ src/fns.c | 22 +++++++++-------- 8 files changed, 65 insertions(+), 50 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 8f707331f8..211671c2d3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -688,8 +688,6 @@ sc.el, x-menu.el, rnews.el, rnewspost.el ** New function `read-char-choice' reads a restricted set of characters, discarding any inputs not inside the set. -** `y-or-n-p' and `yes-or-no-p' now accept format string arguments. - ** `image-library-alist' is renamed to `dynamic-library-alist'. The variable is now used to load all kind of supported dynamic libraries, not just image libraries. The previous name is still available as an diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0fcc4687ce..3966debad8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2011-01-20 Chong Yidong + + * subr.el (y-or-n-p): Revert 2011-01-07 change, removing ARGS. + + * files.el (find-alternate-file, basic-save-buffer) + (basic-save-buffer-2, revert-buffer, recover-file) + (kill-buffer-ask, abort-if-file-too-large) + (set-visited-file-name, write-file, backup-buffer) + (basic-save-buffer, save-some-buffers): + * dired-aux.el (dired-compress-file): Callers changed. + 2011-01-19 Glenn Morris * vc/vc-svn.el (vc-svn-after-dir-status, vc-svn-parse-status): diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index e701d4342b..9338934875 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -821,8 +821,8 @@ Otherwise, the rule is a compression rule, and compression is done with gzip.") (let ((out-name (concat file ".gz"))) (and (or (not (file-exists-p out-name)) (y-or-n-p - "File %s already exists. Really compress? " - out-name)) + (format "File %s already exists. Really compress? " + out-name))) (not (dired-check-process (concat "Compressing " file) "gzip" "-f" file)) (or (file-exists-p out-name) diff --git a/lisp/dired.el b/lisp/dired.el index 13d0a8ff39..36bd9f6f12 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3562,7 +3562,7 @@ Ask means pop up a menu for the user to select one of copy, move or link." ;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command ;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown ;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff -;;;;;; dired-diff) "dired-aux" "dired-aux.el" "adcb55a439048f158f47c5c96b3dad09") +;;;;;; dired-diff) "dired-aux" "dired-aux.el" "b30af1396920c8bf22f3c83746bb73f9") ;;; Generated autoloads from dired-aux.el (autoload 'dired-diff "dired-aux" "\ diff --git a/lisp/files.el b/lisp/files.el index 312ecb3852..16b43d72c3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1558,8 +1558,8 @@ killed." (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 "Buffer %s is modified; save it first? " - (buffer-name)) + (if (yes-or-no-p (format "Buffer %s is modified; save it first? " + (buffer-name))) (save-buffer) (unless (yes-or-no-p "Kill and replace the buffer without saving it? ") (error "Aborted")))) @@ -1762,9 +1762,9 @@ When nil, never request confirmation." OP-TYPE specifies the file operation being performed (for message to user)." (when (and large-file-warning-threshold size (> size large-file-warning-threshold) - (not (y-or-n-p "File %s is large (%dMB), really %s? " - (file-name-nondirectory filename) - (/ size 1048576) op-type))) + (not (y-or-n-p (format "File %s is large (%dMB), really %s? " + (file-name-nondirectory filename) + (/ size 1048576) op-type)))) (error "Aborted"))) (defun find-file-noselect (filename &optional nowarn rawfile wildcards) @@ -3584,8 +3584,8 @@ the old visited file has been renamed to the new name FILENAME." (let ((buffer (and filename (find-buffer-visiting filename)))) (and buffer (not (eq buffer (current-buffer))) (not no-query) - (not (y-or-n-p "A buffer is visiting %s; proceed? " - filename)) + (not (y-or-n-p (format "A buffer is visiting %s; proceed? " + filename))) (error "Aborted"))) (or (equal filename buffer-file-name) (progn @@ -3696,7 +3696,7 @@ Interactively, confirmation is required unless you supply a prefix argument." (or buffer-file-name (buffer-name)))))) (and confirm (file-exists-p filename) - (or (y-or-n-p "File `%s' exists; overwrite? " filename) + (or (y-or-n-p (format "File `%s' exists; overwrite? " filename)) (error "Canceled"))) (set-visited-file-name filename (not confirm)))) (set-buffer-modified-p t) @@ -3750,8 +3750,8 @@ BACKUPNAME is the backup file name, which is the old file renamed." (and targets (or (eq delete-old-versions t) (eq delete-old-versions nil)) (or delete-old-versions - (y-or-n-p "Delete excess backup versions of %s? " - real-file-name)))) + (y-or-n-p (format "Delete excess backup versions of %s? " + real-file-name))))) (modes (file-modes buffer-file-name)) (context (file-selinux-context buffer-file-name))) ;; Actually write the back up file. @@ -4324,8 +4324,8 @@ Before and after saving the buffer, this function runs ;; Signal an error if the user specified the name of an ;; existing directory. (error "%s is a directory" filename) - (unless (y-or-n-p "File `%s' exists; overwrite? " - filename) + (unless (y-or-n-p (format "File `%s' exists; overwrite? " + filename)) (error "Canceled"))) ;; Signal an error if the specified name refers to a ;; non-existing directory. @@ -4338,8 +4338,9 @@ Before and after saving the buffer, this function runs (or (verify-visited-file-modtime (current-buffer)) (not (file-exists-p buffer-file-name)) (yes-or-no-p - "%s has changed since visited or saved. Save anyway? " - (file-name-nondirectory buffer-file-name)) + (format + "%s has changed since visited or saved. Save anyway? " + (file-name-nondirectory buffer-file-name))) (error "Save not confirmed")) (save-restriction (widen) @@ -4353,8 +4354,8 @@ Before and after saving the buffer, this function runs (eq require-final-newline 'visit-save) (and require-final-newline (y-or-n-p - "Buffer %s does not end in newline. Add one? " - (buffer-name)))) + (format "Buffer %s does not end in newline. Add one? " + (buffer-name))))) (save-excursion (goto-char (point-max)) (insert ?\n)))) @@ -4416,9 +4417,10 @@ Before and after saving the buffer, this function runs (if (not (file-exists-p buffer-file-name)) (error "Directory %s write-protected" dir) (if (yes-or-no-p - "File %s is write-protected; try to save anyway? " - (file-name-nondirectory - buffer-file-name)) + (format + "File %s is write-protected; try to save anyway? " + (file-name-nondirectory + buffer-file-name))) (setq tempsetmodes t) (error "Attempt to save to a file which you aren't allowed to write")))))) (or buffer-backed-up @@ -4609,7 +4611,7 @@ change the additional actions you can take on files." (progn (if (or arg (eq save-abbrevs 'silently) - (y-or-n-p "Save abbrevs in %s? " abbrev-file-name)) + (y-or-n-p (format "Save abbrevs in %s? " abbrev-file-name))) (write-abbrev-file nil)) ;; Don't keep bothering user if he says no. (setq abbrevs-changed nil) @@ -4784,8 +4786,8 @@ given. With a prefix argument, TRASH is nil." (list dir (if (directory-files dir nil directory-files-no-dot-files-regexp) (y-or-n-p - "Directory `%s' is not empty, really %s? " - dir (if trashing "trash" "delete")) + (format "Directory `%s' is not empty, really %s? " + dir (if trashing "trash" "delete"))) nil) (null current-prefix-arg)))) ;; If default-directory is a remote directory, make sure we find its @@ -4984,8 +4986,8 @@ non-nil, it is called instead of rereading visited file contents." (dolist (regexp revert-without-query) (when (string-match regexp file-name) (throw 'found t))))) - (yes-or-no-p "Revert buffer from file %s? " - file-name)) + (yes-or-no-p (format "Revert buffer from file %s? " + file-name))) (run-hooks 'before-revert-hook) ;; If file was backed up but has changed since, ;; we should make another backup. @@ -5105,7 +5107,7 @@ non-nil, it is called instead of rereading visited file contents." ;; to emulate what `ls' did in that case. (insert-directory-safely file switches) (insert-directory-safely file-name switches)))) - (yes-or-no-p "Recover auto save file %s? " file-name)) + (yes-or-no-p (format "Recover auto save file %s? " file-name))) (switch-to-buffer (find-file-noselect file t)) (let ((inhibit-read-only t) ;; Keep the current buffer-file-coding-system. @@ -5225,10 +5227,10 @@ This command is used in the special Dired buffer created by (defun kill-buffer-ask (buffer) "Kill BUFFER if confirmed." - (when (yes-or-no-p - "Buffer %s %s. Kill? " (buffer-name buffer) - (if (buffer-modified-p buffer) - "HAS BEEN EDITED" "is unmodified")) + (when (yes-or-no-p (format "Buffer %s %s. Kill? " + (buffer-name buffer) + (if (buffer-modified-p buffer) + "HAS BEEN EDITED" "is unmodified"))) (kill-buffer buffer))) (defun kill-some-buffers (&optional list) diff --git a/lisp/subr.el b/lisp/subr.el index 25f36269df..d36e96e5f8 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2067,12 +2067,10 @@ floating point support." nil)))))) (set-advertised-calling-convention 'sit-for '(seconds &optional nodisp) "22.1") -(defun y-or-n-p (prompt &rest args) +(defun y-or-n-p (prompt) "Ask user a \"y or n\" question. Return t if answer is \"y\". -The string to display to ask the question is obtained by -formatting the string PROMPT with arguments ARGS (see `format'). -The result should end in a space; `y-or-n-p' adds \"(y or n) \" -to it. +PROMPT is the string to display to ask the question. It should +end in a space; `y-or-n-p' adds \"(y or n) \" to it. No confirmation of the answer is requested; a single character is enough. Also accepts Space to mean yes, or Delete to mean no. \(Actually, it uses @@ -2091,7 +2089,7 @@ is nil and `use-dialog-box' is non-nil." use-dialog-box) (setq answer (x-popup-dialog t `(,prompt ("yes" . act) ("No" . skip)))) - (setq prompt (concat (apply 'format prompt args) + (setq prompt (concat prompt (if (eq ?\s (aref prompt (1- (length prompt)))) "" " ") "(y or n) ")) diff --git a/src/ChangeLog b/src/ChangeLog index 735b6e4789..7227d2e994 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-01-20 Chong Yidong + + * fns.c (Fyes_or_no_p): Revert 2011-01-07 change, removing ARGS. + 2011-01-19 Paul Eggert Fix X11 compilation failure. diff --git a/src/fns.c b/src/fns.c index 236e498bea..52570a8af9 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2450,24 +2450,23 @@ do_yes_or_no_p (Lisp_Object prompt) /* Anything that calls this function must protect from GC! */ -DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, MANY, 0, +DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0, doc: /* Ask user a yes-or-no question. Return t if answer is yes. -The string to display to ask the question is obtained by -formatting the string PROMPT with arguments ARGS (see `format'). -The result should end in a space; `yes-or-no-p' adds -\"(yes or no) \" to it. +PROMPT is the string to display to ask the question. It should end in +a space; `yes-or-no-p' adds \"(yes or no) \" to it. The user must confirm the answer with RET, and can edit it until it has been confirmed. Under a windowing system a dialog box will be used if `last-nonmenu-event' -is nil, and `use-dialog-box' is non-nil. -usage: (yes-or-no-p PROMPT &rest ARGS) */) - (int nargs, Lisp_Object *args) +is nil, and `use-dialog-box' is non-nil. */) + (Lisp_Object prompt) { register Lisp_Object ans; + Lisp_Object args[2]; struct gcpro gcpro1; - Lisp_Object prompt = Fformat (nargs, args); + + CHECK_STRING (prompt); #ifdef HAVE_MENUS if (FRAME_WINDOW_P (SELECTED_FRAME ()) @@ -2488,7 +2487,10 @@ usage: (yes-or-no-p PROMPT &rest ARGS) */) } #endif /* HAVE_MENUS */ - prompt = concat2 (prompt, build_string ("(yes or no) ")); + args[0] = prompt; + args[1] = build_string ("(yes or no) "); + prompt = Fconcat (2, args); + GCPRO1 (prompt); while (1) -- 2.20.1