From 8e478f3ea25791775cc3d184a0f74668163640c6 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Tue, 13 Oct 1998 08:45:52 +0000 Subject: [PATCH] * lisp/nnheaderxm.el (nnheader-xmas-Y-or-n-p): New function. It will be used for the substitute of `nnheader-Y-or-n-p' under XEmacs. * lisp/nnheader.el (nnheader-Y-or-n-p): Rewrite for Emacs 19 or later except for XEmacs. --- lisp/nnheader.el | 21 ++++++++++++--------- lisp/nnheaderxm.el | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/lisp/nnheader.el b/lisp/nnheader.el index 3122dd8..99ef061 100644 --- a/lisp/nnheader.el +++ b/lisp/nnheader.el @@ -809,17 +809,20 @@ find-file-hooks, etc. (defun nnheader-Y-or-n-p (prompt) "Ask user a \"Y/n\" question. Return t if answer is neither \"n\", \"N\" nor \"C-g\"." - (if (and (featurep 'xemacs) (should-use-dialog-box-p)) - (yes-or-no-p-dialog-box prompt) - (let ((cursor-in-echo-area t) - (echo-keystrokes 0) - (log-message-max-size 0) - (inhibit-quit t) - message-log-max ans) + (let ((cursor-in-echo-area t) + (echo-keystrokes 0) + (inhibit-quit t) + ans) + (let (message-log-max) (while (not (memq ans '(?\ ?N ?Y ?\C-g ?\e ?\n ?\r ?n ?y))) (message "%s(Y/n) " prompt) - (setq ans (read-char-exclusive))) - (not (memq ans '(?\C-g ?N ?n)))))) + (setq ans (read-char-exclusive)))) + (if (memq ans '(?\C-g ?N ?n)) + (progn + (message "%s(Y/n) No" prompt) + nil) + (message "%s(Y/n) Yes" prompt) + t))) (when (string-match "XEmacs\\|Lucid" emacs-version) (require 'nnheaderxm)) diff --git a/lisp/nnheaderxm.el b/lisp/nnheaderxm.el index f788042..7c1435c 100644 --- a/lisp/nnheaderxm.el +++ b/lisp/nnheaderxm.el @@ -32,9 +32,30 @@ (,function ,@args)) time repeat)) +(defun nnheader-xmas-Y-or-n-p (prompt) + "Ask user a \"Y/n\" question. Return t if answer is neither \"n\", \"N\" nor \"C-g\"." + (if (should-use-dialog-box-p) + (yes-or-no-p-dialog-box prompt) + (let ((cursor-in-echo-area t) + (echo-keystrokes 0) + (inhibit-quit t) + event) + (message "%s(Y/n) " prompt) + (while (or (not (key-press-event-p (setq event (next-command-event)))) + (not (or (eq (event-key event) 'escape) + (memq (event-to-character event) + '(?\ ?N ?Y ?\C-g ?\e ?\n ?\r ?n ?y)))))) + (if (memq (event-key event) '(?\C-g ?N ?n)) + (progn + (message "%s(Y/n) No" prompt) + nil) + (message "%s(Y/n) Yes" prompt) + t)))) + (fset 'nnheader-run-at-time 'nnheader-xmas-run-at-time) (fset 'nnheader-cancel-timer 'delete-itimer) (fset 'nnheader-cancel-function-timers 'ignore) +(fset 'nnheader-Y-or-n-p 'nnheader-xmas-Y-or-n-p) (provide 'nnheaderxm) -- 1.7.10.4