Alex Henning home about projects blog

My Blog

Licensing - WTFPL

My favorite license is WTFPL. The actual content according to wikipedia:

                   Version 2, December 2004
Copyright (C) 2004 Sam Hocevar
 14 rue de Plaisance, 75014 Paris, France
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

As you can see, it's very short and straight forward. You can do whatever you want. I was looking at it again today, when I realized that most of my code on github didn't have an actual license. So, I went back and licensed them under the WTFPL, because quite frankly, I wrote most of it for the fun of writing it and learning. I don't want any of the nonsense associated with longwinded licenses.

That said, I'm licensing the code to this blog under the WTFPL, but keeping the license to the content of the posts. Why? Because, I don't really feel copies of my ramblings spread over the internet randomly. That said, if you actually have a good reason, just ask me for permission.

Posted on 08 November 2010 in wtfpl licenses

Coloring Text in Emacs

I was working on a dashboard for blogging in emacs as part of my current goal of learning emacs lisp, and I would a very annoying problem. I wanted to color certain lines, this isn't syntax highlighting, merely, coloring of key lines.

At first I duckduckgo'd and duckduckgo'd, but all I could find was syntax highlighting of keywords and this page. I looked at add-text-properties and propertize. I was trying the property face, however, the property I wanted isn't face, but font-lock-face. Why? It has something to do with font-lock-mode… it was a good half of a day wasted. Anyways, I ended up with a nice little function for highlighting the current line:

