Filling in the occupational blanks

Following up on an interview, a journalist asked:

If I were to say that you freelance as [blank] consultant, what would be the word that fills that blank?

2015-01-14 Filling in the occupational blanks -- index card #experiment #occupation

2015-01-14 Filling in the occupational blanks – index card #experiment #occupation

Tricky question. “Freelance” is definitely the wrong word for it, since I doubt I’ll be taking on any more clients and the word obscures my current fascination with a self-directed life. It might make sense to use the word “independent” if we really need to contrast this with stable employment.

Technically, I spend a fraction of my time consulting, and I can define the kind of consulting that I do in a compact phrase. But based on my 2014 numbers, that’s only 12% of my time. This is much less than the 37% of the time I spend sleeping, or even the 18% of the time I spend on discretionary projects or the 15% of the time I spend taking care of myself (not including the 7% of the time I spend on chores, errands, and other things).

Since no one gets introduced as a sleeper even though that’s what we mostly do with our lives, maybe my discretionary projects will yield a neat occupational description for people who need to have that introductory phrase.

  • Am I a writer (3%)? (“Author” is a smidge more self-directed and respectable, maybe, but I still don’t feel like I’ve written Real Books since all my resources are compilations of blog posts). A blogger? This is a category so large, it could mean anything.
  • A sketchnoter (3%)? Alternatively: a sketchnote artist or a doodler, depending on whether I’m making it sound more respectable or more approachable. But the popular understanding of sketchnotes (if there is one) is that of recording other people’s thoughts, and I’m focusing on exploring my own questions.
  • An Emacs geek (2%)? Too obscure; it doesn’t provide useful information for most people. Maybe an open source developer, which also includes the 1% of the time I spend coding – but I do more writing about software than writing actual software or contributing to projects. An open source advocate? But I don’t push it on people or try to change people’s minds.

In the rare meetups I go to, I usually mention a bunch of my interests (drawing, writing, coding, experimenting), and people pick whatever they’re curious about. But most times, I try to preempt the “What do you do?” question with something more interesting for me, like what people are learning about or interested in. It’s so much easier when someone recognizes me from my blog, because then we can jump straight to the interests we have in common.

From time to time, I come across people who persistently ask, “But what do you do? What’s your day job?” I confess it’s a bit fun to tweak the box they want to put me in. One approach I’ve heard other people use is to playfully acknowledge the difficulty of categorization. “On Mondays, I _. On Tuesdays, I _. On Wednesdays, I___. …” Others gleefully embrace descriptions like “I’m unemployed.”

But I’m missing the purpose of that introductory phrase or that short bio here. It’s not about shaking up the other person’s worldview. At its best, that occupational association helps the listener or reader quickly grasp an idea of the other person’s life and where the other person is coming from. An accountant probably has a different way of looking at things than a primary school teacher does. One’s occupation provides the other person with the ability to contextualize what one says (“Oh, of course she thinks of things as systems and processes; she works with code all day.”). During small talk, it gives people easy things to talk about while they’re waiting for a more interesting topic of conversation to appear: “What kinds of things do you write?”

Let’s say, then, that my goals for this phrase would be:

  • to help people understand my context quickly, and how that might differ from their perspective
  • to make the other person more comfortable by:
    • being able to associate me with a stereotype that adds information, possibly fleshing out this mental profile with differences later on
    • in conversation, letting them easily think of questions to ask, addressing the phatic nature of small talk (we’re not actually talking, we’re making polite noises)
  • to branch off into more interesting conversations, avoiding the dead-end that often comes up after the ritualistic exchange of “What do you do?”

Of these goals, I like the third (interesting conversations) the most.

Here are a few of my options:

  • I can accept convention and pick one aspect of what I do, especially if I tailor it to their interests. For example, at a business event, I might introduce myself as a social business consultant who helps really large companies improve internal collaboration through analytics and custom development for enterprise social network platforms (well, isn’t that a mouthful). At visual thinking events, I might introduce myself as a sketchnoter focusing on exploring my own ideas.
  • I can waffle by introducing several aspects, still within the vocabulary of regular occupations: a consultant and a writer, for example.
  • I can say, “It’s complicated!” and explain my 5-year experiment, self-directed living, and learning/coding/writing/drawing/sharing.

Anyway, circling back to this writer and his likely use of some kind of occupation as a way to introduce and contextualize me:

  • It might be interesting to play with no occupational categorization. Some context may be provided by age (31) – it’s common enough in newspapers and books. The editor might send it back with a question, “Yes, but what does she do?”, but there it is.
  • It might also be interesting to play with my difficulty of categorization. “Sacha Chua, who couldn’t come up with a single phrase to describe her occupation, …”
  • Or, since it’s no skin off my back if this is not fully representative, I could just let him write whatever he wants to write. Freelance consultant. Blogger. Sketchnoter. Amateur experimenter. Independent developer. “Consultant” is a very small part of my identity, actually, so developer or blogger might be interesting. A possible missed opportunity here is that the wrong frame might result in people not being able to identify with and learn from stuff (“Of course she can deal with this, she’s a coder”; “Bah, another blogger, is that all she does?”; “Why should I listen to her? Freelance is just a fancy word for unemployed.”). But it’ll do under time pressure. =)

I’m writing this on January 14 and posting this in the future (because I limit posts to one a day), so the article will likely be out by now. If I remember, I’ll update this with what he actually used. =) But I needed to think about it out loud, and I’m sure the situation will come up again in the future. Perhaps by then I’ll have a more compact way to describe myself.

Since other people have figured this out before, I can learn from them. (And possibly from you!) After all, I’m nowhere near as interesting as Benjamin Franklin or Leonardo da Vinci, and somehow they managed to settle down into a sequence of nouns. Here’s the one from Wikipedia’s entry for Leonardo da Vinci:

Leonardo di ser Piero da Vinci (15 April 1452 – 2 May 1519) was an Italian painter, sculptor, architect, musician, mathematician, engineer, inventor, anatomist, geologist, cartographer, botanist, and writer.

Three or four nouns should be a good thing for me to strive for, eh? Even one or two nouns, if I can get to some level of distinction.

As for introductions – people can pick whatever aspect they want. I am multi-faceted and growing. =)

Weekly review: Week ending January 23, 2015

I posted nine blog posts this week, relaxing that once-a-day bottleneck that I’ve been using for the past few years. Mainly, it’s because I want to talk about Emacs more than once a week while still keeping lots of variety so that I can talk about non-tech topics too. Daily readers: Is the volume unmanageable? How can I make this better for you?

On my consulting gig, I leveled up in terms of using Tableau. I think I’ve gotten the hang of dashboard actions now, and I’m more comfortable using calculated fields for attributes and aggregates. Whee!

This has been a good week for planning ahead and learning from others. The Quantified Self Toronto meetup on Monday got me thinking about an Epic Quest of Awesome, and that spun off a long, thoughtful conversation about questions. I’m looking forward to fleshing that out a bit more over the next few weeks.

Oh, and I finally applied for my passport, picked up my Cultural Access Pass, and took care of a number of other errands. Have day pass, will Get Stuff Done.

The Emacs microhabit I’m going to focus on this week is selecting multiple things in Helm, since that’s one of its key features. =)

Blog posts

  1. Weekly review: Week ending January 16, 2015
  2. Minimizing upward or downward skew in your sketchnotes
  3. Improving my evil plans for Emacs
  4. Breaking down the skill of outlining
  5. Developing Emacs micro-habits: Abbreviations and templates
  6. Move your goalposts to get around an inability to finish projects How redefining your projects can help you satisfy a novelty-seeking brain, and how you can deal with interests or experiments that don’t have clear ends
  7. Emacs Chat with Steve Purcell
  8. Visualizing the internal citation network of my blog
  9. Filling in the occupational blanks


  1. 2015.01.17 Evening tweaks – index card #routines
  2. 2015.01.17 My Evil Plans for Emacs are yielding results – index card #emacs #sharing
  3. 2015.01.17 Playing with the index card format – index card #drawing
  4. 2015.01.17 Thoughts from Sketchnote Hangout – colour – index card #color #drawing
  5. 2015.01.17 Weekend routines – index card #life #routines
  6. 2015.01.18 Digging into my thoughts about emptying one’s cup – #emacs #writing
  7. 2015.01.18 Emacs microhabit – Switching windows – index card #emacs #microhabit
  8. 2015.01.18 Journey to Emacs – Beginnings – index card #emacs #beginner
  9. 2015.01.18 Journey to Emacs – stages – index card #emacs
  10. 2015.01.18 Narratives – index card #storytelling #perspective
  11. 2015.01.18 The Sense of Style – index card #book #writing
  12. 2015.01.18 Thinking about evil-mode and Emacs – index card #emacs
  13. 2015.01.19 A good way to track writing revisions – index card #editing #tech
  14. 2015.01.19 Deeper outlines – index card #writing
  15. 2015.01.19 How can I get better at research – index card #learning
  16. 2015.01.19 Imagining an editing experiment – index card #delegation #writing #editing
  17. 2015.01.19 Improving my sharing – index card #writing #sharing
  18. 2015.01.19 Quantified Self Toronto – epic quests, kids, stopwatches, art projects
  19. 2015.01.20 Asking better questions – index card #asking
  20. 2015.01.20 Skill trees – asking questions – index card #skill
  21. 2015.01.20 Skill trees – web – index card #skill #coding
  22. 2015.01.20 Skill trees – writing – index card #skill
  23. 2015.01.20 What do I want from this quest list and skill tree visualization – index card
  24. 2015.01.21 Goal strategies – index card #popular-goals
  25. 2015.01.21 Playing with popular goals – Happiness – index card #popular-goals
  26. 2015.01.21 Popular goals – Fame – index card #popular-goals
  27. 2015.01.21 Popular goals – Health – index card #popular-goals
  28. 2015.01.21 Popular goals – Knowledge or experience – index card #popular-goals
  29. 2015.01.21 Popular goals – Meaning – index card #popular-goals
  30. 2015.01.21 Popular goals – Power – index card #popular-goals
  31. 2015.01.21 Popular goals – Wealth – index card #popular-goals
  32. 2015.01.21 Popular goals – tranquility, equanimity – index card #popular-goals
  33. 2015.01.21 What if I tried on common goals – index card #popular-goals
  34. 2015.01.22 Book – Leading the Life You Want – Friedman 2014 – index card #book
  35. 2015.01.22 Buffet of other goals – index card #goals
  36. 2015.01.22 Goals and skills – index card #goals
  37. 2015.01.22 Imagining a good quest or skill discussion – index card #goals #conversation
  38. 2015.01.22 Thesis projects for 2015 – ideas – index card #sharing #plans
  39. 2015.01.23 Book – Leaving a Trace – Alexandra Johnson – index card #writing #book
  40. 2015.01.23 Passport – mail or pickup – index card #decision
  41. 2015.01.23 Rough notes on goals and questions – for follow up – index card #rough #notes
  42. 2015.01.23 Tech upgrade triggers – index card #decision
  43. 2015.01.23 What would help me enjoy travel – index card

Link round-up

Focus areas and time review

  • Business (40.9h – 24%)
    • Earn (9.3h – 22% of Business)
      • Deposit cheque
      • Earn: E1: 1-2 days of consulting
    • Build (18.2h – 44% of Business)
      • Drawing (7.1h)
      • Delegation (0.0h)
      • Packaging (0.0h)
      • Paperwork (1.8h)
      • Fix cucumber for travis
      • Look into recently uploaded images
    • Connect (13.3h – 32% of Business)
      • Go to Quantified Self Toronto meetup
      • Post Quantified Self notes
      • Check out Sketchnote Hangout
      • Check out #lrnbook
  • Relationships (3.7h – 2%)
    • Call pharmacy
  • Discretionary – Productive (21.0h – 12%)
    • Emacs (5.9h – 3% of all)
      • Have Emacs Chat with Steve Purcell
      • Move my text-scale-increase binding
      • Check out speed-type
      • Figure out how to make pivot tables in Org
      • Figure out how to define abbreviations in Org Mode
      • Revise transcript for Steve Purcell
      • Look at Yasnippet doc TODOs
      • Try out Tern
    • Apply for passport – State “WAITING” from “STARTED” [2015-01-16 Fri 15:51]
    • Redeposit into TFSA
    • Invest in bonds in TFSA
    • Analyze index cards so far
    • Make Epic Quest of Awesome sheet
    • Pick up cultural access pass from Front and Parliament
    • Reflect on asking questions
    • Apply for passport
    • Type in goals
    • Brainstorm ideas for final project
    • Start git directory for drafts
    • Writing (8.1h)
  • Discretionary – Play (6.6h – 3%)
  • Personal routines (22.8h – 13%)
  • Unpaid work (14.7h – 8%)
  • Sleep (58.3h – 34% – average of 8.3 per day)

