* lisp/battery.el (battery-update): Handle the case where battery
authorNicolas Richard <theonewiththeevillook@yahoo.fr>
Fri, 25 Apr 2014 18:01:18 +0000 (14:01 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 25 Apr 2014 18:01:18 +0000 (14:01 -0400)
status is "N/A".

Fixes: debbugs:17319

lisp/ChangeLog
lisp/battery.el

index 60543c6..9943884 100644 (file)
@@ -1,7 +1,12 @@
+2014-04-25  Nicolas Richard  <theonewiththeevillook@yahoo.fr>
+
+       * battery.el (battery-update): Handle the case where battery
+       status is "N/A" (bug#17319).
+
 2014-04-24  Eli Zaretskii  <eliz@gnu.org>
 
-       * tooltip.el (tooltip-show-help-non-mode, tooltip-show-help): Use
-       equal-including-properties to compare help-echo strings.  (Bug#17331)
+       * tooltip.el (tooltip-show-help-non-mode, tooltip-show-help):
+       Use equal-including-properties to compare help-echo strings (bug#17331).
 
 2014-04-24  Leo Liu  <sdl.web@gmail.com>
 
index 1eef80a..b493634 100644 (file)
@@ -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))
 \f