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 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!

Emacs: How I organize my Org files

Michael Jones wanted to know how I organized my Org Mode files. Here’s how I do things!

Org Mode for Emacs is an outliner that lets you add a little structure to plain text files. Not only can you use it to move around, hide, and show sections of your outline, but you can also:

  • schedule tasks and mark them as complete,
  • add hyperlinks and formatting,
  • estimate effort and track time,
  • export to HTML and other formats,
  • and even include code that you can run in-line.

I started with a single Org Mode file (appropriately called organizer.org), but I’ve gradually fleshed this out into a number of files. My goals for organizing my files this way are to be able to:

image

  • Publish some files while keeping other files private,
  • Add or remove groups of tasks from my agenda, or focus my agenda/search on the current file,
  • Simplify processing my weekly review (categorizing accomplishments/tasks),
  • Get a quick overview of important things, and
  • Have file-specific options, like columns.

I often use Org agenda custom commands to jump around. For example, one agenda command lists projects, and pressing RET on an agenda line will take me to that project. I also use org-capture to take a note from anywhere, and I use org-goto to navigate my files. For jumping to a specific file, I use ido-find-file.

I use several Org Mode files. The six files below have a little more than 1.3MB of text in total – tiny! – but they help me tremendously. I also have lots of other Org files like my Emacs configuration and my blog index (I often use Org for publishing), but these are my main files.

Personal tasks and notes: organizer.org

This is the catch-all for any tasks or notes that don’t belong to the files below. Here’s the rough structure:

  • Quick notes: Tidbits that might not make it into their own blog posts, but which can be included in weekly reviews
  • Reference: Hours, license keys, etc.
  • Open loops: Anything I need to check on every so often
  • Projects: High-level things I’m focusing on
  • Financial goals: Things to save up for
  • Someday/maybe: Projects to do someday
  • Weekly review: Divided by year
  • Monthly review: More summaries
  • Plans: Personal plans
  • 2011, 2012, 2013…: I use org-capture to quickly jot down notes. The datetree option automatically files them by day, which makes older ones easier to archive.
  • Tasks: A bucket for miscellaneous tasks

Anything to do with business: business.org

I organize these by the types of tasks I focus on and the notes I want to keep.

  • Earn
    • Clients
    • Leads
  • Build
    • Projects
    • Research
    • Business ideas
    • Blog
    • Delegation
    • Planning
    • Business hygiene (accounting, etc.)
    • Learning
  • Connect
    • Meetups
    • Hangouts
    • Other
  • Reference
  • Tasks

Relationships: people.org

I organize these by relationships so that I can remember who’s out there.

  • Family
  • Extended family
  • Canada friends
  • Hacklab
  • Barkada
  • Letters
  • Meetups
  • Bloggers
  • Family friends
  • Other tasks

Regular tasks: routines.org

I organize these by frequency and omit the tasks from my weekly review. This also contains my “In case of…” scenarios and my backup documentation.

  • Every day
  • Once a week
  • Once a month
  • Once a quarter
  • Once a year
  • When…

Outline for future blog posts: sharing/index.org

I organize this by topic. See http://sach.ac/outline for the published version

Decision review: decisions.org

I organize these by status. I also use org-choose markers (ex: CHOSEN, MAYBE) inside the categories, but the headings make it easier to review.

  • Pending
  • Current
  • For review
  • Someday / maybe
  • Archive

Personal finance: ledger.org

I use John Wiegley’s command-line Ledger program to manage my finances. My financial data is in separate ledger-mode files, and I use an Org file with org-babel to make it easier for me to answer some questions about my finances. For example:

  • Given my average monthly expenses and the amount of money I’ve set aside, how long can I sustain my early-retirement experiment?
  • Am I ahead or behind in terms of household contributions?
  • What did I spend on last month?
  • Are my virtual envelopes balanced?

How do you organize your Org files or outlines?

Everyone’s got different ways of organizing outlines, and people also also change over time. How do you organize yours?