Visualizing the internal citation network of my blog

I’m curious about the internal citation of my blog. Which thoughts have been developed over a long chain of posts? Which posts do I often link to? Where are there big jumps in time? Where have I combined threads?

2014-12-03 Internal citation network

I’ll probably need to build my own data extractor so that it can:

  • ignore weekly and monthly reviews, since I link to everything in those,
  • reconcile short and long permalinks, redirection, and sneak previews,
  • and maybe even index my sketches and look at follow-ups

and I’ll probably want to create something that I could eventually plot as an SVG or imagemap using Graphviz, or maybe analyze using Gephi.

It would be super-interesting to create some kind of output that I could fold into my blog outline or into individual posts. I would need a static dump for that one, I think.

How would I build something like this? One time, I used Ruby to analyze the text of my blog. That might work. I might be able to pull out all the link hrefs, do lookups…

As of Dec 3, 2014, there are 87 posts in 2014 that link to previous posts, out of 259 non-review posts (so roughly 34%). I used this SQL query to get that:

SELECT post_title FROM wp_posts WHERE post_content LIKE ‘%<a href=”’ AND post_date >= ‘2014-01-01′ AND post_title NOT LIKE ‘%review:%’ AND post_state=’publish';

Hmm. I might even be able to do some preliminary explorations with Emacs and text processing instead of writing a script to analyze this, if I focus on 2014 and ignore the special cases (short permalinks, redirection, and sneak previews), just to see what the data looks like. Rough technical notes:

perl -i -p -e s/href/\nhref/gi 2014-manip.html
grep 2013-manip.html > list-2013
perl -i -p -e "s/(<\/a>(<\/h2>)?).*/$1/gi" list-2013
(defun sacha/misc-clean-up-reviews ()
  (while (re-search-forward "\\(Monthly\\|Weekly\\) review: .*</h2>" nil t)
    (let ((start (line-beginning-position)))
      (re-search-forward "</h2>")
      (delete-region start (line-beginning-position))
      (goto-char (line-beginning-position)))))

