Function: native--compile-skip-on-battery-p

native--compile-skip-on-battery-p is a byte-compiled function defined in comp-run.el.gz.

Signature

(native--compile-skip-on-battery-p)

Documentation

Should we skip JIT compilation because we're running on battery power?

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp-run.el.gz
(defun native--compile-skip-on-battery-p ()
  "Should we skip JIT compilation because we're running on battery power?"
  ;; The `battery-status-function' API is not specified so as to
  ;; render it cleanly machine-readable, so we resort to heuristics.
  ;; We could extend the API to return machine-readable information in
  ;; the alist when an optional boolean argument is provided to the
  ;; `battery-status-function'; we could use `func-arity' to check
  ;; whether a custom `battery-status-function' supports the extension.
  ;; However, so far in the time we've had battery.el, it would appear
  ;; that this is the first time we've wanted to use the information
  ;; other than just for generating messages.
  (and-let* (((not native-comp-async-on-battery-power))
             ((require 'battery))
             battery-status-function
             (res (funcall battery-status-function))
             ((or (member (cdr (assq ?L res)) '("off-line" "BAT" "Battery"))
                  ;; If %L has not given us what we need, we don't
                  ;; consider battery charge levels or percentages,
                  ;; because power users often configure their batteries
                  ;; to stop charging at less than 100% as a way to
                  ;; extend the lifetime of their battery hardware.
                  (string= (cdr (assq ?b res)) "+")
                  (member (cdr (assq ?B res)) '("charging" "pending-charge"))
                  (not (string= (cdr (assq ?B res)) "discharging")))))))