diff options
| author | Lute Kamstra | 2005-07-01 11:03:19 +0000 |
|---|---|---|
| committer | Lute Kamstra | 2005-07-01 11:03:19 +0000 |
| commit | 12d6b12433b560d4e82833a6c5f2dfbc4763c10c (patch) | |
| tree | 19d48ae83aee805fde6874f68968a534d9739a3d | |
| parent | b97c98ad01e66166679c23cc5e6a9a1a018f7bd8 (diff) | |
| download | emacs-12d6b12433b560d4e82833a6c5f2dfbc4763c10c.tar.gz emacs-12d6b12433b560d4e82833a6c5f2dfbc4763c10c.zip | |
(battery-linux-proc-apm): Fix typo in docstring.
Catch errors with ignore-errors. Use temporary buffer.
(battery-linux-proc-acpi): Fix typo in docstring. Document `%r'.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/battery.el | 81 |
2 files changed, 43 insertions, 42 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0aaf512a1bb..77cc2e53db4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2005-07-01 Lute Kamstra <lute@gnu.org> | 1 | 2005-07-01 Lute Kamstra <lute@gnu.org> |
| 2 | 2 | ||
| 3 | * battery.el (battery-linux-proc-apm): Fix typo in docstring. | ||
| 4 | Catch errors with ignore-errors. Use temporary buffer. | ||
| 5 | (battery-linux-proc-acpi): Fix typo in docstring. Document `%r'. | ||
| 6 | |||
| 3 | * facemenu.el (facemenu-unlisted-faces): Delete foreground and | 7 | * facemenu.el (facemenu-unlisted-faces): Delete foreground and |
| 4 | background color faces. | 8 | background color faces. |
| 5 | (facemenu-set-foreground, facemenu-set-background): Use | 9 | (facemenu-set-foreground, facemenu-set-background): Use |
diff --git a/lisp/battery.el b/lisp/battery.el index 42ceec0c90c..6e94c176513 100644 --- a/lisp/battery.el +++ b/lisp/battery.el | |||
| @@ -171,53 +171,49 @@ The following %-sequences are provided: | |||
| 171 | %B Battery status (verbose) | 171 | %B Battery status (verbose) |
| 172 | %b Battery status, empty means high, `-' means low, | 172 | %b Battery status, empty means high, `-' means low, |
| 173 | `!' means critical, and `+' means charging | 173 | `!' means critical, and `+' means charging |
| 174 | %p battery load percentage | 174 | %p Battery load percentage |
| 175 | %s Remaining time in seconds | 175 | %s Remaining time in seconds |
| 176 | %m Remaining time in minutes | 176 | %m Remaining time in minutes |
| 177 | %h Remaining time in hours | 177 | %h Remaining time in hours |
| 178 | %t Remaining time in the form `h:min'" | 178 | %t Remaining time in the form `h:min'" |
| 179 | (let (driver-version bios-version bios-interface line-status | 179 | (let (driver-version bios-version bios-interface line-status |
| 180 | battery-status battery-status-symbol load-percentage | 180 | battery-status battery-status-symbol load-percentage |
| 181 | seconds minutes hours remaining-time buffer tem) | 181 | seconds minutes hours remaining-time tem) |
| 182 | (unwind-protect | 182 | (with-temp-buffer |
| 183 | (save-excursion | 183 | (ignore-errors (insert-file-contents "/proc/apm")) |
| 184 | (setq buffer (get-buffer-create " *battery*")) | 184 | (when (re-search-forward battery-linux-proc-apm-regexp) |
| 185 | (set-buffer buffer) | 185 | (setq driver-version (match-string 1)) |
| 186 | (erase-buffer) | 186 | (setq bios-version (match-string 2)) |
| 187 | (insert-file-contents "/proc/apm") | 187 | (setq tem (string-to-number (match-string 3) 16)) |
| 188 | (re-search-forward battery-linux-proc-apm-regexp) | 188 | (if (not (logand tem 2)) |
| 189 | (setq driver-version (match-string 1)) | 189 | (setq bios-interface "not supported") |
| 190 | (setq bios-version (match-string 2)) | 190 | (setq bios-interface "enabled") |
| 191 | (setq tem (string-to-number (match-string 3) 16)) | 191 | (cond ((logand tem 16) (setq bios-interface "disabled")) |
| 192 | (if (not (logand tem 2)) | 192 | ((logand tem 32) (setq bios-interface "disengaged"))) |
| 193 | (setq bios-interface "not supported") | 193 | (setq tem (string-to-number (match-string 4) 16)) |
| 194 | (setq bios-interface "enabled") | 194 | (cond ((= tem 0) (setq line-status "off-line")) |
| 195 | (cond ((logand tem 16) (setq bios-interface "disabled")) | 195 | ((= tem 1) (setq line-status "on-line")) |
| 196 | ((logand tem 32) (setq bios-interface "disengaged"))) | 196 | ((= tem 2) (setq line-status "on backup"))) |
| 197 | (setq tem (string-to-number (match-string 4) 16)) | 197 | (setq tem (string-to-number (match-string 6) 16)) |
| 198 | (cond ((= tem 0) (setq line-status "off-line")) | 198 | (if (= tem 255) |
| 199 | ((= tem 1) (setq line-status "on-line")) | 199 | (setq battery-status "N/A") |
| 200 | ((= tem 2) (setq line-status "on backup"))) | 200 | (setq tem (string-to-number (match-string 5) 16)) |
| 201 | (setq tem (string-to-number (match-string 6) 16)) | 201 | (cond ((= tem 0) (setq battery-status "high" |
| 202 | (if (= tem 255) | 202 | battery-status-symbol "")) |
| 203 | (setq battery-status "N/A") | 203 | ((= tem 1) (setq battery-status "low" |
| 204 | (setq tem (string-to-number (match-string 5) 16)) | 204 | battery-status-symbol "-")) |
| 205 | (cond ((= tem 0) (setq battery-status "high" | 205 | ((= tem 2) (setq battery-status "critical" |
| 206 | battery-status-symbol "")) | 206 | battery-status-symbol "!")) |
| 207 | ((= tem 1) (setq battery-status "low" | 207 | ((= tem 3) (setq battery-status "charging" |
| 208 | battery-status-symbol "-")) | 208 | battery-status-symbol "+"))) |
| 209 | ((= tem 2) (setq battery-status "critical" | 209 | (setq load-percentage (match-string 7)) |
| 210 | battery-status-symbol "!")) | 210 | (setq seconds (string-to-number (match-string 8))) |
| 211 | ((= tem 3) (setq battery-status "charging" | 211 | (and (string-equal (match-string 9) "min") |
| 212 | battery-status-symbol "+"))) | 212 | (setq seconds (* 60 seconds))) |
| 213 | (setq load-percentage (match-string 7)) | 213 | (setq minutes (/ seconds 60) |
| 214 | (setq seconds (string-to-number (match-string 8))) | 214 | hours (/ seconds 3600)) |
| 215 | (and (string-equal (match-string 9) "min") | 215 | (setq remaining-time |
| 216 | (setq seconds (* 60 seconds))) | 216 | (format "%d:%02d" hours (- minutes (* 60 hours)))))))) |
| 217 | (setq minutes (/ seconds 60) | ||
| 218 | hours (/ seconds 3600)) | ||
| 219 | (setq remaining-time | ||
| 220 | (format "%d:%02d" hours (- minutes (* 60 hours)))))))) | ||
| 221 | (list (cons ?v (or driver-version "N/A")) | 217 | (list (cons ?v (or driver-version "N/A")) |
| 222 | (cons ?V (or bios-version "N/A")) | 218 | (cons ?V (or bios-version "N/A")) |
| 223 | (cons ?I (or bios-interface "N/A")) | 219 | (cons ?I (or bios-interface "N/A")) |
| @@ -240,12 +236,13 @@ in Linux version 2.4.20 and 2.6.0. | |||
| 240 | 236 | ||
| 241 | The following %-sequences are provided: | 237 | The following %-sequences are provided: |
| 242 | %c Current capacity (mAh) | 238 | %c Current capacity (mAh) |
| 239 | %r Current rate | ||
| 243 | %B Battery status (verbose) | 240 | %B Battery status (verbose) |
| 244 | %b Battery status, empty means high, `-' means low, | 241 | %b Battery status, empty means high, `-' means low, |
| 245 | `!' means critical, and `+' means charging | 242 | `!' means critical, and `+' means charging |
| 246 | %d Temperature (in degrees Celsius) | 243 | %d Temperature (in degrees Celsius) |
| 247 | %L AC line status (verbose) | 244 | %L AC line status (verbose) |
| 248 | %p battery load percentage | 245 | %p Battery load percentage |
| 249 | %m Remaining time in minutes | 246 | %m Remaining time in minutes |
| 250 | %h Remaining time in hours | 247 | %h Remaining time in hours |
| 251 | %t Remaining time in the form `h:min'" | 248 | %t Remaining time in the form `h:min'" |