Show
Ignore:
Timestamp:
09/09/06 16:30:10 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/emacs-lisp/timer.el

    r4037 r4161  
    3333;; [triggered-p high-seconds low-seconds usecs repeat-delay 
    3434;;  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) 
    3537 
    3638(defun timer-create () 
    37   "Create a timer object." 
     39  "Create a timer object which can be passed to `timer-activate'." 
    3840  (let ((timer (make-vector 8 nil))) 
    3941    (aset timer 0 t) 
     
    6163(defun timer-set-idle-time (timer secs &optional repeat) 
    6264  "Set the trigger idle time of TIMER to SECS. 
     65SECS may be an integer, floating point number, or the internal 
     66time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'. 
    6367If optional third argument REPEAT is non-nil, make the timer 
    6468fire each time Emacs is idle for that many seconds." 
    6569  (or (timerp timer) 
    6670      (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)) 
    7181  (aset timer 4 repeat) 
    7282  timer) 
     
    105115(defun timer-relative-time (time secs &optional usecs) 
    106116  "Advance TIME by SECS seconds and optionally USECS microseconds. 
    107 SECS may be a fraction." 
     117SECS may be either an integer or a floating point number." 
    108118  (let ((high (car time)) 
    109119        (low (if (consp (cdr time)) (nth 1 time) (cdr time))) 
     
    165175(defun timer-activate (timer &optional triggered-p reuse-cell) 
    166176  "Put TIMER on the list of active timers. 
     177 
     178If TRIGGERED-P is t, that means to make the timer inactive 
     179\(put it on the list, but mark it as already triggered). 
     180To remove from the list, use `cancel-timer'. 
    167181 
    168182REUSE-CELL, if non-nil, is a cons cell to reuse instead 
     
    249263  nil) 
    250264 
    251 ;; Remove TIMER from the list of active timers or idle timers. 
    252 ;; Only to be used in this file.  It returns the cons cell 
    253 ;; that was removed from the list. 
    254265(defun cancel-timer-internal (timer) 
     266  "Remove TIMER from the list of active timers or idle timers. 
     267Only to be used in this file.  It returns the cons cell 
     268that was removed from the timer list." 
    255269  (let ((cell1 (memq timer timer-list)) 
    256270        (cell2 (memq timer timer-idle-list))) 
     
    263277;;;###autoload 
    264278(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. 
     280This affects ordinary timers such as are scheduled by `run-at-time', 
     281and idle timers such as are scheduled by `run-with-idle-timer'." 
    266282  (interactive "aCancel timers of function: ") 
    267283  (let ((tail timer-list)) 
     
    277293  
    278294;; 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.") 
    282301 
    283302(defvar timer-max-repeats 10 
     
    413432  "Perform an action the next time Emacs is idle for SECS seconds. 
    414433The action is to call FUNCTION with arguments ARGS. 
    415 SECS may be an integer or a floating point number. 
     434SECS may be an integer, a floating point number, or the internal 
     435time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'. 
     436If Emacs is currently idle, and has been idle for N seconds (N < SECS), 
     437then it will call FUNCTION in SECS - N seconds from now. 
    416438 
    417439If REPEAT is non-nil, do the action each time Emacs has been idle for 
     
    426448    (timer-set-function timer function args) 
    427449    (timer-set-idle-time timer secs repeat) 
    428     (timer-activate-when-idle timer
     450    (timer-activate-when-idle timer t
    429451    timer)) 
    430452  
    431453(defun with-timeout-handler (tag) 
     454  "This is the timer function used for the timer made by `with-timeout'." 
    432455  (throw tag 'timeout)) 
    433456