aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2014-03-22 17:08:47 -0700
committerGlenn Morris2014-03-22 17:08:47 -0700
commit9e37f3b9c3321029fb12479c1e1bbba7e708f8f5 (patch)
treefaaf583c2158a3afe3d561230cfdc9f87db80d05
parent3e702d1649d4f4f67ed355a26ff707733c39e6d8 (diff)
downloademacs-9e37f3b9c3321029fb12479c1e1bbba7e708f8f5.tar.gz
emacs-9e37f3b9c3321029fb12479c1e1bbba7e708f8f5.zip
Backport Yeeloong battery.el fix from trunk
Ref: http://lists.gnu.org/archive/html/emacs-devel/2014-03/msg00782.html * lisp/battery.el (battery-linux-sysfs): Search for each field from the beginning of the buffer.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/battery.el6
2 files changed, 10 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7cf7d50118c..24248ded265 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12014-03-23 Richard Stallman <rms@gnu.org>
2
3 * battery.el (battery-linux-sysfs): Search for each field
4 from the beginning of the buffer.
5
12014-03-22 Dmitry Gutov <dgutov@yandex.ru> 62014-03-22 Dmitry Gutov <dgutov@yandex.ru>
2 7
3 * emacs-lisp/package.el (package-desc): Use the contents of the 8 * emacs-lisp/package.el (package-desc): Use the contents of the
diff --git a/lisp/battery.el b/lisp/battery.el
index 28ddf368f5f..1eef80ab339 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -458,12 +458,15 @@ The following %-sequences are provided:
458 (and (re-search-forward "POWER_SUPPLY_STATUS=\\(.*\\)$" nil t) 458 (and (re-search-forward "POWER_SUPPLY_STATUS=\\(.*\\)$" nil t)
459 (member charging-state '("Unknown" "Full" nil)) 459 (member charging-state '("Unknown" "Full" nil))
460 (setq charging-state (match-string 1))) 460 (setq charging-state (match-string 1)))
461 (goto-char (point-min))
461 (when (re-search-forward 462 (when (re-search-forward
462 "POWER_SUPPLY_\\(CURRENT\\|POWER\\)_NOW=\\([0-9]*\\)$" 463 "POWER_SUPPLY_\\(CURRENT\\|POWER\\)_NOW=\\([0-9]*\\)$"
463 nil t) 464 nil t)
464 (setq rate (float (string-to-number (match-string 2))))) 465 (setq rate (float (string-to-number (match-string 2)))))
466 (goto-char (point-min))
465 (when (re-search-forward "POWER_SUPPLY_TEMP=\\([0-9]*\\)$" nil t) 467 (when (re-search-forward "POWER_SUPPLY_TEMP=\\([0-9]*\\)$" nil t)
466 (setq temperature (match-string 1))) 468 (setq temperature (match-string 1)))
469 (goto-char (point-min))
467 (let (full-string now-string) 470 (let (full-string now-string)
468 ;; Sysfs may list either charge (mAh) or energy (mWh). 471 ;; Sysfs may list either charge (mAh) or energy (mWh).
469 ;; Keep track of both, and choose which to report later. 472 ;; Keep track of both, and choose which to report later.
@@ -477,7 +480,8 @@ The following %-sequences are provided:
477 (string-to-number full-string)) 480 (string-to-number full-string))
478 charge-now (+ charge-now 481 charge-now (+ charge-now
479 (string-to-number now-string)))) 482 (string-to-number now-string))))
480 ((and (re-search-forward 483 ((and (progn (goto-char (point-min)) t)
484 (re-search-forward
481 "POWER_SUPPLY_ENERGY_FULL=\\([0-9]*\\)$" nil t) 485 "POWER_SUPPLY_ENERGY_FULL=\\([0-9]*\\)$" nil t)
482 (setq full-string (match-string 1)) 486 (setq full-string (match-string 1))
483 (re-search-forward 487 (re-search-forward