diff options
| author | Richard M. Stallman | 2006-09-08 12:00:40 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-09-08 12:00:40 +0000 |
| commit | b8bd37f2f80d5436ad2d4a18561da1dc69f54ac4 (patch) | |
| tree | 52493163f9b8fbfa6e2c67be93c99bb87018bb4f | |
| parent | 3ac5a59d71e23392cdc31f609a9ce32e80f42dfd (diff) | |
| download | emacs-b8bd37f2f80d5436ad2d4a18561da1dc69f54ac4.tar.gz emacs-b8bd37f2f80d5436ad2d4a18561da1dc69f54ac4.zip | |
(timer-create, timer-activate): Doc fixes.
(cancel-timer-internal): Add doc string.
(cancel-function-timers): Doc fix.
(with-timeout-handler, timer-event-last*): Add doc strings.
| -rw-r--r-- | lisp/emacs-lisp/timer.el | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index 82eac50c874..54c5aff305a 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el | |||
| @@ -32,9 +32,11 @@ | |||
| 32 | ;; Layout of a timer vector: | 32 | ;; Layout of a timer vector: |
| 33 | ;; [triggered-p high-seconds low-seconds usecs repeat-delay | 33 | ;; [triggered-p high-seconds low-seconds usecs repeat-delay |
| 34 | ;; function args idle-delay] | 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 | (defun timer-create () | 38 | (defun timer-create () |
| 37 | "Create a timer object." | 39 | "Create a timer object which can be passed to `timer-activate'." |
| 38 | (let ((timer (make-vector 8 nil))) | 40 | (let ((timer (make-vector 8 nil))) |
| 39 | (aset timer 0 t) | 41 | (aset timer 0 t) |
| 40 | timer)) | 42 | timer)) |
| @@ -173,6 +175,10 @@ fire repeatedly that many seconds apart." | |||
| 173 | (defun timer-activate (timer &optional triggered-p reuse-cell) | 175 | (defun timer-activate (timer &optional triggered-p reuse-cell) |
| 174 | "Put TIMER on the list of active timers. | 176 | "Put TIMER on the list of active timers. |
| 175 | 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'. | ||
| 181 | |||
| 176 | REUSE-CELL, if non-nil, is a cons cell to reuse instead | 182 | REUSE-CELL, if non-nil, is a cons cell to reuse instead |
| 177 | of allocating a new one." | 183 | of allocating a new one." |
| 178 | (if (and (timerp timer) | 184 | (if (and (timerp timer) |
| @@ -256,10 +262,10 @@ of allocating a new one." | |||
| 256 | (setq timer-idle-list (delq timer timer-idle-list)) | 262 | (setq timer-idle-list (delq timer timer-idle-list)) |
| 257 | nil) | 263 | nil) |
| 258 | 264 | ||
| 259 | ;; Remove TIMER from the list of active timers or idle timers. | ||
| 260 | ;; Only to be used in this file. It returns the cons cell | ||
| 261 | ;; that was removed from the list. | ||
| 262 | (defun cancel-timer-internal (timer) | 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." | ||
| 263 | (let ((cell1 (memq timer timer-list)) | 269 | (let ((cell1 (memq timer timer-list)) |
| 264 | (cell2 (memq timer timer-idle-list))) | 270 | (cell2 (memq timer timer-idle-list))) |
| 265 | (if cell1 | 271 | (if cell1 |
| @@ -270,7 +276,9 @@ of allocating a new one." | |||
| 270 | 276 | ||
| 271 | ;;;###autoload | 277 | ;;;###autoload |
| 272 | (defun cancel-function-timers (function) | 278 | (defun cancel-function-timers (function) |
| 273 | "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'." | ||
| 274 | (interactive "aCancel timers of function: ") | 282 | (interactive "aCancel timers of function: ") |
| 275 | (let ((tail timer-list)) | 283 | (let ((tail timer-list)) |
| 276 | (while tail | 284 | (while tail |
| @@ -284,9 +292,12 @@ of allocating a new one." | |||
| 284 | (setq tail (cdr tail))))) | 292 | (setq tail (cdr tail))))) |
| 285 | 293 | ||
| 286 | ;; Record the last few events, for debugging. | 294 | ;; Record the last few events, for debugging. |
| 287 | (defvar timer-event-last-2 nil) | 295 | (defvar timer-event-last nil |
| 288 | (defvar timer-event-last-1 nil) | 296 | "Last timer that was run.") |
| 289 | (defvar timer-event-last nil) | 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.") | ||
| 290 | 301 | ||
| 291 | (defvar timer-max-repeats 10 | 302 | (defvar timer-max-repeats 10 |
| 292 | "*Maximum number of times to repeat a timer, if real time jumps.") | 303 | "*Maximum number of times to repeat a timer, if real time jumps.") |
| @@ -440,6 +451,7 @@ This function returns a timer object which you can use in `cancel-timer'." | |||
| 440 | timer)) | 451 | timer)) |
| 441 | 452 | ||
| 442 | (defun with-timeout-handler (tag) | 453 | (defun with-timeout-handler (tag) |
| 454 | "This is the timer function used for the timer made by `with-timeout'." | ||
| 443 | (throw tag 'timeout)) | 455 | (throw tag 'timeout)) |
| 444 | 456 | ||
| 445 | ;;;###autoload (put 'with-timeout 'lisp-indent-function 1) | 457 | ;;;###autoload (put 'with-timeout 'lisp-indent-function 1) |