Category Archives: emacs

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.

New to Emacs? Start here:

On this page:

Emacs Chat: Magnar Sveen (Emacs Rocks)

UPDATE 2014-01-27: Transcript posted!
UPDATE: Want just the audio? MP3 / OGG

Here are the notes from my chat with Magnar Sveen, the creator of the Emacs Rocks screencast series and a number of other great Emacs resources. Enjoy!

0m48s Magnar has been using Emacs for two years
2m30s Moving from TextMate
3m45s World of Warcraft
4m10s Friend’s influence
5m10s Learning as a game
6m10s Other ways of learning – time outside work
7m44s Screencasting
9m30s Things Magnar wants to learn more about – Org
10m19s What else Magnar does with Emacs
11m17s Norwegian text adventure game
12m08s Outside Emacs: family, board games (120!)
13m41s Managing a large hobby project
14m30s Learning through projects
14m48s Dealing with feeling overwhelmed by Emacs
16m38s Hardware
20m20s Emacs configuration
20m40s Projects with perspective-mode
21m32s Find file in project, ido-vertical-mode, flx-ido
23m45s Switching between projects
25m01s Guide-key
25m56 Rebinding C-h
26m36 paredit and smartparens
29m20s visual-regexp
30m35s annoying-arrows-mode
32m45s project-archetype
35m15s Wishlist: package management
35m55s Satisfied with configuration
35m25s Marks and regions
37m20s Configuration is on github
37m40s evil-mode
40m00s Feedback on Emacs Rocks
42m00s Growing to appreciate Emacs because of extensibility
43m15s The giraffe book
44m57s Getting code into core
49m39 Emacs koans?
51m45s IRC bot
52m50s Learning from other people in the office
54m40s Other questions
56m23s Board game recommendations

Read or download the transcript

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 Org Mode Customization Survey

Org Mode is an outlining and TODO tool for Emacs. Except it’s so much more than that, since people have written all sorts of code to make it do way more than an outliner (or even a text editor!) usually does. Seriously, it even has a Sudoku solver. (The code is optional, so you don’t lose memory if you don’t load it.)

If you use Emacs and you haven’t tried out Org Mode yet, check it out.

If you’ve made Org Mode a part of your life, you’ve probably customized lots of little things about it. Please help the developers by submitting the customization survey to Mike McLean!

As discussed a few days ago on this list, Carsten and the other developers are interested in what and how us users are customizing Org mode. This was first done in 2009, so a re-do of the survey is useful as is for how people are using Org now, as well as a comparison to the past.

Carsten provided the function that was used before to collect the raw data and I am working on the data collection and summarization this time around.

I have place the function on Github, https://github.com/SkydiveMike/org-customization-survey
The raw elisp is at: https://raw.github.com/SkydiveMike/org-customization-survey/master/org-customization-survey.el

All you need to do is:
1. Load and eval the function
2. Execute (interactive) org-customization-survey
3. Review the buffer, cleanse for sensitive information if any
4. Email the buffer to [email protected] (If your Emacs is configured for email, C-c C-c will send)

I’m looking forward to the results, which will most likely be posted to the Org Mode mailing list.

Curious about my Org configuration? Check out my annotated Emacs config.

Using Emacs to figure out where I need to improve in order to type faster

I’ve been thinking about how to type faster than 110wpm, and digging into the specific factors that I could improve. In particular, I wanted to get a sense of:

  • my theoretical top speed
  • whether alternates or rolls are better for me
  • how quickly I can twitch, measured by single-key repeats or two-key alternations

shutterstock_145785482

By using totally artificial typing tests (ex: type “thththth…”) instead of word-based ones, I can explore the relationships between character combinations and speed without worrying about hitting SPC, sounding out words, correcting errors, and so on. Since I can do the tests in short sprints, I can rest enough in between to minimize my risk of RSI.

Using Emacs to test my raw typing speed

I haven’t come across an online typing test that gives the kind of stats I want, or even a per-character or digram breakdown. I thought about writing a Javascript-based typing timer, but I figured it would be less work to cajole Emacs into measuring what I wanted. Here’s the code:

(defun sacha/timer-go ()
  "Quick keyboard timer."
  (interactive)
  (insert "GO\n")
  (run-with-timer 3 nil (lambda () (insert "\n")))  ; for warmup
  (run-with-timer 15 nil (lambda () ; 12 seconds + the 3-second warmup
                           (let ((col (- (point) (line-beginning-position))))
                             (insert (format " | %d | \n" col)))
                           )))
