Numbering Org Table Rows

Álvaro Ramírez tweeted a handy tip that I used to know about but had forgotten:

Lots of tables need a row number and using this tip it’s easy to add them when you’ve finished making the table rather than putting them in as you go along. That’s especially handy if you decide to reorder the rows.

Normally mc/insert-numbers will start the numbering at 0 but you can change that with a prefix argument. Long ago I mapped that function to Hyper+~ but I like the way Ramírez maps it to # in the region-bindings-mode-map. That makes it much more intuitive and easy to remember. Maybe if I’d done that to begin with, I wouldn’t have forgotten about it.

Posted in General | Tagged , | Leave a comment

Running Your Life With Emacs

I’ve written a lot about how I hate leaving Emacs and find that its consistent UX and key bindings make a huge difference in the efficiency of my workflow. Not everyone agrees. Many people think I’m being overly sensitive when I say that I can’t effectively use multiple editors because the different key bindings mess with my muscle memory.

On the other hand, Garrett Hopper agrees with me. In a post entitled Running Your Life With Emacs, he says

…I often want to use the same efficient key bindings I use while programming when I’m doing other tasks. I want to be writing an email or documentation and edit a code snippet in the same way I normally edit code. I want to manage Git repositories right from my editor without having to touch the mouse. I want to browse the web in my editor, so I can easily copy code examples and run them. I want to track my to-do lists and the amount of time spent on each task.

That’s an excellent summary of my feelings.

Hopper says he hates switching context and that by doing as much as possible in Emacs, he reduces it to a minimum. He even does much of his browsing in Emacs. I find that eww doesn’t render sites reliably so I have a hard time embracing it. Almost all my time is spent in either Emacs or Safari so eliminating my reliance on Safari would mean I would almost never have to leave Emacs. I can only hope.

The rest of the post covers the many advantages of Emacs including

  • Discoverability
  • Built-in documentation
  • Customizability
  • A rich package system
  • and, of course, Org Mode

It’s an interesting post and if you’re an “everything in Emacs” adherent, it provides some self affirmation.

Posted in General | Tagged | Leave a comment

Goto

Everyone in our field knows about Dijkstra’s famous paper Go To Statement Considered Harmful but how many have actually read the paper or know what his arguments were? Mostly we use it as a template to generate memes of the form “\(X\) Considered Harmful.”

Vivek Haldar has a video blog entry in which he reads the paper for us. “Read” means he goes over the paper in detail and talks about the arguments that Dijkstra makes. The paper is short—only one and a half pages—so this isn’t as tedious as it might sound. The video itself is just short of 6 minutes. If you haven’t read the paper, you really should watch the video if only to know what you’re talking about when you invoke Dijkstra’s name.

Dijkstra makes his argument in technical terms. A more succinct and approachable take is presented by Professor David Brailsford in the excellent Computerphile video, GOTO, Goto & Goto. In it, Brailsford says that the point of eliminating gotos is to make our intentions clear. Consider the while loop

while (x > 0)
{    
    do_something_with(x);
    x = x - 1;
}        

and its implementation with gotos

l1: if (x <= 0)
        goto l2;
    do_something_with(x);
    x = x - 1;
    goto l1;
l2:            

No one with more than a week’s experience will have the slightest difficulty understanding the while loop with a single glance but the goto version—especially with a less trivial example—is harder to understand because it’s not immediately clear that we have a loop. What’s the purpose of that first goto, for example? Without reading further down we can’t tell if it’s part of a loop, a simple if statement, or something else.

The Computerphile video, along with some silliness with a Rubik’s cube at the end1, is about five and a half minutes so you can watch both videos in less than a dozen minutes. You should: they’re both worthwhile.

Footnotes:

1

Involving the two Gotos at the end of the video’s title

Posted in Programming | Tagged | Leave a comment

Dealing with GitHub Pull Requests in Emacs

Laurent Charignon has an very nice package for dealing with GitHub pull requests from within Emacs. His package, github-review, allows you to retrieve the pull request from GitHub and deal with it entirely within Emacs. You can even work off-line if you retrieve the pull requests first.

When invoked, github-review displays the description from the PR and a diff of the proposed changes. You can add additional comments or code snippets to the buffer. After reviewing the PR, you can accept, reject, or comment on it and have the results returned to GitHub.

Besides the obvious benefit of not having to leave Emacs, you can easily see related code to provide better context. If you often deal with PRs, this package seems like a real win. It’s probably worthwhile even if you only occasionally have to deal with them. The interface is simple and easy to use. Although Charignon says it’s not yet in Melpa, it’s been added since his post.

Posted in General | Leave a comment

How and Why To Normalize Unicode

From the excellent TeX Tip twitter feed, I found a pointer to an excellent article by Alessandro Segala concerning something I didn’t know much about and that many Irreal readers might not know about either: how and why to normalize unicode. If you’re like me, you haven’t even heard of normalizing Unicode before.

