Category Archives: emacs

On this page:

Emacs beginner resources

Sometimes it’s hard to remember what it’s like to be a beginner, so I’m experimenting with asking other people to help me with this. =) I asked one of my assistants to look for beginner tutorials for Emacs and evaluate them based on whether they were interesting and easy to understand. Here’s what she put together! – Sacha

Emacs #1 - Getting Started and Playing Games by jekor
Probably the most helpful Emacs tutorial series on YouTube. Goes beyond the “what to type” how-tos that other tutorials seem bent on explaining over and over. Emphasizes games and how they help users familiarize themselves with the all-keyboard controls. 5/5 stars

Org-mode beginning at the basics
What it says on the tin. Essential resource for those who are new to Emacs and org-mode. Provides steps on how to organize workflow using org-mode written in a simple, nontechnical, writing style. 5/5 stars

Xah Emacs Tutorial
Though the landing page says that the tutorial is for scientists and programmers, beginners need not be intimidated! Xah Emacs Tutorial is very noob-friendly. Topics are grouped under categories (e.g. Quick Tips, Productivity, Editing Tricks, etc.) Presentation is a bit wonky though. 4.5/5 stars

RT 2011: Screencast 01 – emacs keyboard introduction by Kurt Scwehr
Keyboard instruction on Emacs from the University of New Hampshire. Very informative and also presents some of the essential keystrokes that beginners need to memorize to make the most out of the program. But at 25 mins, I think that the video might be too long for some people. 4/5 stars

Emacs Wiki
Nothing beats the original- or in this case, the official- wiki. Covers all aspects of Emacs operation. My only gripe with this wiki is that the groupings and presentation are not exactly user-friendly (links are all over the place!), and it might take a bit of time for visitors to find what they are looking for. 4/5 stars

Mastering Emacs: Beginner’s Guide to Emacs
The whole website itself is one big tutorial. Topics can be wide-ranging but it has a specific category for beginners.
whole website itself is one big tutorial. Looks, feels, and reads more like a personal blog rather than a straightforward wiki/tutorial. 4/5 stars

Jessica Hamrick’s Absolute Beginner’s Guide to Emacs
Clear and concise. Primarily focused on providing knowledge to people who are not used to text-based coding environments. It covers a lot of basic stuff, but does not really go in-depth into the topics. Perfect for “absolute beginners” but not much else. 3/5 stars

Jim Menard’s Emacs Tips and Tricks
Personal tips and tricks from a dedicated Emacs user since 1981. Not exactly beginner level, but there’s a helpful trove of knowledge here. Some chapters are incomplete. 3/5 stars

Emacs Redux
Not a tutorial, but still an excellent resource for those who want to be on the Emacs update loop. Constantly updated and maintained by an Emacs buff who is currently working on a few Emacs related projects. 3/5 stars

Jeremy Zawodny’s Emacs Beginner’s HOWTO
Lots of helpful information, but is woefully not updated for the past decade or so. 2/5 stars

This list was put together by Marie Alexis Miravite. In addition, you might want to check out how Bernt Hansen uses Org, which is also pretty cool.

Emacs Chat: Tom Marble

Emacs Chat: Tom Marble – Invoicing with Org and LaTeX; Clojure

Guest: Tom Marble

Tom Marble’s doing this pretty nifty thing with Org Mode, time tracking, LaTeX, and invoice generation. Also, Clojure + Emacs, and other good things. Enjoy!

For the event page, you may click here.

For the transcript, you may click here.

Want just the audio? Get it from archive.org: MP3

Check out Emacs Chat for more interviews like this. Got a story to tell about how you learned about or how you use Emacs? Get in touch!

Emacs Chat: Iannis Zannos – Emacs and SuperCollider

Emacs! Music! Iannis Zannos shares how Emacs can be used for all sorts of awesomeness with Org Mode and SuperCollider.

Check this event page for details and comments =)

Transcript available here!

Emacs Basics: Customizing Emacs

This entry is part 3 of 3 in the series Emacs Basics

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 download the MP3 from Archive.org

Customize

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:

  • Regexp matching filename: .
  • Backup directory name: ~/.emacs.d/backups

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.

~/.emacs.d/init.el

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!

Series Navigation« Emacs Basics: Call commands by name with M-x (with tips for better completion using ido or helm)

More Emacs drawings: Dired, moving around

This entry is part 4 of 4 in the series A Visual Guide to Emacs

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.

2014-02-24 Emacs tips - use Dired to manage files #dired #emacs

