New public branch gnus-6_10.
[elisp/gnus.git-] / lisp / nnheaderxm.el
1 ;;; nnheaderxm.el --- making Gnus backends work under XEmacs
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;;         Katsumi Yamaoka <yamaoka@jpl.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (defun nnheader-xmas-run-at-time (time repeat function &rest args)
30   (start-itimer
31    "nnheader-run-at-time"
32    `(lambda ()
33       (,function ,@args))
34    time repeat))
35
36 (defun nnheader-xmas-Y-or-n-p (prompt)
37   "Ask user a \"Y/n\" question. Return t if answer is neither \"n\", \"N\" nor \"C-g\"."
38   (if (should-use-dialog-box-p)
39       (yes-or-no-p-dialog-box prompt)
40     (let ((cursor-in-echo-area t)
41           (echo-keystrokes 0)
42           (inhibit-quit t)
43           event)
44       (message "%s(Y/n) " prompt)
45       (while (or (not (key-press-event-p (setq event (next-command-event))))
46                  (not (or (eq (event-key event) 'escape)
47                           (memq (event-to-character event)
48                                 '(?\  ?N ?Y ?\C-g ?\e ?\n ?\r ?n ?y))))))
49       (if (memq (event-key event) '(?\C-g ?N ?n))
50           (progn
51             (message "%s(Y/n) No" prompt)
52             nil)
53         (message "%s(Y/n) Yes" prompt)
54         t))))
55
56 (fset 'nnheader-run-at-time 'nnheader-xmas-run-at-time)
57 (fset 'nnheader-cancel-timer 'delete-itimer)
58 (fset 'nnheader-cancel-function-timers 'ignore)
59 (fset 'nnheader-Y-or-n-p 'nnheader-xmas-Y-or-n-p)
60
61 (provide 'nnheaderxm)
62
63 ;;; nnheaderxm.el ends here.