The problem stems from the fact that many Unicode characters have more than one representation. The example that Segala gives is the character ë. It can be represented as either a single Unicode character or as the composition of two: the lowercase ‘e’ and the umlaute, ‘¨’. In both cases the displayed result is the same, ë, but the internal representation is different.

This matters a lot when you’re checking for equality, as in a search say. If someone enters their name as Zoë you may not find it in your database if it’s stored in a different representation. Unicode normalization is a way of solving this problem. The idea is to convert all representations of ë to a single one. According to Segala, there are 4 standard representations and you can use whichever is more convenient but the goal is to have all characters use the same one.

Happily, there are standard library functions to do this. For example, in JavaScript you can use the built-in function String.prototype.normalize() to do it. Take a look at Segala’s post for details and more information.

Posted in General | Tagged | Leave a comment

EmacsCast #8: Writing

Rakhim Davletkaliyev is back with another episode of his Emacs podcast, EmacsCast. This time he presents part one of a two-part series on writing in Emacs and Org mode. My first thought as I started to listen to the podcast was, “Mwa Ha Ha, he’s now been totally assimilated into the Emacs Borg.” I don’t know if that’s really true or not but in the first episodes he made a point of saying that he wasn’t looking to switch editors, he just wanted to experiment with Emacs and see what all the excitement is about. Since then, he starting using Emacs and Org mode to produce his blog(s) and was doing more and more of his work in Emacs.

This podcast documents his continuing journey down that road. The current episode concentrates on using Emacs for writing. Davletkaliyev says that he now does all his writing in Emacs and Org mode and he spends most of the podcast—after his usual recap of recent configuration changes—discussing how Org mode makes writing easier and is really the best tool he’s found for writing projects.

He begins by noting that Org mode matches his default writing method. He likes to start with an outline—maybe as simple as a list of chapters, perhaps more detailed—and then “fill in the blanks.” He describes the outline as a skeleton and adding the actual content as putting meat on the skeleton.

One common use case in writing is having the text open in two different windows. For example, a complicated novel may have several niche characters and it’s helpful to have a list of their names and other information about them available while writing the story. Or you may want to keep your outline open in one window while working on a particular chapter or scene in another window. That’s basically the setup that Jay Dixit uses. In either case, Emacs’ indirect buffers are exactly what you need. Davletkaliyev talks about that in some detail.

Finally, when the writing’s done you’ll probably want to export to some other format such as PDF, HTML, or docx/ODT. Org mode makes that easy, either directly or through its interface to Pandoc. Davletkaliyev talks about a book he’s writing that he exports to several formats. He has things set up so that when he saves the source document, all the other formats are generated automatically.

He promises to discuss more use cases in part 2 of the podcast. The podcast is just short of 26 minutes and definitely worth listening to when you have a half hour to spare.

Posted in General | Tagged , | Leave a comment

An Afterword on Being Almost There

In a comment to my recent post on achieving a digital life, Zarniwoop asks about the risks of putting all my eggs in one basket if everything I need for everyday carry is on my iPhone. That’s a question I often get when I talk about folding as much as possible into my phone.

While it’s a good question, I don’t find the concern compelling. Zarniwoop asks particularly about what happens when the power fails but there are other ways things can go wrong. The potential problems that I see are:

  1. My iPhone could get lost or stolen.
  2. I could run out of power or break it.
  3. Using a phone to do things like open doors and start cars broadens the attack surface for criminals.

The thing is, these are problems for the current solutions as well and I think a cogent argument can be made that putting things on the phone actually reduces the risk. Let’s take a look at each problem in turn.

It’s true I could lose my phone or have it stolen but for me, at least, that’s pretty unlikely. It’s unlikely because I almost always keep it in my pocket when I’m not using it and even if I put it down, it’s always right in front of me and I never leave it unattended. Sadly, I’m pretty obsessive about making sure I always have my phone with me, even if I’m at home.

I’ve never lost my phone or left somewhere. On the other hand, I have lost my wallet. More than once. Wallets are, I think, easier to lose than phones and when you do it’s a lot harder to replace the wallet’s contents than the phone’s contents. Losing my wallet means a trip to Department of Motor Vehicles and hours of soul-sucking time spent waiting in line to get a replacement license. If my license is on my phone, all I need to is replace the phone and do a restore. Furthermore, while documents on my phone are not impossible to get at, they’re a lot harder to exploit than those in a lost wallet. Just ask the FBI.

Similarly, my habits make it very unlikely that I’ll run out of power. First of all, I hate talking on the phone so my iPhone serves mostly as a mobile computer and only secondarily as a phone. I can go days without making or taking a call on it. Secondly, I’m punctilious about charging my phone every night. I rarely get below 90% power. If I did, auxiliary batteries are cheap and easy to obtain. And as much as I hate spoiling the lines of my phone, I have it in a case that does a pretty good job of protecting it from drops so while still a small concern, I don’t worry much about damage.

