diff options
| author | Richard M. Stallman | 1996-02-02 19:58:21 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-02-02 19:58:21 +0000 |
| commit | 04ec3e397ec816a6c210c5ccad2793cbcfbf6c99 (patch) | |
| tree | 8bd6e7534d200881fbeae686eee078ddf88840c7 | |
| parent | 91341ed256e300051342c2ef9d560db1d06f0bc8 (diff) | |
| download | emacs-04ec3e397ec816a6c210c5ccad2793cbcfbf6c99.tar.gz emacs-04ec3e397ec816a6c210c5ccad2793cbcfbf6c99.zip | |
(display-time): Rewrite to use built-in timers.
(display-time-event-handler): Renamed from display-time-filter;
now takes no parameters.
(display-time-sentinel): Function deleted.
(display-time-process): Variable deleted.
(display-time-timer): New variable.
| -rw-r--r-- | lisp/time.el | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/lisp/time.el b/lisp/time.el index f61cd52d882..af5cb03c347 100644 --- a/lisp/time.el +++ b/lisp/time.el | |||
| @@ -37,7 +37,7 @@ default, which is system-dependent, and is the same as used by Rmail.") | |||
| 37 | (defvar display-time-day-and-date nil "\ | 37 | (defvar display-time-day-and-date nil "\ |
| 38 | *Non-nil means \\[display-time] should display day and date as well as time.") | 38 | *Non-nil means \\[display-time] should display day and date as well as time.") |
| 39 | 39 | ||
| 40 | (defvar display-time-process nil) | 40 | (defvar display-time-timer nil) |
| 41 | 41 | ||
| 42 | (defvar display-time-interval 60 | 42 | (defvar display-time-interval 60 |
| 43 | "*Seconds between updates of time in the mode line.") | 43 | "*Seconds between updates of time in the mode line.") |
| @@ -63,41 +63,18 @@ If `display-time-day-and-date' is non-nil, the current day and date | |||
| 63 | are displayed as well. | 63 | are displayed as well. |
| 64 | After each update, `display-time-hook' is run with `run-hooks'." | 64 | After each update, `display-time-hook' is run with `run-hooks'." |
| 65 | (interactive) | 65 | (interactive) |
| 66 | (let ((live (or (and (eq system-type 'ms-dos) dos-display-time) | 66 | (require 'timer) |
| 67 | (and display-time-process | 67 | (if (timerp display-time-timer) |
| 68 | (eq (process-status display-time-process) 'run))))) | 68 | (cancel-timer display-time-timer) |
| 69 | (if (not live) | 69 | (setq display-time-timer (timer-create))) |
| 70 | (progn | 70 | (setq display-time-string "") |
| 71 | (if display-time-process | 71 | (or global-mode-string (setq global-mode-string '(""))) |
| 72 | (delete-process display-time-process)) | 72 | (or (memq 'display-time-string global-mode-string) |
| 73 | (or global-mode-string (setq global-mode-string '(""))) | 73 | (setq global-mode-string |
| 74 | (or (memq 'display-time-string global-mode-string) | 74 | (append global-mode-string '(display-time-string)))) |
| 75 | (setq global-mode-string | 75 | (timer-set-time display-time-timer (current-time) display-time-interval) |
| 76 | (append global-mode-string '(display-time-string)))) | 76 | (timer-set-function display-time-timer 'display-time-event-handler) |
| 77 | (setq display-time-string "") | 77 | (timer-activate display-time-timer)) |
| 78 | (if (eq system-type 'ms-dos) | ||
| 79 | (setq dos-display-time t) | ||
| 80 | ;; Using a pty is wasteful, and the separate session causes | ||
| 81 | ;; annoyance sometimes (some systems kill idle sessions). | ||
| 82 | (progn | ||
| 83 | (let ((process-connection-type nil)) | ||
| 84 | (setq display-time-process | ||
| 85 | (start-process "display-time" nil | ||
| 86 | (expand-file-name | ||
| 87 | "wakeup" exec-directory) | ||
| 88 | (int-to-string display-time-interval)))) | ||
| 89 | (process-kill-without-query display-time-process) | ||
| 90 | (set-process-sentinel display-time-process | ||
| 91 | 'display-time-sentinel) | ||
| 92 | (set-process-filter display-time-process | ||
| 93 | 'display-time-filter))))))) | ||
| 94 | |||
| 95 | (defun display-time-sentinel (proc reason) | ||
| 96 | (or (eq (process-status proc) 'run) | ||
| 97 | (setq display-time-string "")) | ||
| 98 | ;; Force mode-line updates | ||
| 99 | (force-mode-line-update t) | ||
| 100 | (sit-for 0)) | ||
| 101 | 78 | ||
| 102 | (defvar display-time-string-forms | 79 | (defvar display-time-string-forms |
| 103 | '((if display-time-day-and-date | 80 | '((if display-time-day-and-date |
| @@ -124,7 +101,7 @@ For example, the form | |||
| 124 | 101 | ||
| 125 | would give mode line times like `94/12/30 21:07:48 (UTC)'.") | 102 | would give mode line times like `94/12/30 21:07:48 (UTC)'.") |
| 126 | 103 | ||
| 127 | (defun display-time-filter (proc string) | 104 | (defun display-time-event-handler () |
| 128 | (let* ((now (current-time)) | 105 | (let* ((now (current-time)) |
| 129 | (time (current-time-string now)) | 106 | (time (current-time-string now)) |
| 130 | (load (condition-case () | 107 | (load (condition-case () |