]> code.delx.au - gnu-emacs/blobdiff - lisp/battery.el
Update copyright year to 2015
[gnu-emacs] / lisp / battery.el
index 1eef80ab33902462a6c5d8643305d025a783dd93..41e5979f1f228055832b04dd9ba05fd728686a8e 100644 (file)
@@ -1,6 +1,6 @@
 ;;; battery.el --- display battery status information  -*- coding: utf-8 -*-
 
-;; Copyright (C) 1997-1998, 2000-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2015 Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
 ;; Keywords: hardware
@@ -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