Reformatting JSON

A long time ago, I wrote about a way to prettify JSON. It had the advantage that it didn’t require you to load a heavyweight package such as js2-mode when all you wanted was to reformat some JSON in a reasonable way. The downside was that it called a Python module, json.tool, to do the work. That’s OK unless you don’t have Python installed or don’t want to shell out to an external process.

Now Wataru Miyaguni has an Elisp solution that doesn’t require you to shell out to an external process. The json-reformat package reformats JSON into a standard format. If, like me, you don’t write in JSON enough to justify use of one of the heavyweight JSON packages but nevertheless occasionally want to reformat JSON into a publishable format, this could be just what you need.

Posted in General | Tagged | 0 Comments

Metadata and You

I know it’s preaching to the choir and even to me it seems like the gazillionith time I’ve written about it but we really must convince our friends and neighbors that metadata isn’t some harmless bit of information that’s on our phone bills anyway. After all, if metadata really were harmless and unrevealing, the NSA wouldn’t be so eager to collect it, would they? A recent article in The Guardian describes a study which shows that sensitive data about your life is easily discerned by examining metadata.

The study’s participants installed an application on their phones that recorded who they called and the duration of the call. Given that these were all volunteers, there’s some self-selection bias here but you’d think people with something to hide wouldn’t be signing up (although one participant was pretty clearly growing pot, so maybe they would). Another person was found to be almost certainly suffering from Multiple Sclerosis and a third to have just discovered that she was pregnant.

There were calls to Alcohol Anonymous, NARAL, gun shops, divorce lawyers, STD clinics, and strip clubs. Notice that with the possible exception of the pot grower, none of these activities are illegal or even particularly exceptional. They are, however, private matters that most people wouldn’t care to have made public and that’s the point. We hear over and over that “if you’re not doing anything wrong you have nothing to fear.” This study shows just how wrong that is.

The Guardian article is useful to point at when you’re trying to educate your less security-savvy friends about the dangers of metadata.

Posted in General | Tagged | 0 Comments

An Org Mode Cookbook

As you all know, I’m always talking up Org Mode and encouraging people to try it out. Org is so flexible that I spend a large percentage of my Emacs time in it. Where others might use a spreadsheet, I just use an Org table with automatic column or row calculations. Where others use Word or some like spawn of the devil, I use Org Mode and export it to whatever form I need. Where others torture themselves by writing blog posts in WordPress’s built-in editor, I use Org Mode with all the power of Emacs and then automatically post it to the Irreal site with org2blog/wp.

All that capability comes with a downside, though. It’s hard to get started and learn what you can do. Like Emacs itself, it’s easy to be overwhelmed by sheer magnitude of what’s included in the box. Until now, the most useful sources of information were the Org Manual (of course), and Bernt Hansen’s Org Mode – Organize Your Life In Plain Text. Hansen’s article is particularly useful because it’s a (constantly updated) Org file that documents how he uses Org Mode along with examples that demonstrate the various aspects of Org. The examples serve as an excellent go-by for the new user. When I was first starting with Org, I’d find an example of what I was trying to do in his document and mimic what he did. If you’re an Org Mode user (new or not) you really should take a look at it.

Now Eric Neilsen has produced a document similar but complementary to Hansen’s. His Emacs org-mode examples and cookbook is like Hansen’s Organize Your Life In Plain Text in that it serves as a cookbook with recipes for performing various tasks in Org Mode. Although there is a bit of overlap, Neilsen concentrates on producing LaTeX documents and with interacting with Python and R. While Hansen’s document is (mostly) concerned with things a consultant might want to do, Neilsen’s is more oriented to the needs of a researcher. His guide will be especially useful to someone wanting to produce publishable papers—especially for papers produced using the reproducible research model.

Neilsen’s cookbook is an excellent addition to the must-have Org documentation. I’ve added it to my Docs bookmark in my browser. Take a few minutes to look it over and I’m sure you’ll want to do the same thing.

Posted in General | Tagged , | 0 Comments

Emacs Focus Hooks

Bozhidar Batsov continues his excellent series on the upcoming Emacs 24.4 release with a post about new hooks for when frames go in or out of focus. As Batsov explains, that allows you to easily save the current file or even all files when a frame goes out of focus.

As with some of the other enhancements in 24.4, you probably won’t be using this facility every day but it does, as Batsov says, move Emacs towards the goal of making everything possible from the user level.

Posted in General | Tagged | 0 Comments

