Some Dired Tips

Tim Visher, who used to produce the popular VimGolf in Emacs Videos, has a couple of useful tips about using dired:

As a clarification, note that w copies the file name not the file itself into the kill ring. You can do several files at once by marking them.

I don’t think I’ve seen any of them before and they certainly aren’t on the dired cheat sheet that comes with Emacs. You can, of course, find the ‘w’ command in the dired help buffer but as far as I can see you have to check the documentation for dired-copy-filename-as-kill to get the information on the prefixes.

Posted in General | Tagged | Leave a comment

California Stores the DNA of All Babies Born in the State

What could go wrong? The iron law of data collection, that’s what. It’s been a while since I’ve written about the iron law, so here’s a quick recap: The iron law states: Whenever the government (or anyone else for that matter) collects data, two things are guaranteed:

  1. No matter the reason given for its collection, it will be used for more and more purposes.
  2. It will inevitably be abused.

Through the years, I’ve provided several examples of the iron law in action. California’s collection and retention of babies’ DNA is only the latest and it exactly parallels what happened in Sweden1: the DNA was collected with the rationale that it was needed for the testing and treatment of genetic diseases. It wasn’t long before law enforcement started showing up with warrants. In California’s case, the state can even sell the data to third parties for “valid scientific studies.”

Although California mothers are supposed to be told that they can request that the data be destroyed, they often aren’t and even when they are it’s with a mass of other new born baby information that all but guarantees it won’t be read. Efforts to have parental consent be opt in was beaten back by vested interests. You can read the article for the details.

The point, though, is what it always is: if you allow the data to be collected it will eventually be abused. The only way to prevent that abuse is stop the collection or in the case of such things as testing for genetic diseases that the samples be destroyed as soon as the analysis is completed.

Footnotes:

1

Ironically, in that post I said that such collection would be blatantly illegal in the U.S. That shows what I know.

Posted in General | Tagged | Leave a comment

Emacs Tools for Writers

As you all know, I’m fond of posts that show the versatility of Emacs by documenting its use by writers. At first glance, writing—a novel, say—seems to be the direct antithesis of what most of us use Emacs for. But when you think of it, it’s all just wrangling text and we all want to do that in the most efficient way possible. That’s were Emacs comes in.

Scott Nesbitt has a nice post entitled 5 Emacs modes for writers. Those five modes are:

  1. Muse,
  2. Org mode,
  3. Flyspell,
  4. WC mode, and
  5. WriteGood mode.

I depend on three of the five. I use Org mode for virtually all of my writing these days so I don’t need Muse. Applications like WriteGood mode remind me of my eighth grade English teacher so I avoid them for admittedly emotional reasons. I use a different app for word counting—also called WC mode—but either one will serve. Any or all of these tools will make whatever writing you do easier.

Nesbitt also mentions Fountain mode (if you’re doing screen manuscripts), Markdown mode (if you prefer Markdown or have to use it in some instances), and Writeroom mode (if you want to write on a blank screen). Years ago, Jerry Pournelle used to sing the praises of an editor called (I think) WRITE. It was for CP/M and would doubtless be considered primitive today but it had the virtue of being distraction-free by offering a blank screen with no tool bars or other widgets to seduce your attention. If that sounds attractive, give Writeroom a try.

Posted in General | Tagged , | Leave a comment

Making Slides with Org-reveal

Scott Nesbitt has an informative post on how to set up and use Reveal.js and Org-reveal for generating slide decks. There are several solutions for making slides that leverage Emacs and Org mode but Org-reveal is the simplest that I’ve seen. If you’re giving talks all the time, you should at least look at Beamer and it’s org interface but if you only occasionally need to generate slides and you’re looking for a simple, quick-start method, Org-reveal is just what you need.

Nesbitt’s post tells you how to install Reveal.js and Org-reveal. Note, though, that if you’re using ELPA, the name of the package is “ox-reveal” not “org-reveal.”

