6085 comments
2357 subscribers
6224 on Twitter
Subscribe! Feed reader E-mail

Reading these posts, you can probably tell that I really, really like the Emacs text editor.

View my Emacs configuration.

Check out Planet Emacsen to read other Emacs geeks’ blogs. For all things Emacs, check out the EmacsWiki.

On this page:

Getting ready for the Emacs Conference

I’m in London for Emacs Conference 2013 (squee!!), which is tomorrow. John Wiegley and I are starting the day off with a whirlwind tour of Emacs’ past, present, and future. The program looks excellent, and I can’t wait to learn from all these wonderful people. Let’s find out what sketchnotes of an extremely geeky conference look like! =D

I’d worked on this presentation about 9 hours before leaving for London. I wrote most of the presentation code on the airplane (functions to go forward and backward, and to process the current slide).

I finished the rest of the content this morning, then headed out with Alex and his wife Tina. Today I got to experience a slice of regular life over here: a walk through the market, a grocery trip, a yummy home-cooked meal. Alex and Tina have been fantastic hosts! =)

After dinner, I worked a little more on the presentation. I made slides and a PDF just in case my Org presentation doesn’t work out, and helped with nametags and the list of people attending.

I’m looking forward to the conference. I think this will be an excellent adventure! I’ll post my presentation afterwards, so subscribe to my blog or follow the #emacsconf hashtag. If you’re attending tomorrow, come and say hi! I’ll be the short Asian girl bouncing around and possibly hyperventilating at all the awesomeness. I’ll also be drawing sketchnotes on a tablet PC, assuming I don’t give up and stick everything into org-capture instead. =)

Short URL: http://sachachua.com/blog/p/24622

Emacs: Use function keys for custom keyboard shortcuts

Quick tip since it was an aha! moment for some people on the #emacs IRC channel.

You can define keyboard shortcuts that are sequences of keys. This is how Emacs can have keyboard shortcuts like C-c C-c. The function keys are great for this, because (a) they often don’t have assigned functions (or have ones that you don’t mind losing), and (b) you don’t have to press two or more keys to start your shortcut sequence, like you would do with C-c.

I like using F8 or F9 because I’m right-handed and my keyboard groups function keys together. On my keyboard, there’s a slight gap separating F5-F8 and F9-F12, which means it’s easy to distinguish F8 from F9 by feel if I happen to land on the edge.

Define those keyboard shortcuts as sequences so that you can add more shortcuts easily without having to rejig your muscle memory.

(global-set-key (kbd "<f9> <f9>") 'org-agenda-list)
(global-set-key (kbd "<f9> <f8>") (lambda () (interactive) (org-capture nil "r")))

If you want to rebind something that was previously bound to a non-prefix map, you can unbind it first:

(global-unset-key (kbd "<f9>"))
Short URL: http://sachachua.com/blog/p/24535

Emacs Chat: Carsten Dominik

In which Carsten shares how he got started with Emacs, the joys of Calc, and other cool things. =)

Carsten Dominik from Sacha Chua on Vimeo.

Want just the audio? Get it from archive.org: MP3, Ogg Vorbis (gosh, archive.org has been automatically converting to Ogg all this time? That’ll simplify my post-production… )

Short URL: http://sachachua.com/blog/p/24609

Emacs chat: Thomas Kjeldahl Nilsson

I got to chat with Thomas about Emacs and picking up configuration snippets from EmacsWiki. He’s so lucky – he gets to work with lots of other Emacs geeks! =)

Thomas Kjeldahl Nilsson – Emacs chat from Sacha Chua on Vimeo.

More about Thomas on kjeldahlnilsson.net

Just want the audio? Get it from archive.org

Short URL: http://sachachua.com/blog/p/24597

Learn Emacs Lisp by reading Emacs Lisp

Learning Emacs Lisp can help you really tweak your Emacs environment to fit you, saving time, smoothening out frustrations, and making things easier. Reading code is an essential part of learning how to code. By reading other people’s code, you’ll not only discover interesting syntax and library features, but you’ll also start absorbing the idioms – the ways of doing things. (This is why it’s important to read good, well-formatted code.)

