From: michael@cadilhac.name (Michaël Cadilhac)
Cc: emacs-devel@gnu.org
Subject: Re: Proposal for battery.el
Date: Thu, 02 Nov 2006 23:02:07 +0100 [thread overview]
Message-ID: <87u01hy0bk.fsf@lrde.org> (raw)
In-Reply-To: <E1GfkPb-0007PW-V9@fencepost.gnu.org> (Richard Stallman's message of "Thu\, 02 Nov 2006 16\:47\:47 -0500")
[-- Attachment #1.1.1: Type: text/plain, Size: 277 bytes --]
Richard Stallman <rms@gnu.org> writes:
> What is the purpose of making battery-search-one-match-in-files
> return a list of files?
To see if you read the proposals ;-)
I used that in the elaboration of the patch, but it's indeed useless
now.
Please consider this version.
[-- Attachment #1.1.2: battery.patch --]
[-- Type: text/x-patch, Size: 4110 bytes --]
Index: lisp/battery.el
===================================================================
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
--- lisp/battery.el 2 Nov 2006 21:56:48 -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"))
--- 355,373 ----
60)))
hours (/ minutes 60)))
(list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
! (cons ?L (or (battery-search-for-one-match-in-files
! (mapcar (lambda (e) (concat e "/state"))
! (directory-files "/proc/acpi/ac_adapter/"
! t "\\`[^.]"))
! "state: +\\(.*\\)$" 1)
!
"N/A"))
! (cons ?d (or (battery-search-for-one-match-in-files
! (mapcar (lambda (e) (concat e "/temperature"))
! (directory-files "/proc/acpi/thermal_zone/"
! t "\\`[^.]"))
! "temperature: +\\([0-9]+\\) C$" 1)
!
"N/A"))
(cons ?r (or (and rate (concat (number-to-string rate) " "
rate-type)) "N/A"))
***************
*** 478,483 ****
--- 452,470 ----
(or (cdr (assoc char alist)) ""))))
format t t))
+ (defun battery-search-for-one-match-in-files (files regexp match-num)
+ "Search REGEXP in the list of files FILES.
+ Return the parenthesized expression numbered by MATCH-NUM."
+ (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)))
+ (when files
+ (match-string match-num))))
+
\f
(provide 'battery)
Index: lisp/ChangeLog
===================================================================
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
--- lisp/ChangeLog 2 Nov 2006 21:56:57 -0000
***************
*** 0 ****
--- 1,8 ----
+ 2006-10-31 Michaël Cadilhac <michael.cadilhac@lrde.org>
+
+ * 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-for-one-match-in-files): New. Search a regexp in
+ a list of files.
+
[-- Attachment #1.1.3: Type: text/plain, Size: 391 bytes --]
--
/!\ My mail address changed, please update your files accordingly.
| Michaël `Micha' Cadilhac | I cannot reproduce this bug, |
| Epita/LRDE Promo 2007 | but I have installed a change |
| http://michael.cadilhac.name | which I think will fix it. |
`-- - JID: micha@amessage.be --' -- Kim F. Storm - --'
[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]
[-- Attachment #2: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2006-11-02 22:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-31 15:54 Proposal for battery.el Michaël Cadilhac
[not found] ` <E1GfkPb-0007PW-V9@fencepost.gnu.org>
2006-11-02 22:02 ` Michaël Cadilhac [this message]
2006-11-04 6:36 ` Richard Stallman
2006-11-04 17:41 ` Michaël Cadilhac
2006-11-04 18:23 ` Romain Francoise
2006-11-04 18:31 ` martin rudalics
2006-11-04 20:04 ` Romain Francoise
2006-11-05 12:53 ` Michaël Cadilhac
2006-11-05 13:23 ` Romain Francoise
2006-11-05 19:22 ` Richard Stallman
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=87u01hy0bk.fsf@lrde.org \
--to=michael@cadilhac.name \
--cc=emacs-devel@gnu.org \
/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.