Unicode Font Redux

A couple of days ago I wrote about finally solving a long standing Emacs problem involving missing glyphs in my default font. I was really happy to have the problem resolved. So pleased I wrote about it in glowing terms.

That solution involved installing the unicode-fonts package, which scans your fonts for missing glyphs, finds them in other installed fonts, and arranges for them to be used in place of the missing glyphs. It’s a really great package but it does much more than I need. I really just wanted to specify an alternate font for those missing glyphs.

As soon as I published my post, Xah Lee and Artur Malabarba suggested a simpler solution. I was happy with unicode-fonts but couldn’t resist the one line solution that Lee and Malabarba offered. So I disabled unicode-fonts and added the line

(set-fontset-font "fontset-default" nil 
                  (font-spec :size 20 :name "Symbola"))

to my init.el. It worked perfectly, of course, so I uninstalled unicode-fonts and went with the Lee-Malabarba solution.

Malabarba notes that the documentation for set-fontset-font is a bit opaque. That’s an understatement. I had to read it several times before I could figure out why it worked for my problem. No matter. If you’re having the same problem you can just think of it as a magic incantation.

Posted in General | Tagged | 2 Comments

Fast Toggling Emacs Modes

Over at Endless Parentheses, which I’ve mentioned before, Artur Malabarba has a really good idea. He shows how to define a custom key map that he uses to toggle modes that he uses frequently. He binds the commands to the prefix【Ctrl+x t】, an unused key sequence in stock Emacs. Then he has a third key that mnemonically suggest the mode he wants to toggle. Thus,【Ctrl+x t c】toggles column-number-mode and【Ctrl+x t r】toggles read-only-mode and so on.

Oddly, none of the shortcuts that he proposes are ones I care about but I do have a list of my own

l linum-mode
o org-mode
p paredit-mode
t text-mode
v visual-line-mode

As Malabarba says, these aren’t keys I’ll use everyday but they are mnemonic enough that I’ll be able to remember then.

Doubtless you have your own list of modes you’d like to be able to toggle easily and Malabarba’s method makes it easy to bind them to an easily remembered key.

A very useful post, I think. I’m going to implement the above list in my own init.el as soon as I finish writing this.

Posted in General | Tagged | 11 Comments

Backup Fonts for Unicode Glyphs

Trey Harris posed a question on the Google+ Emacs Community that’s been bothering me for some time. I use the terrific Inconsolata as the default for monospaced fonts but many of the Unicode glyphs are missing. Mac OS X takes care of finding missing glyphs in native apps like Terminal.app or Mail.app but with Emacs I just get a missing glyph. I’ve tried various fixes over the years but nothing worked very well.

Harris suggested using the unicode-fonts package to handle this. Happily, it’s an ELPA package so I just loaded it up and added the required lines to my init.el and those missing glyphs starting appearing in Emacs. Years of frustration gone just like that.

There are still a few missing characters but the README for unicode-fonts lists a few font packages that you can load to supply most characters you’re apt to need. Even without loading the extra fonts, I’ve got almost everything I need so I haven’t bothered with them. If you’ve been having a problem with missing Unicode glyphs, give unicode-fonts a try. It’s easy to load with ELPA and if it doesn’t work for you, it’s easy to uninstall. It’s a huge win for me.

Posted in General | Tagged , | 6 Comments

Russ Cox on Debugging

There’s a new site, Debuggers, that is sort of reminiscent of The Setup. The idea is that every week (on Tuesdays) they publish a short questionnaire with a programmer asking about his or her most interesting debugging problem.

This week Russ Cox describes one of his most interesting bugs. As regular readers know, I admire Cox and his work a lot and always learn something new from his writings. Cox’s bug involves threads and locking, surely one of the most fertile grounds for bugs. What’s interesting is the way that assumptions about the locking mechanisms and manual memory management conspire to make a bug that was really hard to understand.

I’ll let Cox tell his story and only urge you to give it a read. Like me, you’ll very likely learn something.

Posted in Programming | Leave a comment

The 10 Greatest Programmers of all Time

Last week, I wrote about NetWork World’s 14 Greatest Living Programmers. This week, I’m Programmer has a list of The 10 Greatest Programmers in the World of all Time.

Lists of these sorts are always silly, of course, but nevertheless fun to read and argue about. I’m Programmer’s list is pretty noncontroversial. It starts out with DMR and ends with Knuth. Those in between are just as worthy. It’s got Thompson, Stroustrup, Gosling, Kernigham, Torvolds, and others. Each entry has a picture and short blurb of the candidates accomplishments. Best of all, it’s not a slide show.

You might possibly argue that someone more deserving was left off the list but you would, I think, be hard put to claim that anyone on the list didn’t deserve to be there. But take a look and see for yourself. Leave a comment if you disagree with the list or think someone more deserving was left off it.

Posted in General | Tagged | Leave a comment

Let’s Play Emacs Golf!

It’s been a while since Irreal has had an EmacsGolf challenge but yesterday’s post on Programming Silliness suggested a nice one. When I ran the grep, I got

A
a
aa
Ab
aba
faff
fe
fed
fee
feed

The challenge is in two parts:

  1. Rearrange the long, single column list into four columns the way it was in yesterday’s post.
  2. I was lazy in yesterday’s post and left the results sorted by rows instead of the more natural by columns. Rearrange the list so that the results are sorted by columns.
Posted in General | Tagged | Leave a comment

Programming Silliness

The other day I saw this post. Although I’m not interested in Java, I was struck by the magic number CAFEBABE that marked the beginning of the structure. That got me wondering how many words can be made with the hexadecimal digits A-F. Before you read further, ask yourself how you’d go about solving this problem.

Being a developer, my first thought was, “Well I’ll just write a quick Lisp program.” The only aspect I wasn’t sure of was whether I should use Common Lisp or Emacs Lisp. It was pretty easy to layout the general structure in either language.

Then I had that “DUH” moment when I realized I was working way too hard. The easy way to solve this problem is

grep -v [^a-fA-F] /usr/share/dict/words

which gave me the results

A a aa Ab
aba abac abaca abaff
abb Abba Abe abed
acca accede ace ad
Ada Adad adad add
Adda adda added Ade
ade adead ae aface
affa B b ba
baa Bab baba babe
bac bacaba bacca baccae
bad bade bae baff
be Bea bead beaded
bebed bed bedad bedded
bedead bedeaf Bee bee
beef C c ca
cab caba cabda Caca
cad cade caeca caffa
ce cede cee D
d da dab dabb
dabba dace dad Dada
dada dade dae daff
de dead deaf Deb
deb decad decade dee
deed deedeed deface E
e ea ebb ecad
Ecca Ed Edda edea
efface F f fa
Faba Fabaceae facade face
faced fad fade faded
fae faff fe fed
fee feed

Sadly, cafe isn’t in the system dictionary on my MacBook but the method stands.

The moral here is that we developers should remember that not every problem is a nail. Now that I think about it, this is the exact same point that I made two years ago.

Posted in Programming | Tagged | 3 Comments

SBCL 1.2.1 and Slime

A couple of weeks ago, SBCL 1.2.1 came out and as I reported at the time, although it compiled and installed correctly, there was a problem with Slime. The 1.2.1 SBCL release changed some internals that Slime relied on and as a consequence Slime wouldn’t compile.

Now Xach has released this month’s Quicklisp distribution with a new version of Slime that fixes the problem. I reinstalled SBCL 1.2.1, fired it up, and everything was fine. If you had the same problem, it’s now safe to install the latest SBCL. If for some inexplicable reason you’re not using Quicklisp, just grab the new slime from GitHub.

Even if you didn’t have the problem, it’s worth noting that the new Quicklisp distribution is available. As usual, there is lots of goodness in it.

Posted in Programming | Tagged , , | Leave a comment

Résumés with Markdown or Org-mode

Continuing with our theme of using Emacs for writing rather than coding, Mark Szepieniec and Christophe-Marie Duquesne have a couple of nice posts about writing your résumé in Markdown and then exporting it to the desired format with Pandoc.

There’s a lot to be said for this strategy. You can have a single master copy for your résumé and use it to generate whatever format is needed. The same master copy can generate a nice HTML for your Web site, a PDF for an employer that prefers a traditional format, or a Word document for employment agencies, which generally prefer that format. If you try to keep separate copies for each of these different formats, errors are sure to creep in and some formats will have the latest updates missing.

Both these posts discuss using Markdown for your master copy but exactly the same strategy works for Org-mode. You might not even need Pandoc with Org-mode because of Org’s powerful export engine. Either way, I think the Markdown/Org-mode method is the winning strategy. You have a single, portable source for your resume that can be exported to just about any desired format. One thing for sure, it’s a lot better than using Word or one of its demonic spawn. It’s also better, I submit, than writing it in TeX or LaTeX for many of the same reasons.

Posted in General | Tagged | 4 Comments

Creative Writing with Emacs

Like many (most?) Emacs users, I do all my writing with Emacs. This mostly involves Org-mode but even when it doesn’t I’m still in some sort of Emacs buffer. I just came across this old Stack Exchange post asking about Emacs configurations for creative writing.

If you’re looking for an excellent writing tool, you should check out this thread. Also be sure to follow the link to Randall Wood’s Woodnotes Guide to Emacs for Writers. It covers those aspects of Emacs most likely to be useful to writers. Wood doesn’t consider coding at all, only creative writing.

I know many writers like tools such as Scrivener for organizing their writing. While I’ve never used any of those special tools—let alone the horror that is Word—I find it hard to believe that an appropriately configured Emacs is not equally good or better. One of the nice things about writing with Emacs and Org-mode or Markdown is that you can export to Word format with Pandoc or Org’s export engine. That’s really handy because you can write with a decent editor and still provide your publisher with the Word document that most publishers insist upon.

It’s an interesting thread. If you do any writing, especially creative writing, you should check it out.

Update: Randal → Randall

Posted in General | Tagged | 8 Comments