2014-02-24 Emacs tips – use Dired to manage files #dired #emacs

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.

2014-02-27 Map for getting the hang of Emacs movement #emacs #map #guide

2014-02-27 Map for getting the hang of Emacs movement #emacs #map #guide

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!

Series Navigation« Some tips for learning Org Mode for Emacs

Emacs Basics: Call commands by name with M-x (with tips for better completion using ido or helm)

This entry is part 2 of 3 in the series Emacs Basics

Emacs has way too many keyboard shortcuts to memorize. Fortunately, you can call commands by name by typing M-x and the name of the command. M- stands for the Meta key. If your keyboard does not have a Meta key (and most don’t, these days), use Alt or Option. For example, on a PC keyboard, you can type Alt-x. Alternatively, you can replace Meta with ESC. M-x then becomes ESC x.

If you know the name of the command to execute, you can type it after M-x, and then press RET (the Return key, which is the same as the Enter key). For example, M-x find-file opens a file. M-x save-buffer saves the current file. You can use TAB to complete words. Use <up> and <down> to go through your command history.

What if you don’t know the name of the command to execute? You can use M-x apropos-command to search for the command using keywords. If you know the keyboard shortcut or you can find the command on a menu, you can also use M-x describe-key and then do the keyboard shortcut or select it from the menu.

If a command you execute has a keyboard shortcut, it will flash briefly at the bottom of your screen. For example:

You can run the command `find-file' with C-x C-f

Using TAB for completion can be a little slow. Here are two ways to make that and a whole lot of other things faster: ido and helm. To explore these approaches, you will need to add the MELPA package repository to your configuration. To set that up, add the following to the beginning of your ~/.emacs.d/init.el file.

(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)

Then use M-x eval-buffer to load the changes into your current Emacs, and use M-x package-refresh-contents to reload the list of packages.

Helm mode

This is what completion with Helm looks like:

2014-03-17 13_06_54-c__sacha_personal_organizer.org.png

Figure 2: Helm

Use M-x package-install to install the helm package. Then you can try it out with M-x helm-mode . After you start Helm mode, try M-x again. You can type in multiple words to search for a command, and you can use <up> and <down> to go through completions. Use M-p and M-n to go through your command history.

If you like it, here’s some code that you can add to your ~/.emacs.d/init.el file to load it automatically next time, and to tweak it for more convenience.

(require 'helm-config) 
(helm-mode 1)

Use M-x eval-buffer to load your changes.

If you change your mind and want to disable helm-mode, you can toggle it off with M-x helm-mode .

Ido, ido-hacks, smex, ido-vertical-mode, and flx-ido

Ido is like Helm, but it takes a different approach. Here’s what this combination will get you:

2014-03-17 12_40_40-MELPA.png

Figure 1: ido, smex, ido-vertical-mode, and flx-ido

If you want to give this a try, remove or comment out (helm-mode 1) from your ~/.emacs.d/init.el (if you added it), and disable helm-mode if you still have it active from the previous section.

To set Ido up, use M-x package-install to install ido, smex, ido-vertical-mode, ido-hacks, and flx-ido.

After the packages are installed, add the following code to your ~/.emacs.d/init.el .

(ido-mode 1)
(require 'ido-hacks nil t)
(if (commandp 'ido-vertical-mode) 
    (progn
      (ido-vertical-mode 1)
      (setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)))
(if (commandp 'smex)
    (global-set-key (kbd "M-x") 'smex))
(if (commandp 'flx-ido-mode)
    (flx-ido-mode 1))

Use M-x eval-buffer to load your changes, then try M-x again. You should now have much better completion. You’ll be able to call commands by typing in part of their names. Use <up> and <down> to go through the completion options, and use <left> and <right> to go through your history.

Try it for a week. If you like it, keep it. If you don’t like it, try the Helm approach.

Other tips

When you learn keyboard shortcuts, try to remember the names of the commands as well. You can do that with C-h k (describe-key). For example, M-x calls the command execute-extended-command. That way, even if you forget the keyboard shortcut, you can call the command by name.

If you forget the name of the command and you don’t know the keyboard shortcut for it, you can look for it in the menus or in the help file. You can open the help file with C-h i (info). You can also use M-x apropos-command to search through the commands that you can call with M-x.

Make your own cheat sheet with frequently-used keyboard shortcuts and commands to help you learn more about Emacs. Good luck!

Emacs Basics: M-x

Emacs Basics: M-x

You can download the MP3 from archive.org.

Series Navigation« Emacs Basics: Using the mouseEmacs Basics: Customizing Emacs »