Writing Leanpub Books with Org Mode

As most of you know, I’ve moved almost all my writing chores to Org mode so I’m always on the lookout for new writing workflows that leverage Org. I particularly enjoy posts about using Org mode to write books.

Lakshmi Narasimhan has such a post. In it, he explains how he’s using Org to write a book for Leanpub. Leanpub uses Markdown for input but it turns our that there’s an Org exporter that converts to Leanpub input. That makes it easy to write in Org and still meet Leanpub’s requirements.

Leanpub has a simple and structured publishing protocol so Narasimhan was able to automate almost all of it. In his case, he puts his text in a shared Dropbox folder and Leanpub does the rest. One file, Book.txt, lists the files containing the chapters of the book. Another similar file, Sample.txt, lists the sample chapters. Narasimhan generates those file automatically from a single Org file that contains the chapters as the top level headings.

Take a look at his post for the details of how he ties everything together and how he maintains metadata about the book. Everything, including his writing times, is included in the single Org file. If you’re thinking of publishing a book with Leanpub, you absolutely must read his post. His workflow is simple and effective and lets him concentrate on writing instead of the ancillary tasks. Even if you aren’t planning on writing for Leanpub, the post describes a nice workflow that should be translatable to many long form writing projects.

Posted in General | Tagged , | 1 Comment

Emacs Modifier Keys on OS X

Yesterday, I wrote about using a prefix keymap to help deal with the shortage of available key sequences. That’s a good solution for what Xah Lee calls take-a-break commands. For frequently used commands it’s more efficient to use the 【Hyper】 and 【Super】 modifier keys. These do have some commands bound to them but are hardly ever used so they are a good place to look for fast key sequences.

The problem is that modern keyboards, alas, no longer include them. I partially solved that problem by mapping the 【fn】 key to 【Hyper】. That’s easy to do with Emacs but it’s not the only solution. And, of course, it doesn’t address where to assign the 【Super】 key.

Grant Rettke has an excellent video post on how to map OS X keys to the Emacs modier keys. If you’re an OS X user, you should definitely take a look. Emacs is pretty flexible about mapping the OS X modifier keys to the Emacs modifier keys and let’s you do things like map the the right 【⌘ Cmd】 key to 【Super】 while leaving the left 【⌘ Cmd】 to serve its normal OS X functions.

Rettke even shows how you can toggle the special behavior of these keys on and off for various situations. The video is short and definitely worth watching if you work with OS X.

Posted in General | Tagged , | Leave a comment

Defining a Keymap Prefix

I’ve written about this before but it’s a useful technique and worth revisiting now and then. One of the problems all Emacs users face eventually is a lack of practical key sequences for commands. One way of solving this problem is to define your own keymap prefix. Just as many of the built-in commands have the prefix 【Ctrl+x】, we can define our own prefix and add commands to an additional key.

Between this technique and defining hydras, you can easily assign a key sequence to what Lee describes as take-a-break commands. For commands you use a lot, especially during text input, it makes sense to assign a key to one of the (usually ignored) other prefix keys: 【Super】 and 【Hyper】. I have hyper mapped the the 【fn】 key and use sequences such as 【fn+a】 to call often used commands, avy-goto-word-1 in this case.

Posted in General | Tagged | Leave a comment

Org Clocking and Idle Time

Marcin Borkowski (mbork) posts some useful information on Org mode clocking that I didn’t know. If you’re tracking your time on a task with Org mode clocking, it’s easy to forget to stop the clock when you finish or get interrupted. That can distort your task time because it adds time to the clock when you weren’t actually working on the task.

Of course, this is Emacs so there’s a solution. It turns out that Org has the notion of idle time—configurable, naturally—that notices when you’re not doing anything with Emacs1 and will present you with a menu when the idle time exceeds the configured limit. The menu asks you what you want to do about the idle time. You could just ignore it, stop the clock, subtract the idle time from the clock, or various other actions. See mbork’s post for the details. He also has a link to the relevant Org manual page so that you can see all the options.

Footnotes:

1

On some systems this may be the actual user idle time. Consult the manual for details.

Posted in General | Tagged , | Leave a comment

Rolling Your Own Crypto

Via Jean-Philippe Paradis:

