diff options
author | Nicolas Richard <theonewiththeevillook@yahoo.fr> | 2014-04-25 14:01:18 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-04-25 14:01:18 -0400 |
commit | 0507406b6ca75c4366dd16855123e8fc9b012c6b (patch) | |
tree | a8810668f268969f5f63ff07ee21eac084cb4343 /lisp/battery.el | |
parent | 844465d6cac7c243e37e446067b1a2e06be293da (diff) | |
download | emacs-0507406b6ca75c4366dd16855123e8fc9b012c6b.tar.gz |
* lisp/battery.el (battery-update): Handle the case where battery
status is "N/A".
Fixes: debbugs:17319
Diffstat (limited to 'lisp/battery.el')
-rw-r--r-- | lisp/battery.el | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lisp/battery.el b/lisp/battery.el index 1eef80ab339..b49363489a8 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -201,19 +201,18 @@ seconds." (defun battery-update () "Update battery status information in the mode line." - (let ((data (and battery-status-function (funcall battery-status-function)))) + (let* ((data (and battery-status-function (funcall battery-status-function))) + (percentage (car (read-from-string (cdr (assq ?p data)))))) (setq battery-mode-line-string (propertize (if (and battery-mode-line-format - (<= (car (read-from-string (cdr (assq ?p data)))) - battery-mode-line-limit)) - (battery-format - battery-mode-line-format - data) + (numberp percentage) + (<= percentage battery-mode-line-limit)) + (battery-format battery-mode-line-format data) "") 'face - (and (<= (car (read-from-string (cdr (assq ?p data)))) - battery-load-critical) - 'error) + (and (numberp percentage) + (<= percentage battery-load-critical) + 'error) 'help-echo "Battery status information"))) (force-mode-line-update)) |