From: Richard M. Stallman Date: Fri, 21 Mar 2014 23:20:31 +0000 (-0400) Subject: Fix bugs that screwed M-x battery on Yeeloong X-Git-Tag: emacs-25.0.90~2640^2~344^2~22 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8266cd885b38e8f03187ab0886d49d5976bd7b35;p=emacs.git Fix bugs that screwed M-x battery on Yeeloong * lisp/battery.el (battery-linux-sysfs): Search for each field from the beginning of the buffer. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cdb9c3536a6..90a608a069d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2014-03-21 Richard Stallman + * battery.el (battery-linux-sysfs): Search for each field + from the beginning of the buffer. + * subr.el (set-transient-map): Clear out function and value of the temporary symbol when we're done with it. 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: (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