Once you’ve gotten Reveal.js and Org-reveal loaded, making a slide deck is simply at matter of writing an Org outline, where each headline corresponds to a slide. You can make subsidiary slides by using sub-headlines as described in the Org-reveal README on GitHub.

Nesbitt’s post shows you how to control the look of the slides and choose the transition technique. He also shows you how to include images. Check out the README for more detailed information such as how to include Mathematics, give slides headers, footers, and numbers, and a few other “advanced” techniques.

If you’re giving that talk tomorrow and don’t have time to waste, Nesbitt’s post will tell you all you need to know. If you have a bit more time, the README file in the Org-reveal repository will show you how to spruce the slides up.

Posted in General | Tagged , | Leave a comment

Batch Editing with ed

I’ve written before about the ed editor and the faithful who still use it today. A tweet by Mike Zamansky lead me to this Julia Evans post on batch editing files with ed. Evans has a typical editing problem: she wants to duplicate each line in several files that contain a certain string but also change the string to something else on the new line. See her post for the details.

She chose to do this by writing an ed script to make the change and then call ed with the script (presumably) as part of a larger shell script that does this for each file. My first thought was that this made sense even today because ed scripts have always been used in just this way and it’s still an easy and elegant solution. But then I got to wondering how I’d perform that task.

My inclination was to try some sort of Emacs trick, of course. Evans is a Vim user so she doesn’t have the awesome power of Emacs at her fingertips and can be forgiven for falling back to ed. Since we haven’t had an Emacs puzzle for a while, here’s a challenge: figure out how you’d use Emacs to get this done.

Zamansky, being less inclined to rush in, offers the following excellent Sed solution:

It’s probably hard to beat that solution even with Emacs but see what you can do.

Posted in General | Tagged , | Leave a comment

Spaces After Periods

I feel almost like a troll writing about this. The controversy as to whether there should be one space or two after a period is surely one of the most pointless of holy wars. Yet holy war it is. For those of you can came in late—that is, who grew up using computers instead of typewriters—the issue is whether typists should put one or two spaces after the period ending a sentence. The two spaces made sense for typewriters with their fixed-width fonts as it made the text slightly easier to read. When computers came along and everyone started using proportional fonts, the second space was no longer needed. At least that’s what the typography experts said.

Nonetheless, the debate raged on. Having learned to type on actual typewriters, I was for many years in the two space camp, if only out of habit. Around 2011, I changed to using a single space, adjusted my Emacs to recognize that as a sentence end (as related here), and have been happily conserving spaces ever since.

One of the reasons I say the argument is mostly pointless is that when documents are typeset, the composition software is probably going to ignore that extra space anyway. That’s something Avi Selk found out when he tried to insert an extra space in the headline to this Washington Post article on the controversy: it broke the formatting. And, sorry two-spacers, once he got it working it looked weird. Follow the link and see for yourself.

Both Selk’s article and a a similar one in Ars Technica by Sean Gallagher report the results of a study published in Attention, Perception, & Psychophysics that found two spaces slightly increased reading speed in some subjects.

Leaving aside the fact that the majority of psychological studies are not reproducible and therefore suspect, there’s plenty to criticize about this study on its own terms. Most glaringly, to me, is that the study tested its subjects using the fixed-width font Courier New 14. The researchers justified this on the grounds that the font was standard for this type of study but that misses the point: Of course the extra space helps with typewriter-like fonts. Everyone agrees about that; the question is does it make sense with proportional fonts. In any event, the modest increase in reading speed (≈ 10 words/minute) was seen only by those who used two spaces.

So the TL;DR is that we don’t really know more than we did before and the debate will continue unabated. The Washington Post article appears to favor the two-spacer camp while the Ars Technical article seems partial to the one-spacers. Go read both articles; there’s something for everyone.

Posted in General | Tagged , | Leave a comment

A Timestamp Hydra

