From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 11:47:53 2020 Received: (at submit) by debbugs.gnu.org; 11 Jun 2020 15:47:53 +0000 Received: from localhost ([127.0.0.1]:37816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjPQm-0006Fi-7v for submit@debbugs.gnu.org; Thu, 11 Jun 2020 11:47:53 -0400 Received: from lists.gnu.org ([209.51.188.17]:51996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjPQj-0006FY-Kf for submit@debbugs.gnu.org; Thu, 11 Jun 2020 11:47:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjPQj-0003BN-Cb for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2020 11:47:49 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35466) by eggs.gnu.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jjPQg-0004n5-1x for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2020 11:47:49 -0400 Received: by mail-wr1-x42d.google.com with SMTP id x14so6686943wrp.2 for ; Thu, 11 Jun 2020 08:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:user-agent:mime-version; bh=BmlrRPMmFWp3IL/TdSavuI/a1tfrkMNh803PiMpGQ1s=; b=gyk02A6tItDukfslFoTgBF0wJBUmz9D8yHcBi2IQUXMOoJoWF9ghd2BRN0K4AKxPfV njE/zRteX+MlVHx1Ivrr5XilSl9FpwcRFu3s/HRfhZdXauJvbLmmpK50pnbfvNBWqzwT r8hJyYKjffacwjIhSs0QdC2Q74JQKwVZ1xhyIj7VZsY3fq4zobsr5ieSd7nsWBuJV2CS +4chmaInlgdtleZaZk48Ne7Qg5VNZmvp7j8As5QwkypXOLdi57vNg/AlIz5LhaYSUKoH xy36iJq6zlmkICESXmZ47laDzsaNaeYAGgR29D39C06uW5KDs/kw3FVibJERhbRmLP9A pRSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version; bh=BmlrRPMmFWp3IL/TdSavuI/a1tfrkMNh803PiMpGQ1s=; b=oTU3WYq0/Azz0Ok18GqmUxGGBnVhY8qJPqMp3s7BWR6a1VJLnZWNMn4p3Nw5PJbg8U eozEiyRiHHC2OfMOPOzfae59G4Gxb3qNOUdTD2jxOCQyZH75PDtN06whO1bQ63di5EyR bhFHLDWSYM9oGv/W32Ahf/uVFLPDI/8h3k4slbDEHbU5FGjAsDTqoxUgOGAIMabxAw99 trS+9HuSG+PS19CdhGq7ttcxH60RRUJWs+PZcXr3icxQTfxu62k2EC7vzkq6PnGWGmXB NatXTIINzcdsETKjqoupJHNiYZ82qhlRD7QPpFIJkqrNzegdLNfXlOivn67wdC71H2+W cFqA== X-Gm-Message-State: AOAM531gUwxPqIvjFrzrItsTQn3W38ONa0iMzNKC8n00nxbmmksIl8Iw 7SL91nxqLLBmTNkmYolMnQQ9P80Kbps= X-Google-Smtp-Source: ABdhPJxmNveulJbui1hGO2NyMowAF91v8aazglkDRE02NGZzd8KY8vGUNnH66DZqK5c71NJRI27evA== X-Received: by 2002:adf:fe8d:: with SMTP id l13mr9835791wrr.282.1591890463600; Thu, 11 Jun 2020 08:47:43 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id a16sm5550857wrx.8.2020.06.11.08.47.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 08:47:42 -0700 (PDT) From: "Basil L. Contovounesios" To: bug-gnu-emacs@gnu.org Subject: 28.0.50; Various battery.el improvements Date: Thu, 11 Jun 2020 16:47:40 +0100 Message-ID: <87tuzhzjs3.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: none client-ip=2a00:1450:4864:20::42d; envelope-from=contovob@tcd.ie; helo=mail-wr1-x42d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Debbugs-Cc: Mattias Engdeg=C3=A5rd Tags: patch While working on bug#39491, I came across various opportunities for improvement in battery.el. The attached patch reorders battery-status-function checks based on obsolescence, adds two new faces for use in battery-mode-line-format, makes battery-update more robust, fixes documentation, indentation, and various regexps used, and simplifies file searches and logic. CCing Mattias to comment on the rx changes. WDYT? Thanks, --=20 Basil --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Various-battery.el-improvements.patch Content-Transfer-Encoding: quoted-printable >From 676bd462516b930adccfa83309a4fb6ab9189750 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Thu, 11 Jun 2020 13:48:37 +0100 Subject: [PATCH] Various battery.el improvements * lisp/battery.el: Mention BSD support in Commentary. Don't load preloaded lisp/emacs-lisp/timer.el. (battery--files): New function. (battery--find-linux-sysfs-batteries): Use it and make fewer syscalls. (battery-status-function): Perform GNU/Linux checks in increasing order of obsolescence: sysfs, ACPI, and then APM. Simplify Darwin check. Ensure w32-battery-status is functionp, not just fboundp. Add :version tag now that battery-upower is the default. (battery-echo-area-format, battery-mode-line-format): Mention %s. (battery-load-low, battery-load-critical): New faces. (battery-update): Display battery-mode-line-format even if percentage is N/A. Apply faces battery-load-low or battery-load-critical according to the percentage, but append them so they don't override user customizations. Update all mode lines since we are in global-mode-string. (battery-linux-proc-apm-regexp): Mark as obsolete, replacing with... (battery--linux-proc-apm): ...this new rx definition. (battery-linux-proc-apm): Use it. Fix indentation. Simplify. (battery--acpi-rate, battery--acpi-capacity): New rx definitions. (battery-linux-proc-acpi): Use them. Fix pathological whitespace regexps. Simplify. (battery-linux-sysfs): Fix docstring and indentation. Reduce number of file searches. Simplify. (battery-bsd-apm): Fix docstring. Simplify. (battery-pmset): Fix docstring. Simplify ID regexp. * lisp/emacs-lisp/rx.el (rx-define): Indent as a defun. * test/lisp/battery-tests.el (battery-linux-proc-apm-regexp): Test new battery--linux-proc-apm rx definition. (battery-acpi-rate-regexp, battery-acpi-capacity-regexp): New tests. --- lisp/battery.el | 365 ++++++++++++++++++++----------------- lisp/emacs-lisp/rx.el | 2 +- test/lisp/battery-tests.el | 39 +++- 3 files changed, 230 insertions(+), 176 deletions(-) diff --git a/lisp/battery.el b/lisp/battery.el index b8855a8ce3..142d22ea15 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -23,18 +23,18 @@ =20 ;;; Commentary: =20 -;; There is at present support for GNU/Linux, macOS, and Windows. +;; There is at present support for GNU/Linux, BSD, macOS, and Windows. ;; This library supports: ;; - UPower (https://upower.freedesktop.org) via D-Bus API. -;; - the `/sys/class/power_supply/' files of Linux >=3D 2.6.39. -;; - the `/proc/acpi/' directory structure of Linux 2.4.20 and 2.6. -;; - the `/proc/apm' file format of Linux version 1.3.58 or newer. +;; - The `/sys/class/power_supply/' files of Linux >=3D 2.6.39. +;; - The `/proc/acpi/' directory structure of Linux 2.4.20 and 2.6. +;; - The `/proc/apm' file format of Linux version 1.3.58 or newer. +;; - BSD by using the `apm' program. ;; - Darwin (macOS) by using the `pmset' program. ;; - Windows via the GetSystemPowerStatus API call. =20 ;;; Code: =20 -(require 'timer) (require 'dbus) (eval-when-compile (require 'cl-lib)) @@ -60,39 +60,41 @@ battery-upower-line-power-device (defconst battery-upower-dbus-service "org.freedesktop.UPower" "Well-known UPower service name for the D-Bus system.") =20 +(defun battery--files (dir) + "Return a list of absolute file names in DIR or nil on error. +Value does not include \".\" or \"..\"." + (ignore-errors (directory-files dir t directory-files-no-dot-files-regex= p))) + (defun battery--find-linux-sysfs-batteries () - (let ((dirs nil)) - (dolist (file (directory-files "/sys/class/power_supply/" t)) - (when (and (or (file-directory-p file) - (file-symlink-p file)) - (file-exists-p (expand-file-name "capacity" file))) - (push file dirs))) + "Return a list of all sysfs battery directories." + (let (dirs) + (dolist (dir (battery--files "/sys/class/power_supply/")) + (when (file-exists-p (expand-file-name "capacity" dir)) + (push dir dirs))) (nreverse dirs))) =20 (defcustom battery-status-function (cond ((dbus-ping :system battery-upower-dbus-service) #'battery-upower) ((and (eq system-type 'gnu/linux) - (file-readable-p "/proc/apm")) - #'battery-linux-proc-apm) + (battery--find-linux-sysfs-batteries)) + #'battery-linux-sysfs) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) - (file-directory-p "/sys/class/power_supply/") - (battery--find-linux-sysfs-batteries)) - #'battery-linux-sysfs) + (file-readable-p "/proc/apm")) + #'battery-linux-proc-apm) ((and (eq system-type 'berkeley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) - (condition-case nil - (with-temp-buffer - (and (eq (call-process "pmset" nil t nil "-g" "ps") 0) - (> (buffer-size) 0))) - (error nil))) + (ignore-errors + (with-temp-buffer + (and (eq (call-process "pmset" nil t nil "-g" "ps") 0) + (not (bobp)))))) #'battery-pmset) - ((fboundp 'w32-battery-status) + ((functionp 'w32-battery-status) #'w32-battery-status)) "Function for getting battery status information. The function has to return an alist of conversion definitions. @@ -102,6 +104,7 @@ battery-status-function =20 CONVERSION is the character code of a \"conversion specification\" introduced by a `%' character in a control string." + :version "28.1" :type '(choice (const nil) function)) =20 (defcustom battery-echo-area-format @@ -113,12 +116,13 @@ battery-echo-area-format `battery-status-function'. Here are the ones generally available: %c Current capacity (mAh or mWh) %r Current rate of charge or discharge +%L AC line status (verbose) %B Battery status (verbose) %b Battery status: empty means high, `-' means low, `!' means critical, and `+' means charging %d Temperature (in degrees Celsius) -%L AC line status (verbose) %p Battery load percentage +%s Remaining time (to charge or discharge) in seconds %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours %t Remaining time (to charge or discharge) in the form `h:min'" @@ -134,7 +138,7 @@ battery-mode-line-limit :type 'integer) =20 (defcustom battery-mode-line-format - (cond ((eq battery-status-function 'battery-linux-proc-acpi) + (cond ((eq battery-status-function #'battery-linux-proc-acpi) "[%b%p%%,%d=C2=B0C]") (battery-status-function "[%b%p%%]")) @@ -145,12 +149,13 @@ battery-mode-line-format `battery-status-function'. Here are the ones generally available: %c Current capacity (mAh or mWh) %r Current rate of charge or discharge +%L AC line status (verbose) %B Battery status (verbose) %b Battery status: empty means high, `-' means low, `!' means critical, and `+' means charging %d Temperature (in degrees Celsius) -%L AC line status (verbose) %p Battery load percentage +%s Remaining time (to charge or discharge) in seconds %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours %t Remaining time (to charge or discharge) in the form `h:min'" @@ -170,6 +175,18 @@ battery-load-critical A battery load percentage below this number is considered critical." :type 'integer) =20 +(defface battery-load-low + '((t :inherit warning)) + "Face used in mode line string when battery load is low. +See the option `battery-load-low'." + :version "28.1") + +(defface battery-load-critical + '((t :inherit error)) + "Face used in mode line string when battery load is critical. +See the option `battery-load-critical'." + :version "28.1") + (defvar battery-update-timer nil "Interval timer object.") =20 @@ -202,7 +219,7 @@ display-battery-mode (delq 'battery-mode-line-string global-mode-string)) (add-to-list 'global-mode-string 'battery-mode-line-string t) (setq battery-update-timer (run-at-time nil battery-update-interval - 'battery-update-handler)) + #'battery-update-handler)) (battery-update)) (message "Battery status not available") (setq display-battery-mode nil))) @@ -214,34 +231,42 @@ battery-update-handler (defun battery-update () "Update battery status information in the mode line." (let* ((data (and battery-status-function (funcall battery-status-functi= on))) - (percentage (car (read-from-string (cdr (assq ?p data)))))) - (setq battery-mode-line-string - (propertize (if (and battery-mode-line-format - (numberp percentage) - (<=3D percentage battery-mode-line-limit)) - (battery-format battery-mode-line-format data) - "") - 'face - (and (numberp percentage) - (<=3D percentage battery-load-critical) - 'error) - 'help-echo "Battery status information"))) - (force-mode-line-update)) + (percentage (car (read-from-string (cdr (assq ?p data))))) + (res (and battery-mode-line-format + (or (not (numberp percentage)) + (<=3D 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)) + ;;; `/proc/apm' interface for Linux. =20 -(defconst battery-linux-proc-apm-regexp - (concat "^\\([^ ]+\\)" ; Driver version. - " \\([^ ]+\\)" ; APM BIOS version. - " 0x\\([0-9a-f]+\\)" ; APM BIOS flags. - " 0x\\([0-9a-f]+\\)" ; AC line status. - " 0x\\([0-9a-f]+\\)" ; Battery status. - " 0x\\([0-9a-f]+\\)" ; Battery flags. - " \\(-?[0-9]+\\)%" ; Load percentage. - " \\(-?[0-9]+\\)" ; Remaining time. - " \\(.*\\)" ; Time unit. - "$") +;; Regular expression matching contents of `/proc/apm'. +(rx-define battery--linux-proc-apm + (: bol (group (+ (not ?\s))) ; Driver version. + " " (group (+ (not ?\s))) ; APM BIOS version. + " 0x" (group (+ xdigit)) ; APM BIOS flags. + " 0x" (group (+ xdigit)) ; AC line status. + " 0x" (group (+ xdigit)) ; Battery status. + " 0x" (group (+ xdigit)) ; Battery flags. + " " (group (? ?-) (+ digit)) ?% ; Load percentage. + " " (group (? ?-) (+ digit)) ; Remaining time. + " " (group (* nonl)) ; Time unit + eol)) + +(defconst battery-linux-proc-apm-regexp (rx battery--linux-proc-apm) "Regular expression matching contents of `/proc/apm'.") +(make-obsolete-variable 'battery-linux-proc-apm-regexp + "it is no longer used." "28.1") =20 (defun battery-linux-proc-apm () "Get APM status information from Linux (the kernel). @@ -261,12 +286,12 @@ battery-linux-proc-apm %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours %t Remaining time (to charge or discharge) in the form `h:min'" - (let (driver-version bios-version bios-interface line-status - battery-status battery-status-symbol load-percentage - seconds minutes hours remaining-time tem) + (let ( driver-version bios-version bios-interface line-status + battery-status battery-status-symbol load-percentage + seconds minutes hours remaining-time tem ) (with-temp-buffer (ignore-errors (insert-file-contents "/proc/apm")) - (when (re-search-forward battery-linux-proc-apm-regexp) + (when (re-search-forward (rx battery--linux-proc-apm) nil t) (setq driver-version (match-string 1)) (setq bios-version (match-string 2)) (setq tem (string-to-number (match-string 3) 16)) @@ -279,9 +304,7 @@ battery-linux-proc-apm (cond ((=3D tem 0) (setq line-status "off-line")) ((=3D tem 1) (setq line-status "on-line")) ((=3D tem 2) (setq line-status "on backup"))) - (setq tem (string-to-number (match-string 6) 16)) - (if (=3D tem 255) - (setq battery-status "N/A") + (unless (=3D (string-to-number (match-string 6) 16) 255) (setq tem (string-to-number (match-string 5) 16)) (cond ((=3D tem 0) (setq battery-status "high" battery-status-symbol "")) @@ -298,7 +321,7 @@ battery-linux-proc-apm (setq minutes (/ seconds 60) hours (/ seconds 3600)) (setq remaining-time - (format "%d:%02d" hours (- minutes (* 60 hours)))))))) + (format "%d:%02d" hours (% minutes 60))))))) (list (cons ?v (or driver-version "N/A")) (cons ?V (or bios-version "N/A")) (cons ?I (or bios-interface "N/A")) @@ -306,27 +329,31 @@ battery-linux-proc-apm (cons ?B (or battery-status "N/A")) (cons ?b (or battery-status-symbol "")) (cons ?p (or load-percentage "N/A")) - (cons ?s (or (and seconds (number-to-string seconds)) "N/A")) - (cons ?m (or (and minutes (number-to-string minutes)) "N/A")) - (cons ?h (or (and hours (number-to-string hours)) "N/A")) + (cons ?s (if seconds (number-to-string seconds) "N/A")) + (cons ?m (if minutes (number-to-string minutes) "N/A")) + (cons ?h (if hours (number-to-string hours) "N/A")) (cons ?t (or remaining-time "N/A"))))) =20 ;;; `/proc/acpi/' interface for Linux. =20 +(rx-define battery--acpi-rate (&rest hour) + (: (group (+ digit)) " " (group ?m (in "AW") hour))) +(rx-define battery--acpi-capacity (battery--acpi-rate ?h)) + (defun battery-linux-proc-acpi () "Get ACPI status information from Linux (the kernel). -This function works only with the `/proc/acpi/' format introduced -in Linux version 2.4.20 and 2.6.0. +This function works only with the `/proc/acpi/' interface +introduced in Linux version 2.4.20 and 2.6.0. =20 The following %-sequences are provided: %c Current capacity (mAh) -%r Current rate +%r Current rate of charge or discharge +%L AC line status (verbose) %B Battery status (verbose) %b Battery status, empty means high, `-' means low, `!' means critical, and `+' means charging %d Temperature (in degrees Celsius) -%L AC line status (verbose) %p Battery load percentage %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours @@ -342,45 +369,51 @@ battery-linux-proc-acpi ;; information together since displaying for a variable amount of ;; batteries seems overkill for format-strings. (with-temp-buffer - (dolist (dir (ignore-errors (directory-files "/proc/acpi/battery/" - t "\\`[^.]"))) - (erase-buffer) - (ignore-errors (insert-file-contents (expand-file-name "state" dir))) - (when (re-search-forward "present: +yes$" nil t) - (and (re-search-forward "charging state: +\\(.*\\)$" nil t) + (dolist (dir (battery--files "/proc/acpi/battery/")) + (ignore-errors + (insert-file-contents (expand-file-name "state" dir) nil nil nil= t)) + (goto-char (point-min)) + (when (re-search-forward (rx "present:" (+ space) "yes" eol) nil t) + (and (re-search-forward (rx "charging state:" (+ space) + (group (not space) (* nonl)) eol) + nil t) (member charging-state '("unknown" "charged" nil)) ;; On most multi-battery systems, most of the time only one ;; battery is "charging"/"discharging", the others are ;; "unknown". (setq charging-state (match-string 1))) - (when (re-search-forward "present rate: +\\([0-9]+\\) \\(m[AW]\\)$" + (when (re-search-forward (rx "present rate:" (+ space) + (battery--acpi-rate) eol) nil t) (setq rate (+ (or rate 0) (string-to-number (match-string 1)))) (when (> rate 0) - (setq rate-type (or (and rate-type - (if (string=3D rate-type (match-string 2)) - rate-type - (error - "Inconsistent rate types (%s vs. %s)" - rate-type (match-string 2)))) - (match-string 2))))) - (when (re-search-forward "remaining capacity: +\\([0-9]+\\) m[AW]h$" + (cond ((not rate-type) + (setq rate-type (match-string 2))) + ((not (string=3D rate-type (match-string 2))) + (error "Inconsistent rate types (%s vs. %s)" + rate-type (match-string 2)))))) + (when (re-search-forward (rx "remaining capacity:" (+ space) + battery--acpi-capacity eol) nil t) (setq capacity (+ (or capacity 0) (string-to-number (match-string 1)))))) (goto-char (point-max)) (ignore-errors (insert-file-contents (expand-file-name "info" dir))) - (when (re-search-forward "present: +yes$" nil t) - (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$" + (when (re-search-forward (rx "present:" (+ space) "yes" eol) nil t) + (when (re-search-forward (rx "design capacity:" (+ space) + battery--acpi-capacity eol) nil t) (cl-incf design-capacity (string-to-number (match-string 1)))) - (when (re-search-forward "last full capacity: +\\([0-9]+\\) m[AW]h$" + (when (re-search-forward (rx "last full capacity:" (+ space) + battery--acpi-capacity eol) nil t) (cl-incf last-full-capacity (string-to-number (match-string 1)))) - (when (re-search-forward - "design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t) + (when (re-search-forward (rx "design capacity warning:" (+ space) + battery--acpi-capacity eol) + nil t) (cl-incf warn (string-to-number (match-string 1)))) - (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$" + (when (re-search-forward (rx "design capacity low:" (+ space) + battery--acpi-capacity eol) nil t) (cl-incf low (string-to-number (match-string 1))))))) (setq full-capacity (if (> last-full-capacity 0) @@ -394,79 +427,70 @@ battery-linux-proc-acpi 60) rate)) hours (/ minutes 60))) - (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A")) + (list (cons ?c (if capacity (number-to-string capacity) "N/A")) (cons ?L (or (battery-search-for-one-match-in-files - (mapcar (lambda (e) (concat e "/state")) - (ignore-errors - (directory-files "/proc/acpi/ac_adapter/" - t "\\`[^.]"))) - "state: +\\(.*\\)$" 1) - + (mapcar (lambda (d) (expand-file-name "state" d)) + (battery--files "/proc/acpi/ac_adapter/")) + (rx "state:" (+ space) (group (not space) (* nonl)= ) eol) + 1) "N/A")) (cons ?d (or (battery-search-for-one-match-in-files - (mapcar (lambda (e) (concat e "/temperature")) - (ignore-errors - (directory-files "/proc/acpi/thermal_zone/" - t "\\`[^.]"))) - "temperature: +\\([0-9]+\\) C$" 1) - + (mapcar (lambda (d) (expand-file-name "temperature= " d)) + (battery--files "/proc/acpi/thermal_zone/"= )) + (rx "temperature:" (+ space) (group (+ digit)) " C= " eol) + 1) "N/A")) - (cons ?r (or (and rate (concat (number-to-string rate) " " - rate-type)) "N/A")) + (cons ?r (if rate + (concat (number-to-string rate) " " rate-type) + "N/A")) (cons ?B (or charging-state "N/A")) - (cons ?b (or (and (string=3D charging-state "charging") "+") - (and capacity (< capacity low) "!") - (and capacity (< capacity warn) "-") - "")) - (cons ?h (or (and hours (number-to-string hours)) "N/A")) - (cons ?m (or (and minutes (number-to-string minutes)) "N/A")) - (cons ?t (or (and minutes - (format "%d:%02d" hours (- minutes (* 60 hours)))) - "N/A")) - (cons ?p (or (and full-capacity capacity - (> full-capacity 0) - (number-to-string - (floor (* 100 capacity) full-capacity))) - "N/A"))))) + (cons ?b (cond ((string=3D charging-state "charging") "+") + ((and capacity (< capacity low)) "!") + ((and capacity (< capacity warn)) "-") + (""))) + (cons ?h (if hours (number-to-string hours) "N/A")) + (cons ?m (if minutes (number-to-string minutes) "N/A")) + (cons ?t (if minutes (format "%d:%02d" hours (% minutes 60)) "N/= A")) + (cons ?p (if (and full-capacity capacity (> full-capacity 0)) + (number-to-string (floor (* 100 capacity) full-capa= city)) + "N/A"))))) =20 ;;; `/sys/class/power_supply/BATN' interface for Linux. =20 (defun battery-linux-sysfs () - "Get ACPI status information from Linux kernel. + "Get sysfs status information from Linux kernel. This function works only with the new `/sys/class/power_supply/' -format introduced in Linux version 2.4.25. +interface introduced in Linux version 2.4.25. =20 The following %-sequences are provided: %c Current capacity (mAh or mWh) -%r Current rate +%r Current rate of charge or discharge +%L Power source (verbose) %B Battery status (verbose) %b Battery status, empty means high, `-' means low, `!' means critical, and `+' means charging %d Temperature (in degrees Celsius) %p Battery load percentage -%L AC line status (verbose) %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours %t Remaining time (to charge or discharge) in the form `h:min'" - (let (charging-state temperature hours percentage-now - ;; Some batteries report charges and current, other energy and pow= er. + (let (;; Some batteries report charges and current, others energy and po= wer. ;; In order to reliably be able to combine those data, we convert = them ;; all to energy/power (since we can't combine different charges if ;; they're not at the same voltage). (energy-full 0.0) (energy-now 0.0) (power-now 0.0) - (voltage-now 10.8)) ;Arbitrary default, in case the info is missing. + (voltage-now 10.8) ; Arbitrary default, in case the info is missin= g. + charging-state temperature hours percentage-now) ;; SysFS provides information about each battery present in the ;; system in a separate subdirectory. We are going to merge the ;; available information together. (with-temp-buffer - (dolist (dir (ignore-errors - (battery--find-linux-sysfs-batteries))) - (erase-buffer) - (ignore-errors (insert-file-contents - (expand-file-name "uevent" dir))) + (dolist (dir (battery--find-linux-sysfs-batteries)) + (ignore-errors + (insert-file-contents (expand-file-name "uevent" dir) nil nil ni= l t)) (goto-char (point-min)) (when (re-search-forward "POWER_SUPPLY_VOLTAGE_NOW=3D\\([0-9]*\\)$" nil t) @@ -502,7 +526,7 @@ battery-linux-sysfs voltage-now)) (cl-incf energy-now (* (string-to-number now-string) voltage-now))) - ((and (progn (goto-char (point-min)) t) + ((and (goto-char (point-min)) (re-search-forward "POWER_SUPPLY_ENERGY_FULL=3D\\([0-9]*\\)$" nil t) (setq full-string (match-string 1)) @@ -511,7 +535,6 @@ battery-linux-sysfs (setq now-string (match-string 1))) (cl-incf energy-full (string-to-number full-string)) (cl-incf energy-now (string-to-number now-string))))) - (goto-char (point-min)) (unless (zerop power-now) (let ((remaining (if (string=3D charging-state "Discharging") energy-now @@ -519,9 +542,9 @@ battery-linux-sysfs (setq hours (/ remaining power-now))))))) (when (and (> energy-full 0) (> energy-now 0)) (setq percentage-now (/ (* 100 energy-now) energy-full))) - (list (cons ?c (cond ((or (> energy-full 0) (> energy-now 0)) - (number-to-string (/ energy-now voltage-now))) - (t "N/A"))) + (list (cons ?c (if (or (> energy-full 0) (> energy-now 0)) + (number-to-string (/ energy-now voltage-now)) + "N/A")) (cons ?r (if (> power-now 0.0) (format "%.1f" (/ power-now 1000000.0)) "N/A")) @@ -532,27 +555,20 @@ battery-linux-sysfs "N/A")) (cons ?d (or temperature "N/A")) (cons ?B (or charging-state "N/A")) - (cons ?b (or (and (string=3D charging-state "Charging") "+") - (and percentage-now (< percentage-now battery-load-critical) "!") - (and percentage-now (< percentage-now battery-load-low) "-") - "")) - (cons ?p (cond - ((and percentage-now (format "%.1f" percentage-now))) - (t "N/A"))) - (cons ?L (cond - ((battery-search-for-one-match-in-files - (list "/sys/class/power_supply/AC/online" - "/sys/class/power_supply/ACAD/online" - "/sys/class/power_supply/ADP1/online") - "1" 0) - "AC") - ((battery-search-for-one-match-in-files - (list "/sys/class/power_supply/AC/online" - "/sys/class/power_supply/ACAD/online" - "/sys/class/power_supply/ADP1/online") - "0" 0) - "BAT") - (t "N/A")))))) + (cons ?b (cond ((string=3D charging-state "Charging") "+") + ((not percentage-now) "") + ((< percentage-now battery-load-critical) "!") + ((< percentage-now battery-load-low) "-") + (""))) + (cons ?p (if percentage-now (format "%.1f" percentage-now) "N/A"= )) + (cons ?L (pcase (battery-search-for-one-match-in-files + '("/sys/class/power_supply/AC/online" + "/sys/class/power_supply/ACAD/online" + "/sys/class/power_supply/ADP1/online") + (rx (in "01")) 0) + ("0" "BAT") + ("1" "AC") + (_ "N/A")))))) =20 ;;; `upowerd' interface. @@ -675,19 +691,20 @@ battery-upower =20 ;;; `apm' interface for BSD. + (defun battery-bsd-apm () "Get APM status information from BSD apm binary. The following %-sequences are provided: +%P Advanced power saving mode state (verbose) %L AC line status (verbose) %B Battery status (verbose) %b Battery status, empty means high, `-' means low, - `!' means critical, and `+' means charging -%P Advanced power saving mode state (verbose) -%p Battery charge percentage -%s Remaining battery charge time in seconds -%m Remaining battery charge time in minutes -%h Remaining battery charge time in hours -%t Remaining battery charge time in the form `h:min'" + `!' means critical, and `+' means charging +%p Battery load percentage +%s Remaining time (to charge or discharge) in seconds +%m Remaining time (to charge or discharge) in minutes +%h Remaining time (to charge or discharge) in hours +%t Remaining time (to charge or discharge) in the form `h:min'" (let* ((os-name (car (split-string ;; FIXME: Can't we use something like `system-type= '? (shell-command-to-string "/usr/bin/uname")))) @@ -753,7 +770,7 @@ battery-bsd-apm (setq seconds (string-to-number battery-life) minutes (truncate seconds 60))) (setq hours (truncate minutes 60) - remaining-time (format "%d:%02d" hours (mod minutes 60)))) + remaining-time (format "%d:%02d" hours (% minutes 60)))) (list (cons ?L (or line-status "N/A")) (cons ?B (or (car battery-status) "N/A")) (cons ?b (or (cdr battery-status) "N/A")) @@ -761,9 +778,9 @@ battery-bsd-apm "N/A" battery-percentage)) (cons ?P (or apm-mode "N/A")) - (cons ?s (or (and seconds (number-to-string seconds)) "N/A")) - (cons ?m (or (and minutes (number-to-string minutes)) "N/A")) - (cons ?h (or (and hours (number-to-string hours)) "N/A")) + (cons ?s (if seconds (number-to-string seconds) "N/A")) + (cons ?m (if minutes (number-to-string minutes) "N/A")) + (cons ?h (if hours (number-to-string hours) "N/A")) (cons ?t (or remaining-time "N/A"))))) =20 @@ -778,21 +795,25 @@ battery-pmset %b Battery status, empty means high, `-' means low, `!' means critical, and `+' means charging %p Battery load percentage -%h Remaining time in hours -%m Remaining time in minutes -%t Remaining time in the form `h:min'" - (let (power-source load-percentage battery-status battery-status-symbol - remaining-time hours minutes) +%m Remaining time (to charge or discharge) in minutes +%h Remaining time (to charge or discharge) in hours +%t Remaining time (to charge or discharge) in the form `h:min'" + (let ( power-source load-percentage battery-status battery-status-symbol + remaining-time hours minutes ) (with-temp-buffer (ignore-errors (call-process "pmset" nil t nil "-g" "ps")) (goto-char (point-min)) - (when (re-search-forward "\\(?:Currentl?y\\|Now\\) drawing from '\\(= AC\\|Battery\\) Power'" nil t) + (when (re-search-forward ;; Handle old typo in output. + "\\(?:Currentl?y\\|Now\\) drawing from '\\(AC\\|Battery\\) Po= wer'" + nil t) (setq power-source (match-string 1)) - (when (re-search-forward "^ -InternalBattery-0\\([ \t]+(id=3D[0-9]+)\\)*[= \t]+" nil t) + (when (re-search-forward (rx bol " -InternalBattery-0" (+ space) + (* "(id=3D" (+ digit) ")" (+ space))) + nil t) (when (looking-at "\\([0-9]\\{1,3\\}\\)%") (setq load-percentage (match-string 1)) (goto-char (match-end 0)) - (cond ((looking-at "; charging") + (cond ((looking-at-p "; charging") (setq battery-status "charging" battery-status-symbol "+")) ((< (string-to-number load-percentage) battery-load-critical) diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index aa4b2addd4..88bb0a8bd6 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -1381,7 +1381,7 @@ rx-define For more details, see Info node `(elisp) Extending Rx'. =20 \(fn NAME [(ARGS...)] RX)" - (declare (indent 1)) + (declare (indent defun)) `(eval-and-compile (put ',name 'rx-definition ',(rx--make-binding name definition)) ',name)) diff --git a/test/lisp/battery-tests.el b/test/lisp/battery-tests.el index 052ae49a80..e5706807cc 100644 --- a/test/lisp/battery-tests.el +++ b/test/lisp/battery-tests.el @@ -22,9 +22,9 @@ (require 'battery) =20 (ert-deftest battery-linux-proc-apm-regexp () - "Test `battery-linux-proc-apm-regexp'." + "Test `rx' definition `battery--linux-proc-apm'." (let ((str "1.16 1.2 0x07 0x01 0xff 0x80 -1% -1 ?")) - (should (string-match battery-linux-proc-apm-regexp str)) + (should (string-match (rx battery--linux-proc-apm) str)) (should (equal (match-string 0 str) str)) (should (equal (match-string 1 str) "1.16")) (should (equal (match-string 2 str) "1.2")) @@ -36,7 +36,7 @@ battery-linux-proc-apm-regexp (should (equal (match-string 8 str) "-1")) (should (equal (match-string 9 str) "?"))) (let ((str "1.16 1.2 0x03 0x00 0x00 0x01 99% 1792 min")) - (should (string-match battery-linux-proc-apm-regexp str)) + (should (string-match (rx battery--linux-proc-apm) str)) (should (equal (match-string 0 str) str)) (should (equal (match-string 1 str) "1.16")) (should (equal (match-string 2 str) "1.2")) @@ -48,6 +48,39 @@ battery-linux-proc-apm-regexp (should (equal (match-string 8 str) "1792")) (should (equal (match-string 9 str) "min")))) =20 +(ert-deftest battery-acpi-rate-regexp () + "Test `rx' definition `battery--acpi-rate'." + (let ((str "01 mA")) + (should (string-match (rx (battery--acpi-rate)) str)) + (should (equal (match-string 0 str) str)) + (should (equal (match-string 1 str) "01")) + (should (equal (match-string 2 str) "mA"))) + (let ((str "23 mW")) + (should (string-match (rx (battery--acpi-rate)) str)) + (should (equal (match-string 0 str) str)) + (should (equal (match-string 1 str) "23")) + (should (equal (match-string 2 str) "mW"))) + (let ((str "23 mWh")) + (should (string-match (rx (battery--acpi-rate)) str)) + (should (equal (match-string 0 str) "23 mW")) + (should (equal (match-string 1 str) "23")) + (should (equal (match-string 2 str) "mW"))) + (should-not (string-match (rx (battery--acpi-rate) eos) "45 mWh"))) + +(ert-deftest battery-acpi-capacity-regexp () + "Test `rx' definition `battery--acpi-capacity'." + (let ((str "01 mAh")) + (should (string-match (rx battery--acpi-capacity) str)) + (should (equal (match-string 0 str) str)) + (should (equal (match-string 1 str) "01")) + (should (equal (match-string 2 str) "mAh"))) + (let ((str "23 mWh")) + (should (string-match (rx battery--acpi-capacity) str)) + (should (equal (match-string 0 str) str)) + (should (equal (match-string 1 str) "23")) + (should (equal (match-string 2 str) "mWh"))) + (should-not (string-match (rx battery--acpi-capacity eos) "45 mW"))) + (ert-deftest battery-format () "Test `battery-format'." (should (equal (battery-format "" ()) "")) --=20 2.26.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 12:27:06 2020 Received: (at 41808) by debbugs.gnu.org; 11 Jun 2020 16:27:06 +0000 Received: from localhost ([127.0.0.1]:37881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQ2k-000157-LD for submit@debbugs.gnu.org; Thu, 11 Jun 2020 12:27:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49308) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQ2j-00014C-0g for 41808@debbugs.gnu.org; Thu, 11 Jun 2020 12:27:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37321) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjQ2d-0006jj-G1; Thu, 11 Jun 2020 12:26:59 -0400 Received: from [176.228.60.248] (port=2691 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jjQ2b-0002AE-9G; Thu, 11 Jun 2020 12:26:58 -0400 Date: Thu, 11 Jun 2020 19:26:43 +0300 Message-Id: <835zbx601o.fsf@gnu.org> From: Eli Zaretskii To: "Basil L. Contovounesios" In-Reply-To: <87tuzhzjs3.fsf@tcd.ie> (contovob@tcd.ie) Subject: Re: bug#41808: 28.0.50; Various battery.el improvements References: <87tuzhzjs3.fsf@tcd.ie> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41808 Cc: 41808@debbugs.gnu.org, mattiase@acm.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "Basil L. Contovounesios" > Date: Thu, 11 Jun 2020 16:47:40 +0100 > Cc: mattias engdegÄrd > > - ((fboundp 'w32-battery-status) > + ((functionp 'w32-battery-status) > #'w32-battery-status)) Is something wrong with fboundp? I think we have dozens if not hundreds of such uses of fboundp, so if something's wrong with it, we had better fixed them all. From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 12:30:06 2020 Received: (at 41808) by debbugs.gnu.org; 11 Jun 2020 16:30:06 +0000 Received: from localhost ([127.0.0.1]:37890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQ5e-0001BJ-BZ for submit@debbugs.gnu.org; Thu, 11 Jun 2020 12:30:06 -0400 Received: from mail1438c50.megamailservers.eu ([91.136.14.38]:56678 helo=mail263c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQ5c-00019s-I5 for 41808@debbugs.gnu.org; Thu, 11 Jun 2020 12:30:05 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1591892998; bh=pf7RMq2Pjz/76iy2aaJVNAUbAAyYo1rzWdX8xlpSyCc=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Wa2XK13rNFlBPHiaOaKNWT3QNeUsbScEV5jVPVgo4iWyftr3hDsZH5J//+HtvDVGJ FQLOWkYK/6+Y/dUDqLcEAN1YC3UZUfBHZLImUw9NKC+wbAaC6Fd1yjdKs0u3l1LeXS YNJdxff9lKU4FXZzoZnlytY85fYPnMzJIkpb3O64= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail263c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 05BGTu0u002297; Thu, 11 Jun 2020 16:29:57 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Subject: Re: bug#41808: 28.0.50; Various battery.el improvements From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <87tuzhzjs3.fsf@tcd.ie> Date: Thu, 11 Jun 2020 18:29:55 +0200 Content-Transfer-Encoding: 7bit Message-Id: References: <87tuzhzjs3.fsf@tcd.ie> To: "Basil L. Contovounesios" X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F1C.5EE25BB0.0023, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=e6d4tph/ c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=2_LIK_qIBCBEndqABTwA:9 a=CjuIK1q_8ugA:10 a=BhrJvqtl3CMA:10 X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 11 juni 2020 kl. 17.47 skrev Basil L. Contovounesios : > > CCing Mattias to comment on the rx changes. That's fine, thank you! Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: tcd.ie] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 41808 Cc: 41808@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 11 juni 2020 kl. 17.47 skrev Basil L. Contovounesios : > > CCing Mattias to comment on the rx changes. That's fine, thank you! From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 13:22:34 2020 Received: (at 41808) by debbugs.gnu.org; 11 Jun 2020 17:22:34 +0000 Received: from localhost ([127.0.0.1]:37936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQuP-0002bC-S0 for submit@debbugs.gnu.org; Thu, 11 Jun 2020 13:22:34 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:44592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQuN-0002ay-Kc for 41808@debbugs.gnu.org; Thu, 11 Jun 2020 13:22:32 -0400 Received: by mail-wr1-f49.google.com with SMTP id y17so6977164wrn.11 for <41808@debbugs.gnu.org>; Thu, 11 Jun 2020 10:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=+nMgOyRt+mJuG7pFv7wX86kMQhhpK4icvItw0ige984=; b=aWdojTkfw1vgKIwbGfCor1hpcqhiaMZi1rEYccZYz9IUNAWwfJy5lslbz6dHWTEJS8 m5zmGTzqWtNrLG9JA2rXs2L6MH5VBozJd/8BZUHFwY+P5/V+uzA5jjynFQtCH7vAg7eT 5sZQORqTDfjzYPEuxDihLaCmjsG5E8Z61a0Em6V4pN3dNxJf5In9RmVV0Xl9WrsezQsk xQf+dadtZgmxZMW8cSNh6BJ6uswimqLdF8ad18Rue96KdkFb76zB0mPFORU0Zb8dYgqM VYjkkuPFgCKrLAi1EN+duSFirjViEgqB9gJio8RodAVpXvFOqwVzcH/tuyEKpNHIdhPH ugLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=+nMgOyRt+mJuG7pFv7wX86kMQhhpK4icvItw0ige984=; b=ZmpP4l+inr572y4DGeYc41QwViG76tgaWm8LOrJrRgCQoujwrBf5t08BS72/9bzREI w1grDjU0H0d5ptUUcLYuZ9JWbjtwU9u3mdQEyyKtkQ8x7bR57pfih+9ASgY7u5c64Wvg PY/fXHjIoJQ1owIu7uppX/b9rzm/r5Z6bHc+vlOxumRMRGXpGtw/D3DYwypNkVvJAi/a wsTR1gA3BYBSeQpeuLOUjydCcPgzkXcxgI9S4RbYEGSCMSNLXAwp8JAL6eS8QEQQc0JE a3FGSb3ZfjFXL/dwj/AN/qp2WNxMv/NdX/1wCq+GPZLeIzdPOhQZ5pUXxXPuLLirpcXM Z0lQ== X-Gm-Message-State: AOAM533+LQ3sWKC9+B/2Q2PvTcx8MdNhDye79PpH0KFZSiBiuCCTEo4g 0KdWEtWAuNz+6kIGZiD3YklKzg== X-Google-Smtp-Source: ABdhPJxcSFV7W96drn3yyUoU/oGAuZ36fr/p5q4A4NUaO5SYUrHdFehWRz0EYcXl8/NQp4MIvrrNEw== X-Received: by 2002:a5d:6109:: with SMTP id v9mr10435879wrt.26.1591896144942; Thu, 11 Jun 2020 10:22:24 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id b187sm5243037wmd.26.2020.06.11.10.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 10:22:23 -0700 (PDT) From: "Basil L. Contovounesios" To: Eli Zaretskii Subject: Re: bug#41808: 28.0.50; Various battery.el improvements References: <87tuzhzjs3.fsf@tcd.ie> <835zbx601o.fsf@gnu.org> Date: Thu, 11 Jun 2020 18:22:22 +0100 In-Reply-To: <835zbx601o.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 11 Jun 2020 19:26:43 +0300") Message-ID: <87ftb1frg1.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41808 Cc: 41808@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: "Basil L. Contovounesios" >> Date: Thu, 11 Jun 2020 16:47:40 +0100 >> Cc: mattias engdeg=C3=A5rd >>=20 >> - ((fboundp 'w32-battery-status) >> + ((functionp 'w32-battery-status) >> #'w32-battery-status)) > > Is something wrong with fboundp? I think we have dozens if not > hundreds of such uses of fboundp, so if something's wrong with it, we > had better fixed them all. The only reason I switched to functionp is because battery-status-function is passed to funcall, but now that I think about it again we're only checking whether the definition exists at all here, so I reverted to fboundp. Thanks, --=20 Basil From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 13:23:08 2020 Received: (at 41808) by debbugs.gnu.org; 11 Jun 2020 17:23:08 +0000 Received: from localhost ([127.0.0.1]:37940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQuy-0002cb-3z for submit@debbugs.gnu.org; Thu, 11 Jun 2020 13:23:08 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:44651) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjQuw-0002br-Le for 41808@debbugs.gnu.org; Thu, 11 Jun 2020 13:23:07 -0400 Received: by mail-wr1-f43.google.com with SMTP id y17so6979066wrn.11 for <41808@debbugs.gnu.org>; Thu, 11 Jun 2020 10:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=UO48uxKGnnSgdh/LJPyleebOQ6thqqL1rzFUegcpXE0=; b=bCXcodiGy4GNrRg+LvNwAEnD553CK01vWn5zDsu7hUlXUsNreXD8kPsALKE3S0GICV BsyMwWp2QVF7Z4Jhcot0ukZN8Lyojsy0Yt2GPVS9hOd/ZVNqYdTTYgx78dD/lyqdPjiL xC0Kqf6oJS1k8+aSjnUVQCKSEdRQ01RAFgbicn/hWj6YF+JoCWnTrz1QHFixOuBZ00RO 3+s9SmghfZGbY4tw2E8HglUmmXJXOxHzdicSufCLhL8K2vkd1ByDmWuof3gG8gfH31lI O4j5GMOpB30aZbOl6v1pD7z8QjABfuabCV7suy3XRfzID6uiN+5xMfkhpZXXAl+1bUxm PeQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=UO48uxKGnnSgdh/LJPyleebOQ6thqqL1rzFUegcpXE0=; b=cdEqnbfIUiLXlS7Zx+DvWcrx7N3YUcxID+SlHTBF4R4T0mQMBN1Rn4jA+Qt5pZOrwM AKNnrjE+IEYU357Ur1tJN70xLSbCLXsUF0exKjG6nFA+MKG/5MwhPAZav349Ith5mmd0 lVKQlFHFIhOEuR8pTxGfWAjSWHQdSUNaYuYsU3MGusueFlXAAQQPN21YFAYL57ivfeO9 dCkWA87WjRnjqQclNNSvk5iVyeN4JD9dbtPAp6c4MZ3TBnxFF+mA1iKjpaW+sokVjeL0 JPb945Y6bF6izS+pLvB2W/C5IYK5Lhk1dEdNIEcdkUjAwt8ee2GIelslrr3xVHgD4NZZ GEQg== X-Gm-Message-State: AOAM530jHWZm2eu1YLN8/vWNP9KupZII0LSNqNL9cbzv7WEhLJZoVWJm kN/dd+GhVw2LFPnyRToW+T9w5Q== X-Google-Smtp-Source: ABdhPJxDX2/V53dfwqRtSfdDKRgsJBKpJmJ3d5NEgQM1D0W30LgyJeBXb8pVWxPOFwtMlI5jI8pKVw== X-Received: by 2002:adf:a350:: with SMTP id d16mr10923138wrb.237.1591896181066; Thu, 11 Jun 2020 10:23:01 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id k26sm5165684wmi.27.2020.06.11.10.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 10:23:00 -0700 (PDT) From: "Basil L. Contovounesios" To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Subject: Re: bug#41808: 28.0.50; Various battery.el improvements References: <87tuzhzjs3.fsf@tcd.ie> Date: Thu, 11 Jun 2020 18:22:59 +0100 In-Reply-To: ("Mattias =?utf-8?Q?Engdeg=C3=A5rd=22's?= message of "Thu, 11 Jun 2020 18:29:55 +0200") Message-ID: <878sgtfrf0.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 41808 Cc: 41808@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > 11 juni 2020 kl. 17.47 skrev Basil L. Contovounesios : >>=20 >> CCing Mattias to comment on the rx changes. > > That's fine, thank you! Thanks. --=20 Basil From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 18 11:45:37 2020 Received: (at control) by debbugs.gnu.org; 18 Jun 2020 15:45:37 +0000 Received: from localhost ([127.0.0.1]:54149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlwjR-0005ei-H5 for submit@debbugs.gnu.org; Thu, 18 Jun 2020 11:45:37 -0400 Received: from mail-qt1-f173.google.com ([209.85.160.173]:33909) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jlwjM-0005UO-0w for control@debbugs.gnu.org; Thu, 18 Jun 2020 11:45:35 -0400 Received: by mail-qt1-f173.google.com with SMTP id u17so4807174qtq.1 for ; Thu, 18 Jun 2020 08:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=y7BztUd7ThSgD4vyBTzXI8WTuTkpek+vP9HaihA6ji0=; b=Sz0bZBqgNNERXyFb/GzelcR8efSs2HdN6XnyeHyqD8txXFzuALe+2ZYuHMQb07PDcz Fy7Dlxmc7k7m0JMsz7rCdwuLRcOuq/h5qsTD9okJRn37olq0lQO5gIWbLyySjEJs/ppe cfmel3G5IEddyhVUzWSJ1z1ekadfwA4EqD5cFcIxiQITl4xFURkDb1QMgPSoJO5d0NdU 3i3WZinJGKXn3YgOlTT9OJrO9Qs6/4ORy+g5Chv2b3ui/4qjxzhg5+YGqLri4zJBa4HH FiOvu08KZ8tRQ757r6A6mKCijWkQr3tREBh9gVqGDF9ApsADrfw107yUAMNXmuhWt5u8 dObA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=y7BztUd7ThSgD4vyBTzXI8WTuTkpek+vP9HaihA6ji0=; b=LZ0eyl0UQ2Dod3519Sv/guVnpojl6Prs74aaRGCU2i6bVaW6clQ3GWASuLFZ7ai/q4 1x8fwWLJlkz7P71WgqWKhI1EjazhHNYsEOgQ7eY/enqshAu4ZtIbylsxfgEAX5j4vOVZ IRXs2YY0Bg62H3dOx9UndlKp7Rukxad679tfE6FwGNqzH6O1tDKRX2Mr+iMwQ7KF9Xqb 1+xTxPpsiC/rlBbwEaaQ/cjl1/CIy5IXo9DjRopkKy0JJ7fIOZluhfCMF0xOTGB9eniI 1//KOWamUoDxULbdjshNGYRHAUZwH7nodOXgZ2KoaQmMk64gMHOU9iRCgwT/OMo4mmu0 9OFQ== X-Gm-Message-State: AOAM533JgTM6Q4QShj9nXC2x/LklftutR2pgDrlIm3/yIIpcMCQJ/30E sJxqDp1SdQbd+L5fkH9kez9oXw== X-Google-Smtp-Source: ABdhPJzpBXuF9sgRDOIXq/aB4Xpx0XAYIUZ0ul1wKHK47k1nKBXULIMALPyepSZy0t9inT3pA2rl7A== X-Received: by 2002:ac8:3f70:: with SMTP id w45mr5034751qtk.253.1592495126475; Thu, 18 Jun 2020 08:45:26 -0700 (PDT) Received: from localhost ([2a02:8084:20e2:c380:1f68:7ff5:120d:64e]) by smtp.gmail.com with ESMTPSA id m26sm3820535qtm.73.2020.06.18.08.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 08:45:25 -0700 (PDT) From: "Basil L. Contovounesios" To: Eli Zaretskii Subject: Re: bug#41808: 28.0.50; Various battery.el improvements References: <87tuzhzjs3.fsf@tcd.ie> <835zbx601o.fsf@gnu.org> <87ftb1frg1.fsf@tcd.ie> Date: Thu, 18 Jun 2020 16:45:23 +0100 In-Reply-To: <87ftb1frg1.fsf@tcd.ie> (Basil L. Contovounesios's message of "Thu, 11 Jun 2020 18:22:22 +0100") Message-ID: <87wo44ml7w.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control Cc: 41808-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 41808 fixed close 41808 28.1 quit Pushed to master and closing. Various battery.el improvements (bug#41808) 23a148c950 2020-06-18 12:58:28 +0100 https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=23a148c9506f2a5bce71bd5c8822bb7cde6697e8 -- Basil From unknown Fri Jun 20 07:21:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 17 Jul 2020 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator