Org-mode 9.5 Is Out

Bastien writes to tell us that Org-mode 9.5 has been released. The big thing about the release is the new citation engine but there are lots of other changes too. You can see what’s in the new release by perusing the Change Log.

Org really is a jewel. The next time someone tells you that Emacs is old, dead technology, ask them why, then, all those other editors are so busy copying Org-mode and trying to port it into their own products.

Posted in General | Tagged , | Leave a comment

Make Scripts Executable Automatically

Bozhidar Batsov has a splendid tip over at Emacs Redux. I’m pretty sure he’s mentioned it before but it’s so useful it bears repeating. The tip is how to make scripts executable. “Scripts” means a file that has a shebang line. That is, a line that starts with #! followed by an application to execute.

The usual workflow is to write the script, save the file, and then change its permissions to make it executable. But it turns out that Emacs provides a better—or at least easier—way. The trick is to use the executable-make-buffer-file-executable-if-script-p command. It checks for the shebang line, makes sure that no execute bits are already set, and if not sets the execute bits respecting the umask.

The usual procedure is to call executable-make-buffer-file-executable-if-script-p from a hook function as described by Batsov in his post. If you’ve every written a script and tried to run it only to discover that it’s not executable, this tip will save you some time and frustration.

Posted in General | Tagged | Leave a comment

Easy Draw

The other day, I wrote about line drawing tools in Emacs. For those who like interactive systems, I mentioned ditaa, which takes an ASCII art diagram and turns it into a pretty PNG file. AKIYAMA Kouhei (misohena) has a project that offers a true visual drawing tool that runs in Emacs. Here’s a demonstration.

I haven’t tried it out yet but it looks pretty nice. The project is called el-easydraw. It’s not on MELPA and misohena doesn’t say whether he plans to add it but all the code is available on GitHub.

If you’re looking for a visual drawing tool for Emacs this is something you should definitely take a look at. It’s still early days for the project so it will be interesting to see how it evolves.

Posted in General | Tagged , | Leave a comment

Spanish Punctuation in Org-mode

The other day, I saw this tweet from John Cook’s TeX Tips Twitter account:

I was vaguely aware of this but had never thought much about it. Still, I do occasionally have a need for ¿ and ¡ so I wondered if it would work in Org-mode.

It turns out that it does if you use the TeX input method. I usually have that turned on for my blog posts so that the mapping --- \(\mapsto\) — works correctly. It turns out that it works in any text buffer, not just Org buffers. Now if I want an exclamation in Spanish, I can use !` to start it. ¡Perfecto!

Posted in General | Tagged , | Leave a comment

Another Piece Falls Into Place In The COVID Puzzle

The Intercept_ has just reported on a 2018 DARPA grant proposal for gain-of-function research on corona viruses. It’s another piece of evidence in the question of the provenance of COVID-19. That question is the contentious issue of whether COVID-19 had a natural zoonotic origin or was the result of a laboratory accident. There’s still no definitive answer one way or the other but many scientists in the field feel like this is a tipping point in favor of the lab accident hypothesis.

Why is that? The researchers proposed to build a virus exactly like COVID-19. In particular, they proposed to modify a bat coronavirus to have a furin cleavage site at the S1, S2 junction on the virus genome. That’s unusual—actually, unheard of—in SARS-related betacoronaviruses but is, in fact, exactly what COVID-19 had. That feature is what makes COVID-19 so contagious and deadly.

Who were these researchers? Those who have been following the story won’t be surprised to learn that the PI was none other than Peter Daszak who keeps popping up in this saga. He was, you’ll recall, behind the disinformation campaign insisting that a lab accident was a conspiracy theory. He was also part of the WHO investigation team that went to China and concluded, guess what, that COVID-19 had natural origins. Needless to say, he neglected to reveal this grant application and the obvious conflict of interest it entails.

This is a serious, existential matter. If it’s true that this was a lab accident, it’s an expensive wake-up call to stop doing this type of research before we manage to wipe out everyone. That sounds hyperbolic but here’s the Intercept_ quoting Stuart Newman, a professor of Cell Biology at New York Medical College,

Newman, a longtime critic of gain-of-function research and founder of the Council for Responsible Genetics, said that the proposal confirmed some of his worst fears. “This is not like slightly stepping over the line,” said Newman. “This is doing everything that people say is going to cause a pandemic if you do it.”

It’s time Daszak and some of the other players in this drama were subpoenaed to appear before Congress, put under oath, and asked what they know about the happenings in Wuhan. That may finally give us some answers.

Posted in General | Tagged | Leave a comment

Writing Elisp Functions

John Kitchin is back with another in his series of videos comparing Python and Elisp programming. This time it’s about writing Elisp functions. Earlier, Kitchin made a video discussing how to write Python functions. This video is a followup that reimplements the Python functions in Elisp following the original implementation strategy as closely as possible.

The video mostly focuses on handling the function arguments. The canonical Elisp function using defun is pretty straightforward. You call the function by specifying each of the arguments listed in the function definition with the possible exception of optional arguments. There are no keywords. Keywords can be included if you use cl-defun to define the function. That enables certain Common Lisp additions including keywords.

At one point, Kitchin wants to test if every value of a list of boolean values is t. The natural way of doing that is

(apply #'and list-of-booleans)

but that doesn’t work because and is a macro, not a function. Kitchin couldn’t remember how to do it and ended up using the -all? predicate from the Dash library. I couldn’t remember either but I did remember writing about it years ago. It turns out that it was 10 years ago so no wonder I didn’t remember. You can read that post for a discussion of the issues and the standard Elisp way of performing an and or or on a sequence of values.

Kitchin says he’s trying to get his viewers to the point where they can begin writing their own Elisp applications. The video is 26 minutes so you’ll need to schedule some time but as always with Kithcin’s content, it’s worth your time.

Posted in General | Tagged , | Leave a comment

Red Meat Friday: Dark Mode, Like It Or Not

I should have been suspicious. The Minions have been uncharacteristically quiet lately and behaving themselves; until they weren’t. Then, of course, they sprung another light-mode/dark-mode post on me.

It turns out there are a lot of sociopaths out there. Here’s a couple of examples:

  • The new Safari (Version 15.0) comes configured to allow any random Web site to force a color change to what Safari calls the tab bar. That’s basically everything above the site’s canvas. The idea, I suppose, is to make the browser display consistent: if it’s a dark-mode site, then the whole browser display is in dark-mode. The problem is that WordPress sites all forced a dark-mode tab bar even for sites like Irreal that are definitely light-mode.
  • Some especially evil person is offering an iOS Safari extension that forces a site’s display into dark-mode, regardless of the site’s preferred presentation.

Happily, right thinking people are not consigned to suffer these indignities. No one has to load and install Dark Reader and there is a way to keep sites from messing with your tab bar: In macOS, you can disable it by opening Safari preferences, choosing the Tabs tab, and unclicking the Show color in tab bar checkbox. It’s similar for iOS but the name of the option is slightly different as explained here.

Meanwhile, I’ve sent the Minions to bed without supper so maybe we won’t have any more of these posts. But don’t bet on it.

Posted in General | Tagged , , | Leave a comment

Drawing Diagrams in Emacs

Junji Zhi has an interesting post on drawing diagrams in Emacs. He wanted to draw diagrams for system modeling and do it from within Emacs. There are several ways of accomplishing that but Zhi chose Mermaid. It basically provides a markup language for the diagram and then renders a PNG. It’s much like the Graphviz’s dot language that I usually use for this type of thing.

For those who prefer a more visual approach, there’s ditaa, which takes an ASCII art diagram and turns it into a very nice looking PNG picture. It’s really easy to use but I rarely turn to it because I find Emacs’ Artist Mode difficult to use. That’s probably because my manual dexterity is challenged even to the extent of dealing with—for most people—the excellent artist-mode.

The point is, there is almost certainly a way of drawing a diagram in Emacs that you will find comfortable. I’ve never used Mermaid but it seems like a nice program that’s pretty easy to use. I’ll probably keep using dot because I’m used to it and it’s similar to Mermaid. I’ve used ditaa but mostly just as a test drive. If you’re good with artist-mode, ditaa is a quick and easy way of getting a diagram without having to learn a markup language.

As usual, Emacs lets you have it your way. Whichever way of drawing diagrams is most natural for you, Emacs has a package that supports it.

Posted in General | Tagged | Leave a comment

Iteration with Elisp

John Kitchen has important things to do so naturally he’s procrastinating. That’s probably bad for him but it’s good for us because he has another Elisp video up. This one considers various ways of iterating in Elisp. Earlier, he had posted a video on iteration in Python and this video considers the corresponding idioms in Elisp.

To me, the most general (non-recursive) iteration technique in Lisp is the do statement. It’s so powerful that you can do significant work even with an empty body. It’s powerful but not exactly transparent. Kitchin mostly focuses on the cl-loop macro. It’s natural and seems to translate amazingly well into Python even though Elisp predates Python by many years.

I’ve never been able to warm up to the loop macro but Kitchen’s demonstration of its use is more persuasive than any polemic could be. Take a look at the video to see it in action. It can do all sorts of things in a natural way much as Python does with list comprehensions.

Kitchin also considers using while. You can specify an ending condition or you can exit from the while by throwing an exception. That’s Lisp’s version of the break verb in other languages’ version of while.

The other iteration method that I use a lot that Kitchin doesn’t mention is the dolist macro. It’s sort of like a list comprehension but easier to use. In those situations where Kitchin uses cl-loop, I’d be inclined to use dolist. Still, Kitchin makes a good case for cl-loop and has encouraged me to spend a bit of time getting more comfortable with it.

The video is just short of 24 minutes so you’ll have to put some time aside for it but as usual with Kitchin’s videos, it’s worth it.

Posted in General | Tagged , | Leave a comment

String Formatting

One of the things we programmers do all the time is to build strings of the sort

In a survey of 342 programmers, 312 preferred Emacs.

where the two numbers and the string “Emacs” are variables. If, like me, you have multiple decades of C experience, the first thing you think of is printf. In C, you would render the above string as

(printf "In a survery of %d programmers, %d preferred %s",
 survey_total, editor_total, editor_type);

This idiom is so well established that you seldom see it done any other way.

Emacs Lisp has a direct analogue called format. Those of us permanently imprinted with the printf pattern seldom think of doing it any other way but Elisp offers several other methods of producing such strings.

John Kitchin has just posted a very nice video that considers several ways of formatting strings. He admits that he usually reaches first for format but some of the other methods he considers make the code more readable.

He looks at six ways of formatting strings:

  1. format
  2. format-spec
  3. f-string
  4. s-string
  5. mustache
  6. templatel

The first two are built in and the others are contributed functions. My years of C have permanently warped my brain so I stick to format almost all the time. If you like to make your code a little less opaque, you might want to give the others a try. The video is a good demonstration of their use.

The video is just over 22 and a half minutes so you’ll need to schedule some time. As usual with Kitchin’s videos, you learn things you probably didn’t know so it’s definitely worthwhile spending a few minutes with it.

Posted in General | Tagged , | Leave a comment