Org Mode and Broken Links

As a couple of you have pointed out to me recently, HTML links in my posts are sometimes getting broken. That happens when the link has a parameter specified with a question mark and equal sign. For example, here’s a link to one of my blog posts that gets affected

Building a Blog with Org Mode

For some reason Org Mode has started escaping equal signs in links so that the above gets turned into

http://irreal.org/blog/?p%3D2168

which is, of course, incorrect. This happens in org-link-escape, which is called by org-make-link-string when I insert a link with 【Ctrl+c Ctrl+l】. No problem, I thought, they must have added the equal sign to the list of characters to escape; I’ll just fix it up with a buffer local variable or something. Unfortunately, when I checked I discovered that the equal sign has always been there and that neither org-link-escape nor org-make-link-string have been changed in over a year.

I put in a little bit of time trying to track down what changed (it didn’t do this in Org 7 and maybe even not in the early Org 8 versions) but couldn’t find anything. I’ll keep looking but in the mean time, here’s a little bit of Elisp that I threw together to fix things up:

(defun jcs-clean-link ()
  "Clean up munged = in an Org link."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (search-forward-regexp "\\[\\[[^]%]*\\(%3D\\)[^]]*\\]" nil t)
      (replace-match "=" nil nil nil 1))))

I can call that before exporting the Org file to HTML and everything will be fine. I may advise the exporting function to call jcs-clean-link for me but for now I’m doing it manually.

The whole thing has not been a total waste of time, though, because I learned two new things. First, calling 【Meta+xvisible-mode shows the links as they really are rather than just the description part. I used to switch to text-mode to do this which is sort of a pain so this is a good find for me.

Second, although it doesn’t help me with the current problem, I discovered that you can set Org variables affecting export—even if they aren’t one of those supported by an option—with the BIND directive. To set variable to value, you just add the line

#+BIND: variable value

to your Org file. You also have to set org-export-allow-bind-keywords to t for this to work. Back when I thought my links were getting munged during export, I speculated that maybe XHTML Strict required the escaping and I was able to disprove that by using BIND to cause the file to be exported as HTML4.

If any of you know what’s going on with the links, please leave a comment.

Posted in General | Tagged , | 5 Comments

Emacs Regular Expression Recap

Xah Lee has a nice summary of Emacs regular expressions and how they differ from the other familiar varieties. I may have linked to an older version of this a while ago but it’s a worthwhile link for anyone who hasn’t seen it.

If you regularly use Emacs, Perl, and Unix regexs, this is a good resource to help you keep the Emacs differences in mind. You can get much the same information from the Emacs documentation, of course, but it’s handy to have a nice summary like this and you may want to bookmark it.

Posted in General | Tagged | 1 Comment

Building a Blog with Org Mode

As regular readers know, Irreal posts begin as Org Mode files that are subsequently published to WordPress with org2blog. This works very well for me but not everyone wants to run WordPress. For those of you who want to build your own blog, Bastien Guerry has a great post that shows you how to build and publish a blog from Emacs Org Mode.

It’s astounding how easy it is. Guerry walks you through the process from your first post to adding an RSS feed. What you end up with is a static blog and the associated RSS feed. In the spirit of eating his own dog food, Guerry publishes his blog this way. You can see the result by clicking on the home button at the linked post.

Guerry is an interesting guy and one of the heroes of Org Mode. For anyone interested in some background, I’ve written about him here, here, and here.

Posted in General | Tagged , | 2 Comments

Hating Apple

My friend Watts has a perspicacious tweet concerning those who hate Apple:

At times I suspect hating Apple is at least as much of a fashion
statement as buying them is.

That’s right, I think. How else to reconcile the near universal panning of the new iPhones by the technical press with Apple’s announcement that weekend sales of the new iPhones set a new record of nine million units? Apple also revealed, in the same announcement, that over 200 million iOS devices are now running iOS 7, which was mostly panned by the press as well.

Posted in General | Tagged | Leave a comment

The New York Times on Encryption Backdoors

In a bit of good news, The New York Times has published an editorial Calling on the NSA to close their backdoors. There’s nothing in the editorial that will be news to Irreal readers but it’s useful because it educates the public at large as to the issues at stake. It’s easy for us geeks, who sometimes seem to understand these things at the DNA level, to forget that to most people encryption backdoors (and even the associated massive surveillance) is (1) an esoteric technical issue not understandable by normal folks and (2) something that has no impact on their lives.