Where to find code

You can use C-h k (describe-key) to explore the code behind keystrokes, menu items, and mouse actions. If the source code is installed, you should see a hyperlink in the information window that appears. It’s a good idea to install the Emacs Lisp source code for Emacs.

If you know the name of the function you’re interested in, C-h f (describe-function) will link to the source code and describe the function.

You can find lots of other Emacs code snippets on http://emacswiki.org and in blog posts on http://planet.emacsen.org . gnu.emacs.sources and other Emacs-related newsgroups or mailing lists are useful, too.

How to understand code

At first glance, Emacs Lisp looks like a mess of parentheses and strange incantations. setq? defun? cdar?

This is true at second glance, too.

Read through the Emacs Lisp intro manual either online or in Emacs (C-h i m Emacs Lisp Intro). You’ll probably understand very little the first few times through. This is okay. All you need to do is get a vague idea of what things are called so that you can look them up when you need to.

Now read your code again. Slightly of it should make sense.

Skim the Emacs Lisp manual, too. This is a reference, so you’ll understand even less of it as an Emacs Lisp newbie, but it’s good for picking up terms.

You don’t need to understand all of Emacs Lisp in order to take advantage of other people’s configuration snippets. You’ll learn things along the way.

Make liberal use of C-h f to describe functions and C-h v (describe-variable) to investigate. You can jump to function definitions with find-function, which is worth binding to a keystroke. For example, to map F8 to find-function temporarily, use M-x global-set-key RET F8 find-function.

How to step through code

Edebug is an interactive debugger for Emacs so that you can step through the code instead of guessing what the code will do. (Edebug documentation) Use M-x edebug-defun to prepare the function you’re interested in, then run the function. Press SPC to step through the code, e to evaluate expressions (you can use this to find the values of numbers), h to continue until the specified point, b to set a breakpont, g to execute until a breakpoint, and q to stop debugging.

Super awesome.

How to make code your own

You can copy code to the *scratch* buffer or another file, tweak it a little, evaluate or edebug the code, and see what changed. If you like your changes, you can:

  • rename the function and add it to your configuration file,
  • use advice to modify the existing function, or
  • redefine the function (keeping the name as-is) and adding it to your configuration file. (This can lead to weird behaviour, so do this carefully!)

Enjoy!

Other reading:

EmacsWiki: Learn Emacs Lisp

Thanks to bl3u for the nudge to write about this!

Short URL: http://sachachua.com/blog/p/24534

Got Emacs questions? Let’s try Emacs tutoring / pair programming!

Getting started with Emacs? Need help tweaking your Emacs configuration? Curious about the tools and packages out there? Want to learn more about Emacs Lisp? Working on some open source Emacs code? Just want to talk Emacs with someone?

We can connect on Skype or Google Hangout, or I can ssh into your system if you’ve got that set up. Pay-what-you-can-and-what-you-think-it’s-worth. =) (It’s an experiment!) Student / in between jobs? Reach out anyway!

Comment below, contact me, or e-mail me at sacha@sachachua.com with the subject “Emacs pair programming”. I’m generally available M-W-F and I’m in Toronto, so Eastern Standard Time (EST). Tell me when you’re available (and what timezone you’re in), what you’re curious about, and other things it would be nice to know about you. Let’s see what we can do! =)

Short URL: http://sachachua.com/blog/p/24533

Emacs Chat with Avdi Grimm (Org-mode, Ruby, etc.)

Update 2013-03-16: Get the MP3 or Ogg Vorbis files, or listen to them on archive.org!

Thanks to Matthew Darling’s comment on my post about code coaching, I came across Avdi Grimm’s work with pair programming – and was delighted to find that he uses Emacs too. =) Check out my Skype chat with Avdi about Org-mode literate programming, Ruby, and how he got started with Emacs.

Emacs Chat with Avdi Grimm from Sacha Chua on Vimeo.

If you liked this, you might also like my chat with John Wiegley. Do you use Emacs? Want to share your story and the nifty things you think other people should know about? Comment below or get in touch with me!

Short URL: http://sachachua.com/blog/p/24540

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging