Escaping Org Examples in Org

From Karl Voit we have this really useful piece of advice:

If you follow the link to Stack Overflow you'll discover the proper way to include Org markup as an example in an Org file. For a trivial example of this see yesterday's post in which I included a small bit of Org markup.

The idea is that you put the example in an Org source block rather than, say, an Example block:

#+BEGIN_SRC org
With a bunch of other stuff
#+END_SRC


but that's not quite enough. In my Org source file for this post the above was entered as:

#+BEGIN_SRC org
,#+BEGIN_SRC org
With a bunch of other stuff
,#+END_SRC
#+END_SRC


As you can see, the Org markup that you want to appear as the example (and not be acted on) is escaped by a comma. Although the Stack Overflow post does not make it clear, the easy way to do this is to insert the #+BEGIN_SRC org and #+END_SRC markers and then call org-edit-special, which is normally bound to 【Ctrl+c '】, and enter your Org example without worrying about escaping. When you finish by typing 【Ctrl+c '】 again, Org mode will automatically add the escaping for you.

I'm really glad to learn this trick. Trying to add Org mode markup in an example never worked well for me. Yesterday, I saw Voit's tweet and, serendipitously, was able to use it immediately in my next post.

Posted in General | Tagged , | Leave a comment

Two New König Videos

Rainer König has posted two new videos in his OrgMode Tutorial series. Unfortunately for him but fortunately for us it's raining in Augsburg so König has had to forego gardening in favor of making more of his excellent Org Mode videos.

This time he discusses dynamic blocks and habit training. Unless you're really an Org mode expert, there's sure to be a lot of things you didn't know in the videos.

The first video talks about dynamic blocks. You may be familiar with them for displaying clocking data but they turn out to be much more general. It's easy to set one up: you just add

#+BEGIN: function <parameters>
#+END:


to your Org file. The function identifier on the #+BEGIN: line represents the name of the function to generate the dynamic block. You can add parameter name/value pairs if necessary.

There are two builtin functions—clocktable and columnview—to cover the common cases of building dynamic blocks of clocking data and columnview representations. These are useful since the clocking data and columnview representations are normally buffer overlays and there's no way to capture or export them. By building a dynamic block you get normal text that you can process however you like. See the video for the details on how to generate these dynamic blocks. There are keyboard shortcuts so you don't have to bother with adding the #+BEGIN:/#+END: markers.

The second video considers habit tracking. The idea is that you have some periodic task that you want to establish as a habit—practicing an instrument, say—so you tell Org mode that it's a habit you want to track and how often you want to do it and Org mode will provide a nice graphic in your agenda tracking your performance. You handle them just as you would TODOs. When you complete a task you mark it complete and Org tracks it for you. König has an excellent demonstration of this with his own bass and guitar practicing.

As always, these are excellent and informative videos. The two video are 13:12 and 12:37 (min:sec) long so you should have no problem scheduling them. As I've said before, these videos are the best introduction to Org mode that I know of and I can't recommend them enough.

Posted in General | Tagged , | Leave a comment

Configuring Emacs for PHP

Ben Simon has a nice post on setting up Emacs for PHP. I don't write in PHP and have no plans to start but Simon says it's hard to get an intelligent setup for it that works for all PHP coding styles.

Simon recommends using php-mode from Melpa instead of the one that comes built into Emacs. That works well for files that are strictly code but for files that have markup he recommends web-mode. He gives his configuration for both packages; they should provide a good starting point for your own setup.

If you like autocompletion, you might also want to try ac-php. Simon shows a configuration for that as well. Simon offers step-by-step installation and set up instructions for each of these packages and says that together they make for a modern PHP development environment.

Posted in General | Tagged | 1 Comment

Common Lisp and Pink Floyd

Common Lisp and Pink Floyd. How could it get better than that?

Posted in General | Tagged , , | Leave a comment

Resistance is Futile...

…you will be assimilated:

Data Sharing in Publications

John Kitchin has a really interesting article in ACS Catalysis on Effective Data Sharing in Scientific Publishing. In it, Kitchin discusses various strategies for embedding supporting data—such as tables and processing code—in a publication's PDF or source file so that other researchers can recreate the results or use the data for further analysis.

He begins by noting that one can simply embed supporting documents directly in the PDF, $\LaTeX$ or Word document. The problem with that method is that it's easy for the actual data and its representation in the final paper to diverge.

A better solution, Kitchin says, is to use Org mode and generate the published tables and results directly from data embedded in the manuscript source. Followers of Kitchin's blog (or even Irreal) will recognize that this is Kitchin's longtime publishing process. He and his group write their papers in Org mode along with the supporting data and code. That way, future researchers have everything they need to reproduce and extend the results.

If you're interested in using Org mode to write papers or in reproducible research, you'll enjoy Kitchin's paper.

Say What?!?

I don't have the words…

Posted in General | Tagged | 3 Comments

Reading Code with Emacs

I have long believed that one of the best ways to move from journeyman to master coder is to read the code of the masters. I learned most of my advanced C techniques by reading the Unix source code. Other languages have different masters that you can learn from. Nathaniel Knight has a post that suggests some convenient methods of reading code with Emacs. These boil down to learning the marking and narrowing commands.

Once you learn to conveniently mark expressions and functions, for example, you can narrow to the region and look just at the code you're interested in. That may not seem like a huge win but as Knight explains, it often makes working with the code easier. Once you get in the habit of using narrowing, you'll want to take a look at Artur Malabarba's excellent post on narrow-or-widen-dwim. It's really great because you need only call a single command and it figures out what you want to do by context. It's a huge timesaver.

Knight also covers the little-known clone-indirect-buffer command. That's just what you need when you want to narrow to two (or more) separate areas at the same time. Again, the utility of doing this may not be obvious but it turns out to be tremendously useful. One common use case is where you have different types of code in the same buffer. You can clone the buffer, narrow to the desired code segments, and then work in the appropriate Emacs mode for each segment independently.

You can follow Knight's recipe for doing this but there's an easier way. The code discussed at the link is just a little bit of Elisp to automate the cloning and narrowing steps but it's a real time saver. Follow the link to Zane Ashby's post (at the easier way link) to see an example of the use case I mentioned.

Posted in General | Tagged | 1 Comment

Scimax

The ACM Technews newsletter has a short piece on John Kitchin's Scimax project. Here's the CMU article on Scimax, which gives an overview of the project.

Basically, Scimax is the collection of (mostly) Elisp utilities that Kitchin has put together to help with his group's writing and publishing of papers. It features using Org mode to write the papers in a reproducible research way and then publish them to the format required by the journal they are submitting the paper to. There are also some tools to aid in teaching. For more details, check out Kitchin's Scimax page.

The nice thing about Scimax is that all the utilities are packaged up into a single project repository that anyone interested can download and use. The project is hosted on Github if you're interested.

Posted in General | Tagged , | Leave a comment

Mark Rectangle

If you're like me you don't often have occasion to mark rectangles so it's easy to forget how simple it is to do. Here's a nice reminder from Tony Garnock-Jones.

Posted in General | Tagged | 3 Comments