Sacha Chua, as everyone here knows, is relentless about improving her work flow and procedures. Happily for us, she’s also diligent about sharing the results of her efforts with the rest of us. Her recent outstanding post on cultivating Emacs micro-habits is an excellent example of this.
She’s thought more deeply than most of us about which habits make sense and are worth the effort to burn into our muscle memory. The post represents some of her conclusions so far. Even if you’re an experienced Emacs user, you are likely to find something useful in the post that you didn’t know.
For example, she has a nice idiom for dealing with the problem of writing commands that work on the entire buffer unless a region is defined. I’ve long used a macro for that but Chua has another way. Suppose we want to extract the contents of a buffer into a string unless a region is defined, in which case we want the contents of just the region. Chua uses conditon-case
like this:
(setq contents (condition-case nil (buffer-substring beg end) (mark-inactive (buffer-string))))
That’s not a micro-optimization in itself but is part of a function that copies code into a blog post, posts it as a Gist, and adds a link to the Gist in the blog post. That’s something useful too if you post code as a Gist.
Another nice trick I learned is how to programmatically retrieve properties from an Org mode buffer. That’s also very useful if you want to write code to automatically process an Org buffer.
The whole post is full of goodness and you really should give it a read. If you’re interested in improving your work flow, you’ll probably find something useful.