From: Juanma Barranquero Date: Thu, 27 Feb 2014 14:21:28 +0000 (+0100) Subject: lisp/subr.el (y-or-n-p): Fix double space issue in message. X-Git-Tag: emacs-24.3.90~357^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=298520dfb7f609e41db1368ff47834d3d04e2183;p=emacs.git lisp/subr.el (y-or-n-p): Fix double space issue in message. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37e0b7aa1a2..07781adc191 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2014-02-27 Juanma Barranquero + + * subr.el (y-or-n-p): Fix double space issue in message. + 2014-02-27 Michael Albinus * net/tramp.el (tramp-call-process): Improve trace message. diff --git a/lisp/subr.el b/lisp/subr.el index ad783acc929..1bfa3c83a35 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2206,14 +2206,16 @@ is nil and `use-dialog-box' is non-nil." ;; ¡Beware! when I tried to edebug this code, Emacs got into a weird state ;; where all the keys were unbound (i.e. it somehow got triggered ;; within read-key, apparently). I had to kill it. - (let ((answer 'recenter)) + (let ((answer 'recenter) + (padded (lambda (prompt &optional dialog) + (let ((l (length prompt))) + (concat prompt + (if (or (zerop l) (eq ?\s (aref prompt (1- l)))) + "" " ") + (if dialog "" "(y or n) ")))))) (cond (noninteractive - (setq prompt (concat prompt - (if (or (zerop (length prompt)) - (eq ?\s (aref prompt (1- (length prompt))))) - "" " ") - "(y or n) ")) + (setq prompt (funcall padded prompt)) (let ((temp-prompt prompt)) (while (not (memq answer '(act skip))) (let ((str (read-string temp-prompt))) @@ -2224,14 +2226,10 @@ is nil and `use-dialog-box' is non-nil." ((and (display-popup-menus-p) (listp last-nonmenu-event) use-dialog-box) - (setq answer - (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) + (setq prompt (funcall padded prompt t) + answer (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) (t - (setq prompt (concat prompt - (if (or (zerop (length prompt)) - (eq ?\s (aref prompt (1- (length prompt))))) - "" " ") - "(y or n) ")) + (setq prompt (funcall padded prompt)) (while (let* ((scroll-actions '(recenter scroll-up scroll-down scroll-other-window scroll-other-window-down)) @@ -2264,9 +2262,7 @@ is nil and `use-dialog-box' is non-nil." (discard-input)))) (let ((ret (eq answer 'act))) (unless noninteractive - ;; FIXME this prints one too many spaces, since prompt - ;; already ends in a space. Eg "... (y or n) y". - (message "%s %s" prompt (if ret "y" "n"))) + (message "%s%c" prompt (if ret ?y ?n))) ret)))