From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael@cadilhac.name (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: Proposal for battery.el Date: Tue, 31 Oct 2006 16:54:52 +0100 Organization: Epita/LRDE Message-ID: <87lkmwpjjn.fsf@lrde.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0497572816==" X-Trace: sea.gmane.org 1162310171 30840 80.91.229.2 (31 Oct 2006 15:56:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Oct 2006 15:56:11 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 31 16:56:05 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gevy2-0001zv-Fk for ged-emacs-devel@m.gmane.org; Tue, 31 Oct 2006 16:55:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gevy2-0000b5-3F for ged-emacs-devel@m.gmane.org; Tue, 31 Oct 2006 10:55:58 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GevxE-0008SA-JI for emacs-devel@gnu.org; Tue, 31 Oct 2006 10:55:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gevx5-0008Li-QI for emacs-devel@gnu.org; Tue, 31 Oct 2006 10:55:08 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gevx5-0008LX-DG for emacs-devel@gnu.org; Tue, 31 Oct 2006 10:54:59 -0500 Original-Received: from [62.39.139.2] (helo=kualalumpur.lrde.epita.fr) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Gevx5-00007T-7r for emacs-devel@gnu.org; Tue, 31 Oct 2006 10:54:59 -0500 Original-Received: from mahaena.lrde.epita.fr ([192.168.101.66] helo=mahaena.lrde) by kualalumpur.lrde.epita.fr with esmtp (Exim 4.50) id 1Gevx2-0000LL-Lr for emacs-devel@gnu.org; Tue, 31 Oct 2006 16:54:56 +0100 Original-To: emacs-devel@gnu.org Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEU/JREXDATg1LV8UCao i1fQpmoP3Nd6AAACa0lEQVQ4jWWUQW7jMAxFqZEPICJzAjXeM6W8dyNqX9ji/a8yn04xnWIEJLD9 LJH85DcJFyJV3erqPty8ExHfBikXSdn0WVezC0hOAQiA2nCsAHOqEnPe4k+puU8zw/t+xquqjRKA 4lHsmQBT8C5pDtBwfwH8VdcHI5+FHtjRxrQRwZsf3hNjZRKAPEzHEdH9mFNSYb5dQK3r8KM6ftNy KikAirDZFWdVkDqbxjGFbAcwbQCxxc8mPRHUGOcCIMgMACV23RfJTch3gC6ofT3qCdG0NyUUPfYF yQrKCIAnuYsgX2qPzW2i9sNrfSOSPPZQiygtCNlCjlpXJV38lIKshF/AZzsAMoArdCKNHfXukPuJ ImbLh+9J2gXwap0QpZ7NjZ7ekdkFcDiqPiLGcHmuvaG/AHgy62s52Lae1ABoA7D6d2kDoAvgbnyD ZutEd6lTHOXfYPHVJDH1K8a1+oyrjoZpAGn1x5pfwPr2E9yjxSpk50/gEyKgD/+BD/KzN3tQ13b8 Cx5loF0AgnZf5IUny9hRHQOYBllHDM+6s3oviZBu77mFjDm621Np3hkjR90wE1BkTYvhdDgDgCmR xWChFfcYAOqMm5NZkVWMur8AL5+oeMQOob2FmY76FiM+PrDDZypwGdqokSlAaQOmGH6mW8KpsOwl 0YOLedjSITr6scNRF8D4PesH33QmLrx8AzjpV/3kkg025w2gfAFYKCLluJAc4Ap+h18oo4S8wzaY klDsBUTiY8EZFkg5Iass75FubC9wd8qa0u9+gRxAsAKEaRAo6iB+vwCMGmdBjvgidQGA1ntMX4CS ZYGV/wADyL80LIX/UAAAAABJRU5ErkJggg== User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.90 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:61483 Archived-At: --===============0497572816== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Hi! Battery.el offers nice features about laptop status, however, my Acer Aspire 1680 gentoo 2006.1 with a 2.6.18 kernel using ACPI is breaking some parts of the file detections in battery.el: the ac_adapter is called AC0. I propose the following change that factor some part of the code. I don't think the thermometers have been put in a special order in the code, so I believe my patch doesn't break anything. TIA ! --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: inline; filename=battery.patch Content-Transfer-Encoding: quoted-printable Index: lisp/battery.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/battery.el,v retrieving revision 1.36 diff -c -r1.36 battery.el *** lisp/battery.el 9 May 2006 22:43:35 -0000 1.36 =2D-- lisp/battery.el 31 Oct 2006 15:45:47 -0000 *************** *** 355,399 **** 60))) hours (/ minutes 60))) (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A")) ! (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state") ! (with-temp-buffer ! (insert-file-contents ! "/proc/acpi/ac_adapter/AC/state") ! (when (re-search-forward "state: +\\(.*\\)$" nil t) ! (match-string 1)))) "N/A")) ! (cons ?d (or (when (file-exists-p ! "/proc/acpi/thermal_zone/THRM/temperature") ! (with-temp-buffer ! (insert-file-contents ! "/proc/acpi/thermal_zone/THRM/temperature") ! (when (re-search-forward ! "temperature: +\\([0-9]+\\) C$" nil t) ! (match-string 1)))) ! (when (file-exists-p ! "/proc/acpi/thermal_zone/THM/temperature") ! (with-temp-buffer ! (insert-file-contents ! "/proc/acpi/thermal_zone/THM/temperature") ! (when (re-search-forward ! "temperature: +\\([0-9]+\\) C$" nil t) ! (match-string 1)))) ! (when (file-exists-p ! "/proc/acpi/thermal_zone/THM0/temperature") ! (with-temp-buffer ! (insert-file-contents ! "/proc/acpi/thermal_zone/THM0/temperature") ! (when (re-search-forward ! "temperature: +\\([0-9]+\\) C$" nil t) ! (match-string 1)))) ! (when (file-exists-p ! "/proc/acpi/thermal_zone/THR2/temperature") ! (with-temp-buffer ! (insert-file-contents ! "/proc/acpi/thermal_zone/THR2/temperature") ! (when (re-search-forward ! "temperature: +\\([0-9]+\\) C$" nil t) ! (match-string 1)))) "N/A")) (cons ?r (or (and rate (concat (number-to-string rate) " " rate-type)) "N/A")) =2D-- 355,373 ---- 60))) hours (/ minutes 60))) (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A")) ! (cons ?L (or (battery-search-one-match-in-files ! (mapcar (lambda (e) (concat e "/state")) ! (directory-files "/proc/acpi/ac_adapter/" ! t "\\`[^.]")) ! "state: +\\(.*\\)$" 1) !=20 "N/A")) ! (cons ?d (or (battery-search-one-match-in-files ! (mapcar (lambda (e) (concat e "/temperature")) ! (directory-files "/proc/acpi/thermal_zone/" ! t "\\`[^.]")) ! "temperature: +\\([0-9]+\\) C$" 1) !=20 "N/A")) (cons ?r (or (and rate (concat (number-to-string rate) " " rate-type)) "N/A")) *************** *** 478,483 **** =2D-- 452,474 ---- (or (cdr (assoc char alist)) "")))) format t t)) =20=20 + (defun battery-search-one-match-in-files (files regexp &optional match-nu= m) + "Search REGEXP in the list of files FILES. + If MATCH-NUM is non-nil, return the parenthesized expression numbered by = it. + Otherwise, return a list starting with the first file that had a match fo= llowed + by the untested files in FILES." + (with-temp-buffer + (while (and files + (not (or (ignore-errors + (insert-file-contents (car files)) + (re-search-forward regexp)) + (erase-buffer)))) + (setq files (cdr files))) + (if match-num + (when files + (match-string match-num)) + files))) +=20 (provide 'battery) =20=20 Index: lisp/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.10237 diff -c -0 -r1.10237 ChangeLog *** lisp/ChangeLog 31 Oct 2006 11:07:10 -0000 1.10237 =2D-- lisp/ChangeLog 31 Oct 2006 15:45:56 -0000 *************** *** 0 **** =2D-- 1,8 ---- + 2006-10-31 Micha=EBl Cadilhac +=20 + * battery.el (battery-linux-proc-acpi): Search an ac_adapter in + `/proc/acpi/ac_adapter/*'. Ditto for the thermometers in + `/proc/acpi/thermal_zone/*'. + (battery-search-one-match-in-files): New. Search a regexp in + a list of files. +=20 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable =2D-=20 /!\ My mail address changed, please update your files accordingly. | Micha=EBl `Micha' Cadilhac | =ABTu aimeras ton prochain.=BB = | | Epita/LRDE Promo 2007 | D'abord, Dieu ou pas, = | | http://michael.cadilhac.name | j'ai horreur qu'on me tutoie. = | `-- - JID: micha@amessage.be --' -- P. Desproges - -= -' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFFR3HPUJhDmOfFA3URAv9yAJ9Mbdw22If1EDajHVXhg28azNyzDwCgxslq JOWUHwrUdOxb+BRMcdLqFAQ= =c1p5 -----END PGP SIGNATURE----- --==-=-=-- --===============0497572816== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0497572816==--