1 ;;; nnheaderxm.el --- making Gnus backends work under XEmacs
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (if (condition-case nil
32 (unless (or itimer-process itimer-timer)
33 (itimer-driver-start))
34 ;; Check whether there is a bug to which the difference of
35 ;; the present time and the time when the itimer driver was
36 ;; woken up is subtracted from the initial itimer value.
37 (let* ((inhibit-quit t)
38 (ctime (current-time))
39 (itimer-timer-last-wakeup
42 (setcar ctime (1- (car ctime)))))
44 (itimer (start-itimer "nnheader-run-at-time" 'ignore 5)))
45 (sleep-for 0.1) ;; Accept the timeout interrupt.
47 (> (itimer-value itimer) 0)
48 (delete-itimer itimer))))
50 (defun nnheader-xmas-run-at-time (time repeat function &rest args)
51 "Emulating function run as `run-at-time'.
52 TIME should be nil meaning now, or a number of seconds from now.
53 Return an itimer object which can be used in either `delete-itimer'
55 (apply #'start-itimer "nnheader-run-at-time"
56 function (if time (max time 1e-9) 1e-9)
58 (defun nnheader-xmas-run-at-time (time repeat function &rest args)
59 "Emulating function run as `run-at-time' in the right way.
60 TIME should be nil meaning now, or a number of seconds from now.
61 Return an itimer object which can be used in either `delete-itimer'
63 (let ((itimers (list nil)))
66 (apply #'start-itimer "nnheader-run-at-time"
67 (lambda (itimers repeat function &rest args)
68 (let ((itimer (car itimers)))
73 (lambda (itimer repeat function &rest args)
74 (set-itimer-restart itimer repeat)
75 (set-itimer-function itimer function)
76 (set-itimer-function-arguments itimer args)
77 (apply function args)))
78 (set-itimer-function-arguments
80 (append (list itimer repeat function) args)))
83 (lambda (itimer function &rest args)
84 (delete-itimer itimer)
85 (apply function args)))
86 (set-itimer-function-arguments
88 (append (list itimer function) args)))))
89 1e-9 (if time (max time 1e-9) 1e-9)
90 nil t itimers repeat function args)))))
92 (defalias 'nnheader-run-at-time 'nnheader-xmas-run-at-time)
93 (defalias 'nnheader-cancel-timer 'delete-itimer)
94 (defalias 'nnheader-cancel-function-timers 'ignore)
95 (defalias 'nnheader-string-as-multibyte 'identity)
99 ;;; nnheaderxm.el ends here