February 6th, 2007 by Ryan McGeary · 3 Comments
This one is personal preference, but I find it annoying when emacs beeps on errors. I like knowing when something bad/unexpected happened, but the beep is too much when the sound is on and useless when muted. Add this to your
.emacs to enable a visual alert cue that flashes the frame instead:
Note: From what I can tell, this only works under a windowing system, so it won’t do much good if you run emacs in terminal mode.
Tags:quick · tips
February 3rd, 2007 by Ryan McGeary · 3 Comments
Part of the reason we started M-x all-things-emacs was to encourage newcomers to the emacs world. The emacs learning curve is a steep one, and sometimes it’s easy for the more advanced members of the contingent to take some of the basics for granted. This is the first of a series of newbie tips where we hope to help emacs beginners climb that learning curve.
Add this to your
.emacs file to improve productivity:
(fset 'yes-or-no-p 'y-or-n-p)
Several emacs actions require user confirmation before proceeding and by default, the
yes-or-no-p function is used to prompt the user for a yes/no response. Typing
yes RET or
no RET can be a burden, but typing
n is quicker and intuitive. The call to
fset aliases the
yes-or-no-p function to instead yield the results of
y-or-n-p, resulting in fewer keystrokes.
I also use the
fset function to alias those actions that maybe don’t warrant their own hot key combination, but perhaps deserve a shorter name for faster
M-x access. For example, suppose I wanted to alias
delete-trailing-whitespace to a shorter alternative. Try this:
(fset 'dtw 'delete-trailing-whitespace)
Now, I can remove trailing whitespace from each line of the current buffer by running
P.S. I thought about making the first beginner tip a discussion about the built-in emacs tutorial (
C-h t) and the other built-in help actions (
M-x help), but that’s pretty well documented already.
Update: piyo pointed out in the comments that the
dtw alias should be defined using
defalias instead of
fset according to the conventions in the Elisp Manual. Thanks.
(defalias 'dtw 'delete-trailing-whitespace)
Tags:newbie · tips
January 29th, 2007 by Ryan McGeary · 12 Comments
This is part one of a two-part series. Here we’ll discuss some straight forward options for maximizing and resizing the emacs window on startup. In part two, we’ll explore a more advanced alternative.
I like to maximize my emacs window (aka frame) to fit the entire screen when I really want to focus on what I’m doing. On larger displays, this allows me to split windows every which way and view multiple buffers at once. The other day, I realized I was manually maximizing my emacs window after every startup, and I decided I had to put an end to that. There are several ways to accomplish this with elisp, and I am going to touch on a few.
[Read more →]
Tags:elisp · osx · tips · windows · x
January 26th, 2007 by Rob Christie · 5 Comments
This is the first in a series of real world uses of emacs keyboard macros. Emacs macros are normally mentioned as a powerful feature of emacs, but many times I find the examples that are given are more academic in nature and don’t drive home their usefulness. These posts will show examples of macros “in the wild.” Part of the fun of becoming proficient with macros is that it both allows you to quickly complete a mundane task, and at the same time provides a bit of a mental exercise because you must think through the process for generalizing the task at hand. [Read more →]
Tags:java · kb-macros · tips
January 23rd, 2007 by Ryan McGeary · 2 Comments
After years of emacs usage, sometimes I feel like my fingers get ahead of me. The esoteric set of key combinations are an extension of my subconscious. Maybe my cerebellum short circuits the impulses from my frontal lobe, but when I’m asked how I perform a particular task in emacs, often I cannot answer without ghost typing on my imaginary keyboard. I’m either not alone or destined for the loony bin. My wife’s money is on the latter.
To help recover those lost keystrokes, try
M-x view-lossage. This function displays the last 100 input keystrokes in an emacs-esque way. It is also bound to
If you ever want to record more than 100 keystrokes, try
M-x open-dribble-file. After specifying the file location, it starts writing all keyboard characters to the file. To stop the dribble, pass
nil as the file argument like so:
Speaking of dribble, you’ve got a little something on your chin. On the left. No, your other left.
January 17th, 2007 by Rob Christie · 10 Comments
I use this function almost daily. Why? Well, it’s because too many developers use editors that muck the alignment of the source.
(defun iwb ()
"indent whole buffer"
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max)))
Open a file,
M-x iwb, save, commit, and edit happily.
I can’t take credit for it, but it seems like it should be passed along. I think I originally copied it from another co-worker’s
.emacs file when I started using emacs.
Tags:elisp · tips
January 17th, 2007 by Ryan McGeary · No Comments
I was going to provide a follow-up to my Emacs on Mac OS X post, but for Windows hackers. It turns out that Derek Slager beat me to it and did a great job. Check out his description of how to Install Emacs on Windows. In addition, he does a fine job of explaining how to Manage Emacs Instances with gnuserv.
Though, one thing I recommend differently is to first install cygwin and use your cygwin home directory (e.g.
/home/user) instead of
C:\Documents and Settings\user. If anything, you’ll benefit from the unix utilities that accompany cygwin. Be sure to configure emacs to recognize cygwin paths.
Additionally, if you would like to live on the edge with Emacs 22 and don’t want to muck with the complications associated with compiling emacs from source, give EmacsW32 a try. They have an Emacs 22 binary distribution for Windows.
Update: Derek Slager now has a guide that explains how to Compile Emacs from CVS on Windows
Tags:tips · windows
January 13th, 2007 by Ryan McGeary · 12 Comments
Like many, I am a recent Mac OS X convert. I left Windows about 9 months ago and haven’t looked back. Upon switching, I found several different emacs distributions. While each has its own strengths and weaknesses, only Carbon Emacs made the cut. Here’s why:
[Read more →]
Tags:osx · tips
January 12th, 2007 by Rob Christie · No Comments
Some how I missed Steve Yegge’s Blog Rants until the fall of last year. My only excuse is that I have been head down on a project (the article initially came out in early 2005; I don’t know how I missed it). Effective Emacs, 10 Specific Ways To Improve Your Emacs Productivity is a great article. It’s like a Joel Test for emacs gurus. I probably score a 6.5 in terms of using the 10 best practices/tips that are listed.
January 12th, 2007 by Rob Christie · No Comments
We’d like to introduce a small blog focused on “the one true editor.” I use emacs daily. My intent for this blog is initially the following:
- Provide links to recent emacs happenings. As an emacs user I feel like I browse different sites and blogs, and find useful information in various nooks and crannies of the web, but there is not currently a single place where this information gets consolidated (other than my delicious tags).
- Provide another location other than the newsgroups and wiki for emacs users to communicate.
- Provide what few gems of emacs wisdom I have.
- Hopefully generate more discussion on emacs.
Tags:misc · news