;ELC   
;;; Compiled by pot@pot.cnuce.cnr.it on Tue Mar 18 15:36:45 2003
;;; from file /home/pot/gnu/emacs-pretest.new/lisp/battery.el
;;; in Emacs version 21.3
;;; with bytecomp version 2.85.4.1
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`battery.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(byte-code "\300\301!\210\302\303\304\305\306\307\310\311&\207" [require timer custom-declare-group battery nil "Display battery status information." :prefix "battery-" :group hardware] 8)
#@299 *Function for getting battery status information.
The function has to return an alist of conversion definitions.
Its cons cells are of the form

    (CONVERSION . REPLACEMENT-TEXT)

CONVERSION is the character code of a "conversion specification"
introduced by a `%' character in a control string.
(custom-declare-variable 'battery-status-function '(cond ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) 'battery-linux-proc-apm)) '(#$ . -807) :type '(choice (const nil) function) :group 'battery)
#@304 *Control string formatting the string to display in the echo area.
Ordinary characters in the control string are printed as-is, while
conversion specifications introduced by a `%' character in the control
string are substituted as defined by the current value of the variable
`battery-status-function'.
(custom-declare-variable 'battery-echo-area-format '(cond ((eq battery-status-function 'battery-linux-proc-apm) "Power %L, battery %B (%p%% load, remaining time %t)")) '(#$ . -1327) :type '(choice string (const nil)) :group 'battery)
#@37 String to display in the mode line.
(defvar battery-mode-line-string nil (#$ . 1870))
#@304 *Control string formatting the string to display in the mode line.
Ordinary characters in the control string are printed as-is, while
conversion specifications introduced by a `%' character in the control
string are substituted as defined by the current value of the variable
`battery-status-function'.
(custom-declare-variable 'battery-mode-line-format '(cond ((eq battery-status-function 'battery-linux-proc-apm) " [%b%p%%]")) '(#$ . -1963) :type '(choice string (const nil)) :group 'battery)
#@58 *Seconds after which the battery status will be updated.
(custom-declare-variable 'battery-update-interval '60 '(#$ . -2464) :type 'integer :group 'battery)
#@24 Interval timer object.
(defvar battery-update-timer nil (#$ . 2627))
#@185 Display battery status information in the echo area.
The text being displayed in the echo area is controlled by the variables
`battery-echo-area-format' and `battery-status-function'.
(defalias 'battery #[nil "\302\303\203 	\203 \304	 \"\202 \305\"\207" [battery-echo-area-format battery-status-function message "%s" battery-format "Battery status not available"] 5 (#$ . 2703) nil])
#@270 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.
(defalias 'display-battery #[nil "\304	\204 \305\306\301\300\307#\210\n\203 \310\n!\210\311\312\313#\314 \207" [battery-mode-line-string global-mode-string battery-update-timer battery-update-interval "" ("") add-to-list t cancel-timer run-at-time nil battery-update-handler battery-update] 4 (#$ . 3099) nil])
(defalias 'battery-update-handler #[nil "\300 \210\301\302!\207" [battery-update sit-for 0] 2])
#@53 Update battery status information in the mode line.
(defalias 'battery-update #[nil "\303\203 	\203 \304	 \"\202 \305\306\307#\310 \207" [battery-mode-line-format battery-status-function battery-mode-line-string propertize battery-format "" help-echo "Battery status information" force-mode-line-update] 4 (#$ . 3787)])
#@54 Regular expression matching contents of `/proc/apm'.
(defconst battery-linux-proc-apm-regexp "^\\([^ ]+\\) \\([^ ]+\\) 0x\\([0-9a-f]+\\) 0x\\([0-9a-f]+\\) 0x\\([0-9a-f]+\\) 0x\\([0-9a-f]+\\) \\(-?[0-9]+\\)% \\(-?[0-9]+\\) \\(.*\\)$" (#$ . 4119))
#@558 Get APM status information from Linux kernel.
This function works only with the new `/proc/apm' format introduced
in Linux version 1.3.58.

The following %-sequences are provided:
%v Linux driver version
%V APM BIOS version
%I APM BIOS status (verbose)
%L AC line status (verbose)
%B Battery status (verbose)
%b Battery status, empty means high, `-' means low,
   `!' means critical, and `+' means charging
%p battery load percentage
%s Remaining time in seconds
%m Remaining time in minutes
%h Remaining time in hours
%t Remaining time in the form `h:min'
(defalias 'battery-linux-proc-apm #[nil "\306\211\211\211\211\211\211\211\211\211\211\211\211?@ABCDE\306\216\212\307\310!\211q\210\311 \210\312\313!\210\314F!\210\315\316!E\315\317!D\320\315\321!!\322\317\"\204T \323C\202\324C\322\325\"\203d \326C\202n \322\327\"\203n \330C\320\315\331!!\211\332U\203\200 \333B\202\225 \316U\203\214 \334B\202\225 \317U\203\225 \335B\320\315\336!!\211\337U\203\247 \340A\202\320\315\341!!\211\332U\203\274 \342A\343@\202\346 \316U\203\313 \344A\345@\202\346 \317U\203\332 \346A\347@\202\346 \321U\203\346 \350A\351@\315\352!?\353\315\354!!\315\355!\356\230\203\375 \357_\357\245\360\245\361\362\f\357_Z#*\363E\206\340B\364D\206\340B\365C\206'\340B\366B\206/\340B\367A\2067\340B\370@\206?\343B\371?\206G\340B\372\203S\373!\206T\340B\374\f\203`\373\f!\206a\340B\375\203m\373!\206n\340B\376\n\206u\340B\257.\207" [tem buffer remaining-time hours minutes seconds nil get-buffer-create " *battery*" erase-buffer battery-insert-file-contents "/proc/apm" re-search-forward match-string 1 2 battery-hex-to-int-2 3 logand "not supported" "enabled" 16 "disabled" 32 "disengaged" 4 0 "off-line" "on-line" "on backup" 6 255 "N/A" 5 "high" "" "low" "-" "critical" "!" "charging" "+" 7 string-to-number 8 9 "min" 60 3600 format "%d:%02d" 118 86 73 76 66 98 112 115 number-to-string 109 104 116 load-percentage battery-status-symbol battery-status line-status bios-interface bios-version driver-version battery-linux-proc-apm-regexp] 14 (#$ . 4372)])
#@35 Substitute %-sequences in FORMAT.
(defalias 'battery-format #[(format alist) "\306G\307\310\211\211\211W\203Z H\n\2042 \311\312\"\203) \313\202Q \f\314!P\202Q \311\312\"\203@ \f\315P\202O \316\"\211\203O \f	AP\310T\211\202 \n\203b \f\315P\f.\207" [format elem flag char result length 0 "" nil char-equal 37 t char-to-string "%" assoc index alist] 7 (#$ . 6494)])
#@138 Insert contents of file FILE-NAME after point.
FILE-NAME can be a non-ordinary file, for example, a named pipe.
Return t if file exists.
(defalias 'battery-insert-file-contents #[(file-name) "\305\306\307\306\212\310\f\306\311\211$-\207" [load-history load-path load-source-file-function load-read-function file-name battery-read-function nil (".") load t] 5 (#$ . 6896)])
#@68 Function for reading expressions from STREAM.
Value is always nil.
(defalias 'battery-read-function #[(&optional stream) "\301\302 \211\303W?\205 c\210\202 )\207" [char nil get-file-char 0] 2 (#$ . 7279)])
(byte-code "\301B\302\301\207" [current-load-list battery-hex-map ((48 . 0) (49 . 1) (50 . 2) (51 . 3) (52 . 4) (53 . 5) (54 . 6) (55 . 7) (56 . 8) (57 . 9) (97 . 10) (98 . 11) (99 . 12) (100 . 13) (101 . 14) (102 . 15))] 2)
#@56 Convert a hexadecimal number (a string) into a number.
(defalias 'battery-hex-to-int #[(string) "\302 \303\216\304\305	\"\203 	\306\225\307O\304\310	\"\203 	\306\225\307O*\311	!\207" [save-match-data-internal string match-data ((set-match-data save-match-data-internal)) string-match "^[ 	]+" 0 nil "^0[xX]" battery-hex-to-int-2] 3 (#$ . 7724)])
(defalias 'battery-hex-to-int-2 #[(string) "\306G\306\307\211W\203) \310\fH\227\"\211\203) \n\311_	A\\\fT\211\202\n \n,\207" [string elem value length index battery-hex-map 0 nil assoc 16] 5])
(provide 'battery)
