summaryrefslogtreecommitdiff
path: root/lisp/battery.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2005-01-04 21:15:09 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2005-01-04 21:15:09 +0000
commit73a6a97294ddb173738541a1209690a9d9440154 (patch)
treeb34d6aca5ad0a57613afe59ecfece27578836fee /lisp/battery.el
parent6bfb8bd66a890522ab6ad5964250920e6f144dbd (diff)
downloademacs-73a6a97294ddb173738541a1209690a9d9440154.tar.gz
(display-battery-mode): Rename from display-battery.
Handle the case where it gets turned off.
Diffstat (limited to 'lisp/battery.el')
-rw-r--r--lisp/battery.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/battery.el b/lisp/battery.el
index b8790450735..69bd68bb0b9 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -1,6 +1,6 @@
;;; battery.el --- display battery status information
-;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004
+;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004, 2005
;; Free Software Foundation, Inc.
;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
@@ -108,20 +108,23 @@ The text being displayed in the echo area is controlled by the variables
"Battery status not available")))
;;;###autoload
-(defun display-battery ()
+(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
`battery-mode-line-format' and `battery-status-function'.
The mode line will be updated automatically every `battery-update-interval'
seconds."
- (interactive)
+ :global t
(setq battery-mode-line-string "")
(or global-mode-string (setq global-mode-string '("")))
- (add-to-list 'global-mode-string 'battery-mode-line-string t)
(and battery-update-timer (cancel-timer battery-update-timer))
- (setq battery-update-timer (run-at-time nil battery-update-interval
- 'battery-update-handler))
- (battery-update))
+ (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)))
(defun battery-update-handler ()
(battery-update)