(local-set-key (kbd "<f7>") 'sacha/timer-go)

This prints “GO” to show you that it’s running. You have three seconds to warm up, so you don’t have to worry about wasting any milliseconds after M-x sacha/timer-go (or F7, the keyboard shortcut I bound mine to). After the warmup, Emacs adds a newline and the “race” is on. There’s a 12 second period of actual typing, and then Emacs adds the number of characters you typed. When you see that, you can stop.

Twelve seconds is a useful number for estimating typing speed because the conversion from characters per minute (CPM) to words per minute (WPM) usually uses a factor of 5: CPM / 5 = WPM. So the number of characters you can type in 60 seconds / 5 is probably the number of “words” you could type in a minute.

Note: L and R refer to left and right hand. I’ve also numbered the fingers with 1 being the thumb and 5 being the pinky. The patterns I used are based on a Dvorak keyboard, but that doesn’t matter as much. You can probably figure out what the equivalent patterns are on your preferred keyboard layout.

Limitations: I didn’t do any special calculations to deal with errors (there were many doubling or transposition errors multi-character sequences), so the actual CPM will be lower. Also, repeated character sequences are definitely not normal and have quirks of their own. It’s interesting to establish the range and see the kinds of errors that show up when I go faster than I’m comfortable with, though.

Pure speed

Key description Pattern Estimated WPM based on CPM/5
keyboard mashing -none- (mashing) 379
keyboard mashing -none- (mashing) 379
keyboard mashing -none- (mashing) 354
R side mashing -none- (mashing) 245
L side mashing -none- (mashing) 217

If you don’t care what you’re typing, it’s easy to type quickly. This is just about how fast my hands go if I don’t have to think about which finger to activate. This mostly ended up as alternating left- and right-hand rolls (ex: aoeusntoahuesnto). Because I didn’t have to precisely alternate, two-handed mashing resulted in more characters than one-handed mashing. Interestingly, my right hand is slightly faster than my left.

Alternates versus rolls

4-key combinations

Key description Pattern Estimated WPM based on CPM/5
R-side 4-key roll snthsnth 232
L-side 4-key roll aoeuaoue 201
L 3 & 2, R 3 & 2 eutheuth 164

3-key combinations

Key description Pattern Estimated WPM based on CPM/5
R 3 & 2, L 3 thethe 187
L 5, R 4 & 2 andand 184
R 3 & 2, L 3 thethe 182
roll R 3 nthnth 176
R 3 & 2, L 3 thethe 170
roll L 3 oeuoue 166
roll L 3 oeuoeu 164
R 3 & 2, L 3 thethe 159
roll R 3 nthnth 152
R 3, L 4 & 3 toetoe 140

I expected rolls to be faster than alternates, but it turns out that alternating works out fine too (“the” and “and” on a Dvorak keyboard). Same-hand rolls had fewer errors than alternates, though – timing can be tricky when doing high-speed repeats. That can be partially handled by autocorrecting “teh” to “the” and similar transpositions. I use an AutoHotkey-based autocorrect script, but it screws up the typing tests I like, so I can’t take advantage of it then.

A roll-optimized keyboard layout might be more effective. 3- and 4-character rolls like the ones I tested aren’t that common in actual typing, but it might be possible to find keyboard layouts that are better-optimized for the languages I use. I’ve read that Arensito, Capewell, and Colemak focus more on rolls and alternating rolls, so they might be worth a look.

Two-character pairs

Key description Pattern Estimated WPM based on CPM/5
alt L and R 1 uhuh 139
L 5, R 5 asas 137
R 2 & 3 chch 135
R 2 & 3 thth 134
L 2, R 3 tutu 130
R 3, L 4 toto 129
L 2, R 2 uhuh 128
R 1 & 5 xsxs 126
L 2 & 3 eueu 124
R 2 and 5 shsh 115

Two-character patterns are slower than three-character patterns, probably indicating that there’s a small delay as I think about repeating things. Alternates and same-hand two-character pairs seem to work okay. Even for same-hand two-character pairs, I get the occasional doubling or transposition error.

Single-finger twitching

Key description Pattern Estimated WPM based on CPM/5
R 2 hhhh 79
R 3 tttt 76
R 1 mmmm 75
R 4 nnnn 74
L 2 uuuu 73
R 5 ssss 71
L 3 eeee 71
L 4 oooo 65
L 1 kkkk 64
L 5 aaaa 61

Single-finger keypresses (no automatic repeats) are slow. Good thing I don’t have to do them that often. If this represents the speed at which I can send an impulse to my finger and have it do something, this might be a limiting factor for my typing speed, which is compensated for by alternates and rolls.

Three characters with repositioning

Key description Pattern Estimated WPM based on CPM/5
R 3, L 2, L 2 cupcup 67
R 3, L 5, R 3 catcat 66
R 2, L 4, R 2 dogdog 64

Moving my fingers takes time too. Also, did you know that there are typing equivalents of tongue-twisters? I can’t type “ranranranran…” a long time without it turning into rna and other permutations. Maybe my brain gets hiccups.

Interrupted combinations

Key description Pattern Estimated WPM based on CPM/5
R 4, L 4, R 3 notnot 63
L 4, R 4, L 3 oneone 57
L 5, R 4, L 3 areare 55

Alternating hands is actually pretty tough if you have to care about timing. Oddly, this is slower than repositioning. Maybe it’s because the repositioning helps me remember where I am in the word when I’m repeating it, so natural typing will be a different case.

Wrap-up

Chunking seems to make a big difference for me. 4-character combinations tend to beat 3-character combinations and those tend to beat 2-character combinations, unless there’s some timing involved. Common combinations (the, and) are easier to type. If I can get better at chunking words into syllables, that might help. The most common digraphs are TH, HE, AN, IN, ER, ON, RE, ED, ND, HA, AT, EN, ES, OF, NT, EA, TI, TO, IO, LE, IS, OU, AR, AS, DE, RT, and VE (source), so that might be good to look at next.

Twitching or moving individual fingers are slow operations, so being able to “look ahead” and move my fingers to the right spots while I’m typing the first few characters helps. Muscle memory also helps minimize errors. Also, maybe finger dexterity and agility exercises?

I’m probably in the region of Diminishing Returns here. I could spend hours inching up my typing speed… or I could spend that time doing other things. Now that I’ve identified specific areas to look into, though, I might be able to set up exercises to take advantage of interstitial time. For example, while I’m reading a book, I could do finger dexterity exercises (pausing, of course, if I feel any hint of strain – I’d like to avoid RSI if I can).

On another note, testing my theoretical speed in this way reminded me a little of how we used to play Decathlon on the computer as kids. (Was it Microsoft Decathlon? The screenshots look familiar…) Somehow our keyboard survived the rampage back then. =)

