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.
(defalias 'dtw 'delete-trailing-whitespace)