1:  (defun blog-set-line-face (face)
2:    (add-text-properties
3:     (line-beginning-position)
4:     (line-end-position)
5:     `(font-lock-face ,face)))

To go along with the color theme, you can use the color theme faces:

I'll probably throw the initial verion of blog.el on github in the next few days.

Posted on 06 November 2010 in emacs lisp highlighting

Installing Emacs from Source on Ubuntu

Essential Libraries

I decided to install emacs from source on Ubuntu. It turns out, installing emacs from source is relatively easy. First, make sure you install support for compiling code and info files.

sudo aptitude install texinfo build-essential

Then, assuming you want to have support for images, there are quiet a few libraries necessary for png, gif, jpeg…

sudo aptitude install libdbus-1-dev libgconf2-dev libgif-dev libgpm-dev libgtk2.0-dev libjpeg62-dev libm17n-dev libncurses5-dev libotf-dev librsvg2-dev libtiff4-dev libXpm-dev

This far, I have to thank for saving me from having to hunt down the names of all of the graphics libraries.

Getting the Source

Then, I cloned the source for the latest from and followed the build the instructions in INSTALL.

 1:  git clone git://
 2:  cd emacs
 3:  ./configure
 4:  make bootstrap
 5:  make
 6:  src/emacs -q ;; This checks that it built properly
 7:  sudo make install
 8:  mv /usr/local/bin/emacs-24.0.50 /usr/local/bin/emacs24
 9:    ;; Change the number to whatever the version is, I moved it to a more convienent name
10:  emacs24 -q

You should now be able to run the latest version of emacs.

Fixing the your .emacs

If you leave out the -q option, you may notice errors when emacs tries to load your .emacs. First, if aby libraries you use defun* or any other functions for cl, make sure you load it.

1:  (require 'cl)

It won't load emacs-goodies-el or any other. The only reason for this, is that the newly built emacs doesn't know where Ubuntu keeps them. (hint: not where emacs expects them) The fix is easy, just add it and all of the directories in it to the load-path.

1:  (add-to-list 'load-path "/usr/share/emacs/site-lisp")
2:    (mapcar '(lambda (dir)
3:                      (add-to-list 'load-path (concat "/usr/share/emacs/site-lisp/" dir)))
4:            (cddr (directory-files "/usr/share/emacs/site-lisp")))


The only problem I currently having is color-theme.el which doesn't seem to be working properly. I'm still working on it… Any other problems?

Posted on 05 November 2010 in emacs ubuntu

Literate programming

When writing synonym.el, I tried doing it as a literate program. I haven't done a whole lot of literate programming yet, and I have a few issues with it.

I still see the the non-code as comments
Whereas in literate programming, the non-code should be more of a narrative that tries to explain everything.
I don't write enough of the "narrative"
And what I write feels much more like a repetition of the code than a complement of it.
I leave out doc-strings
They feel like even more repetition on top of the narrative.
The narrative falls out of sync with the code
This is the same problem that comments suffer, but it's even more confusing in a literate program.

The only two things I really like are the code folding and the ability to have all the code in one big file that the separates out into logical modules.

Posted on 02 November 2010 in literate programming programming style emacs

Introducing Synonym.el

Synonym.el is an elisp package that adds synonym support to emacs. Have you ever been writing something and then couldn't think of the right word? Want a synonym? Why should you have to leave that comfy world that is emacs to find a synonym?

Now you don't have to. A quick M-x t and you're presented with a list of synonyms, just like autocomplete.el, but with synonyms. Right now, it's pretty dumb, and just fetches the synonyms from a server every time you access it. That's far from ideal, I plan on caching it at some point.

*Go, give it a try!*

Posted on 01 November 2010 in synonym emacs

Getting a Motivational Message on Emacs Startup

When I was learning LISP, I used slime in emacs. One of the neat little features I liked was the motivational message it showed on startup. It wasn't really that important, but it was one of those little features that when you notice, brightens your day a little. I use emacs so much, I decided why not add a feature for emacs. (This was a few months ago, when I wanted to learn dome elisp for the first time.)

So first, I created a file ~/Dropbox/wisdom.txt and on each line, I put a quote or a motivational message. Put whatever you want to see on startup in it.

Next we need to read each of the lines into a list, so I use a simple python style read-lines.

1:  (defun read-lines (file)
2:    "Return a list of lines in FILE."
3:    (with-temp-buffer
4:      (insert-file-contents file)
5:      (split-string
6:       (buffer-string) "\n" t)))

Then I load wisdom.txt into a variable named wisdom. I remove any line starting with =";;"= so that I can comment out lines if I wish to.

1:  (setq wisdom (remove-if (lambda (s) (string= (substring s 0 2) ";;"))
2:                          (read-lines "~/Dropbox/wisdom.txt")))

Next, I choose a random element from the list wisdom and show it in the minibuffer.

1:  (defun motivational-message (&rest rest)
2:    (interactive)
3:    (message (elt wisdom (random (length wisdom)))))

Then, I just override it so that it shows at startup. This intentionally goes strait to *scratch*, I use emacs so much that I prefer to go straight scratch.

1:  (defun display-startup-echo-area-message ()
2:    "If it wasn't for this you'd be GNU/Spammed by now"
3:    (motivational-message))

What do you think? Not too painful.

Posted on 31 October 2010 in emacs customizations

River Rage!

Today I went to River Rage a post season FIRST Robotics competition with team 348. It was very enjoyable, we ended up as semifinalists, which wasn't quite what I hoped for. However, it was quite good.

They mixed some things up, for alliance selection, alliances 1-8 selected then 1-8 again as opposed to the annoying snake selection thing FIRST normally does. Also, Alliances couldn't choose other teams in the top 8 which prevented the two best teams from getting together and dominating.

When it actually came to running the elimination matches, they had some ridiculous bracket. It made absolutely no sense to me. It might have if I had seen it on paper. It was annoyingly confusion. Enough complaining though.

It was a very fun day, and every one on our team got to go up!

Posted on 30 October 2010 in robotics river rage first

Pretty Lambdas!

A neat little trick I found a while ago allows emacs to transform (lambda ...) into (\lambda ...) which makes lisp code more concise and easier to read. (You can also use it for python and any other language).

1:  (defun pretty-lambdas ()
2:    (interactive)
3:    (font-lock-add-keywords
4:     nil `(("\\(lambda\\>\\)"
5:            (0 (progn (compose-region (match-beginning 1) (match-end 1)
6:                                      ,(make-char 'greek-iso8859-7 107))
7:                      nil))))))

It is a bit of a mess, but when it's activated you type lambda normally and it auto transforms into \lambda for display, but saves as lambda. This allows you to use it in source code and run the code normally. To enable it, add it as a hook in .emacs or type M-x pretty-lambdas when the file is open.

Edit: I got this from, one of the problems with a large .emacs is sometimes it's hard to remember where you got everything…

Posted on 29 October 2010 in emacs lisp lambda

Keeping Track of Ideas for Blog Posts

So, I've been having some good ideas for blog posts. So many that, rather than post about them, I'm writing a post about how I improved my workflow! So, what improvement have I made? I can now type M-x blog-idea idea and it will save the idea to a file. This is somewhat influenced by org-remember, however, it separates my blog ideas from the rest of the nonsense.

First I created blog/draft/ since I wanted to keep track of my files with org-mode. I separated my initial ideas by topic with the last topic being misc. Then I went about implementing some elisp for M-x blog-idea so that it prompted me for the idea and then appended it to the end of the ideas file.

1:  (defun blog-idea ()
2:    (interactive)
3:    (let* ((idea (read-from-minibuffer "Idea: " nil))
4:           (line (concat "- [ ] " idea "\n")))
5:      (with-temp-buffer
6:        (insert line)
7:        (append-to-file  (point-min) (point-max)
8:                         "~/Dropbox/blog/draft/"))))

Then, I made M-x blog-ideas a shortcut for opening, which is short and sweet:

1:  (defun blog-ideas ()
2:    (interactive)
3:    (find-file "~/Dropbox/blog/draft/"))

This is why I love EMACS!

Posted on 28 October 2010 in blogging workflow

MIT Doesn't use the Common App

I'm applying to a few colleges right now, and they all use the common app, well, except for MIT. It's very convenient, fill write once and apply anywhere. That's not entirely true, some colleges have supplements. For the most part, supplements are short and easy, but some colleges like Caltech have much longer ones with an essay and some short responses.

MIT goes on about how easy it is because they have a few short responses instead of an essay. However, unless you only apply to MIT, odds are you have to write the common app essay anyways. MIT's app requires that you reenter what APs you took, you name and a ton of other basic information that's annoying to enter, but takes more time than writing an essay.

Since, they go on about how easy it is, they're not trying to scare people away. If they were, they could do the common app and have essays that mean something as opposed to busy work. Anyways, this is just me venting cause of all the applications due next Monday.

Posted on 27 October 2010 in misc

All Posts