Next steps

Because alternation can lead to typing errors or slowness for me, I might look into Colemak, which optimizes for single-hand rolls. Still, I’m pretty happy with Dvorak, and the Colemak FAQ warns that the switch might not be worth it. Another thing I’m looking into is Plover, which lets you do stenography using a regular keyboard. My laptop keyboard can’t easily do some of the combinations and I’m more visual than phonetic when it comes to words, so it might be a challenge to learn.

The easiest win will probably come from training my speech recognition software to recognize my words more accurately. I’ve been dictating book notes to my computer. This is great because it reinforces the key points of the book in my memory, trains the computer, and helps me practice clear diction. I’ve gotten to the point of using speech recognition to take notes during my first pass through a book, editing after each paragraph. I feel that the accuracy is gradually improving. I make fewer edits as I learn how to speak the way the computer wants me to and I teach the computer to understand the way I speak.

Besides, an average of 107 wpm on Dvorak is fast enough to let me get words out of my head and onto my computer, and I can focus on what I want to say instead of how to type.  There’s plenty more to learn about how to write efficiently. Time to go back to David Fryxell’s How to Write Fast (While Writing Well)! So it’s interesting to dig into what my rate-limiting factors are when it comes to typing faster, but it’s even better to focus on how I can think faster (although speech recognition will still be useful for the benefits mentioned above).

Have you analyzed your typing? What did you learn?

Image credits: Keyboard with time (Cienpies Design, Shutterstock)

When I blog with Emacs and when I blog with other tools

English: org-mode logo: http://orgmode.org/wor...

English: org-mode logo: http://orgmode.org/worg/org-faq.php#unicorn (Photo credit: Wikipedia)

I would love to be able to write all of my blog posts within Emacs. I like the outline tools and simple markup of Org Mode. Org Mode and org2blog are invaluable when I’m writing a post with lots of code or keyboard commands, because it’s easy to set up syntax highlighting or add teletype text. Here’s an interesting self-referential example of org2blog’s power that uses #INCLUDE to include the Org blog post source in the post itself.

If I expect that a post will have lots of images, I tend to use Windows Live Writer because it takes care of resizing and aligning images, linking to the original size. Because it uses my blog’s stylesheet, I can get a sense of how the text will flow around it. I can quickly draw an idea in Autodesk Sketchbook Pro, copy and paste it into Windows Live Writer, and then resize it until it feels balanced on the page. Sometimes I draft a post in Emacs and then open it in Windows Live Writer or ScribeFire so that I can add images.

