Mercurial > emacs
comparison lisp/battery.el @ 21317:566100bc6eef
(battery-linux-proc-apm): Re-use the temporary buffer.
(battery-insert-file-contents): Disable code conversion.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 30 Mar 1998 04:39:53 +0000 |
parents | ac1673121774 |
children | 983f253505d0 |
comparison
equal
deleted
inserted
replaced
21316:8bfa13d10dd1 | 21317:566100bc6eef |
---|---|
167 (let (driver-version bios-version bios-interface line-status | 167 (let (driver-version bios-version bios-interface line-status |
168 battery-status battery-status-symbol load-percentage | 168 battery-status battery-status-symbol load-percentage |
169 seconds minutes hours remaining-time buffer tem) | 169 seconds minutes hours remaining-time buffer tem) |
170 (unwind-protect | 170 (unwind-protect |
171 (save-excursion | 171 (save-excursion |
172 (setq buffer (generate-new-buffer " *battery*")) | 172 (setq buffer (get-buffer-create " *battery*")) |
173 (buffer-disable-undo buffer) | |
174 (set-buffer buffer) | 173 (set-buffer buffer) |
174 (erase-buffer) | |
175 (battery-insert-file-contents "/proc/apm") | 175 (battery-insert-file-contents "/proc/apm") |
176 (re-search-forward battery-linux-proc-apm-regexp) | 176 (re-search-forward battery-linux-proc-apm-regexp) |
177 (setq driver-version (match-string 1)) | 177 (setq driver-version (match-string 1)) |
178 (setq bios-version (match-string 2)) | 178 (setq bios-version (match-string 2)) |
179 (setq tem (battery-hex-to-int-2 (match-string 3))) | 179 (setq tem (battery-hex-to-int-2 (match-string 3))) |
203 (and (string-equal (match-string 9) "min") | 203 (and (string-equal (match-string 9) "min") |
204 (setq seconds (* 60 seconds))) | 204 (setq seconds (* 60 seconds))) |
205 (setq minutes (/ seconds 60) | 205 (setq minutes (/ seconds 60) |
206 hours (/ seconds 3600)) | 206 hours (/ seconds 3600)) |
207 (setq remaining-time | 207 (setq remaining-time |
208 (format "%d:%02d" hours (- minutes (* 60 hours))))))) | 208 (format "%d:%02d" hours (- minutes (* 60 hours)))))))) |
209 (and buffer (kill-buffer buffer))) | |
210 (list (cons ?v (or driver-version "N/A")) | 209 (list (cons ?v (or driver-version "N/A")) |
211 (cons ?V (or bios-version "N/A")) | 210 (cons ?V (or bios-version "N/A")) |
212 (cons ?I (or bios-interface "N/A")) | 211 (cons ?I (or bios-interface "N/A")) |
213 (cons ?L (or line-status "N/A")) | 212 (cons ?L (or line-status "N/A")) |
214 (cons ?B (or battery-status "N/A")) | 213 (cons ?B (or battery-status "N/A")) |
247 (defun battery-insert-file-contents (file-name) | 246 (defun battery-insert-file-contents (file-name) |
248 "Insert contents of file FILE-NAME after point. | 247 "Insert contents of file FILE-NAME after point. |
249 FILE-NAME can be a non-ordinary file, for example, a named pipe. | 248 FILE-NAME can be a non-ordinary file, for example, a named pipe. |
250 Return t if file exists." | 249 Return t if file exists." |
251 (let ((load-read-function 'battery-read-function) | 250 (let ((load-read-function 'battery-read-function) |
251 (load-source-file-function nil) | |
252 (load-path '(".")) | 252 (load-path '(".")) |
253 (load-history nil)) | 253 (load-history nil)) |
254 (save-excursion | 254 (save-excursion |
255 (load file-name nil t t)))) | 255 (load file-name nil t t)))) |
256 | 256 |