unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 9363@debbugs.gnu.org
Subject: bug#9363: display-battery-mode
Date: Wed, 24 Aug 2011 21:12:08 +0300	[thread overview]
Message-ID: <874o16el1j.fsf@mail.jurta.org> (raw)

When ACPI is turned off with `acpi=off' after booting the Linux kernel
`M-x display-battery-mode RET' fails with:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  read-from-string(nil)
  battery-update()
  display-battery-mode(toggle)
  call-interactively(display-battery-mode t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)

whereas `M-x battery RET' displays a polite message "Battery status not available".

This patch fixes `display-battery-mode' to display the same message when
`battery-status-function' is nil.

I don't know if it's desirable to force turning off this mode and to
reset the value of `display-battery-mode' to nil in this case.
But at least, the message is informative with this patch:

=== modified file 'lisp/battery.el'
--- lisp/battery.el	2011-06-27 08:04:55 +0000
+++ lisp/battery.el	2011-08-24 18:11:15 +0000
@@ -173,13 +173,15 @@ (define-minor-mode display-battery-mode
   (setq battery-mode-line-string "")
   (or global-mode-string (setq global-mode-string '("")))
   (and battery-update-timer (cancel-timer battery-update-timer))
-  (if (not display-battery-mode)
-      (setq global-mode-string
-	    (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)))
+  (if (and battery-status-function battery-mode-line-format)
+      (if (not display-battery-mode)
+	  (setq global-mode-string
+		(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))
+    (message "Battery status not available")))
 
 (defun battery-update-handler ()
   (battery-update)





             reply	other threads:[~2011-08-24 18:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24 18:12 Juri Linkov [this message]
2011-08-25 13:37 ` bug#9363: display-battery-mode Stefan Monnier
2011-08-25 19:50   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874o16el1j.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=9363@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).