OrgMode Tutorial Episode 7, Snippet 5

It’s Christmas Eve and Rainer König has just landed his sleigh on the roof of the Irreal International Headquarters with a gift. After a long absence, he’s back with another episode of his OrgMode Tutorial video series. This time he looks at goal setting and tracking.

König considers two ways of using Org mode for recording and tracking goals. The first uses the PROPERTY drawer to set the type of goal in a normal TODO type file. König shows how to use column view to easily set and maintain these settings.

Then König considers the strategy of using a separate goals.org file. In this solution he uses a custom capture template to easily capture a series of fields for each goal. It’s a nice example of using a “fill-in-the-blanks” capture template that would be useful in many different applications.

The video is just a bit over 20 and a half minutes so you’ll probably have to schedule some time. It’s a nice example of using Org mode for one of its signature type of applications.

Posted in General | Tagged , | Leave a comment

Steve Purcell

Like most Emacs users, I depend on Melpa to install my packages and keep them up to date. I have a couple of packages from the other repositories but the majority of them come from Melpa. It’s easy to get grumpy when something goes wrong: there’s a build error, there’s a missing file, a package takes a while to get into Melpa, and so on.

The truth though, is that Melpa is a volunteer operation run by Steve Purcell. Everything that happens on Melpa happens because Purcell or one of his helpers spent their time doing it for free. I was reminded of that by this thread on Twitter:

If you click on the tweet, you’ll see that it started with Purcell saying he was 18 days behind in dealing with pull requests. To deal with that, Purcell spent 3 and a half hours on a holiday weekend to clear the backlog. As Murray says, we all owe Purcell thanks for a job well done and for donating his time for this unpaid but very important work.

Purcell lives in New Zealand so most of us are unlikely to run into him but if you do, be sure to give him your thanks and buy him a beer. It’s the least we can do.

Posted in General | Tagged | 1 Comment

Comments

One of the perennial programmer arguments—not quite up there with Emacs v. Vim but enduring nonetheless—is whether or not we should comment our code and if so, how. some folks say that the need for comments is a code smell: an indication that the programmer did not write the code clearly enough. If the code is clear and well-structured, they say, there is no need for comments.

I’ve been doing this long enough to know the truth of this bit of programmer wisdom. Sometimes I’m lazy and don’t adequately comment. I’m always sorry later. Nate Finch has an interesting post that claims this is always true. For everyone.

Finch says that except for trivial examples there are no bad comments. Some may be superfluous but even in that case they don’t really hurt anything and are certainly better than not commenting at all. At the other end of the spectrum, Finch says that the most useful comments are the “why” comments. These are the comments that tell the reader why you’re doing what you’re doing. They’re important because they capture domain knowledge that’s not implicit in the code itself.

In the comments (heh), John Martin observes that the ideal of self-documenting code is never realized in practice. Except, again, in trivial cases I think that’s true. This bit of Elisp:

(defun add-a-to-b (a b)
  (+ a b))

could, I suppose, be called self-documenting but any serious piece of code is unlikely to be so.

So the TL;DR for this post is: I agree with Finch. Comment your code.

UPDATE [2017-12-23 Sat 15:13]:

I was rereading this post and noticed that my example of “self-documenting” code inadvertently made the Martin’s larger point. I intentionally wrote it to be so obvious that no comments were needed but on rereading it I realized that I chose a misleading name, add-a-to-b. That name suggests something like \(b \leftarrow a + b\), which is not, of course, what the code does. So it turns out that writing self-documenting code even in trivial cases isn’t that easy.

Posted in Programming | Tagged | 1 Comment

flet, cl-flet and Dynamic/Lexical Binding

This is a post for Elisp programmers who have some Common Lisp (CL) experience. One nice feature of CL is the flet macro that lets you temporarily bind a function lexically. Emacs Lisp also has a flet in the cl library but it’s slightly different in that the binding is dynamic. If you’re not clear on what that means Chris Wellons has a nice discussion of the difference and a practical example of why the difference matters.

In Emacs 24.3 the cl-lib library was introduced to replace the cl library. Mostly that amounted to renaming the functions to have a ‘cl-’ prefix but cl-flet differs from flet in that the binding is lexical as in Common Lisp. In general, that’s a good thing because it makes Elisp consistent with CL as far as flet is concerned and is almost always the desired behavior. It turns out, though, that the old behavior was useful in certain circumstances such as stubbing out functions during testing.

Happily, there’s an easy solution. Both Wellons and Artur Malabarba explain the problem and the solution. Malabarba’s post is short and to the point while Wellons explains things in more detail. If you’re a serious Elisp programmer you should definitely read both posts. There’s a lot of confusion about flet and cl-flet and the two posts linked above do an excellent job of clearing things up.

Update [2017-12-22 Fri 13:36]: flexflet; cl-flexcl-flet

Posted in General | Tagged , | 3 Comments

