comparison lisp/battery.el @ 59363:9120644ff426

(display-battery-mode): Rename from display-battery. Handle the case where it gets turned off.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 04 Jan 2005 21:15:09 +0000
parents 38f1d5865861
children abd0d265b4ba cb67264d6096
comparison
equal deleted inserted replaced
59362:07f5b835edb6 59363:9120644ff426
1 ;;; battery.el --- display battery status information 1 ;;; battery.el --- display battery status information
2 2
3 ;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004 3 ;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004, 2005
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 5
6 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org> 6 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
7 ;; Keywords: hardware 7 ;; Keywords: hardware
8 8
106 (battery-format battery-echo-area-format 106 (battery-format battery-echo-area-format
107 (funcall battery-status-function)) 107 (funcall battery-status-function))
108 "Battery status not available"))) 108 "Battery status not available")))
109 109
110 ;;;###autoload 110 ;;;###autoload
111 (defun display-battery () 111 (define-minor-mode display-battery-mode
112 "Display battery status information in the mode line. 112 "Display battery status information in the mode line.
113 The text being displayed in the mode line is controlled by the variables 113 The text being displayed in the mode line is controlled by the variables
114 `battery-mode-line-format' and `battery-status-function'. 114 `battery-mode-line-format' and `battery-status-function'.
115 The mode line will be updated automatically every `battery-update-interval' 115 The mode line will be updated automatically every `battery-update-interval'
116 seconds." 116 seconds."
117 (interactive) 117 :global t
118 (setq battery-mode-line-string "") 118 (setq battery-mode-line-string "")
119 (or global-mode-string (setq global-mode-string '(""))) 119 (or global-mode-string (setq global-mode-string '("")))
120 (add-to-list 'global-mode-string 'battery-mode-line-string t)
121 (and battery-update-timer (cancel-timer battery-update-timer)) 120 (and battery-update-timer (cancel-timer battery-update-timer))
122 (setq battery-update-timer (run-at-time nil battery-update-interval 121 (if (not display-battery-mode)
123 'battery-update-handler)) 122 (setq global-mode-string
124 (battery-update)) 123 (delq 'battery-mode-line-string global-mode-string))
124 (add-to-list 'global-mode-string 'battery-mode-line-string t)
125 (setq battery-update-timer (run-at-time nil battery-update-interval
126 'battery-update-handler))
127 (battery-update)))
125 128
126 (defun battery-update-handler () 129 (defun battery-update-handler ()
127 (battery-update) 130 (battery-update)
128 (sit-for 0)) 131 (sit-for 0))
129 132