GNU bug report logs - #23216
25.1.50; battery.el doesn't allow for exotic power supply types in sysfs.

Previous Next

Package: emacs;

Reported by: Matthew Leach <matthew <at> mattleach.net>

Date: Mon, 4 Apr 2016 16:11:01 UTC

Severity: minor

Tags: patch

Merged with 25800

Found in versions 24.5, 25.1.50

Fixed in version 26.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23216 in the body.
You can then email your comments to 23216 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23216; Package emacs. (Mon, 04 Apr 2016 16:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matthew Leach <matthew <at> mattleach.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 04 Apr 2016 16:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matthew Leach <matthew <at> mattleach.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50;
 battery.el doesn't allow for exotic power supply types in sysfs.
Date: Mon, 04 Apr 2016 16:09:54 +0000
[Message part 1 (text/plain, inline)]
Hello,

battery.el doesn't allow the customizing of the regexp used to filter
folders under /sys/class/power_supply/.  On more exotic systems, this
doesn't necessarily have the name BAT[0-9].  For example, on my machine
I have:

matthew <at> armson /sys/class/power_supply $ ls
bq27500-0  gpio-charger

Attached is a patch that allows this value to be customized.

Thanks,
Matt

In GNU Emacs 25.1.50.1 (armv7l-unknown-linux-gnueabihf, GTK+ Version 3.18.9)
 of 2016-04-03 built on armson
Repository revision: f7c5f79ca565d3ef3feeb1e0af5ca261f1bcf58a
Windowing system distributor 'The X.Org Foundation', version 11.0.11802000
Configured using:
 'configure --prefix=/usr/local'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS NOTIFY ACL GNUTLS
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LANG: C
  locale-coding-system: nil

Major mode: Emacs-Lisp

Minor modes in effect:
  magit-auto-revert-mode: t
  auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  text-scale-mode: t
  diff-auto-refine-mode: t
  smartparens-mode: t
  hl-sexp-mode: t
  show-paren-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Mark saved where search started
battery-linux-sysfs-regexp
C-x C-g is undefined
Saving file /home/matthew/Development/emacs/lisp/battery.el...
Wrote /home/matthew/Development/emacs/lisp/battery.el
Mark set
Mark saved where search started [2 times]
Quit [2 times]
Saving file /home/matthew/Development/emacs/lisp/battery.el...
Wrote /home/matthew/Development/emacs/lisp/battery.el

Load-path shadows:
/home/matthew/.emacs.d/elpa/emms-20160304.920/tq hides /usr/local/share/emacs/25.1.50/lisp/emacs-lisp/tq

Features:
(shadow linum magit-blame magit-stash magit-bisect magit-remote
magit-commit magit-sequence magit magit-apply magit-wip magit-log
magit-diff smerge-mode magit-core magit-autorevert autorevert filenotify
magit-process magit-popup magit-mode magit-git magit-section magit-utils
git-commit log-edit pcvs-util add-log with-editor async-bytecomp async
tramp-sh tramp tramp-compat tramp-loaddefs trampver ucs-normalize shell
server jka-compr face-remap eieio-opt speedbar sb-image ezimage dframe
find-func help-fns em-unix em-script em-prompt em-ls em-hist em-pred
em-glob em-dirs em-cmpl em-basic em-banner em-alias battery emacsbug vc
vc-dispatcher vc-git map macrostep-c cmacexp macrostep flyspell
whitespace cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs tsdh-light-theme mailalias smtpmail ispell
bbdb-message sendmail nnir gnus-cite smiley shr-color color qp
mm-archive mail-extr gnus-bcklg shr svg dom misearch multi-isearch
gnus-async gnus-ml gnus-topic nndraft nnmh utf-7 nnfolder network-stream
puny nsm starttls gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-cache
gnus-sum bbdb-gnus bbdb-mua bbdb-com crm bbdb bbdb-site timezone
gnus-demon nntp gnus-group gnus-undo gnus-article-treat-patch diff-mode
gnus-start gnus-cloud nnimap nnmail mail-source tls gnutls utf7 netrc
nnoo parse-time gnus-spec gnus-int gnus-range message rfc822 mml mml-sec
epa derived epg mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader gnus-win gnus nnheader subr-x gnus-util
rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums mail-utils mm-util
mail-prsvr wid-edit tsdh-dark-theme conf-toplev conf-sp smartparens dash
conf-coffee conf-windmove windmove conf-whitespace conf-slime slime-repl
slime-parse slime compile etags xref project arc-mode archive-mode
noutline outline pp hyperspec browse-url conf-faces hl-sexp thingatpt
conf-eshell em-term term disp-table ehelp em-smart pcomplete comint
ansi-color ring esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg
esh-groups eshell esh-module esh-mode esh-util conf-erc conf-emms
emms-librefm-stream xml emms-librefm-scrobbler emms-playlist-limit
emms-volume easy-mmode emms-volume-amixer emms-i18n emms-history
emms-score emms-stream-info emms-metaplaylist-mode emms-bookmarks
emms-cue emms-mode-line-icon emms-browser sort emms-playlist-sort
emms-last-played emms-player-xine emms-player-mpd tq emms-lyrics
emms-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap emms-streams emms-show-all
emms-tag-editor format-spec emms-mark emms-cache emms-info-ogginfo
emms-info-mp3info emms-playlist-mode emms-player-vlc advice
emms-source-playlist emms-source-file locate dired dired-loaddefs
emms-player-mplayer emms-playing-time emms-player-simple emms-info
later-do emms-setup emms-mode-line emms emms-compat conf-elisp
conf-packages conf-dir conf-dired conf-c-mode conf-auctex conf-asm
conf-ace-jump conf-personal ido seq edmacro kmacro paren finder-inf
slime-autoloads info package epg-config url-handlers url-parse
auth-source cl-seq eieio byte-opt bytecomp byte-compile cl-extra
help-mode easymenu cconv eieio-core cl-macs gv eieio-loaddefs
cl-loaddefs pcase cl-lib password-cache url-vars time-date mule-util
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 newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame
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 charscript
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
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 dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 8 481780 48466)
 (symbols 24 55472 0)
 (miscs 20 295 1628)
 (strings 16 109507 15863)
 (string-bytes 1 3721327)
 (vectors 8 73068)
 (vector-slots 4 1538007 53194)
 (floats 8 765 882)
 (intervals 28 7541 2713)
 (buffers 520 47)
 (heap 1024 55108 1933))

-- 
Matt
[0001-Make-sysfs-file-name-regexp-in-battery.el-customizab.patch (text/x-diff, inline)]
From 1dd40b00d00b5690063ec2b7b0d3b08de41f02cb Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew <at> mattleach.net>
Date: Mon, 4 Apr 2016 16:05:05 +0000
Subject: [PATCH] Make sysfs file name regexp in battery.el customizable.

* lisp/battery.el (battery-linux-sysfs-regexp): Replace
  `battery--linux-sysfs-regexp' with defcustom.
  (battery-status-function): Rename to `battery-linux-sysfs-regexp'.
  (battery-linux-sysfs): Likewise.
---
 lisp/battery.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/battery.el b/lisp/battery.el
index b5e312f..091980d 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -38,8 +38,11 @@
   :prefix "battery-"
   :group 'hardware)
 
-;; Either BATn or yeeloong-bat, basically.
-(defconst battery--linux-sysfs-regexp "[bB][aA][tT][0-9]?$")
+(defcustom battery-linux-sysfs-regexp "[bB][aA][tT][0-9]?$"
+  "Regexp for folder names to be searched under
+  /sys/class/power_supply/ that contain battery information."
+  :type 'regexp
+  :group 'battery)
 
 (defcustom battery-status-function
   (cond ((and (eq system-type 'gnu/linux)
@@ -51,7 +54,7 @@
 	((and (eq system-type 'gnu/linux)
 	      (file-directory-p "/sys/class/power_supply/")
 	      (directory-files "/sys/class/power_supply/" nil
-                               battery--linux-sysfs-regexp))
+                               battery-linux-sysfs-regexp))
 	 #'battery-linux-sysfs)
 	((and (eq system-type 'berkeley-unix)
 	      (file-executable-p "/usr/sbin/apm"))
@@ -445,7 +448,7 @@ The following %-sequences are provided:
       (dolist (dir (ignore-errors
 		    (directory-files
 		     "/sys/class/power_supply/" t
-                     battery--linux-sysfs-regexp)))
+                     battery-linux-sysfs-regexp)))
 	(erase-buffer)
 	(ignore-errors (insert-file-contents
 			(expand-file-name "uevent" dir)))
-- 
2.8.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23216; Package emacs. (Wed, 13 Apr 2016 06:26:01 GMT) Full text and rfc822 format available.

Message #8 received at 23216 <at> debbugs.gnu.org (full text, mbox):

From: Matthew Leach <matthew <at> mattleach.net>
To: 23216 <at> debbugs.gnu.org
Subject: Re: bug#23216: 25.1.50;
 battery.el doesn't allow for exotic power supply types in sysfs.
Date: Wed, 13 Apr 2016 07:25:27 +0100
Hi all,

Matthew Leach <matthew <at> mattleach.net> writes:

[...]

> Attached is a patch that allows this value to be customized.

Would it be possible for this patch to be applied, if it's OK?

Thanks,
-- 
Matt




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 16 Apr 2016 11:44:02 GMT) Full text and rfc822 format available.

Notification sent to Matthew Leach <matthew <at> mattleach.net>:
bug acknowledged by developer. (Sat, 16 Apr 2016 11:44:02 GMT) Full text and rfc822 format available.

Message #13 received at 23216-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Matthew Leach <matthew <at> mattleach.net>
Cc: 23216-done <at> debbugs.gnu.org
Subject: Re: bug#23216: 25.1.50;
 battery.el doesn't allow for exotic power supply types in sysfs.
Date: Sat, 16 Apr 2016 14:42:50 +0300
> From: Matthew Leach <matthew <at> mattleach.net>
> Date: Wed, 13 Apr 2016 07:25:27 +0100
> 
> Matthew Leach <matthew <at> mattleach.net> writes:
> 
> [...]
> 
> > Attached is a patch that allows this value to be customized.
> 
> Would it be possible for this patch to be applied, if it's OK?

Pushed to master.

In the future, whenever you introduce a defcustom, please include a
suitable ':version' tag for it.  (I did it for this variable.)

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23216; Package emacs. (Sat, 16 Apr 2016 21:21:02 GMT) Full text and rfc822 format available.

Message #16 received at 23216-done <at> debbugs.gnu.org (full text, mbox):

From: Matthew Leach <matthew <at> mattleach.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 23216-done <at> debbugs.gnu.org
Subject: Re: bug#23216: 25.1.50;
 battery.el doesn't allow for exotic power supply types in sysfs.
Date: Sat, 16 Apr 2016 22:20:14 +0100
Hi Eli,

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Matthew Leach <matthew <at> mattleach.net>
>> Date: Wed, 13 Apr 2016 07:25:27 +0100
>> 
>> Matthew Leach <matthew <at> mattleach.net> writes:
>> 
>> [...]
>> 
>> > Attached is a patch that allows this value to be customized.
>> 
>> Would it be possible for this patch to be applied, if it's OK?
>
> Pushed to master.

Great - thanks.

>
>
> In the future, whenever you introduce a defcustom, please include a
> suitable ':version' tag for it.  (I did it for this variable.)

Ah, I didn't know about that.  I will bear that in mind.

Thanks,
-- 
Matt




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 15 May 2016 11:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 21 Feb 2017 02:54:02 GMT) Full text and rfc822 format available.

Forcibly Merged 23216 25800. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 21 Feb 2017 02:54:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 22 Mar 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 36 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.