• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/emacs-lisp/

Lines Matching refs:time

1 ;;; timer.el --- run a function with args at some time in future
48 (defun timer-set-time (timer time &optional delta)
49 "Set the trigger time of TIMER to TIME.
50 TIME must be in the internal format returned by, e.g., `current-time'.
55 (aset timer 1 (car time))
56 (aset timer 2 (if (consp (cdr time)) (car (cdr time)) (cdr time)))
57 (aset timer 3 (or (and (consp (cdr time)) (consp (cdr (cdr time)))
58 (nth 2 time))
63 (defun timer-set-idle-time (timer secs &optional repeat)
64 "Set the trigger idle time of TIMER to SECS.
66 time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'.
68 fire each time Emacs is idle for that many seconds."
80 (timer-inc-time timer secs))
84 (defun timer-next-integral-multiple-of-time (time secs)
88 (let ((time-base (ash 1 16)))
91 (let* ((float-time-base (float time-base))
93 (time-usec (+ (* million
94 (+ (* float-time-base (nth 0 time))
95 (nth 1 time)))
96 (nth 2 time)))
98 (mod-usec (mod time-usec secs-usec))
99 (next-usec (+ (- time-usec mod-usec) secs-usec))
100 (time-base-million (* float-time-base million)))
101 (list (floor next-usec time-base-million)
102 (floor (mod next-usec time-base-million) million)
106 (let* ((mod-sec (mod (+ (* (mod time-base secs)
107 (mod (nth 0 time) secs))
108 (nth 1 time))
110 (next-1-sec (+ (- (nth 1 time) mod-sec) secs)))
111 (list (+ (nth 0 time) (floor next-1-sec time-base))
112 (mod next-1-sec time-base)
115 (defun timer-relative-time (time secs &optional usecs)
118 (let ((high (car time))
119 (low (if (consp (cdr time)) (nth 1 time) (cdr time)))
120 (micro (if (numberp (car-safe (cdr-safe (cdr time))))
121 (nth 2 time)
139 (defun timer-inc-time (timer secs &optional usecs)
140 "Increment the time set in TIMER by SECS seconds and USECS microseconds.
142 (let ((time (timer-relative-time
146 (aset timer 1 (nth 0 time))
147 (aset timer 2 (nth 1 time))
148 (aset timer 3 (or (nth 2 time) 0))))
150 (defun timer-set-time-with-usecs (timer time usecs &optional delta)
151 "Set the trigger time of TIMER to TIME plus USECS.
152 TIME must be in the internal format returned by, e.g., `current-time'.
158 (aset timer 1 (nth 0 time))
159 (aset timer 2 (nth 1 time))
163 (make-obsolete 'timer-set-time-with-usecs
164 "use `timer-set-time' and `timer-inc-time' instead."
219 timer to activate immediately, or at the right time, if Emacs
281 This affects ordinary timers such as are scheduled by `run-at-time',
307 or because the system's time changes. If such an occurrence makes it
311 (defun timer-until (timer time)
313 TIMER is a timer, and stands for the time when its next repeat is scheduled.
314 TIME is a time-list."
315 (let ((high (- (car time) (aref timer 1)))
316 (low (- (nth 1 time) (aref timer 2))))
334 (timer-inc-time timer (aref timer 4) 0)
335 ;; If real time has jumped forward,
336 ;; perhaps because Emacs was suspended for a long time,
339 (< 0 (timer-until timer (current-time))))
340 (let ((repeats (/ (timer-until timer (current-time))
343 (timer-inc-time timer (* (aref timer 4) repeats)))))
363 (defun run-at-time (time repeat function &rest args)
364 "Perform an action at time TIME.
366 TIME should be one of: a string giving an absolute time like
368 `diary-entry-time'; note that such times are interpreted as times
369 today, even if in the past); a string giving a relative time like
372 seconds from now; a value from `encode-time'; or t (with non-nil
378 (interactive "sRun at time: \nNRepeat interval: \naFunction: ")
385 (if (null time)
386 (setq time (current-time)))
389 (if (and (eq time t) repeat)
390 (setq time (timer-next-integral-multiple-of-time (current-time) repeat)))
393 (if (numberp time)
394 (setq time (timer-relative-time (current-time) time)))
397 (if (stringp time)
398 (let ((secs (timer-duration time)))
400 (setq time (timer-relative-time (current-time) secs)))))
403 ;; which admittedly is rather stupid if we have passed that time
404 ;; already. (Though only Emacs hackers hack Emacs at that time.)
405 (if (stringp time)
408 (let ((hhmm (diary-entry-time time))
409 (now (decode-time)))
411 (setq time
412 (encode-time 0 (% hhmm 100) (/ hhmm 100) (nth 3 now)
415 (or (consp time)
416 (error "Invalid time format"))
419 (timer-set-time timer time repeat)
433 (apply 'run-at-time secs repeat function args))
444 "Perform an action the next time Emacs is idle for SECS seconds.
447 time format (HIGH LOW USECS) returned by, e.g., `current-idle-time'.
451 If REPEAT is non-nil, do the action each time Emacs has been idle for
452 exactly SECS seconds (that is, only once for each time Emacs becomes idle).
457 (y-or-n-p "Repeat each time Emacs is idle? ")
461 (timer-set-idle-time timer secs repeat)
480 event (such as keyboard input, input from subprocesses, or a certain time);
504 The idea is that the time you spend in the debugger should not
512 (time-subtract
513 ;; The time that this timer will go off.
515 (current-time))))
524 (timer-set-time timer (time-add (current-time) delay))