From: Sebastian Wiesner <swiesner@lunaryorn.com>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: 18157@debbugs.gnu.org
Subject: bug#18157: 24.4.50; battery-pmset fails to report critical battery state
Date: Tue, 16 Feb 2016 19:41:25 +0100 [thread overview]
Message-ID: <B87C8850-DDF0-412F-B75D-49FB298A9579@lunaryorn.com> (raw)
In-Reply-To: <874md81z5z.fsf@amu.edu.pl>
> Am 16.02.2016 um 15:56 schrieb Marcin Borkowski <mbork@mbork.pl>:
>
> On 2014-07-31, at 16:16, Sebastian Wiesner <swiesner@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
next prev parent reply other threads:[~2016-02-16 18:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 13:16 bug#18157: 24.4.50; battery-pmset fails to report critical battery state Sebastian Wiesner
2016-02-16 14:56 ` Marcin Borkowski
2016-02-16 18:41 ` Sebastian Wiesner [this message]
2016-02-16 19:04 ` Eli Zaretskii
2016-02-20 5:51 ` John Wiegley
2016-02-16 23:43 ` Marcin Borkowski
2016-02-20 7:36 ` Lars Ingebrigtsen
2016-02-20 7:35 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B87C8850-DDF0-412F-B75D-49FB298A9579@lunaryorn.com \
--to=swiesner@lunaryorn.com \
--cc=18157@debbugs.gnu.org \
--cc=mbork@mbork.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).