It’s astounding how many “standard” formats there are for date/time stamps. Two or three years ago, I gave up my American provincialism on the matter and settled on the formats

  • 2018-05-09,
  • 2018-05-09 Wed, and
  • 2018-05-09 Wed 13:24.

I like them because they are unambiguous—unkike, say 10/11/12—and easy to parse programmatically. They also seem more logical because they move from the more general to the more specific. What kind of logical sense does “May 9, 2018” make?

Still, other folks prefer different formats such as ISO-8601, which I’d use except it confuses the civilians with the T and offset. Whatever your preferences, Grant Rettke has you covered with a hydra to generate timestamps in multiple formats. You may think it’s silly to have so many formats available but sometimes you’re dealing with entities that insist on a certain format and Rettke’s hydra let’s you use whatever’s appropriate. If your favorite format isn’t included, it’s trivial to add another.

Rettke leverages hydras for his workflow a lot and this is another excellent example of how their use can make your workflow easier. Some folks don’t like them but unless you fall into that category, you’ll probably find that they can ease your workflow by grouping similar tasks into a simple menu-driven interface.

Posted in General | Tagged | Leave a comment

SSH Tips

If you’re reading Irreal, the chances are that you’re also a frequent SSH user. Very often it’s because you have to log into servers or development boxes at work. I use it even at home to log into remote or local machines and, of course, for remote repositories.

One of the things that can be really annoying about using SSH, is remembering the domain and host names (which in some situations can even be an IP address) and dealing with the passwords. Happily, both of these problems are easily solved and Ivan Zinovyev tells you how.

Even better, Zinovyev gives you three other tips for making your SSH experience better. If you have long running (remote) applications or several connections to the same machine, Zinovyev shows you how to keep the session alive, even if the underlying connection goes down. He also shows you how to reuse a single SSH connection for multiple sessions.

None of this is hard and involves only a few additions to your ~/.ssh/config file, which you probably already have. If you’re using SSH, you should definitely take a look at Zinovyev’s post.

UPDATE [2018-05-10 Thu 18:41]: .sshr/config.ssh/config

Posted in General | Tagged | Leave a comment

Text Manipulation with Command Line Utilities

If your computing experience has always involved GUI tools, you may be unfamiliar or rusty with the command line tools that Unix provides. Similarly, if, like me, you do almost all your text manipulation from within Emacs, you might also be rusty with the command line tools. Happily, Kade Killary has a solution.

Killary has a very useful post entitled Command Line Tricks for Data Scientists that discusses those tools and how to use them for a variety of everyday text manipulation chores. Although the title mentions data scientists particularly, the information is useful for anyone manipulating data in their day-to-day work.

He covers the tools

  1. Iconv
  2. Head
  3. Tr
  4. Wc
  5. Split
  6. Sort & Uniq
  7. Cut
  8. Paste
  9. Join
  10. Grep
  11. Sed
  12. Awk

and gives examples of their use. For some of the tools, like Iconv and Head, he tells you everything you’ll ever need to know; for others, like Sed and Awk, he mentions just a few use cases and points you to the documentation for more details.

At the end of the post he gives a series of links to further information. One of those links points to this Sed introduction and tutorial. It’s the best tutorial on Sed I’ve seen so if you took the advice in my Sed post, you’ll definitely want to take a look and bookmark it.

Posted in General | Tagged , | Leave a comment

Emacs 26.1 Should Be Released Very Soon

Eli Zaretskii is asking the Emacs Devel list if there are any objections to releasing Emacs 26.1 in a week. That was on [2018-05-06 Sun] so we should be seeing the new Emacs soon. I’ve been running Emacs 26.1 RC1 for a while and haven’t had any problems. Some folks were pushing to get a couple more bug fixes in before the release but there doesn’t appear to be any show stoppers.

As always, congratulations to Eli, John, Nicolas, and the (many) others for their hard work. It’s really nice to have regular releases but it does mean a lot more work for the developers.

I almost missed this announcement but Sacha, as she often does, had me covered with her Emacs News list.

Posted in General | Tagged | Leave a comment