The advantage to having mainstream publications like the NYT weigh in on the situation is that it can help educate the man on the street about the risks these activities bring to all of us. The article mentions that Representative Rush Holt of New Jersey has introduced legislation that would bar the government from demanding that software makers build in backdoors to their products. If you’re a US citizen, this might be a good time to let your representatives know that you support Holt’s measure.

Posted in General | Tagged | Leave a comment

Code Snippets in Org Mode

Everyone who’s hung around Irreal for a while knows that I’m a big fan of Org mode and that I use it to, among other things, write all my blog posts. One of the really nice things about it is the way it handles the embedding of code snippets in the text.

Matthew Keeler has posted an excellent video on embedding code snippets in Org mode. He starts with a simple document and exports it to PDF through LaTex. Then he adds a bit of Python to the document and demonstrates the Org features that support embedding code in documents. Even this short video serves to demonstrate what you can do in Org mode.

If you write documents that include code you really should watch this video. It will make your work much easier. It’s just a little over 6 minutes long so you can watch it while you’re waiting for the coffee to brew.

Posted in General | Tagged , | 3 Comments

Safe Password Hashing

I have written several times about the absolute necessity to properly hash passwords. The tricky part is that properly. It’s a bit subtle to get it right. Happily the folks over at Defuse Security have an excellent guide that

  • Tells you what to do
  • Tells you what not to do
  • Provides source code to proper implementations in PHP, Java, C#, and Ruby

If you’re a developer tasked with the customer authentication system, be sure to read this. There’s lots of good advice in it. And whatever you do, don’t store the passwords in plain text. If you do, you’re going to end up here and be the object of universal derision and scorn.

Posted in General | Tagged | 1 Comment

Dual_EC_DRBG

One of the recently released Snowden documents mentions the NSA’s success at weakening a 2006 NIST encryption standard and getting it accepted as an international ISO standard. While the standard isn’t named, it is widely assumed to be NIST Special Publication 800-90A with the DualECDRBG random number generator being the weakened algorithm. Indeed, the algorithm was weakened to such an extent that it can be said to have a backdoor.

Matthew Green, a John Hopkins research professor, has a great post on DualECDRBG and its flaws. He explains what the flaw is and how it is exploited. The article is fairly technical but not overly mathematical so interested Irreal readers should be able to follow it without problems.

Ironically, DualECDRBG is very slow (about 3 orders of magnitude slower than the other RNGs in SP 800-90A) so there is no reason to use it except these types of algorithms can be proved to be secure and the cautious implementer may be willing to sacrifice the performance for the security. Unfortunately, NIST neglected to include such a proof in SP 800-90A and when cryptographers took a close look they discovered many problems with the algorithm. Read Green’s post for the details.

Incredibly, despite these problems having been known since 2007, there are still implementations using the algorithm. Meanwhile, NIST has reopened public comment on SP 800-90A and is strongly recommending that DualECDRBG not be used until the standard is reissued.

Posted in General | Tagged | Leave a comment

Tracking Emacs Packages

Via Xah Lee’s blog, I came across a really interesting project. Artur Malabarba’s EAT (Emacs Archive Tracker) project checks the Gnu, Marmalade, and Melpa archives every couple of hours and displays a graph showing the number of packages added recently. The data shows that about 75 news packages are being added every month. That’s pretty impressive and shows how active the Emacs community is.

Of course, EAT is written in Emacs Lisp. That shows not just that the community is willing to eat its own dog food but that Elisp really can be used as a general purpose computing platform.

Update: the → the community

Posted in General | Tagged | 1 Comment

Emacs Startup Packages

Xah Lee has a roundup of emacs Starter Kits on his blog. He’s got a list of 5 such kits so there’s a lot to choose from.

Lee also notes that you can just install Emacs and add things as you need them. That’s the approach I took, probably because there weren’t any starter kits when I first came to Emacs. That approach has worked well for me. When a user of one of the starter kits writes about some wonderful feature in his setup, I just add it to mine. Of course, I’m a programmer so this is natural for me. If you’re a bit less technically inclined, one of the starter kits may be the right answer for you. I’ve heard good things about all the kits that Lee lists so pick one and start building your own configuration from there.

Posted in General | Tagged | Leave a comment