GNU bug report logs - #9363
display-battery-mode

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Wed, 24 Aug 2011 18:19:02 UTC

Severity: minor

Tags: patch

Done: Juri Linkov <juri <at> jurta.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 9363 in the body.
You can then email your comments to 9363 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9363; Package emacs. (Wed, 24 Aug 2011 18:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 24 Aug 2011 18:19:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: display-battery-mode
Date: Wed, 24 Aug 2011 21:12:08 +0300
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)




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#9363; Package emacs. (Thu, 25 Aug 2011 13:40:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 9363 <at> debbugs.gnu.org
Subject: Re: bug#9363: display-battery-mode
Date: Thu, 25 Aug 2011 09:37:05 -0400
> 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.

Setting it to nil would be good, yes.


        Stefan




Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Thu, 25 Aug 2011 19:54:01 GMT) Full text and rfc822 format available.

Notification sent to Juri Linkov <juri <at> jurta.org>:
bug acknowledged by developer. (Thu, 25 Aug 2011 19:54:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 9363-done <at> debbugs.gnu.org
Subject: Re: bug#9363: display-battery-mode
Date: Thu, 25 Aug 2011 22:50:39 +0300
>> 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.
>
> Setting it to nil would be good, yes.

Done.




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

This bug report was last modified 12 years and 227 days ago.

Previous Next


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