Emacs Keybindings for Mac OS X

As many Mac OS X/Emacs users know, OS X has many of the Emacs key bindings defined for the entire system. Thus, bindings like 【Ctrl+f】, 【Ctrl+b】, 【Ctrl+a】, 【Ctrl+e】, 【Ctrl+k】, 【Ctrl+y】, 【Ctrl+p】, 【Ctrl+n】, and a few others work across the whole system.

Less well known is that the Cocoa Text System is customizable and you can add other Emacs bindings to make a comfortable and familiar environment whether you’re in Emacs, Mail, Safari, or whatever. Even better is that Jacob Rus has already compiled the necessary bindings for you so all you need do is download the file and install it in the proper place on your system.

The full explanation is available here but the TL;DR is:

  1. Download the bindings file.
  2. Rename the file to DefaultKeyBinding.dict.
  3. Stash the file into the ~/Library/KeyBindings folder.

There’s lot of information at the site, though, so it’s well worth a look. It has bindings with 【Esc】 rather than 【⌥ Opt】 as the 【Meta】 key, BBEdit key bindings for any heretics reading this, and many other tidbits as well. But if you just want Emacs key bindings where 【⌥ Opt】 is the 【Meta】 key, then just follow the 3 steps above.

Posted in General | Tagged | 4 Comments

The Emacs goto-line Command

As I’ve written before, I came to Emacs after years as a Vi/Vim user. One of the things I was used to doing in Vim was to go to line N in a file by typing :N in command mode. I learned Emacs mostly by referring to the Emacs Reference Card that’s included with the distribution and, unfortunately, the reference card does not mention any way of jumping to a particular line. Over time I evolved some dopey way of doing it, probably 【Meta+< Ctrl+N Ctrl+n】 or something equally horrible.

Eventually, I discovered the answer hidden away in the Edit→Go To menu. The official way is 【Meta+g g】 to bring up the Go To Line: prompt in the minibuffer but 【Meta+g Meta+g】 also works and is easier to type. Mac OS X users can use 【⌘ Cmd+l】 if they prefer.

None of this is earth shattering and perhaps I’m the only Emacs user who didn’t know it but I am writing it down in case someone else out there is also wondering how to do it.

Posted in General | Tagged | 6 Comments

Managing Workshifting

In a recent post about workshifting I mentioned that one of the impediments to wider adoption is a fear on the part of managers that they won’t be able to effectively manage their employees if they can’t reach out and touch them. If you’re a manager who is faced with managing workshifters or you’re a workshifter who would like to reassure your manager, there’s an interesting short interview with Michael Kroth coauthor of Managing the Mobile Workforce over at Workshifting.com.

There’s not a lot of information in the interview but there is a pointer to the book’s Web site and blog. The author of the post, the president of an employee training and organizational consulting firm, is highly complementary of the book. It looks like a valuable resource for someone trying to build a virtual team.

Posted in General | Leave a comment

Using Deft With Org Mode In Emacs

Earlier this week I wrote about the Deft package for Emacs. Deft is a note taking facility by Jason Blevens modeled on Notational Velocity. I opined at the time that while Deft provides a simple, lightweight note-taking mode, it doesn’t offer anything that can’t be done with org-capture and an Org file.

It turns out that djcb over at emacs-fu disagrees. Although he, like me, is an avid Org mode user, he likes Deft for taking quick notes. I still don’t see the point and neither did some of his commenters, but djcb replies that although he uses org-capture for things like appointments and todo-items, he prefers to take longer, more free-form notes with Deft. He’s a man who obviously knows what he’s talking about so I agree when he says, “For now, just give it a try (as I do), and see if it sticks…”.

For those of you that want to take that advice, be sure to read his post on quick note-taking with deft and org-mode for some pointers on setting up Deft to work seamlessly with Org. If you find that integrating Deft and Org mode brings definite benefits, be sure to leave a comment for the rest of us.

Posted in General | Tagged , | Leave a comment

And You Thought We Weren’t Making Any Progress

I came across two articles today—one looking backward, one looking forward—that illustrate the incredible progress we’re making in power management and battery life for our electronic devices. This is important because battery technology isn’t making tremendous strides (although there have been a few bright spots) so to solve the problem of iPhones that can’t make it through the day on a single charge or laptops that can’t make it through an airplane flight from New York to San Francisco we need to look at the problem from the other end. We need to find ways to draw less power from the batteries that we already have.

Remember when the MacBook Air came out and we were all swooning at the 7 hour battery life? If you haven’t been paying attention or are still relatively young, that might seems like only major improvement for some time. But as this article in The Atlantic points out, a computer from 20 years ago that was identical to the MacBook Air but had the power efficiency of the typical 1991 computer would drain the Air’s battery in 2.5 seconds. Of course, part of that is that today’s chips are more powerful as well as more efficient but the point stands: we’ve made tremendous strides in making our devices use available power more efficiently.

That’s an example of something else that’s been in the (tech) news a lot lately: Koomey’s Law. Koomey’s Law is a sort of analog to Moore’s Law. It states that for the last 60 years the electrical efficiency of computation has doubled every 18 months.

Where are we headed in the near future? Over at Cult of Mac there is an interesting article saying that new Intel chips could let future MacBooks have practically unlimited battery life. That’s because the new chips are so efficient that an on-board solar cell could keep the battery charged virtually forever. Of course, Apple hasn’t announced such a product and the new chips are still a couple of years out but it does underline the amazing advances we’re making. The Cult of Mac article is very interesting and I urge you to read it. Soon we’ll be shaking our heads in pity for those poor people from 2011 who had MacBooks that could only go 7 hours between charges.

