]> code.delx.au - gnu-emacs/blobdiff - lisp/battery.el
(ldap-search-internal): Handle <file://...> in results.
[gnu-emacs] / lisp / battery.el
index ccafa8bf21308fa29b96e52269349045ae4663e8..5980a839a4a82ccee880d8788e2bab4b5859b827 100644 (file)
@@ -1,6 +1,6 @@
-;;; battery.el --- display battery status information.
+;;; battery.el --- display battery status information
 
-;; Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
 ;; Keywords: hardware
@@ -26,7 +26,7 @@
 
 ;; There is at present only a function interpreting the new `/proc/apm'
 ;; file format of Linux version 1.3.58 or newer.  That is, what a lucky
-;; coincidence, exactly the interface provided by the author's labtop.
+;; coincidence, exactly the interface provided by the author's laptop.
 
 ;;; Code:
 
              (file-readable-p "/proc/apm"))
         'battery-linux-proc-apm))
   "*Function for getting battery status information.
-The function have to return an alist of conversion definitions.
-Cons cells are of the form
+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."
-  :type 'function
+  :type '(choice (const nil) function)
   :group 'battery)
 
 (defcustom battery-echo-area-format
@@ -120,12 +120,13 @@ seconds."
 
 (defun battery-update ()
   "Update battery status information in the mode line."
-  (setq battery-mode-line-string (if (and battery-mode-line-format
-                                         battery-status-function)
-                                    (battery-format
-                                     battery-mode-line-format
-                                     (funcall battery-status-function))
-                                  ""))
+  (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"))
   (force-mode-line-update))
 
 \f
@@ -170,7 +171,7 @@ The following %-sequences are provided:
          (setq buffer (get-buffer-create " *battery*"))
          (set-buffer buffer)
          (erase-buffer)
-         (battery-insert-file-contents "/proc/apm")
+         (insert-file-contents "/proc/apm")
          (re-search-forward battery-linux-proc-apm-regexp)
          (setq driver-version (match-string 1))
          (setq bios-version (match-string 2))
@@ -241,24 +242,6 @@ The following %-sequences are provided:
        (setq result (concat result "%")))
     result))
 
-(defun battery-insert-file-contents (file-name)
-  "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."
-  (let ((load-read-function 'battery-read-function)
-       (load-source-file-function nil)
-       (load-path '("."))
-       (load-history nil))
-    (save-excursion
-      (load file-name nil t t))))
-
-(defun battery-read-function (&optional stream)
-  "Function for reading expressions from STREAM.
-Value is always nil."
-  (let (char)
-    (while (not (< (setq char (get-file-char)) 0))
-      (insert char))))
-
 (defconst battery-hex-map '((?0 .  0) (?1 .  1) (?2 .  2) (?3 .  3)
                            (?4 .  4) (?5 .  5) (?6 .  6) (?7 .  7)
                            (?8 .  8) (?9 .  9) (?a . 10) (?b . 11)