Hello, I’m Sacha Chua, and this is an Emacs Basics video on customizing Emacs. Emacs is incredibly flexible. You can tweak it to do much more than you might expect from a text editor. This week, we’re going to focus on learning how to tweak Emacs with M-x customize and by editing ~/.emacs.d/init.el.
You can change tons of options through the built-in customization interface. Explore the options by typing M-x customize. Remember, that’s Alt-x if you’re using a PC keyboard and Option-x if you’re on a Mac. So for me, that’s Alt-x customize <Enter>. In the future, I’ll just refer to this as the Meta key, so remember which key is equivalent to Meta on your keyboard. (Review – Emacs Basics: Call commands by name with M-x)
After you run
M-x customize, you’ll see different groups of options. Click on the links to explore a group.
For example, people often want to change the backup directory setting. This is the setting that controls where the backup files (the files ending in
~) are created. You’ve probably noticed that they clutter your current directory by default. To change this setting, select the Files > Backup group. Look for the entry that says Backup Directory Alist. Click on the arrow, or move your point to the arrow and press <Enter>. Click on INS, or move your point to INS and press <Enter>. Fill it in as follows:
Click on State and choose Save for future sessions. This will save your changes to
~/.emacs.d/init.el. When you’re done, type q to close the screen.
You can also jump straight to customizing a specific variable. For example, if you want to change the way Emacs handles case-sensitive search, you can use M-x customize-variable to set the case-fold-search variable. By default, case fold search is on, which means that searching for a lower-case “hello” will match an upper-case “HELLO” as well. If you would like to change this so that lowercase only matches lowercase and uppercase matches only uppercase, you can toggle this variable. I like leaving case fold search on because it’s more convenient for me. If you make lots of changes, you can use the Apply and Save button to save all the changes on your current screen.
Not sure what to customize? You can learn about options by browsing through M-x customize or reading the manual (Help > Read the Emacs Manual or M-x info-emacs-manual). You can also search for keywords using M-x customize-apropos.
The Customize interface lets you change lots of options, but not everything can be changed through Customize. That’s where your Emacs configuration file comes in. This used to be a file called
~/.emacs in your home directory, and you’ll still come across lots of pages that refer to a
.emacs file (or “dot emacs”). The new standard is to put configuration code in your
~/.emacs.d/init.el file, which you can create if it does not yet exist.
What goes into your
~/.emacs.d/init.el file? If you open it now, you’ll probably find the settings you saved using
M-x customize. You can also call functions, set variables, and even override the way Emacs works. As you learn more about Emacs, you’ll probably find Emacs Lisp snippets on web pages and in manuals. For example, the Org manual includes the following lines:
(global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-cc" 'org-capture) (global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-cb" 'org-iswitchb)
This code sets C-c l (that’s Control-c l) to run
org-store-link, C-c c to run
org-capture, C-c a to run
org-agenda, and C-c b to run
org-iswitchb. You can add those to the end of your
~/.emacs.d/init.el file. They’ll be loaded the next time you start Emacs. If you want to reload your
~/.emacs.d/init.el without restarting, use M-x eval-buffer.
Emacs Lisp may look strange. Don’t worry, you can get the hang of it even if you don’t think of yourself as a programmer. You can start by copying interesting snippets from other people’s configuration files. Start with small chunks instead of large ones, so you can test if things work the way you want them to. If you need help, StackOverflow and other Q&A resources may be useful.
As you experiment with configuring Emacs, you may run into mistakes or errors. You can find out whether it’s a problem with Emacs or with your configuration by loading Emacs with emacs -Q, which skips your configuration. If Emacs works fine with your configuration, check your
~/.emacs.d/init.el to see which code messed things up. You can comment out regions by selecting them and using M-x comment-region. That way, they won’t be evaluated when you start Emacs. You can uncomment them with M-x uncomment-region.
Emacs gets even awesomer when you tailor it to the way you want to work. Enjoy customizing it!
Focus areas and time review
In the early days of my 5-year experiment with semi-retirement, I brainstormed ways it could fail. I worried that I might end up too distracted to make useful stuff, or that I’d end up being incapable of pursuing my ideas, or that I’d mess up somewhere–paperwork, people, products–and botch the whole thing. I worried that I’d finish the experiment with nothing to show and no compelling story for the gap I’d have in my resume. I worried that W- would get tired of this exploration.
I feel less worried now. Part of it was realizing that I can plan for only so much safety. Part of it was learning how to choose what I’m going to focus on, how to select my projects without managers and track my progress without annual performance reviews. (Well, I still have annual reviews, but they’re self-driven.) Part of it was trusting that I can handle things, a confidence which grew after each small step.
Looking back, I can see the things I found mentally challenging in the beginning, and how I worked around them.
If you’re starting your own experiment or you’re well into one, I’d love to hear about some of the challenges you faced and how you worked around them!
Dired is the Emacs directory editor. You can get to it with C-x C-f (
find-file) if you specify a directory. C-x d (
dired) works too. Dired makes it easy to do batch operations on files. One of the niftiest features that you might not even think of looking for, though, is the ability to make a Dired buffer editable using C-x C-q (
dired-toggle-read-only). Then you can use
replace-regexp, keyboard macros, and all sorts of other ways to change filenames. When you switch back out of editing mode with C-x C-q, the files will be updated.
Here’s a cheat sheet for working with Dired.
Also, bjonnh suggested making a cheat sheet for movement commands. I use the M-b, M-f, C-M-b, and C-M-f shortcuts a lot when working with Emacs Lisp. C-a and C-e are great too.
If you use
evil-mode because you’re used to Vim shortcuts, this cheat sheet won’t be useful to you, but maybe I can make an evil-mode cheat sheet someday.
In other news, I’m slowly becoming the kind of person who can understand SmartParens. I’m getting the hang of slurp and barf, but the rest of it still boggles me. Someday!
How can you figure out a fair budget for delegating work? If you set your budget too low, you might get frustrated by lack of response or by the kinds of results you get. If you set your budget too high, you might waste effort and talent. I can’t give you a price sheet. Besides, your needs will evolve over time. However, I can share some of the things I’ve been learning about budgeting for outsourcing or checking if people’s times are reasonable.
If you’re working with hourly assistance, you can ask people to track their times for specific tasks so that you can get a sense of how much something costs. You can also give a time limit and ask them to send you what they have at the end of that time. This will help you get a sense of their speed and the cost of the task. If you’re working with fixed-cost services, you can translate things back into hourly estimates and compare that with your own experience. Pick one system of measurement so that you can compare your chioces.
Instead of trying to nail down a single price, try to figure out a range that you’re comfortable with. You can start by looking for flat-rate fees from companies or people who post fixed prices online. For example, Transcript Diva lists transcript rates and timelines for some of their competitors as well. For general tasks, services like Fiverr and Fancy Hands help establish a range of $5-15 for common tasks.
Another way to establish a limit for what you’re willing to spend is to consider how long it takes you to do things yourself, and what else you would do with that time. Adjust based on people’s experience. Beginners will take longer to do things than you will, while experienced people may do this just as fast as you can. Specialists who have invested in tools or training may do things even faster. Sometimes it makes sense to delegate a task to someone who isn’t the optimal choice in terms of speed or cost, if they’re more integrated with the way you work or if you want to help them grow. (Sketch: delegation and task efficiency; blog post)
Then experiment. Try delegating a small task to a lower-cost service to see if that will meet your needs. Try delegating a similar task to a premium service to see if it’s worth the price. Try a mid-range service.
Think about the value you can get from the different types of results you have. If a service is expensive but it leads to a lot more income, it may be worth it.
Think of when you’d prefer to do things yourself, too. For example, even though it’s easy to find inexpensive data entry assistance, I prefer to automate straightforward tasks because I get to learn more about automation along the way.
As you delegate, think about what was worth it, and adjust accordingly. Make your experiments a little bit bigger as you get used to the idea. Find your sweet spot, and then keep experimenting. Good luck!