2010-09-23

10 Specific Ways to Improve Your Productivity With Emacs

emacs.png

I was re-reading an old post by Steve Yegge about productivity tips for using Emacs, and I wanted to comment on a few of them, but I was not able to find a way to leave a comment or email him. That combined with the fact that I haven't done a blog entry in over a year, I thought I should blog my comments here.

If you use Emacs (and you should), you owe it to yourself to read his post. He does a very good job explaining why Emacs is better at certain [most] tasks and how to configure it for an even better experience.

10 Specific Ways to Improve Your Productivity With Emacs

As I read this I realized that I had incorporated a lot of his recommendations already. Some I had not implemented, others I had tried and reversed (as noted in my comments inside my dot-emacs files). I've listed his sections that I have comments about.

Item 1: Swap Caps-Lock and Control

This time I am going to try to stick with using Caps_Lock as Control. Since I mostly use Ubuntu Linux setting up my .xmodmap files was pretty simple to do. I will be sure to try his regedit trick on Windows when I get a chance.

Item 2: Invoke M-x without the Alt key

I had this switched off because I was using the C-xC-m key for starting Mingus, but I'm going to try the keybindings he recommends.

Item 3: Prefer backward-kill-word over Backspace

I find it hard to switch finger-memory modes when switching between Emacs' cut/copy/paste bindings and the standard CTRL-X/C/V ones that so many other applications use. Because of this, I use cua-mode. It allows me to keep the Emacs functionality of those keys while still being able to use them as needed. Having said this, I still want the original Emacs cut binding C-w to work as expected.

Since the kill-region command should only be called when a region has been selected, I wrote some code to solve this issue for me. Using the following code will do-the-right-thing when you press C-w:

(defun kill-region-or-word ()
  "Call `kill-region' or `backward-kill-word' depending on
whether or not a region is selected."
  (interactive)
  (if (and transient-mark-mode mark-active)
      (kill-region (point) (mark))
    (backward-kill-word 1)))
(global-set-key "\C-w" 'kill-region-or-word)
Dialog Boxes: The Root of All Evil

Just had to say that I completely agree.

Item 7: Lose the UI

Being nitpicky here but when should be used instead of if in the following code:

(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))

Like so:

(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
Keyboard Macros

As mentioned in the comments section, after you've created a keyboard macro with C-x( and finished it with C-x), and then used it once via C-xe, you can then repeat it by just pressing e.

That's about it for my comments. I hope Steve writes more articles on this topic and finishes his remaining 40 tips.

For more interesting Emacs sites see my previous blog entry about this topic.

If you don't use emacs, you're a pathetic, mewling, masochistic weakling and I can't be bothered to convert you.

-— Ron Echeverri

Tags: emacs programming software technology