From edbb5d8965bf6b84f6717147a3fcfe494374bd6d Mon Sep 17 00:00:00 2001 From: yamaoka Date: Wed, 7 Oct 1998 23:17:39 +0000 Subject: [PATCH] * lisp/message.el (message-kill-buffer): Refer to `message-kill-buffer-query-function'. * lisp/message.el (message-kill-buffer-query-function): New user option. * lisp/nnheader.el (nnheader-Y-or-n-p): New function. --- lisp/message.el | 16 ++++++++++++++-- lisp/nnheader.el | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lisp/message.el b/lisp/message.el index 1e1ac50..4487c32 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -271,6 +271,15 @@ should return the new buffer name." :group 'message-buffers :type 'boolean) +(defcustom message-kill-buffer-query-function 'yes-or-no-p + "*A function called to query the user whether to kill buffer anyway or not. +If it is t, the buffer will be killed peremptorily." + :type '(radio (function-item yes-or-no-p) + (function-item y-or-n-p) + (function-item nnheader-Y-or-n-p) + (function :tag "Other" t)) + :group 'message-buffers) + (defvar gnus-local-organization) (defcustom message-user-organization (or (and (boundp 'gnus-local-organization) @@ -1932,14 +1941,17 @@ The text will also be indented the normal way." "Kill the current buffer." (interactive) (when (or (not (buffer-modified-p)) - (yes-or-no-p "Message modified; kill anyway? ")) + (eq t message-kill-buffer-query-function) + (funcall message-kill-buffer-query-function + "The buffer modified; kill anyway? ")) (let ((actions message-kill-actions) (frame (selected-frame)) (org-frame message-original-frame)) (setq buffer-file-name nil) (kill-buffer (current-buffer)) (message-do-actions actions) - (message-delete-frame frame org-frame)))) + (message-delete-frame frame org-frame))) + (message "")) (defun message-delete-frame (frame org-frame) "Delete frame for editing message." diff --git a/lisp/nnheader.el b/lisp/nnheader.el index bc725b6..4c220ba 100644 --- a/lisp/nnheader.el +++ b/lisp/nnheader.el @@ -856,6 +856,20 @@ find-file-hooks, etc. (fset 'nnheader-cancel-timer 'cancel-timer) (fset 'nnheader-cancel-function-timers 'cancel-function-timers) +(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) + (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)))))) + (when (string-match "XEmacs\\|Lucid" emacs-version) (require 'nnheaderxm)) -- 1.7.10.4