Changeset 4161 for trunk/lisp/emacs-lisp/timer.el
- Timestamp:
- 09/09/06 16:30:10 (2 years ago)
- Files:
-
- trunk/lisp/emacs-lisp/timer.el (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/emacs-lisp/timer.el
r4037 r4161 33 33 ;; [triggered-p high-seconds low-seconds usecs repeat-delay 34 34 ;; function args idle-delay] 35 ;; triggered-p is nil if the timer is active (waiting to be triggered), 36 ;; t if it is inactive ("already triggered", in theory) 35 37 36 38 (defun timer-create () 37 "Create a timer object ."39 "Create a timer object which can be passed to `timer-activate'." 38 40 (let ((timer (make-vector 8 nil))) 39 41 (aset timer 0 t) … … 61 63 (defun timer-set-idle-time (timer secs &optional repeat) 62 64 "Set the trigger idle time of TIMER to SECS. 65 SECS may be an integer, floating point number, or the internal 66 time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'. 63 67 If optional third argument REPEAT is non-nil, make the timer 64 68 fire each time Emacs is idle for that many seconds." 65 69 (or (timerp timer) 66 70 (error "Invalid timer")) 67 (aset timer 1 0) 68 (aset timer 2 0) 69 (aset timer 3 0) 70 (timer-inc-time timer secs) 71 (if (consp secs) 72 (progn (aset timer 1 (car secs)) 73 (aset timer 2 (if (consp (cdr secs)) (car (cdr secs)) (cdr secs))) 74 (aset timer 3 (or (and (consp (cdr secs)) (consp (cdr (cdr secs))) 75 (nth 2 secs)) 76 0))) 77 (aset timer 1 0) 78 (aset timer 2 0) 79 (aset timer 3 0) 80 (timer-inc-time timer secs)) 71 81 (aset timer 4 repeat) 72 82 timer) … … 105 115 (defun timer-relative-time (time secs &optional usecs) 106 116 "Advance TIME by SECS seconds and optionally USECS microseconds. 107 SECS may be a fraction."117 SECS may be either an integer or a floating point number." 108 118 (let ((high (car time)) 109 119 (low (if (consp (cdr time)) (nth 1 time) (cdr time))) … … 165 175 (defun timer-activate (timer &optional triggered-p reuse-cell) 166 176 "Put TIMER on the list of active timers. 177 178 If TRIGGERED-P is t, that means to make the timer inactive 179 \(put it on the list, but mark it as already triggered). 180 To remove from the list, use `cancel-timer'. 167 181 168 182 REUSE-CELL, if non-nil, is a cons cell to reuse instead … … 249 263 nil) 250 264 251 ;; Remove TIMER from the list of active timers or idle timers.252 ;; Only to be used in this file. It returns the cons cell253 ;; that was removed from the list.254 265 (defun cancel-timer-internal (timer) 266 "Remove TIMER from the list of active timers or idle timers. 267 Only to be used in this file. It returns the cons cell 268 that was removed from the timer list." 255 269 (let ((cell1 (memq timer timer-list)) 256 270 (cell2 (memq timer timer-idle-list))) … … 263 277 ;;;###autoload 264 278 (defun cancel-function-timers (function) 265 "Cancel all timers scheduled by `run-at-time' which would run FUNCTION." 279 "Cancel all timers which would run FUNCTION. 280 This affects ordinary timers such as are scheduled by `run-at-time', 281 and idle timers such as are scheduled by `run-with-idle-timer'." 266 282 (interactive "aCancel timers of function: ") 267 283 (let ((tail timer-list)) … … 277 293 278 294 ;; Record the last few events, for debugging. 279 (defvar timer-event-last-2 nil) 280 (defvar timer-event-last-1 nil) 281 (defvar timer-event-last nil) 295 (defvar timer-event-last nil 296 "Last timer that was run.") 297 (defvar timer-event-last-1 nil 298 "Next-to-last timer that was run.") 299 (defvar timer-event-last-2 nil 300 "Third-to-last timer that was run.") 282 301 283 302 (defvar timer-max-repeats 10 … … 413 432 "Perform an action the next time Emacs is idle for SECS seconds. 414 433 The action is to call FUNCTION with arguments ARGS. 415 SECS may be an integer or a floating point number. 434 SECS may be an integer, a floating point number, or the internal 435 time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'. 436 If Emacs is currently idle, and has been idle for N seconds (N < SECS), 437 then it will call FUNCTION in SECS - N seconds from now. 416 438 417 439 If REPEAT is non-nil, do the action each time Emacs has been idle for … … 426 448 (timer-set-function timer function args) 427 449 (timer-set-idle-time timer secs repeat) 428 (timer-activate-when-idle timer )450 (timer-activate-when-idle timer t) 429 451 timer)) 430 452 431 453 (defun with-timeout-handler (tag) 454 "This is the timer function used for the timer made by `with-timeout'." 432 455 (throw tag 'timeout)) 433 456
