Emacs Autoloads

Over at lunarsite, Sebastian Wiesner has a very nice post that explains the ins and outs of autoloads in Emacs lisp. Mostly, autoloads take care of themselves but sometimes users do need to interact with them. Here’s an example that I learned from Steve Purcell.

Of course, if you’re writing packages you will need to understand how autoloads work and when to use them. Wiesner’s post gives you all the information you need. Definitely worth a read even if you’re not writing your own packages.

Posted in General | Tagged | Leave a comment


Recently, I’ve seen several references to the git-timemachine package. It didn’t seem that interesting to me so I ignored it. Then I noticed that Bozhidar Batsov is recommending it on Emacs Redux. When Batsov recommends something, it’s generally an indication that that something is worth a look.

So I loaded git-timemachine from Melpa and started playing with it. It provides a functionality that, as far as I know, is missing or hard to use in git or magit. When you invoke git-timemachine on a file, you can scroll through all the versions of the file in git. This isn’t the commit records but the actual file—you get the ultimate in context.

If you often—or even sometimes—find yourself looking at older version of a file, you should take a look at this package. It’s easy to load and try out with ELPA. You don’t even need to adjust your .emcas or init.el, just load the package and start using it. If you decide you don’t like it, just uninstall it. It’s definitely worth a look.

Posted in General | Tagged , | 1 Comment

News on the Jewel v. NSA Case

Here in the United States, the EFF is prosecuting a suit on the NSA’s indiscriminate collection of Americans’ private digital communications. In 2008 they filed the Jewel v. NSA case alleging that the NSA’s wholesale vacuuming up of Americans’ communications without warrant or specific cause is a violation of the Fourth Amendment.

Now the EFF is arguing to a federal judge that there are enough agreed upon facts to reach a constitutional conclusion and they are asking the judge to rule the NSA’s actions unconstitutional. They argue that the NSA’s actions amount to a general warrant, a legal device that the Fourth Amendment was specifically written to prohibit.

There’s no question that the EFF has the facts on their side but it is far from certain that the judge will rule in their favor. Still, at least the case is moving along and offers hope that these illegal actions will be halted.

There appears to be positive action in Europe too. The European Court of Human Rights has demanded that the GCHQ justify its mass surveillance. Meanwhile, seven ISPs have filed complaints with Britain’s Investigatory Powers Tribunal about GCHQ’s monitoring of Internet communications, something the GCHQ has been worrying about for some time. One can only hope that their fears are realized.

Posted in General | Tagged | Leave a comment

Quantum Theory and Computational Complexity

The Physics arXiv Blog has a really interesting article about the connection between quantum theory and the question of whether or not P = NP. The article starts with the question of why we can’t observe quantum phenomena at the macroscopic scale. Arkady Bolotin of Ben-Gurion University says that the key to understanding the problem is to treat it as a problem of computational complexity.

Briefly—see the article for details—the idea is that while it is possible to solve Schrödinger’s equation for simple systems at the quantum scale, it becomes increasingly difficult as the number of particles increases. Bolotin asks what if it’s impossible to solve Schrödinger’s equation for macroscopic systems in reasonable time. He shows that it is indeed impossible providing P ≠ NP.

The article outlines the argument in terms accessible to those not expert in quantum mechanics. To my—mostly uninformed—mind this provides a persuasive argument for the notion that P ≠ NP. It’s not a proof of course but it is persuasive. If you have the slightest interest in the P ≠ NP problem or are fascinated by the counter intuitive results of quantum mechanics, I’m sure you’ll enjoy the article.

Posted in General | Tagged | 2 Comments

Advanced Programming Mode Implementation

A year and a half ago I mentioned Christopher Wellons’ excellent tutorial on writing a minor mode. Now David Christiansen looks at some of the advanced aspects of implementing programming modes. As with Wellons’ post, Christiansen is documenting the things he learned from implementing his own mode—idris-mode in his case.

I like this post because it explains how to implement features that add polish and utility to your mode. He covers:

  • Imenu
  • Completion
  • Eldoc
  • flycheck and
  • Customize

as well as other hints for writing programming modes.

As with the Wellons post, you’ll want to bookmark this one against the day that you need its advice. As Christiansen says, all this material is well documented but the problem is knowing what’s available so you can look up its documentation.

Posted in Programming | Tagged | 1 Comment

Emacs Themes

I started using Emacs before there was any real support for themes so I just selected the default light configuration. I made a few tweaks like making the cursor a red bar but didn’t do much fiddling otherwise. About three years ago, the white background started bothering my eyes so I changed it to oldlace and I’ve been happy enough with the result that I haven’t made any further changes.

Still, I occasionally run across a tweet or post praising some theme and I always take a look at the screen shots. So far, I haven’t seen anything that I like more than my simple non-theme but I’ll doubtless keep looking at themes people like and point out on the Web.

Now Yuriy Pitometsu over at the Google+ Emacs Community points to a very nice site that has screen shots and information on several themes. If you’re new to Emacs or unhappy with your current theme, you should take a look. Each page of the site lists several themes along with a thumbnail screen shot so you can easily find themes that interest you. Clicking on a theme brings up a larger screen shot and more information. It’s a very nice resource if you’re in the market for a new theme. Recommended.

Posted in General | Tagged | Leave a comment

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 | Leave a comment

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