Git-undo

John Wiegley has released a nice package that can be really helpful if your workflow involves tracking and saving your work with Git. Sometimes you do some work and then decide that you don’t want that change and would like to revert back to what it was. Wiegley’s git-undo makes that easy. You can mark a region and have that region replaced by the working tree or HEAD version of your Git tree. You can also walk back through your Git history undoing previous changes to the region in your Git tree.

It’s not yet in Melpa but it’s a single small file so perhaps Wiegley has no plans to submit it.

Posted in General | Tagged , | Leave a comment

PSA: Importing the OS X Path into Emacs

I’ve probably written about this before but this tweet suggests that not all Mac Emacs users are aware of it:

The exec-path-from-shell package is a must-have for the OS X Emacs user. Before I found it, I could never get the search path for Emacs configured correctly. Once I installed it, all those problems disappeared and I haven’t thought about them since. Really; if you’re using Emacs on a Mac, you need this.

Posted in General | Tagged | Leave a comment

Exporting DOCX/ODT Documents With a Style Sheet

Karl Voit has a really handy tip for those of you unfortunate enough to have to deal with Word (or its evil siblings) documents. Many folks in that cohort make do writing in Org mode and exporting to ODT. If you use Pandoc as your translation engine you can you can also export to DOCX and, as Voit explains, you can incorporate a template into the export so that, say, company styles and logos are respected by the exported document.

This turns out to be pretty easy but probably doesn’t work the way you think it does so you’ll want to be sure to follow the link to Voit’s post.

Posted in General | Tagged , , | Leave a comment

More Calc Recipes

Yesterday’s post on calc generated an interesting discussion in the comments. Frequent commentor Phil offers a particularly nice example of an easy way to add up a row or column of numbers. That’s something that while it doesn’t come up everyday, does occur often enough that it’s worth learning how to do it easily.

Phil also noted that reddit had a pointer to a post by Mark Hepburn that collected some calc recipes from Andrew Hyatt. These recipes and those from Chris Wellons in yesterday’s post are, I think, a good way to get familiar with calc. I’ve tried working through the manual to learn calc but I always got overwhelmed and had a hard time remembering everything. By learning some specific methods for performing useful calculations that come up in your work, you get familiar with how things work and what’s available. After that, it’s much easier to figure out how to do something new.

Posted in General | Tagged , | Leave a comment

Chris Wellons on Emacs Calc

In a nice piece of ironic serendipity, I found this reference to an old Chris Wellons post on Calc while reading my feed with Chris Wellons’ excellent feed reader, elfeed.

As I written a several times, I really like calc and am always amazed at its power. I have a shortcut key for it in Emacs but usually end up just using “quick” mode. That’s mostly because the power of calc comes at the cost of a certain complexity and I don’t use it often enough to internalize its interface. It’s not that calc has a stack based RPN interface—my oldest “computer” was a programmable HP RPN calculator—it’s the sheer number of functions and their sometimes abstruse commands that I find difficult.

Getting better at calc is perpetually on my TODO list. One year it was even a New Year’s resolution but, alas, life intervened and I failed. Reading Wellons’ post, which is a series of examples showing the power of calc, has inspired me to once again try to really learn it. That’s probably going to involve using it more often than I normally would even if that use is “just for practice.” If you have the slightest use for a calculator or sometimes want to do symbolic mathematics, you should take a look at the post. It may inspire you, too, to spend some time learning it.

Update [2017-12-16 Sat 16:19]: Fixed link.

Posted in General | Tagged | 16 Comments

The Dream Achieved?

Back in 2007, Mike Elgan wrote an article about The New Bedouins that really struck and excited me. In it he talked about a trend towards digital nomadism that was starting to take off. The “digital nomad” term was already 10 years old but the technology was finally in place to make it a reality. This was more than just “working from home;” it was the ability to work from anywhere in the world where you could find cell and WiFi service. As I wrote in 2011, this seemed natural and inevitable to us geeks but appeared positively weird to the rest of the population. A year later, even The Economist was taking notice.

For most of my career, I was trapped in a soul-sucking cubical farm and yearned for the freedom promised by the Bedouin life style. These days, many engineers wouldn’t consider a job that didn’t offer flexible workplace arrangements and it’s no longer strange or surprising to find folks working from some exotic location or even the local coffee shop. The practice has become so commonplace that Elgan has revisited the subject in another article declaring that the term “digital nomad” is now obsolete. It’s just something those who are inclined and have a job that makes it possible do. The same technology that makes it possible is used by everyone now and the term—which originally meant someone who used that technology that work from anywhere—is no longer needed.

I think the term is still useful to describe someone who practices workshifting but I take Elgan’s point. The dream has finally been realized. Some managers, of course, still resist workshifting but they’re likely the same ones who think open offices are a great idea and that software engineers are fungible.

Posted in General | Tagged | 2 Comments