]> git.eshelyaron.com Git - emacs.git/commitdiff
Backport Yeeloong battery.el fix from trunk
authorRichard M. Stallman <rms@gnu.org>
Sun, 23 Mar 2014 00:08:47 +0000 (17:08 -0700)
committerGlenn Morris <rgm@gnu.org>
Sun, 23 Mar 2014 00:08:47 +0000 (17:08 -0700)
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.

lisp/ChangeLog
lisp/battery.el

index 7cf7d50118cb613de3a4526f3f2ff04bce764658..24248ded265122f5fd0e2d150ebae415eda27ba0 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-23  Richard Stallman  <rms@gnu.org>
+
+       * battery.el (battery-linux-sysfs): Search for each field
+       from the beginning of the buffer.
+
 2014-03-22  Dmitry Gutov  <dgutov@yandex.ru>
 
        * emacs-lisp/package.el (package-desc): Use the contents of the
index 28ddf368f5f5394ff808e33e73585bd5ccc853a4..1eef80ab33902462a6c5d8643305d025a783dd93 100644 (file)
@@ -458,12 +458,15 @@ The following %-sequences are provided:
          (and (re-search-forward "POWER_SUPPLY_STATUS=\\(.*\\)$" nil t)
               (member charging-state '("Unknown" "Full" nil))
               (setq charging-state (match-string 1)))
+         (goto-char (point-min))
          (when (re-search-forward
                  "POWER_SUPPLY_\\(CURRENT\\|POWER\\)_NOW=\\([0-9]*\\)$"
                  nil t)
            (setq rate (float (string-to-number (match-string 2)))))
+         (goto-char (point-min))
          (when (re-search-forward "POWER_SUPPLY_TEMP=\\([0-9]*\\)$" nil t)
            (setq temperature (match-string 1)))
+         (goto-char (point-min))
          (let (full-string now-string)
            ;; Sysfs may list either charge (mAh) or energy (mWh).
            ;; Keep track of both, and choose which to report later.
@@ -477,7 +480,8 @@ The following %-sequences are provided:
                                        (string-to-number full-string))
                         charge-now  (+ charge-now
                                        (string-to-number now-string))))
-                 ((and (re-search-forward
+                 ((and (progn (goto-char (point-min)) t)
+                       (re-search-forward
                         "POWER_SUPPLY_ENERGY_FULL=\\([0-9]*\\)$" nil t)
                        (setq full-string (match-string 1))
                        (re-search-forward