]> code.delx.au - gnu-emacs/blobdiff - lisp/battery.el
lisp/gnus/nnir.el ("nnir"): Add 'virtual ability to nnir backend
[gnu-emacs] / lisp / battery.el
index 78898534a478e5819bdeb57934e87df2c5ed1ffb..696b1214652c55906231460eb2d4364bb8e65254 100644 (file)
@@ -1,6 +1,6 @@
 ;;; battery.el --- display battery status information  -*- coding: iso-8859-1 -*-
 
-;; Copyright (C) 1997-1998, 2000-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2013 Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
 ;; Keywords: hardware
@@ -31,8 +31,7 @@
 ;;; Code:
 
 (require 'timer)
-(eval-when-compile (require 'cl))
-
+(eval-when-compile (require 'cl-lib))
 \f
 (defgroup battery nil
   "Display battery status information."
@@ -61,7 +60,7 @@
                         (> (buffer-size) 0)))
                (error nil)))
         'battery-pmset)
-       ((eq system-type 'windows-nt)
+       ((fboundp 'w32-battery-status)
         'w32-battery-status))
   "Function for getting battery status information.
 The function has to return an alist of conversion definitions.
@@ -78,7 +77,7 @@ introduced by a `%' character in a control string."
   (cond ((eq battery-status-function 'battery-linux-proc-acpi)
         "Power %L, battery %B at %r (%p%% load, remaining time %t)")
        ((eq battery-status-function 'battery-linux-sysfs)
-        "Power %L, battery %B (%p%% load)")
+        "Power %L, battery %B (%p%% load, remaining time %t)")
        ((eq battery-status-function 'battery-pmset)
         "%L power, battery %B (%p%% load, remaining time %t)")
        (battery-status-function
@@ -360,16 +359,16 @@ The following %-sequences are provided:
        (when (re-search-forward "present: +yes$" nil t)
          (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
-           (incf design-capacity (string-to-number (match-string 1))))
+           (cl-incf design-capacity (string-to-number (match-string 1))))
          (when (re-search-forward "last full capacity: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
-           (incf last-full-capacity (string-to-number (match-string 1))))
+           (cl-incf last-full-capacity (string-to-number (match-string 1))))
          (when (re-search-forward
                 "design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t)
-           (incf warn (string-to-number (match-string 1))))
+           (cl-incf warn (string-to-number (match-string 1))))
          (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
-           (incf low (string-to-number (match-string 1)))))))
+           (cl-incf low (string-to-number (match-string 1)))))))
     (setq full-capacity (if (> last-full-capacity 0)
                            last-full-capacity design-capacity))
     (and capacity rate
@@ -509,7 +508,7 @@ The following %-sequences are provided:
                     "N/A"))
          (cons ?d (or temperature "N/A"))
          (cons ?B (or charging-state "N/A"))
-         (cons ?p (cond ((> charge-full 0)
+         (cons ?p (cond ((and (> charge-full 0) (> charge-now 0))
                          (format "%.1f"
                                  (/ (* 100 charge-now) charge-full)))
                         ((> energy-full 0)