Subject: 28.0.50; two bugs in battery-upower

From: Richard Stallman <[email-masked]>
Date: Fri, 07 Feb 2020 15:14:57 -0500

battery-upower crashes on my laptop because there is no BatteryLevel property.
This code

          (cons ?b (cond ((= level 3) "-")
                         ((= level 4) "!")
                         (online-p "+")
                         (t "")))

needs to handle nil.  I don't know what value it should return for that case.

However, that function has a design flaw: it reports on just the first
battery in the list.  battery-upower-device-list correctly returns a
list with an element for each battery, but battery-upower finds only one
of them (the first one in the list) and ignores the others.

The old code handle all the batteries and added the energy quantities
so as to report accurately the total power available and overall
fraction of charge.  I wrote that code myself, around 10 years ago.

Please restore the lost functionality.

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.30, cairo version 1.14.6)
 of 2020-02-06 built on softly
Repository revision: c4be80112556e06bd7e92138e44051cc8c62e709
Repository branch: master
System Description: Trisquel GNU/Linux Flidas (8.0)

Recent messages:
(("NativePath" . "BAT0") ("Vendor" . "SANYO") ("Model" . "42T4832") ("Serial" . "19849") ("UpdateTime" . 1581079789) ("Type" . 2) ("PowerSupply" . t) ("HasHistory" . t) ("HasStatistics" . t) ("Online") ("Energy" . 35.21) ("EnergyEmpty" . 0.0) ("EnergyFull" . 35.21) ("EnergyFullDesign" . 43.29) ("EnergyRate" . 2.237) ("Voltage" . 12.504) ("Luminosity" . 0.0) ("TimeToEmpty" . 0) ("TimeToFull" . 0) ("Percentage" . 100.0) ("Temperature" . 0.0) ("IsPresent" . t) ("State" . 4) ("IsRechargeable" . t) ("Capacity" . 81.33518133518135) ("Technology" . 1) ("WarningLevel" . 1) ("IconName" . "battery-full-charged-symbolic"))
Back to top level
battery-upower
Saving file /home/rms/emacs-git/build-feb-6/lisp/battery.el...
Wrote /home/rms/emacs-git/build-feb-6/lisp/battery.el
Quit
Power on-line, battery fully-charged (100% load, remaining time 0:00)
Mark set [2 times]
(("line_power_AC" . :line-power) ("battery_BAT0" . :battery) ("battery_BAT1" . :battery))
completing-read-default: Command attempted to use minibuffer while in minibuffer
Quit
Configured using:
 'configure 'CFLAGS=-g -O0' --with-gnutls=no'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 XDBE XIM MODULES THREADS PDUMPER GMP

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  bug-reference-prog-mode: t
  gpm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow mailalias emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec epa epg epg-config gnus-util rmail
rmail-loaddefs text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils misearch
multi-isearch vc-git diff-mode easy-mmode bug-reference help-fns
radix-tree cl-print debug backtrace help-mode find-func battery dbus
xml t-mouse term/linux view derived paren cus-start cus-load advice
finder-inf package easymenu browse-url url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese
eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese composite charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 84673 5995)
 (symbols 48 9669 1)
 (strings 32 27252 1051)
 (string-bytes 1 856458)
 (vectors 16 15529)
 (vector-slots 8 554003 72566)
 (floats 8 45 242)
 (intervals 56 545 268)
 (buffers 1000 12)
 (heap 1024 9701 932))
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)