Increment c-version to 5.32.2.
[bpt/emacs.git] / lisp / battery.el
index d7d3045..3b245ed 100644 (file)
@@ -164,22 +164,29 @@ The text being displayed in the echo area is controlled by the variables
 
 ;;;###autoload
 (define-minor-mode display-battery-mode
-  "Display battery status information in the mode line.
-The text being displayed in the mode line is controlled by the variables
+  "Toggle battery status display in mode line (Display Battery mode).
+With a prefix argument ARG, enable Display Battery mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil.
+
+The text displayed in the mode line is controlled by
 `battery-mode-line-format' and `battery-status-function'.
-The mode line will be updated automatically every `battery-update-interval'
+The mode line is be updated every `battery-update-interval'
 seconds."
   :global t :group 'battery
   (setq battery-mode-line-string "")
   (or global-mode-string (setq global-mode-string '("")))
   (and battery-update-timer (cancel-timer battery-update-timer))
-  (if (not display-battery-mode)
-      (setq global-mode-string
-           (delq 'battery-mode-line-string global-mode-string))
-    (add-to-list 'global-mode-string 'battery-mode-line-string t)
-    (setq battery-update-timer (run-at-time nil battery-update-interval
-                                           'battery-update-handler))
-    (battery-update)))
+  (if (and battery-status-function battery-mode-line-format)
+      (if (not display-battery-mode)
+         (setq global-mode-string
+               (delq 'battery-mode-line-string global-mode-string))
+       (add-to-list 'global-mode-string 'battery-mode-line-string t)
+       (setq battery-update-timer (run-at-time nil battery-update-interval
+                                               'battery-update-handler))
+       (battery-update))
+    (message "Battery status not available")
+    (setq display-battery-mode nil)))
 
 (defun battery-update-handler ()
   (battery-update)
@@ -199,7 +206,7 @@ seconds."
                      'face
                      (and (<= (car (read-from-string (cdr (assq ?p data))))
                                   battery-load-critical)
-                          'font-lock-warning-face)
+                          'error)
                      'help-echo "Battery status information")))
   (force-mode-line-update))
 \f