Update on OS X Emacs Battery Status

Yesterday, I wrote about the problems I had with Emacs when I updated to OS X Mavericks. The problem was that the call to display-battery-mode failed. For OS X, Emacs uses pmset to get the battery status data. With Maverics, pmset was returning a string that began with “Now drawing from ‘(AC|Battery) Power’” but in previous versions returned “Currently drawing from ‘(AC|Battery) Power’.” Since Emacs was looking for the latter string, the output was corrupted and the call to display-battery-mode failed.

It was pretty easy to track this down using Edebug. The problem is that the regular expression used to search the pmset output is a constant string and not configurable. That means that fixing the problem pretty much boils downs to

  1. Fixing battery-pmset, where the problem occurs, to look for “Now” as well as “Currently” or
  2. Making a local copy of battery-pmset that looks for “Now.”

While I was pondering what to do, Bernd Berndsen wrote to tell me that a change had already been pushed to the development branch. Since this is not a critical issue for me, I’m content to wait to the next update. If it’s more important to you, the easiest thing to do is either to edit and recompile battery-pmset on your local version of Emacs or install the latest development branch. Follow the “development branch” link to see the change you need to make.

I’m not privy to Apple’s thinking on this, of course, but the change seems gratuitous to me. Yes, “Now” is slightly better wording than “Currently” but they had to know that it was apt to break programmatic processing of pmset‘s output. If anyone knows why the change was made, please leave a comment.

This entry was posted in General and tagged . Bookmark the permalink.