Now if we could only build better batteries…

Posted in General | Tagged | Leave a comment

The Emacs Regular Expression Builder

Emacs’ regular expressions are notoriously tricky. They aren’t Perl Regular Expression compatible and the escaping rules are not always what you’d expect if you’re used to Unix regular expressions. Most of us, therefore, have experienced wasted time and frustration trying to get a complicated regular expression right. Fortunately, Emacs provides a tool to help ease the way: re-builder.

re-builder provides interactive feedback on your regular expression as you build it. Any matches for a partial or complete regular expression are shown in the current buffer. If you have subexpressions, they are highlighted in a different color so you can see if you’re getting what you expected (non-color displays are handled too). If the regular expression is invalid (at any point) re-builder will tell you and you can query the error with 【Ctrl+c Ctrl+u】 to find out why re-builder is complaining.

When you’re satisfied with the regular expression, you can copy it to the kill ring with 【Ctrl+c Ctrl+w】 and then quit re-builder with 【Ctrl+c Ctrl+q】.

Although re-builder attaches itself to the buffer that is current when you call it, you can change the target buffer with 【Ctrl+c Ctrl+b】 and the desired buffer name.

Summary

Key Sequence Action
Ctrl+c Ctrl+u Show Error
Ctrl+c Ctrl+b Change Target Buffer
Ctrl+c Ctrl+w Copy Regular Expression to Kill Ring
Ctrl+c Ctrl+q Quit re-builder
Posted in General | Tagged | 1 Comment

Happy Programmers’ Day

Today is the 0x100th day of the year: Programmers’ Day. So Happy Programmers’ Day to all my fellow programmers.

Posted in General | Leave a comment

A Lightweight Alternative To Emacs Org Mode

As regular readers know, I am fanatical Org mode user. Almost everything I write in Emacs that isn’t programming code ends up in Org mode. Sometimes, even code does. Still, Org mode is a large system with lots of functionality and that can make it hard to learn.

I recently came across an Emacs package that gives some of the functionality of Org mode and is much simpler to use. Deft is an Emacs mode for dealing with notes. Jason Blevins modeled Deft on Notational Velocity, a Mac note management program. Deft keeps each note in a separate file in the ~/.deft directory (configurable). A note consists of a title on a separate line and then the body of the note. The main interface for Deft is the Deft File Browser, which is simply an Emacs buffer that lists the note titles, the first few words of the body, and the last modification time. The principle operation in Deft is searching and filtering. Filtering is initiated by simply typing some text. Files that have a title or body containing that text show up in the Deft browser on the fly. It’s sort of reminiscent of how Ido interactively pares down the list of target files.

There are a couple of other features but Deft’s main strength is its simplicity. In that, it embraces the Unix principle of doing one task and doing it well (and in plain text, of course). Installation is trivial. Simply clone the source, stash it in the Emacs Lisp search path, and add

(require 'deft)

to your .emacs or init.el file.

If you’re already an Org mode user, org-capture and a notes.org file can accomplish the same thing but if you don’t want to bother with Org mode and want a simple and effective way of managing notes, Deft could be just what you’re looking for. The Deft home page at the above link has a nice write up so go take a look if you’re interested in a lightweight note manager.

Posted in General | Tagged , | 3 Comments

Printing In Emacs Lisp

Xah Lee has added another page to his excellent series on Emacs Lisp. This time it’s about printing in Emacs Lisp. Most of us who have written any elisp are familiar with the message function, which prints a message to the “*Messages*” buffer and echoes it to the minibuffer.

Often times, we want to write messages to some other buffer—the two posts on Xah’s Challenge are examples. The basic mechanism for doing that is to use with-output-to-temp-buffer in conjunction with the print, prin1, or princ functions. Head over to Lee’s post for all the details if you don’t already know them. It’s a nice summary of the various printing commands.

There are several excellent blogs that cover using Emacs (emacs-fu, Got Emacs?, Mastering Emacs, Xah’s Emacs Tutorial, and many others) but Lee’s Emacs Lisp Tutorial is the only one I know that regularly covers Emacs Lisp and how to use it to solve editing problems. Emacs Lisp is pretty much like other Lisps so anyone using Common Lisp or Scheme will be comfortable with most of it but the problem is that Emacs Lisp has tons of functions that are specific to the Emacs editing environment and none of those will be familiar to someone coming from another Lisp. That’s where Lee’s Emacs Lisp Tutorial is essential. He gives you real working examples and you see those commands in action.

Posted in General | Tagged | Leave a comment

Emacs 24 Features

Bozhidar Batsov over at (think) recently loaded the current development version of Emacs 24 and gives us a peek at its features. The post is a very nice look at what’s coming in the next version of Emacs and well worth a look by all Emacs fans. His writeup is fairly comprehensive—at least for the features he covers—so I won’t try to summarize it here; you should go read it yourself.

Batsov doesn’t say whether he is using it for day-to-day work or just playing around with it. I remember using the Emacs 23 development version long before it was officially released and never had any problems. It would be nice to know if Emacs 24 is at that state yet. I’m very happy with Emacs 23 so I don’t feel the need to jump into the new version before it’s completely baked but some of you may be waiting for one of those new features and feel differently. Be sure to let us know if you do adapt it for day-to-day use and how it works out.

Update: Asked and answered. Batsov comments that he has been using Emacs 24 for day-to-day work for about a month and that it’s rock solid. Anyone who can’t wait for those new features should give it a try.

Posted in General | Tagged | 7 Comments