* bug#9363: display-battery-mode
@ 2011-08-24 18:12 Juri Linkov
2011-08-25 13:37 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2011-08-24 18:12 UTC (permalink / raw)
To: 9363
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9363: display-battery-mode
2011-08-24 18:12 bug#9363: display-battery-mode Juri Linkov
@ 2011-08-25 13:37 ` Stefan Monnier
2011-08-25 19:50 ` Juri Linkov
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2011-08-25 13:37 UTC (permalink / raw)
To: Juri Linkov; +Cc: 9363
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9363: display-battery-mode
2011-08-25 13:37 ` Stefan Monnier
@ 2011-08-25 19:50 ` Juri Linkov
0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2011-08-25 19:50 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 9363-done
>> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-25 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-24 18:12 bug#9363: display-battery-mode Juri Linkov
2011-08-25 13:37 ` Stefan Monnier
2011-08-25 19:50 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.