Finally, security is always a concern but I think those problems are less severe when everything’s on my phone. While it seems like using a phone to open your front door is just asking for trouble, it’s really no worse than the traditional key and deadbolt. These days, keys are ludicrously easy to duplicate from a photo—even a far shot will suffice. And as many hackers will tell you, they’re also easy to pick. Choosing a good electronic lock that provides routine firmware updates—such as the August lock I mentioned in the previous post—will go a long way towards giving you a more secure door.

As for cars, the problems with key fobs are legion. Criminals are intercepting and cloning their signals and using them to steal cars. Worse, according to the article on Hyundai’s plans for a digital key, many people are leaving their key fobs in their cars making it easy for the car thieves. Again, everything depends on a secure solution but with a little care for security—not that car manufacturers are particularly good at that—the digital key should be at least as secure as the current system. It could hardly be worse than key fobs.

This is a long post—longer than the original—but it explains once and for all why I don’t worry much about having everything on my phone. Your circumstances and habits may be different from mine so I don’t insist that you should reach the same conclusions but a least you know where mine are coming from.

Posted in General | Tagged , , , | Leave a comment

A History of the Development of C

Someone posted a pointer to an old (1994) paper of Dennis Ritchie on the development of the C language. I haven’t read it in years and it was interesting to revisit it. The paper, along with several others describing aspects of C and Unix, are available on Ritchie’s home page that AT&T still maintains.

I’d forgotten some of the details that he reveals such as why the default name for a Unix executable is a.out and why the precedence rules for the & and == operators are not what you think they should be. If you’re a C programmer, most of the structure of C seems obvious and just what it should be but, in fact, Ritchie struggled with many of the ideas and they were unconventional, if not controversial, at the time.

Most of us know that C is derived from the B language which was in turn derived from BCPL but the paper provides the details of that derivation and how the languages differed. Many of the features that make C so powerful and useful came directly from its predecessors.

C, of course, is credited with making Unix portable but that was not its original goal. The programmers simply wanted a higher order language than assembly in which to build their programs. Indeed, many Unix utilities were first ported from assembly to B and only later to C.

There’s all sorts of interesting historical and technical tidbits in the paper and it’s well worth a few minutes of your time, especially if you’re interested in Unix history or programming languages.

Posted in Programming | Tagged , | Leave a comment

Almost There

As regular readers know, I try to live the digital life as much as I can. By “digital life” I mean eschewing paper and paper processes and running as much of my life as possible with my phone and computers.

One of my goals for that digital life is to be able to leave the house and conduct my affairs with nothing but my iPhone. I’m almost there. My current everyday carry is down to just three things:

  1. My iPhone XR
  2. A Slim Clip Wallet for drivers license and credit card
  3. My House key and, if I’m driving, the car key.

I’m close to eliminating numbers 2 and 3.

These days, most cars use an RFD key fob to open the doors and start the engine. There’s no reason this couldn’t be done from a smartphone and, indeed, Hyundai is planning to do just that on next year’s model. Once Hyundai or some other car maker introduces this, the others are sure to follow. There are, of course, security concerns but Hyundai’s implementation appears more secure than the current key fob solution.

For the front door there are several keyless solutions. I want one that I can use my phone to unlock the door with. One of my (security knowledgeable) family members uses the August Smart Lock (there’s a later version) and swears by it. He can even issue temporary codes for guests and workers. I can install this at any time so I’m theoretically down to two must carries.

The final item to eliminate is the wallet. That means getting rid of my credit card and drivers license. Apple Pay has almost eliminated the need to carry credit cards. More and more big chains are adopting Apple pay; I’m mainly waiting for my grocery store (Publix) and couple other smaller venues to get on board.

That leaves only my drivers license. Happily, Florida has bills pending that would implement a digital license stored on your smartphone. Once passed, I’ll no longer need to carry my license except maybe when flying or voting or something similar.

I expect that in the next year or two I will be able to feel comfortable leaving the house with only my phone.

Posted in General | Tagged , , | Leave a comment

Guess What Day It Is

No, not hump day. It’s the 46th anniversary of the release of Pink Floyd’s iconic Dark Side of the Moon. As I do every year on this date, I’d like to say, “Happy Birthday” to one of the greatest and most successful albums of all time.

As I’ve written before, even though “Money” and “Time” were the two cuts from the album that became hit singles, most observers—at least this observer—consider the last two songs, “Brain Damage” and “Eclipse” to be the enduring masterpieces from the album.

I say something like that every year so this time, I’ll let you judge for yourself:

The video is from 1994. Roger Waters had already left the band but this version is every bit as good as the original from the album. Enjoy.

Posted in General | Tagged , | Leave a comment