Variadic Comparisons in Emacs Lisp

One of the ways that Emacs Lisp differs from other Lisps is that it doesn’t support multiple arguments for comparisons. That is, you can’t write things like

(if (= a b c) do-this else-do-that)

or

(when (< a b c) ...)

You can still express those comparisons, of course, but you have to connect two or more two-argument comparisons with and.

Now, as Bozhidar Batsov points out, that’s about to change. Emacs 24.4 will support variadic comparisons. That’s not a huge change but it does bring Elisp in line with other Lisps and makes it easier to express complex comparisons concisely and clearly. As I wrote before, I’m really impressed with this release and looking forward to its availability.

Posted in Programming | Tagged | 0 Comments

Cory Doctorow on the Politics of Copyright

Cory Doctorow appears in an interesting video where he discusses the politics of copyright and how our current policies just don’t make any sense. He repeatedly applies those policies to other areas where everyone can see how ridiculous they are. Somehow, though, as soon as we start talking about “media” people think it all makes sense.

The video is about 17 minutes long but well worth your time. Watching it made me angry at how stupidly we’re behaving and that no one can see that the purpose of copyright as currently applied is the preservation of the business models of a few large conglomerates. It’s shameful, really.

Posted in General | Tagged | 0 Comments

Tutorial on Using Org Mode to Write Papers

Arne Babenhauserheide has posted another great how-to on using Org Mode. This time it’s on using Org to write technical papers for publication. As with his previous post that I wrote about, this one can be exported to HTML or PDF but renders nicely in either format.

Some of the post is specific to the ACPD Journal but is easily extended to any other journal given their LaTeX style sheet. The nice thing about the tutorial is that it takes a reproducible research approach to writing scientific papers. As faithful Irreal readers know, I’m a big fan reproducible research and hope to see it become the standard for all journal papers.

If your situation requires the publication of papers and you’re an Emacs user, you should take a look at this post. These days, I do almost all my writing through Org Mode and I’m always happy to see ways to see it used for other writing tasks.

Posted in General | Tagged , | 0 Comments

Emacs 24.4 Desktop-Save-Mode

Like many Emacs users, I keep Emacs running continuously on my machines. To maintain the illusion of a constantly running Emacs, I use desktop-save-mode to maintain my configuration across invocations of Emacs or even reboots. Other than things like forgetting my org2blog/wp password, Emacs presents a consistent representation of my work space even if Emacs or the OS restarts.

As Xah Lee explains, Emacs 24.4 expands on these capabilites. These are not huge improvements but incremental changes to make our work flows a bit better. Hop on over to Lee’s post to see what these improvements are.

The more I find out about Emacs 24.4, the more impressed I am. The new release is looking to be a great improvement. Between Lee, Bozhidar Batsov, and, of course, Mickey we’re getting a preview into a really great new release.

Posted in General | Tagged | 0 Comments

Superword- and Subword-Mode in Emacs 24.4

If you like—or are forced to use—camelCaseWords, Emacs has subword-mode that will cause word-based cursor movements to stop at each of the individual words. This can sometimes be useful when you repeatedly need to move to one of the constituent words of a series of compound words.

I rarely have a need to edit camel case words so I never need subword-mode but often have a related problem. In Emacs, when the cursor is in front (or behind) of compound-word or compound_word, moving by word will stop at each constituent word. That’s seldom what you want. You’d like to jump over the whole thing because you’re normally thinking of it as a single word.

As Xah Lee tells us, Emacs 24.4 will have superword-mode that will treat things like compound-word as a single word. That will be handy for programmers who often deal with compound-words or other_compound_words. Lee’s post has the details but notice how the two modes achieve a unification: with subword-mode you always move by word constituents; with superword-mode you always move by the entire compound word, no matter how it’s formed. That’s why the two modes are mutually exclusive.

Posted in General | Tagged | 0 Comments

Writing Books with Org Mode

Oscar Perpiñán Lamigueiro is writing a book. Lots of people do that, of course, but Lamigueiro is doing it with Org Mode. Just the other day, I wrote that Emacs is multifaceted and Lamigueiro demonstrates another of those facets and a pretty high powered one at that.

If you’ve wondered how one might go about producing camera ready copy for a technical book, give Lamigueiro’s post a read. You should also take a look at the Memoir Class documentation that he mentions in the post. I don’t know about you but I love reading things like this. It’s always great to see how people are using Emacs, especially if it’s in ways I haven’t thought of.

Posted in General | Tagged , | 0 Comments