all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Sebastian Wiesner <swiesner@lunaryorn.com>
Cc: mbork@mbork.pl, 18157@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	[thread overview]
Message-ID: <874md81z5z.fsf@amu.edu.pl> (raw)
In-Reply-To: <m238dhmzwj.fsf@lunaryorn.com> (Sebastian Wiesner's message of "Thu, 31 Jul 2014 15:16:44 +0200")

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?

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





  reply	other threads:[~2016-02-16 14:56 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 [this message]
2016-02-16 18:41   ` Sebastian Wiesner
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874md81z5z.fsf@amu.edu.pl \
    --to=mbork@mbork.pl \
    --cc=18157@debbugs.gnu.org \
    --cc=swiesner@lunaryorn.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.