GNU bug report logs - #18157
24.4.50; battery-pmset fails to report critical battery state

Previous Next

Package: emacs;

Reported by: Sebastian Wiesner <swiesner <at> lunaryorn.com>

Date: Thu, 31 Jul 2014 13:18:02 UTC

Severity: normal

Tags: fixed

Found in version 24.4.50

Fixed in version 25.1

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Marcin Borkowski <mbork <at> mbork.pl>
To: Sebastian Wiesner <swiesner <at> lunaryorn.com>
Cc: mbork <at> mbork.pl, 18157 <at> debbugs.gnu.org
Subject: bug#18157: 24.4.50; battery-pmset fails to report critical battery state
Date: Tue, 16 Feb 2016 15:56:56 +0100
On 2014-07-31, at 16:16, Sebastian Wiesner <swiesner <at> lunaryorn.com> wrote:

> `battery-pmset' fails to correctly report critical battery state:  Even
> if the battery charge level is below `battery-load-critical', it reports
> "low" battery state only.
>
> The culprit is the `cond' expression in the body of `battery-pmset'
> which compares the reported `load-percentage' against `battery-load-low'
> first, and then against `battery-load-critical'.
>
> Since the latter is typically lower, it will never be reached, because
> `cond' already returns after the former succeeded.
>
> To fix this issue, `batter-pmset' needs to check `battery-load-critical'
> *first*, and then `battery-load-low'.

Does this patch help?

--8<---------------cut here---------------start------------->8---
diff -u --label /usr/local/share/emacs/25.1.50/lisp/battery.el.gz --label \#\<buffer\ battery.el.gz\> /tmp/jka-com1889YvM /tmp/buffer-content-1889yDZ
--- /usr/local/share/emacs/25.1.50/lisp/battery.el.gz
+++ #<buffer battery.el.gz>
@@ -628,12 +628,12 @@
 	    (cond ((looking-at "; charging")
 		   (setq battery-status "charging"
 			 battery-status-symbol "+"))
-		  ((< (string-to-number load-percentage) battery-load-low)
-		   (setq battery-status "low"
-			 battery-status-symbol "-"))
 		  ((< (string-to-number load-percentage) battery-load-critical)
 		   (setq battery-status "critical"
 			 battery-status-symbol "!"))
+		  ((< (string-to-number load-percentage) battery-load-low)
+		   (setq battery-status "low"
+			 battery-status-symbol "-"))
 		  (t
 		   (setq battery-status "high"
 			 battery-status-symbol "")))

Diff finished.  Tue Feb 16 15:56:03 2016
--8<---------------cut here---------------end--------------->8---

Best,

--
mb




This bug report was last modified 9 years and 89 days ago.

Previous Next


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