It made me laugh but it’s all too true.

Posted in General | Tagged | Leave a comment

Pandoc Upgraded

If you do a lot of your writing with Org mode the way I do, you may sometimes need pandoc to help with exporting your work. If you are one of those people, Karl Voit has some good news for you:

If you haven’t upgraded up yet, head over to the pandoc site and get the new version now. They have prebuilt packages so installation is easy.

Posted in General | Tagged , | Leave a comment

What’s It Take?

Those of us in the US have ample reason to despair of our legislators’ willingness to collude with the NSA in the evisceration of the Fourth Amendment. But at least our congress draws the line when it comes to spying on them. Sadly, the same is not true of our cousins in the UK.

Computer Weekly is reporting that MPs’ private emails are routinely accessed by GCHQ. Yet Parliament goes right on passing draconian surveillance bills. The MPs are even moving ahead with the Investigatory Powers Bill that would expand GCHQ’s abilities to snoop on UK citizens.

What does it take to make Parliament finally say enough is enough and rein in a clearly out of control GCHQ? The MPs are theoretically protected by the Wilson Doctrine, which says that MP communications are off limits without consent from the MP involved. However, a recent move to Microsoft Office 365 for Parliament’s email means that the email is often routed through Microsoft datacenters in Ireland or the Netherlands. Since that means the messages leave the UK’s borders, the GCHQ has felt free to scan MPs’ messages including those from constituents.

When the new system was being planned, there was some concern about this sort of thing happening. MPs were assured that while there might be some risk, it was low and acceptable. One’s tempted to say they deserve what they got except they don’t. MPs are the nation’s law makers and they certainly deserve to have their private communications remain private. Again, what will it take before they start insisting on that? What will it take before Britons, generally, insist on the same?

Posted in General | Tagged | Leave a comment

A Checklist for Backdoor Proposals

The ludicrous and unworkable Burr-Feinstein bill appears dead, a victim of its “do magic somehow” prescriptions and a lack of support from the White House and intelligence agencies. Nonetheless, we can expect more of the same perhaps even from the same know-nothings that gave us Burr-Feinstein.

Daniel J. Weitzner (and others) over at the Lawfare blog have a nice checklist to help evaluate new backdoor proposals. The six items on the checklist are not so much technical as common sense. For instance, number 6 is “Watch for the assumption that human rights and the rule of law prevail throughout the world.” Taken together, the items represent a high but minimal bar that any proposal should meet.

Since the checklist non-technical, it would be nice if our legislators would consult it before churning out more irrational and unworkable legislation. On the other hand, it is, as I say, common sensical so they probably won’t.

Posted in General | Tagged , | Leave a comment

Running Unit Test with Org Mode

Frédérick Giasson has a nice post in which he describes how he uses Org mode to run unit tests on his code. Actually, his goal is to combine the writing, documentation, and testing of his code in a single document using a single tool.

His mechanism for this is to use Literate Programming in Org and to put the tests in the same file next to the function that they’re meant to test. He describes this in terms of Clojure but the technique is obviously generally applicable.

One possible problem with this procedure is if you’re working in a team and not everyone is an Emacs user. Non Emacs users won’t be keen to tangle an Org document to get the code and probably won’t feel comfortable making changes to an Org file. Unless everyone you’re working with is an Emacs user or you’re working alone, this means that Giasson’s workflow will have to be limited to initial development. Still, it’s a powerful technique and well worth experimenting with.

Posted in Programming | Tagged , | 1 Comment

Date Calculations in Org

One of the things that always causes confusion and that is hard to find in the documentation is making date calculations in Org. I was reminded of that when I saw a reddit question on making date calculations in an Org table. The comments to the question give some useful hints.

After I read the reddit query, I remembered that Sacha had, of course, already already covered this material so you should take a look at her post too. One of the things that Sacha points out is that it’s important to use “proper” Org dates—that is, active or inactive dates with the […] or <…> brackets. That ensures that you can perform arithmetic on them directly without having to worry about converting from string to date.

As I said, these two posts are useful because it’s hard to locate the documentation that covers the subject. Once you get in the habit of storing information like this in Org tables, you’ll find that techniques like these are really useful.

Posted in General | Tagged , | Leave a comment