M-x all-things-emacs

The Editor of a Lifetime

August 21st, 2014 by Ryan McGeary · 44 Comments

Perry Metzger has been using Emacs as his text editor since early September, 1983 — nearly 31 years. Over much of that time, it has also been his primary way to read email, compile programs, and perform a variety of other tasks.
Why would anyone use a single program for that long? This talk is partially intended to answer that question.
Emacs remains one of the most important user interfaces (and text editors) for computer professionals almost 40 years after it was created. The talk is intended to be part history, part philosophy, and part speculation on the future. It will also teach Emacs fans how to explain to their skeptical friends why it is still a good idea to learn a tool from the terminal era that requires memorization of dozens of control sequences in an age of GUIs and smart phones.

→ 44 CommentsTags:misc

How I Work: Working with OS X and Emacs

January 4th, 2011 by Ryan McGeary · 223 Comments

Watch the Video

I was featured this week on a new site called How I Work (now defunct). The site is about letting developers watch screencasts to see how other people work and improve their productivity by learning about new tools and practices. Given the interest in how focused work in an all inclusive environment can help productivity, they contacted me about putting up a workbench on how I use Emacs and how it fits into my overall OS X workflow.

Please check it out and vote up my video so other people learn about me, McGeary Consulting Group, and our favorite editor.

→ 223 CommentsTags:misc

YASnippet Updated – Supports Nested Placeholders and More

July 27th, 2009 by Rob Christie · 164 Comments

YASnippet Dropdown Menu Support

YASnippet, or Yet Another Snippet package just released a new beta with many new features. YaSnippet is a template system for emacs. It allows you to type an abbrevation and then trigger that abbreviation into an expansion in your buffer. Some of the new features are:

  • Nested Placeholders: Nested placeholders allow you to support optional attributes or portions of your snippet. If you don’t need these optional attributes then type C-d and exit out of the snippet. This feature is heavily used in TextMate snippets, and now makes borrowing snippets from TextMate even easier. For example, the snippet below gives you a div tag and optionally allows you to specify your id.
     <div${1: id="${2:someid}"}> $0
  • Menu Grouping: The YASnippets menu now supports logical grouping of snippets under the mode. For example, ruby-mode snippets are now grouped into logical areas such as collections and control structures. I don’t normally like using menus in emacs, but I find the logical grouping in lieu of the long list helpful until I have the snippets memorized.
  • Multiple Prompting Mechanisms: If you have multiple snippets attached to the same tag trigger, then you will get prompted for the snippet you desire. You can specify the desired order for how you want to be prompted by setting the function list in the variable yas/prompt-functions. Some people like menus so you might want to use yas/dropdown-prompt (see the screenshot above), but my current preference is yas/ido-prompt.
  • Easier Snippet Development: When working on a new snippet, you can use the command M-x yas/tryout-snippet or C-c C-t which opens a test buffer and expands your new snippet.
  • Snippets within Snippets: You can now call one snippet while within the expansion of another snippet.

For more info, take a look at the YASnippet documentation.

→ 164 CommentsTags:misc · snippet

Copying Lines, not killing

May 18th, 2009 by Greg Reagle · 168 Comments

Do you find yourself often running a yank or undo immediately after killing lines? Would you like to copy a line instead of killing it? Do you wish that there was a prefix argument to C-k (kill-line) that made it copy instead of cut (to use the non-Emacs terminology). Here is your solution—a command that acts just like kill-line except that it is a copy.

(defun copy-line (&optional arg)
  "Do a kill-line but copy rather than kill.  This function directly calls
kill-line, so see documentation of kill-line for how to use it including prefix
argument and relevant variables.  This function works by temporarily making the
buffer read-only, so I suggest setting kill-read-only-ok to t."
  (interactive "P")
  (toggle-read-only 1)
  (kill-line arg)
  (toggle-read-only 0))
(setq-default kill-read-only-ok t)
(global-set-key "\C-c\C-k" 'copy-line)

See also http://www.emacswiki.org/emacs/CopyingWholeLines.

→ 168 CommentsTags:newbie · quick · tips

Quick Tip: Detaching the custom-file

December 6th, 2008 by Ryan McGeary · 186 Comments

I’ve never really liked the built-in customization UI in Emacs (M-x customize). I’m sure plenty of people use it and enjoy it, but, to me, it feels like an abominable tree of never ending and difficult to navigate options. Plus, it sticks your saved customizations as an unorganized mess of elisp smack at the bottom of your init file. I’m not quite sure how to solve my first gripe, but the second is manageable.

By setting the custom-file variable, you can keep those automated customizations in a separate file. Put this in your Emacs init:

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)

Both lines are necessary. The first line tells Custom to save all customizations in the file, but does not load it. The 'noerror argument passed to load prevents errors if the file doesn’t exist. If you had existing customizations in your init file, be sure to copy them to the new custom file.

Now, go enjoy a cleaner init file. This tip is especially useful if you keep your init files under a version control system. You do keep your init files under version control, right?

→ 186 CommentsTags:elisp · quick · tips

Emacs in 5 minutes

December 5th, 2008 by Ryan McGeary · 193 Comments

