Endless Parentheses

Concise ramblings on Emacs productivity.

New on (M)Elpa: speed-of-thought-lisp

New on Elpa post series

When your computer is feeling slow and you decide to upgrade it, where do you start? You start by finding the bottleneck, of course. That awesome CPU won't do you any good with crappy RAM disk. The same logic holds for your coding skills.

Whenever you're writing code, there are two main processes going on —this is a very rough model, but it gets the job done.

  1. You think of what you'll write,
  2. and you write it.

As you become more experienced with a language, the first part gets faster and easier, to the point where you can immediately envisage the solution to any problem you encounter. On the other hand, your actual writing speed is much slower to improve, and caps at a very disappointing maximum.

The solution? Upgrade the bottle-neck, i.e., your hands. speed-of-thought-lisp (or sotlisp) is all about helping your hands keep up with your brain. The mode itself is quite simple, it provides two sets of tools to help your fingers follow your thought-flow. To turn it on, just issue M-x speed-of-thought-mode. While you're at it, make sure you've got something like electric-pair-mode or paredit active, sotlisp is a lot more fluid with these.

Minimal typing with abbrevs

A large number of intelligent abbrevs which expand a function's initials to its name. A few examples:

  • iinsert
  • aand
  • rrequire '
  • wcbwith-current-buffer
  • efnexpand-file-name

It's pointless to list all of them here, there are 136 of them at the moment. The whole purpose of these abbrevs is that you don't need to learn them. Instead of typing insert SPC or maybe ins TAB, you just write i SPC for the same effect. You'll be surprised how quickly this abbreviations become more natural to you than the actual names.

And before you start worrying, these are defined in a way such that they only expand in a place where you would use a function. So hitting SPC after (r gives (require ', but hitting SPC after (delete-region r will not expand the r, because that's obviously not a function. You can safely use short variable names without running into conflicts.

You may I have noticed I've only mentioned functions. Variable abbrevs are on the way!

Speedy keybinds

It also defines 4 commands, which fit tightly into this “follow the thought-flow” way of writing.

M-RET
Break line and insert () with point in the middle.
C-RET
Do forward-up-list then do the above.

Hitting RET followed by a ( was one of the most common key sequences for me while writing elisp, so giving it a quick-to-hit key is a significant improvement.

C-c f
Find function under point. If it is not defined, create a definition for it above the current function and leave point inside.
C-c v
Same, but for variable.

With these commands, you just write your code as you think of it. Once you hit a “stop-point” of sorts in your thought-flow, you hit C-c v on any undefined variables. Then you just write its definition, and hit C-u C-SPC (pop-global-mark) to go back to where you were.

Conclusion

sotlisp is floating around the Elpas, so you can issue the usual M-x package-install RET sotlisp, and activate it in your init file.

(speed-of-thought-mode)

Then you'll be able to do magic such as writing

(with-temp-buffer
  (insert text)
  (buffer-string))

by typing (wtb M-RET i SPC text C-RET bs SPC.

Also coming up is a sotlatex package and perhaps even a sotclojure.

Tags: package, lisp, programming, emacs

Say thanks on Gratipay
comments powered by Disqus