GNU bug report logs - #10332
battery.el not working when multiple batteries are present

Previous Next

Package: emacs;

Reported by: Dan Nicolaescu <dann <at> gnu.org>

Date: Mon, 19 Dec 2011 22:38:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 24.2

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dan Nicolaescu <dann <at> gnu.org>
To: 10332 <at> debbugs.gnu.org
Subject: bug#10332: battery.el not working when multiple batteries are present
Date: Mon, 19 Dec 2011 17:36:00 -0500
On a machine that has a normal battery and another one that can be put
in the CD/DVD slot M-x battery does not work when both batteries are
present.  

Only one battery is discharged at a time, but that seems to confuse
battery.el when computing `rate-type' for the battery not being
discharged.

Here's a proposed patch.



=== modified file 'lisp/battery.el'
--- lisp/battery.el	2011-10-19 12:54:24 +0000
+++ lisp/battery.el	2011-10-20 21:40:57 +0000
@@ -337,14 +337,15 @@
 	       (setq charging-state (match-string 1)))
 	  (when (re-search-forward "present rate: +\\([0-9]+\\) \\(m[AW]\\)$"
 				   nil t)
-	    (setq rate (+ (or rate 0) (string-to-number (match-string 1)))
-		  rate-type (or (and rate-type
+	    (setq rate (+ (or rate 0) (string-to-number (match-string 1))))
+	    (when (> rate 0)
+	      (setq rate-type (or (and rate-type
 				     (if (string= rate-type (match-string 2))
 					 rate-type
 				       (error
 					"Inconsistent rate types (%s vs. %s)"
 					rate-type (match-string 2))))
-				(match-string 2))))
+				  (match-string 2)))))
 	  (when (re-search-forward "remaining capacity: +\\([0-9]+\\) m[AW]h$"
 				   nil t)
 	    (setq capacity







This bug report was last modified 13 years and 47 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.