Mercurial > hg > xemacs-beta
diff lisp/itimer.el @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children |
line wrap: on
line diff
--- a/lisp/itimer.el Mon Aug 13 11:19:22 2007 +0200 +++ b/lisp/itimer.el Mon Aug 13 11:20:41 2007 +0200 @@ -20,8 +20,6 @@ (provide 'itimer) -(require 'lisp-float-type) - ;; `itimer' feature means Emacs-Lisp programmers get: ;; itimerp ;; itimer-live-p @@ -48,7 +46,7 @@ ;; ;; See the doc strings of these functions for more information. -(defvar itimer-version "1.09" +(defvar itimer-version "1.07" "Version number of the itimer package.") (defvar itimer-list nil @@ -64,7 +62,7 @@ (defvar itimer-timer-last-wakeup nil "The time the timer driver function last ran.") -(defvar itimer-short-interval 1e-3 +(defvar itimer-short-interval (if (featurep 'lisp-float-type) 1e-3 1) "Interval used for scheduling an event a very short time in the future. Used internally to make the scheduler wake up early. Unit is seconds.") @@ -161,7 +159,7 @@ ;; Functions to access and modify itimer attributes. (defun itimerp (obj) - "Return non-nil if OBJ is an itimer." + "Return t if OBJ is an itimer." (and (consp obj) (eq (length obj) 8))) (defun itimer-live-p (obj) @@ -183,7 +181,7 @@ (defun itimer-restart (itimer) "Return the value to which ITIMER will be set at restart. -The value nil is returned if this itimer isn't set to restart." +Return nil if this itimer doesn't restart." (check-itimer itimer) (nth 2 itimer)) @@ -196,8 +194,8 @@ (defun itimer-is-idle (itimer) "Return non-nil if ITIMER is an idle timer. Normal timers expire after a set interval. Idle timers expire -only after Emacs has been idle for a specific interval. ``Idle'' -means no command events have occurred within the interval." +only after Emacs has been idle for a specific interval. +``Idle'' means no command events occur within the interval." (check-itimer itimer) (nth 4 itimer)) @@ -210,7 +208,7 @@ (defun itimer-function-arguments (itimer) "Return the function arguments of ITIMER as a list. -ITIMER's function is called with these arguments each time ITIMER expires." +ITIMER's function is called with these argument each time ITIMER expires." (check-itimer itimer) (nth 6 itimer)) @@ -304,7 +302,7 @@ (get-itimer (completing-read prompt itimer-list nil 'confirm initial-input))) (defun delete-itimer (itimer) - "Deletes ITIMER. ITIMER may be an itimer or the name of one." + "Delete ITIMER. ITIMER may be an itimer or the name of one." (check-itimer-coerce-string itimer) (setq itimer-list (delq itimer itimer-list))) @@ -329,13 +327,13 @@ must be an integer. Optional fourth arg RESTART non-nil means that this itimer should be restarted automatically after its function is called. Normally an itimer - is deleted at expiration after its function has returned. - If non-nil RESTART should be a number indicating the value at which the - itimer should be set at restart time. + is deleted at expiration after its function has returned. + If non-nil, RESTART should be a number indicating the value at which + the itimer should be set at restart time. Optional fifth arg IS-IDLE specifies if this is an idle timer. Normal timers expire after a set interval. Idle timers expire - only after Emacs has been idle for specific interval. ``Idle'' - means no command events have occurred within the interval. + only after Emacs has been idle for specific interval. + ``Idle'' means no command events occur within the interval. Returns the newly created itimer." (interactive (list (completing-read "Start itimer: " itimer-list) @@ -505,7 +503,7 @@ tab-stop-list '(22 32 40 60 67)) (abbrev-mode 0) (auto-fill-mode 0) - (buffer-disable-undo (current-buffer)) + (buffer-flush-undo (current-buffer)) (use-local-map itimer-edit-map) (set-syntax-table emacs-lisp-mode-syntax-table)) @@ -673,7 +671,7 @@ (inhibit-quit t)) (setq next-wakeup 600) (cond ((and (boundp 'last-command-event-time) - (consp last-command-event-time)) + (consp 'last-command-event-time)) (setq last-event-time last-command-event-time idle-time (itimer-time-difference (current-time) last-event-time))) @@ -714,22 +712,12 @@ (unwind-protect (condition-case condition-data (save-match-data - ;; Suppress warnings - see comment below. - (defvar last-event-time) - (defvar next-wakeup) - (defvar itimer) - (defvar itimers) - (defvar time-elapsed) (let* ((current-itimer itimer) (quit-flag nil) (inhibit-quit nil) ;; for FSF Emacs timer.el emulation under XEmacs. ;; eldoc expect this to be done, apparently. - (this-command nil) - ;; bind these variables so that the itimer - ;; function can't screw with them. - last-event-time next-wakeup - itimer itimers time-elapsed) + (this-command nil)) (if (itimer-uses-arguments current-itimer) (apply (itimer-function current-itimer) (itimer-function-arguments current-itimer)) @@ -849,9 +837,11 @@ secs (+ secs 65536)) (setq carry 0)) (setq 65536-secs (- (nth 0 t1) (nth 0 t2) carry)) - (+ (* 65536-secs 65536.0) + ;; loses for interval larger than the maximum signed Lisp integer. + ;; can't really be helped. + (+ (* 65536-secs 65536) secs - (/ usecs 1000000.0)))) + (/ usecs (if (featurep 'lisp-float-type) 1e6 1000000))))) (defun itimer-timer-driver (&rest ignored) ;; inhibit quit because if the user quits at an inopportune