Mercurial > emacs
annotate lisp/=timer.el @ 14287:6cf50a9ff10f
(find-file-noselect): Fix error message style.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Wed, 24 Jan 1996 23:25:44 +0000 |
parents | 83f275dcd93a |
children | 64e80af54f06 |
rev | line source |
---|---|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; timer.el --- run a function with args at some time in future |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
7300 | 3 ;; Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc. |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Maintainer: FSF |
45 | 6 |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
11 ;; the Free Software Foundation; either version 2, or (at your option) |
45 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
45 | 23 |
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2086
diff
changeset
|
24 ;;; Commentary: |
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2086
diff
changeset
|
25 |
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2086
diff
changeset
|
26 ;; This package gives you the capability to run Emacs Lisp commands at |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3352
diff
changeset
|
27 ;; specified times in the future, either as one-shots or periodically. |
2319
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2086
diff
changeset
|
28 ;; The single entry point is `run-at-time'. |
d98c49df2acd
Added or corrected Commentary section
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2086
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
30 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
31 |
9641
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
32 (defvar timer-program (expand-file-name "timer" exec-directory) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
33 "The name of the program to run as the timer subprocess. |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
34 It should normally be in the exec-directory.") |
2447
6ff9eee5cdc9
* timer.el (timer-program): New defconst.
Jim Blandy <jimb@redhat.com>
parents:
2319
diff
changeset
|
35 |
45 | 36 (defvar timer-process nil) |
37 (defvar timer-alist ()) | |
38 (defvar timer-out "") | |
39 (defvar timer-dont-exit nil | |
40 ;; this is useful for functions which will be doing their own erratic | |
41 ;; rescheduling or people who otherwise expect to use the process frequently | |
42 "If non-nil, don't exit the timer process when no more events are pending.") | |
43 | |
9641
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
44 ;; Error symbols for timers |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
45 (put 'timer-error 'error-conditions '(error timer-error)) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
46 (put 'timer-error 'error-message "Timer error") |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
47 |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
48 (put 'timer-abnormal-termination |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
49 'error-conditions |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
50 '(error timer-error timer-abnormal-termination)) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
51 (put 'timer-abnormal-termination |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
52 'error-message |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
53 "Timer exited abnormally--all events cancelled") |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
54 |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
55 (put 'timer-filter-error |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
56 'error-conditions |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
57 '(error timer-error timer-filter-error)) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
58 (put 'timer-filter-error |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
59 'error-message |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
60 "Error in timer process filter") |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
61 |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
62 |
6693
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
63 ;; This should not be necessary, but on some systems, we get |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
64 ;; unkillable processes without this. |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
65 ;; It may be a kernel bug, but that's not certain. |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
66 (defun timer-kill-emacs-hook () |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
67 (if timer-process |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
68 (progn |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
69 (set-process-sentinel timer-process nil) |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
70 (set-process-filter timer-process nil) |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
71 (delete-process timer-process)))) |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
72 (add-hook 'kill-emacs-hook 'timer-kill-emacs-hook) |
3661fe3c03d7
(timer-kill-emacs-hook): New function.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
73 |
584 | 74 ;;;###autoload |
45 | 75 (defun run-at-time (time repeat function &rest args) |
76 "Run a function at a time, and optionally on a regular interval. | |
77 Arguments are TIME, REPEAT, FUNCTION &rest ARGS. | |
2086
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
78 TIME, a string, can be specified absolutely or relative to now. |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
79 TIME can also be an integer, a number of seconds. |
45 | 80 REPEAT, an integer number of seconds, is the interval on which to repeat |
8044
6cc76dc79853
(run-at-time): If REPEAT is 0, don't repeat.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
81 the call to the function. If REPEAT is nil or 0, call it just once. |
1983
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
82 |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
83 Absolute times may be specified in a wide variety of formats; |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
84 Something of the form `HOUR:MIN:SEC TIMEZONE MONTH/DAY/YEAR', where |
2086
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
85 all fields are numbers, works; the format used by the Unix `date' |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
86 command works too. |
1983
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
87 |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
88 Relative times may be specified as a series of numbers followed by units: |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
89 1 min denotes one minute from now. |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
90 min does too. |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
91 1 min 5 sec denotes 65 seconds from now. |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
92 1 min 2 sec 3 hour 4 day 5 week 6 fortnight 7 month 8 year |
f7da227e3e68
* timer.el (run-at-time): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
1753
diff
changeset
|
93 denotes the sum of all the given durations from now." |
45 | 94 (interactive "sRun at time: \nNRepeat interval: \naFunction: ") |
8044
6cc76dc79853
(run-at-time): If REPEAT is 0, don't repeat.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
95 (if (equal repeat 0) |
6cc76dc79853
(run-at-time): If REPEAT is 0, don't repeat.
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
96 (setq repeat nil)) |
2086
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
97 ;; Make TIME a string. |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
98 (if (integerp time) |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
99 (setq time (format "%d sec" time))) |
45 | 100 (cond ((or (not timer-process) |
101 (memq (process-status timer-process) '(exit signal nil))) | |
102 (if timer-process (delete-process timer-process)) | |
2447
6ff9eee5cdc9
* timer.el (timer-program): New defconst.
Jim Blandy <jimb@redhat.com>
parents:
2319
diff
changeset
|
103 (setq timer-process |
6ff9eee5cdc9
* timer.el (timer-program): New defconst.
Jim Blandy <jimb@redhat.com>
parents:
2319
diff
changeset
|
104 (let ((process-connection-type nil)) |
9641
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
105 (start-process "timer" nil timer-program)) |
45 | 106 timer-alist nil) |
107 (set-process-filter timer-process 'timer-process-filter) | |
108 (set-process-sentinel timer-process 'timer-process-sentinel) | |
109 (process-kill-without-query timer-process)) | |
110 ((eq (process-status timer-process) 'stop) | |
111 (continue-process timer-process))) | |
112 ;; There should be a living, breathing timer process now | |
2086
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
113 (let* ((token (concat (current-time-string) "-" (length timer-alist))) |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
114 (elt (list token repeat function args))) |
1753
852bc0022185
Use process-send-string instead of send-string.
Michael I. Bushnell <mib@gnu.org>
parents:
1747
diff
changeset
|
115 (process-send-string timer-process (concat time "@" token "\n")) |
2086
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
116 (setq timer-alist (cons elt timer-alist)) |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
117 elt)) |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
118 |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
119 (defun cancel-timer (elt) |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
120 "Cancel a timer previously made with `run-at-time'. |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
121 The argument should be a value previously returned by `run-at-time'. |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
122 Cancelling the timer means that nothing special |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
123 will happen at the specified time." |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
124 (setcar (cdr elt) nil) |
3daa7f080f2b
(run-at-time): Allow an integer as TIME.
Richard M. Stallman <rms@gnu.org>
parents:
1983
diff
changeset
|
125 (setcar (cdr (cdr elt)) 'ignore)) |
45 | 126 |
127 (defun timer-process-filter (proc str) | |
10041
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
128 (setq timer-out (concat timer-out str)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
129 (let (do token error) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
130 (while (string-match "\n" timer-out) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
131 (setq token (substring timer-out 0 (match-beginning 0)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
132 do (assoc token timer-alist) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
133 timer-out (substring timer-out (match-end 0))) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
134 (cond |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
135 (do |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
136 (apply (nth 2 do) (nth 3 do)) ; do it |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
137 (if (natnump (nth 1 do)) ; reschedule it |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
138 (send-string proc (concat (nth 1 do) " sec@" (car do) "\n")) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
139 (setq timer-alist (delq do timer-alist)))) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
140 ((string-match "timer: \\([^:]+\\): \\([^@]*\\)@\\(.*\\)$" token) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
141 (setq error (substring token (match-beginning 1) (match-end 1)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
142 do (substring token (match-beginning 2) (match-end 2)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
143 token (assoc (substring token (match-beginning 3) (match-end 3)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
144 timer-alist) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
145 timer-alist (delq token timer-alist)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
146 (or timer-alist |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
147 timer-dont-exit |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
148 (process-send-eof proc)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
149 ;; Update error message for this particular instance |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
150 (put 'timer-filter-error |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
151 'error-message |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
152 (format "%s for %s; couldn't set at \"%s\"" |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
153 error (nth 2 token) do)) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
154 (signal 'timer-filter-error (list proc str))))) |
b1ee0b2d3f53
(timer-process-filter): No need for save-match-data.
Richard M. Stallman <rms@gnu.org>
parents:
9994
diff
changeset
|
155 (or timer-alist timer-dont-exit (process-send-eof proc)))) |
45 | 156 |
157 (defun timer-process-sentinel (proc str) | |
158 (let ((stat (process-status proc))) | |
9641
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
159 (if (eq stat 'stop) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
160 (continue-process proc) |
45 | 161 ;; if it exited normally, presumably it was intentional. |
162 ;; if there were no pending events, who cares that it exited? | |
9641
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
163 (or (null timer-alist) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
164 (eq stat 'exit) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
165 (let ((alist timer-alist)) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
166 (setq timer-process nil timer-alist nil) |
284c46319091
(timer-error, timer-abnormal-termination,
Richard M. Stallman <rms@gnu.org>
parents:
8044
diff
changeset
|
167 (signal 'timer-abnormal-termination (list proc stat str alist)))) |
1241
de92360b091b
(timer-process-sentinel): Don't set timer-scratch.
Richard M. Stallman <rms@gnu.org>
parents:
1223
diff
changeset
|
168 ;; Used to set timer-scratch to "", but nothing uses that var. |
de92360b091b
(timer-process-sentinel): Don't set timer-scratch.
Richard M. Stallman <rms@gnu.org>
parents:
1223
diff
changeset
|
169 (setq timer-process nil timer-alist nil)))) |
45 | 170 |
3267
ac18ead9965d
(cancel-function-timers): Renamed from spurious duplicate
Richard M. Stallman <rms@gnu.org>
parents:
2447
diff
changeset
|
171 (defun cancel-function-timers (function) |
1577 | 172 "Cancel all events scheduled by `run-at-time' which would run FUNCTION." |
3267
ac18ead9965d
(cancel-function-timers): Renamed from spurious duplicate
Richard M. Stallman <rms@gnu.org>
parents:
2447
diff
changeset
|
173 (interactive "aCancel timers of function: ") |
45 | 174 (let ((alist timer-alist)) |
175 (while alist | |
176 (if (eq (nth 2 (car alist)) function) | |
177 (setq timer-alist (delq (car alist) timer-alist))) | |
178 (setq alist (cdr alist)))) | |
179 (or timer-alist timer-dont-exit (process-send-eof timer-process))) | |
180 | |
181 (provide 'timer) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
182 |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
183 ;;; timer.el ends here |