-
Notifications
You must be signed in to change notification settings - Fork 0
/
irchat-timer.el
56 lines (51 loc) · 1.47 KB
/
irchat-timer.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; -*- emacs-lisp -*-
;;;
;;; see file irchat-copyright.el for change log and copyright info
(eval-when-compile
(require 'irchat-inlines))
(eval-and-compile
(require 'irchat-vars))
(defvar irchat-emacs-major-version
(string-to-number (substring emacs-version 0 2)))
(if (= irchat-emacs-major-version 18)
(progn
(defun irchat-start-timer (function interval)
"Timers are not supported under emacs 18."
nil)
(defun irchat-cancel-timer (timer)
"Timers are not supported under emacs 18."
nil))
(if (or (string-match ".*Lucid.*" (emacs-version))
(string-match ".*XEmacs.*" (emacs-version)))
(progn
(defun irchat-cancel-timer (timer)
"Cancel timer."
(delete-itimer timer))
(defun irchat-start-timer (function interval)
"Add timer function."
(interactive)
(if interval
(start-itimer "IRCHAT" function interval interval))))
(progn
;; (eval-and-compile
;; (require 'timer))
(defun irchat-cancel-timer (timer)
"Cancel timer."
(cancel-timer timer))
(defun irchat-start-timer (func interval)
"Add timer function."
(interactive)
(setq timer-dont-exit t)
(if interval
;; messy implementation as RMS emacs keeps on killing the
;; timers signalling errors. (actually it may lose timers
;; without reason as well...)
(run-at-time (format "%d sec" interval)
interval
'(lambda (f)
(run-at-time "1 sec" nil f)) func))))))
(eval-and-compile
(provide 'irchat-timer))
;;;
;;; eof
;;;