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


Message #11 received at 18157 <at> debbugs.gnu.org (full text, mbox):

From: Sebastian Wiesner <swiesner <at> lunaryorn.com>
To: Marcin Borkowski <mbork <at> mbork.pl>
Cc: 18157 <at> debbugs.gnu.org
Subject: Re: bug#18157: 24.4.50;
 battery-pmset fails to report critical battery state
Date: Tue, 16 Feb 2016 19:41:25 +0100
> Am 16.02.2016 um 15:56 schrieb Marcin Borkowski <mbork <at> mbork.pl>:
> 
> 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?

I'm sorry, are you asking me?  It would be bold to believe that I still cared for this issue now, almost *two years* after I reported it.  

At a cursory look the fix surely looks correct, but I hope you understand that Emacs taking two years for what seems to be a trivial issue to fix does not particularly contribute to my enthusiasm, nor does it motivate me to test this patch.

> --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.