Org Mode also supports images, but it’s not as easy to resize things there. If I wrote a function that used ImageMagick to save the clipboard image to a file, resize it to the appropriate dimensions, and link it to the full-size image, maybe that would do the trick. Still, that sounds like it would be a fair bit of work. Maybe someday. Hmm – any chance someone reading this blog happens to already have that snippet handy? =)

If I need to edit an existing post, I either use the WordPress web interface or I use ScribeFire. That way, I don’t have to fill in the post publishing date again.

It’s a bit of a patchwork system of different tools, but it does the job. What’s your workflow like?

How to learn Emacs keyboard shortcuts (a visual tutorial for newbies)

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

Emacs keyboard shortcuts often mystify beginners because they’re not the same as the shortcuts for other applications (C-w instead of C-x for cutting text, etc.), and they’re long (what do you mean, C-x 5 f?!). I hope this guide will help break down the learning process for you so that you can pick up the keyboard shortcuts step by step. It’s under the Creative Commons Attribution License, so feel free to share!

Click on the image to view or save a larger version. It should print out fine on 8.5×11 paper in landscape mode, and you might even be able to go up to 11×17.

20130830 Emacs Newbie - How to Learn Emacs Keyboard Shortcuts

This is actually my second version of the guide. In the first one, I got a little sidetracked because I wanted to address common frustrations that get in people’s way. Here’s the Grumpy Guide to Learning Emacs Keyboard Shortcuts:

20130830 The Grumpy Guide - How to Learn Emacs Keyboard Shortcuts

The #emacs channel on Freenode was totally awesome in terms of feedback and encouragement. Special thanks go to agumonkey, aidalgol, Fuco, ijp, JordiGH, nicferrier, pkkm, rryoumaa, and webspid0r for suggestions. =)

If you like this, you might also like the similar hand-drawn one-page guide I made on How to Learn Emacs, or my other Emacs-related posts. Enjoy!

For your convenience, you can find this page at http://sach.ac/emacs-keys.

Helping someone get started with Emacs and Org Mode through Org2Blog and LaTeX; troubleshooting steps

Update 2013-08-30: By the way, here’s the link to Christopher Olah’s first post using org2blog. Neato!

The LaTeX logo, typeset with LaTeX

The LaTeX logo, typeset with LaTeX (Photo credit: Wikipedia)

Org2Blog is an awesome geek-friendly way of writing posts and publishing them to a WordPress-based blog. When Christopher Olah told me that he’d gotten convinced to try Org Mode thanks to the enthusiastic recommendations from Michael Nielsen and me, we figured that getting him sorted out with taking notes in Org and publishing them through Org2Blog to his WordPress.com-hosted blog would be an excellent way to start – especially with inline images and LaTeX.

Chris has promised to write a blog post about what he’s learned, but he’ll probably find these notes useful. Here’s what we ran into when getting org2blog working on Ubuntu.

Need to install the files and set up the load paths

We downloaded the following and added them to an ~/.elisp directory

We also set up his ~/.init.d/emacs.el to load the libraries, set the blog list, and load ido-mode and icomplete-mode.

Emacs / Org too old

Metaweblog and Org2blog didn’t work well with Emacs 23 and Org 6. We upgraded to Emacs 24 with apt-get install emacs24 in order to get Org 7.

Can’t find library org

It turns out that you also need to apt-get install emacs24-el in order to include those libraries.

Org still too old for org2blog

We were having some problems with the version detection of org2blog, so we replaced the org2blog he downloaded with the version I forked at https://github.com/sachac/org2blog , which I’ve been using with Org 7.

Then we tested it with org2blog/wp-post-subtree, and that worked. Inline images with org-toggle-inline-images worked too, yay!

Next step: viewing LaTeX fragments, since Chris does a lot of math.

dvipng required

org-preview-latex-fragment wanted dvipng to be installed, so we apt-get install dvipng.

LaTeX fragment preview showed blank images

We looked at the *Messages* buffer and found that the .tex files in /tmp could not be rendered by dvipng because marvosym.sty could not be found. We fixed that with apt-get install texlive-fonts-recommended.

(Doing this on my own, I found that I also needed apt-get install texlive-latex-extra .)

… and then we could see and publish LaTeX fragments, which was awesome. =D

WordPress.com double-interpreted LaTeX fragments

Chris was having problems with LaTeX fragments when org-export-with-LaTeX-fragments was set to dvipng. It turns out that WordPress.com also interprets LaTeX, so it was getting confused by the alt tags. To solve this, use M-x customize org-export-with-LaTeX-fragmentsand choose Leave math verbatim. Then the LaTeX fragments are passed to WordPress, which renders them as PNGs.

Hope that helps!