(defun sacha/org-tabulate-links ()
  (goto-char (point-min))
  (let (main-link edges nodes)
    (while (not (eobp))
      (if (looking-at "^href=\"\\(.*?\\)\".*?</a></h2>")
          ;; Main entry
            (setq nodes (cons (match-string 1) nodes))
            (setq main-link (match-string 1)))
        (if (looking-at "^href=\"\\(.*?\\)\"")
            (setq edges (cons (concat 
                               main-link  ;; from
                               (match-string 1)   ;; to 
                               ) edges))))
      (forward-line 1))
    (kill-new (mapconcat 'identity edges "\n"))))

Ooooh. Pretty. Gephi visualization of the edge list formed by links, using the Yifan Hu layout. That big thread in the middle, that’s the one about taskmasters and choice and productivity, which is indeed the core theme running through this year of the experiment. The cluster on the right is a year in review. We see lots of little links too.

Internal links for entries posted in 2014

Internal links for entries posted in 2014

Now I’m curious about what happens when we add the posts and links from 2013 and 2012, too. I’ve colour-coded this by year, with It ties together posts on sketchnoting, blogging, choice, learning, writing, plans… Neat.



What does this say? It says that even though I write about lots of different things, there are connections between the different topics, and the biggest tangle in the middle has more than 320 nodes. I have lots of blog posts that build on an idea for three or four posts, sometimes spanning several years, even if I don’t think about it in advance. There are 90 such clumps, and it might be good to revisit some of these 2- and 3-post chains to see if I can link them up even further.

Also, it could be interesting to do this analysis with tags, not just year. Hmm… Also, I should dust off my data structures and algorithms, and make my own connected-component analyzer so that I can get a list of the clumps of topics. Good ideas to save for another day!

Emacs Chat with Steve Purcell

In this Emacs Chat, Steve Purcell shares how he got started with Emacs by using a Vim emulation mode, what it’s like to give hundreds of package authors feedback on Emacs Lisp style, and how he’s eventually replacing himself with Emacs Lisp (flycheck-package). He also highlights useful packages for managing buffers of version-controlled files (ibuffer-vc), working with lines if the region isn’t active (whole-line-or-region), or maximizing certain buffers (full-frame).

Quick video table of contents (times are approximate):

0:04 From Vim to Emacs with Viper
0:11 Packages
0:18 Feedback
0:20 Lisp style
0:21 Flycheck
0:28 Versioning
0:32 Config
0:40 ibuffer-vc
0:41 whole-line-or-region
0:44 full-frame
0:47 Not using Emacs for everything
0:48 Auto-complete, hippie-expand
0:51 Graceful degradation with maybe-require-package
0:57 Making sense

Transcript will follow. In the meantime, you can check out Steve’s config at, follow him on Twitter at @sanityinc, or go to his website at You can find other Emacs Chats at .

Got a nifty Emacs workflow or story that you think other people might find useful? I’d love to set up an Emacs Chat episode with you. Please feel free to comment below or e-mail me at [email protected]!

Move your goalposts to get around an inability to finish projects

I hardly ever finish projects. I start them with a burst of enthusiasm, and then I trail off when something else catches my attention. I’ve learned to work with this instead of beating myself up about it. On some days, I might even consider it a good thing. Here’s one of the things I’ve learned:

You can trick your brain by moving the goalposts.

Let’s say that you’re working on a project. Toward the end of the project, you catch yourself losing steam. You’ve gotten 80% of the way there, and the remaining 20% of the work will take four times as much time. The itch to start a different project is pulling you away.

Don’t think of yourself as nearly done. Think of yourself as getting started on another new project that just happens to overlap with the previous one.


In fact, mentally set the beginning of that project to include some of the work you’ve just completed, to take advantage of the Endowed Progress effect (research PDF).


Tada! Goalposts moved. You might find that the newly-reframed project is now novel enough to be included in the list of new projects you enjoy working on, and it might even tempt you away from other distractions.

Moving the goalposts is usually a bad thing. It’s why many people never feel rich, because whenever they reach what used to be unimaginable wealth, they find that the amount of money needed for them to feel happy has gone up. (Solution: don’t anchor happiness to amounts of money.) Moving the goalposts has led to many a logical fallacy in heated arguments. But if you don’t like playing a close-quarters game, moving the goalposts further away can help.

I often use this technique for life-long learning, especially for things that you can’t really declare finished. Can one ever finish learning how to write or draw or program? No, but you can keep moving your targets a little forward as you learn.

You might think, “I won’t be able to celebrate achieving my original goal!” You can still celebrate milestones. Better yet, celebrate even the tiny, tiny steps that you take towards your (constantly-moving) goal. Look behind you once in a while and celebrate the progress you’ve made.

It can be hard to see progress if you don’t have anything tangible. Invest time in looking for useful chunks that you can extract even from work in progress. It’s surprising how few projects are truly all or nothing. If you can share drafts, prototypes, alpha or beta versions, or even blog posts about the journey, you don’t have to worry about the whole thing being a complete waste of time if you get distracted from the project before you finish it. If you always wait until you’ve finished something, you might end up leaving a mess of incomplete projects around.

Worried that your mind will see through this technique and lose interest even earlier in the process? Try being playful about it instead of being too serious. Yes, it’s a mental trick (and not even a particularly complex one), but if your mind likes novelty and beginnings, it can hardly fault you for giving it what it likes.

This technique doesn’t solve everything – I haven’t been able to write a 200-page Emacs book yet, and our couch still doesn’t have a slipcover. But it helps me from time to time, and maybe it will help you too!

Developing Emacs micro-habits: Abbreviations and templates

When it comes to improving how you use Emacs, picking one small change and paying close attention seems to work well. Little things make a lot of difference, especially when frequently repeated over a long period of time. It reminded me of this quote I came across on Irreal:

I’ve gotten the hang of basic multiple-cursors-mode and I’m making gradual progress towards internalizing smart-parens by the simple approach of focusing on one tiny habit at a time. For example, I spent a week reminding myself to use mc/mark-all-like-this-dwim or mc/mark-lines instead of using keyboard macros.

Inspired by the Emacs Advent Calendar, I wanted to start a 52-week series on micro-habits for more effective Emacs use. I brain-dumped an outline of four sets (basic Emacs, Org, programming, meta-habits) of thirteen small tips each. Looking at my list, I realized there were many ideas there that I hadn’t quite gotten the hang of myself. I figured that this might be more of a project for 2016; in the meantime, I could learn by doing.

The first micro-habit I wanted to dig into was that of automating text: abbreviations, templates, and other ways to expand or transform text. I’d used Yasnippet before. I sometimes accidentally expanded keywords instead of indenting lines if my cursor happened to be at the wrong spot. But I hadn’t yet drilled the instinct of automation or the familiarity with templates into my fingers.

This blog post isn’t the easy-to-understand guide to automating text. I’ll write that later, when I’ve figured more things out. In the meantime, I’ll share what I’ve been learning and thinking so far, and maybe you can help me make sense of it.

Emacs has a separate manual for autotyping, which I had never read before. The short manual covers abbrev, skeleton, auto-insert, copyright messages, timestamps, and tempo. Did you know that define-skeleton lets you create a template that accepts multiple interregions if you call your skeleton function with a negative argument? (Interregions? What are those?) It took me an embarrassing amount of time to figure out how to mark interregions and use them. It turns out they have to be contiguous. It might be easier to think of marking the beginning of the region, marking some points in the middle, and then calling the command when your point is at the end – which is probably how most people would interpret the diagrams, but I was trying to mark discontinuous regions because that would be super-cool, and that totally didn’t work. And then I forgot that using helm-M-x means you need to specify numeric arguments after typing M-x instead of before. (I wrote about that very point in one of my blog posts, but it slipped my mind.) Once I got past that, I was delighted to find that it worked as advertised. I still haven’t imagined a situation where I would use it, but it seems like a good sort of thing to know.

What are the practical situations where text automation can help people work more effectively? I looked around to see how other people were using it. Coding, of course – especially if you use Emacs Lisp to transform the text. Debugging, too. Marking up text. Remembering parameters. Wrapping regions. Writing e-mails. Adding blog post metadata. Citing references. Lifehacker has a long list, too.

I came up with several categories I’m going to focus on so that I can more easily recognize opportunities to work better:

2015-01-05 Seeing opportunities for abbreviations and text automation -- index card

2015.01.05 Seeing opportunities for abbreviations and text automation – index card

  • Abbreviations are about typing long words with fewer keystrokes. For example, you might shorten “description” to desc.
  • Phrases are like word abbrevations, but longer. You might want to be able to expand btw to “by the way.”
  • Code benefits from expansion in multiple ways:
    • Automatically inserting characters that are harder to reach on a keyboard, like { and }
    • Being consistent about coding style, like the way many people like adding a comment after the closing brace of an if
    • Transforming text that shows up in multiple places, such as variable names that need getters and setters
    • Filling in the blanks: parameters, comments, etc.
    • Reducing the cognitive load of switching between languages by establishingq a common vocabulary. For example, I sometimes need to look up the syntax of for or the proper way to display a debugging statement when I switch to a language I haven’t used in a while
  • Templates are also useful for consistency in writing, planning, and other areas
  • Text transformation can save time and minimize error.

2015-01-04 Automating text - index card

2015.01.04 Automating text – index card

Translating the examples I’d seen to my personal interests, I could probably find plenty of opportunities to automate text while coding, debugging, writing, planning, or publishing. To dig deeper, I looked at each of the categories in detail.


2015-01-06 Abbreviations -- index card

2015.01.06 Abbreviations – index card

When I was curious about typing faster, I read forum posts from people who had increased their speed by developing their own form of digital shorthand. The trick works on paper, too. When I need to write quickly or in limited space, I use abbreviations like bc for “because” and w/o for “without.” Why not on the computer as well?

I often take advantage of dynamic abbreviations when I know I’ve recently typed the word I want. To trigger those, I just have to type the beginning of the word and then use dabbrev-expand. I haven’t set up my own static abbreviations, though. Main obstacles:

  • I want to write shorter words instead of longer ones
  • In the beginning, it’s faster to type the word instead of thinking of the abbreviation and expanding it
  • If I have to undo or backspace, that makes me slower
  • If I burn this into my muscle memory, I might be more frustrated on other computers or in other apps (then again, I already customize Emacs extensively, so I guess I’m okay with the tradeoff)

Anyway, here’s a short list I’m trying out with define-global-abbrev and hippie-expand:

hw however
bc because
wo without
prob probably
st sometimes

Hmm. Let’s say that it takes me two keystrokes to trigger the expansion, whether it’s the xx keychord I’ve just set up or the M-/ I’ve replaced with hippie-expand. (Hmm, maybe a double-space keychord is a good candidate for expansion too.) Is the retraining worth a ~50% possible reduction in keystrokes? Probably not.

How about text with punctuation, so I can minimize reaching for symbols?

mail [email protected]

Maybe it’s better to look at the words I frequently misspell, or that I tend to slow down then typing. I’ll keep an eye out for those.


2015-01-06 Phrases -- index card

2015.01.06 Phrases – index card

Phrases are an easier sell. Still, I’m trying not to settle into the rut of set phrases. I should cut those mercilessly or avoid writing them from the beginning.

co check out
iti I think I
otoh on the other hand,
mean in the meantime,
fe for example
fi for instance,
oc of course
ip in particular

Code insertion

This is, fortunately, well-trodden ground. The yasnippet package comes with a large collection of snippets for many programming languages. You can start by familiarizing yourself with the pre-defined snippets for the modes that you use. For example, in my installation, they’re under ~/.emacs.d/elpa/yasnippet-20141117.327/snippets. You can use the filename (or keywords defined with key, if specified) as the abbreviation, and you can expand them with yas-expand (which should be bound to TAB if you have yas-global-mode on).

I mostly work with HTML, CSS, Javascript, Ruby on Rails, and Emacs Lisp, so this is the cheat sheet I’ve made for myself:

2015-01-07 Code insertion -- index card

2015.01.07 Code insertion – index card

For HTML, I need to remember that the tags are generally expandable, and that there are a few Lorem Ipsum abbreviations triggered by lorem.1 through .5. CSS has a v abbreviation that sets up a bunch of rules with vendor prefixes. For Javascript, I’ll probably start with f to define a function and log to output something to console.log. Rails has a bunch of iterators like eai that look interesting. As for Emacs Lisp, the pre-defined templates generally add parentheses around common functions so you don’t have to type them, and there are a few shortcuts like bs for buffer-string and cc for condition-case. I think I’ll modify the default snippets to make better use of Yasnippet’s field support, though, so that I don’t have to delete and replace text.


In addition to using text expansion for code, you can use it for planning and writing other text. I saw Karl Voit use it to great effect in my Emacs Chat with him (around the 44:00 mark), and I’ve been gradually refining some templates of my own.

2015-01-07 Templates -- index card

2015.01.07 Templates – index card

For example, here’s the template I’ve been using for sketched books. Note: If you use Yasnippet for Org Mode properties, you may want to set yas-indent-line to fixed or the fields will get confused.

Gist: sbook

# key: sbook
# name: Sketched Book
# --

**** TOSKETCH ${1:short title}
      :TITLE: ${2:long title}
      :SHORT_TITLE: $1
      :AUTHOR: ${3:authors}
      :YEAR: ${4:year}
      :BUY_LINK: ${5:Amazon link}
      :BASENAME: ${6:`(org-read-date nil nil ".")`} Sketched Book - ${2:$(sacha/convert-sketch-title-to-filename yas-text)} - ${3:$(sacha/convert-sketch-title-to-filename yas-text)}
      :ISBN: ${7:ISBN}


***** TODO Sketchnote $1
:Effort: 2:00

[[elisp:sacha/prepare-sketchnote-file][Prepare the file]]

***** TODO Write personal reflection for $1
:Effort: 1:00

[[][View in calendar]]

****** Sketched Book - $2 - $3

$3's /$2/ ($4) ...

I’ve sketched the key points of the book below to make it easier to remember and share. Click on the image for a larger version that you can print if you want.

Haven't read the book yet? You can [[$5][buy it from Amazon]] (affiliate link) or get it from your favourite book sources.

Like this sketch? Check out [[][]] for more. Feel free to share – it’s under the Creative Commons Attribution License, like the rest of my blog.

***** TODO Post $1 to blog
:Effort: 1:00
:QUANTIFIED: Packaging

***** TODO Update sketched books collection
:Effort: 1:00
:QUANTIFIED: Packaging

1. [[elisp:sacha/index-sketched-book][Index sketched book]]
   - [[file:~/Dropbox/Packaging/sketched-books/][Edit index]]
   - [[file:~/Dropbox/Packaging/sketched-books/][Edit ebook]]
2. [[elisp:sacha/package-sketched-book][Compile]]
3. Update [[]]

***** TODO Tweet sneak peek of $1 with attached picture

[[elisp:(progn (kill-new (format "Sneak peek: Sketched Book: %s - %s %s" (org-entry-get-with-inheritance "SHORT_TITLE") (org-entry-get-with-inheritance "AUTHOR") (org-entry-get-with-inheritance "BLOG_POST"))) (browse-url ""))][Copy text and launch Twitter]]

It’s a lot of code and I keep tweaking it as I come across rough corners, but it’s handy to have that all captured in a template that I can easily expand. =)

Text transformation

One of the advantages of tweaking text expansion inside Emacs instead of using a general-purpose text expansion program is that you can mix in some Emacs Lisp to transform the text along the way. I’m still thinking about how to make the most of this, as you can see from this half-filled note-card:

2015-01-07 Text transformation as part of expansion -- index card

2015.01.07 Text transformation as part of expansion – index card

For example, this snippet makes it easier to share source code on my blog while also linking to a Gist copy of the code, in case I revise it or people want to comment on the code snippet itself. It doesn’t use any of the built-in text expansion capabilities, but I think of it as a text expander and transformer because it replaces work I used to do manually. You’ll need the gist package for this one.

Gist: Sacha

(defun sacha/copy-code-as-org-block-and-gist (beg end)
  (interactive "r")
  (let ((filename (file-name-base))
        (mode (symbol-name major-mode))
         (condition-case nil (buffer-substring beg end)
           (mark-inactive (buffer-string))))
        (gist (condition-case nil (gist-region beg end)
                    (mark-inactive (gist-buffer)))))
     (format "\n[[%s][Gist: %s]]\n#+begin_src %s\n%s\n#+end_src\n"
             (oref (oref gist :data) :html-url) filename
             (replace-regexp-in-string "-mode$" "" mode)

Both Yasnippet and Skeleton allow you to use Lisp expressions in your template. If you don’t have all the data yet, you might consider writing another Lisp function that you can call later when you do. For example, in the sketched books code above, I have an Emacs Lisp link that composes a tweet with a link, puts it in the clipboard, and then opens up a web browser. (I do this instead of posting directly because I also want to attach an image to that tweet, and I haven’t figured out how to modify any of the Emacs Twitter clients to do that.)

So that’s what I’ve learned so far about automating text in Emacs. It’ll take me more than a week to get the hang of the abbreviations I’ve just set up, and I’ll probably need to add even more before adding and using abbreviations become true habits. But hey, maybe this will help you pay closer attention to repetitive text and editing actions in Emacs so that you can automate them too, and we can swap notes on useful abbreviations. What kind of text do you expand?

For more information, see: