bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23216: 25.1.50; battery.el doesn't allow for exotic power supply typ


From: Matthew Leach
Subject: bug#23216: 25.1.50; battery.el doesn't allow for exotic power supply types in sysfs.
Date: Mon, 04 Apr 2016 16:09:54 +0000

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@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
>From 1dd40b00d00b5690063ec2b7b0d3b08de41f02cb Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew@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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]