emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104757: Implement battery-mode-line-


From: Richard Stallman
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104757: Implement battery-mode-line-limit option.
Date: Mon, 27 Jun 2011 04:04:55 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104757
committer: Richard Stallman <address@hidden>
branch nick: trunk
timestamp: Mon 2011-06-27 04:04:55 -0400
message:
  Implement battery-mode-line-limit option.
modified:
  lisp/ChangeLog
  lisp/battery.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-06-27 08:01:30 +0000
+++ b/lisp/ChangeLog    2011-06-27 08:04:55 +0000
@@ -1,5 +1,8 @@
 2011-06-27  Richard Stallman  <address@hidden>
 
+       * battery.el (battery-mode-line-limit): New variable.
+       (battery-update): Handle it.
+
        * mail/rmailmm.el (rmail-mime-process-multipart):
        Handle truncated messages.
 

=== modified file 'lisp/battery.el'
--- a/lisp/battery.el   2011-01-25 04:08:28 +0000
+++ b/lisp/battery.el   2011-06-27 08:04:55 +0000
@@ -102,6 +102,11 @@
   "String to display in the mode line.")
 ;;;###autoload (put 'battery-mode-line-string 'risky-local-variable t)
 
+(defcustom battery-mode-line-limit 100
+  "Percentage of full battery load below which display battery status"
+  :type 'integer
+  :group 'battery)
+
 (defcustom battery-mode-line-format
   (cond ((eq battery-status-function 'battery-linux-proc-acpi)
         "[%b%p%%,%d?C]")
@@ -182,16 +187,21 @@
 
 (defun battery-update ()
   "Update battery status information in the mode line."
-  (setq battery-mode-line-string
-       (propertize (if (and battery-mode-line-format
-                            battery-status-function)
-                       (battery-format
-                        battery-mode-line-format
-                        (funcall battery-status-function))
-                     "")
-                   'help-echo "Battery status information"))
+  (let ((data (and battery-status-function (funcall battery-status-function))))
+    (setq battery-mode-line-string
+         (propertize (if (and battery-mode-line-format
+                              (<= (car (read-from-string (cdr (assq ?p data))))
+                                  battery-mode-line-limit))
+                         (battery-format
+                          battery-mode-line-format
+                          data)
+                       "")
+                     'face
+                     (and (<= (car (read-from-string (cdr (assq ?p data))))
+                                  battery-load-critical)
+                          'font-lock-warning-face)
+                     'help-echo "Battery status information")))
   (force-mode-line-update))
-
 
 ;;; `/proc/apm' interface for Linux.
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]