Function: battery-update

battery-update is a byte-compiled function defined in battery.el.gz.

Signature

(battery-update)

Documentation

Update battery status information in the mode line.

Source Code

;; Defined in /usr/src/emacs/lisp/battery.el.gz
(defun battery-update ()
  "Update battery status information in the mode line."
  (let* ((data (and battery-status-function (funcall battery-status-function)))
         (percentage (car (read-from-string (cdr (assq ?p data)))))
         (res (and battery-mode-line-format
                   (or (not (numberp percentage))
                       (<= percentage battery-mode-line-limit))
                   (battery-format battery-mode-line-format data)))
         (len (length res)))
    (unless (zerop len)
      (cond ((not (numberp percentage)))
            ((< percentage battery-load-critical)
             (add-face-text-property 0 len 'battery-load-critical t res))
            ((< percentage battery-load-low)
             (add-face-text-property 0 len 'battery-load-low t res)))
      (put-text-property 0 len 'help-echo "Battery status information" res))
    (setq battery-mode-line-string (or res "")))
  (force-mode-line-update t))