In preparation for a new upcoming PeepCode screencast, Geoffrey Grosenbach put together a quick 5 minute Emacs introduction. It’s a good summary of some Emacs niceties. Geoffrey also wrote up some of his other initial Emacs impressions.

→ 193 CommentsTags:misc · newbie · news · reviews

Emacs Starter Kit

December 5th, 2008 by Ryan McGeary · 99 Comments

Phil Hagelberg recently started a new project called Emacs Starter Kit. Here’s how Phil describes it:

It’s … a set of dotfiles extracted from my years of obsessive Emacs tweaking. It acts as a base config from which new users can get going with minimal fuss. You won’t learn Emacs from it, but it will help you get started out as it provides saner defaults and bundles a lot of really useful functionality.

I’ve been using it as my main config for quite some time now, so it’s got all the libraries I need. If you’re interested in trying out with Emacs but don’t know where to start, give this a shot. If you’re an old hand but are curious to pick up some new tricks, try out the starter kit and let me know if it’s missing some must-have functionality that you’re used to.

Give it a try:

$ git clone git://github.com/technomancy/emacs-starter-kit.git
$ emacs -q -l ~/path/to/emacs-starter-kit/init.el

I’m going to play with this on and off for the next few days and see if I can’t learn a few tricks from an emacs guru.

UPDATE: For those that don’t use Git and can’t find the ‘Download’ button on GitHub, here’s the tarball and the zipball.

→ 99 CommentsTags:elisp · newbie · news · quick · tips

Giving ido-mode a Second Chance

May 19th, 2008 by Ryan McGeary · 126 Comments

Stuart Halloway’s recent screencast titled What You Can Learn From ido.el convinced me that I need to give ido-mode another look, especially since I didn’t realize it had support for flex (aka fuzzy) matching. I was always envious of the fuzzy matching that TextMate users received when finding a file in a project.

I’ve tried ido in the past, but it always turned me off. Today I realized why, and I was finally motivated enough to find a fix. I am a big fan of tab-completion everywhere, so when tab-completion doesn’t work like I expect, I get upset. As it turns out, this is why I (unfairly) disliked ido-mode at first. Due to some other trickery that I would rather not go into, I was guaranteeing that <tab> in the minibuffer would always call minibuffer-complete, which broke the tab behavior in ido:

(define-key minibuffer-local-map [tab] 'minibuffer-complete)

In summary, I’m a doofus. I should probably re-investigate the need for the above mapping; it was necessary because of a global key binding that I shouldn’t have made global in the first place. Without going down that rat hole just yet, here’s my workaround for now:

(ido-mode t)
(setq ido-enable-flex-matching t) ; fuzzy matching is a must have
;; This tab override shouldn't be necessary given ido's default 
;; configuration, but minibuffer-complete otherwise dominates the 
;; tab binding because of my custom tab-completion-everywhere 
;; configuration.
(add-hook 'ido-setup-hook 
          (lambda () 
            (define-key ido-completion-map [tab] 'ido-complete)))

I’m going to give ido-mode a fair chance this time, and I think I’m going to like it. I anticipate growing my custom ido configurations in the near future, and ido-mode could easily make it as a package fave. Thanks Stu.

For those of you who have already realized the power of Interactive Do, what power tricks do you recommend?

Update: Flex or fuzzy matching is the ability to match any item containing the characters in the given sequence. For example, “mwc” might match a file named “my_wicked_class.rb.”

→ 126 CommentsTags:ido · tips

Quick Tip: Easier Window Switching in Emacs

May 1st, 2008 by Rob Christie · 102 Comments

I ran across this thread on easier window switching within emacs using the windmove-xxx commands on gnu.emacs.help a few days ago. It’s always nice to find out about commands I didn’t know about… kinda like C-x M-c M-butterfly. I have always used C-x o and C-x b to move between windows and buffers, but my work monitor is large enough to allow me to split my frame into four windows. Using C-x o to move around has been somewhat of an annoyance. The windmove commands allow you to move up, down, left, and right between windows using a prefix key and the arrows on your keyboard. I have added the following to my .emacs:

(windmove-default-keybindings 'meta)

If you invoke the command without an argument then shift is used as the prefix. I also had to place this below the turning on of pc-selection-mode because it also sets the M-up, M-down, M-left, and M-right keys.

→ 102 CommentsTags:quick · tips

Package Faves: js2-mode

April 4th, 2008 by Ryan McGeary · 134 Comments

I just played with Stevey’s new js2-mode. So many previous javascript modes for emacs just didn’t cut it, but now finally, I’m proud to see a javascript mode that works. Steve did a great job with this package. Kudos.


Grab the latest js2, put it in your load-path, and configure. Full instructions. Here’s my config:

(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(setq js2-basic-offset 2)
(setq js2-use-font-lock-faces t)

(Steve, I’m one of those who like my font-lock settings, so thanks for keeping the font-lock-faces option around for us crazies.)


  • Indenting that works! Finally.
  • Syntax highlighting that works. ‘Bout time.
  • Inline warnings and syntax errors. Useful.
  • Decent code folding. I like.

→ 134 CommentsTags:faves · javascript · reviews