Insert Mode

My pal Watts Martin has a post that explores an artifact from the past: the insert key. Martin, who’s been a Mac head much longer than I have, remembers when Mac keyboards still had an Insert. They no longer do, of course, but my Unicomp Model M clone does as do several other PC keyboards. The key was used to toggle between inserting text and overwriting it. Emacs calls the latter overwrite-mode.

The idea of insert mode is that text in front of the cursor is pushed ahead as new text is added behind it. When insert mode is off—that is, when overwrite-mode is active—the text in front of cursor is overwritten. Overwriting text used to be more common but these days everyone uses insert mode and you rarely see it.

Still, as Martin says, overwriting can sometimes be useful and if you have an Insert key there’s no reason not to use it in Emacs. That’s a one liner and easy do in your init.el. On the Mac, the Insert key is usually mapped to Help but on other systems it probably has a different mapping so you may have to experiment to discover what it is.

Finally, Martin wanted a visual clue as to which mode he was in so he changed the shape of the cursor to reflect the mode. Again, that’s easy to do. He uses overwrite-mode-hook to toggle the cursor shape.

While I agree that overwrite-mode can occasionally be useful I don’t—and have never—used it enough to dedicate an actual key to it. I’m perfectly happy to simply call overwrite-mode to turn it on and off.

Posted in General | Tagged | Leave a comment

Problems With Org Mode Code Blocks

Raymond Zeitler has an interesting post on an aspect of using Org Mode code blocks that I didn’t know about. Zeitler says that he prefers to write his code in separate code files rather than in Org mode code blocks and provides an example of why that is.

The TL;DR is that in certain edge cases, things like differing syntax tables can make code behave differently in Org mode than it does directly in Emacs. Take a look at his post for the details.

I have to say that I’ve never run into this problem. Perhaps that’s because I usually use Org code blocks only for code that will be executed in the Org environment. The few times that I have run the code outside of Org, I haven’t run into the problems that Zeitler describes.

Your mileage may vary, of course, but it’s good to be aware that there are some edge cases that can reach out and bite you if you’re not careful. Most of you, I’m sure, will have my experience but it pays to be aware of what can go wrong.

Posted in General | Tagged , | Leave a comment

Linux Removes Strncpy

Back when I learned C, people were still using strcpy and even gets. After a while, people started saying that strcpy wasn’t safe and that you should use strncpy instead to avoid buffer overruns, either accidental or deliberate.

Those days are long gone, of course, and now even strncpy is considered unsafe. Because of that the Linux project just completed a six year project to banish strncpy from the Linux kernel. The idea was to replace strncpy with strscpy, which fixes the problem with strncpy. The project was a lot more complicated than a simple string replace. Each instance had to be examined to see what the proper remediation was. You can read all about it in Stephen Smith’s blog.

Smith’s post has a nice chart that shows what function you should use for string copying depending on the use case. It’s useful to help you make the right choice when you need to copy a string or, more generally, a chunk of memory from one place to another.

These days there are a lot of people saying that C is unsafe and shouldn’t be used. Those of us who were brought up using it reject that and claim that in the hands of a careful coder, C is still the best language for a wide range of problems.

Even if you’re convinced that you don’t want to write your applications in C, the chances are good that at some point you’ll have to maintain or extend such an application. It is, therefore, useful to know how to do it safely. Smith’s post is a good place to learn how to deal with copying strings safely.

Posted in General | Tagged , | Leave a comment

Using Emacs Input Methods For Foreign Languages

Protesilaos Stavrou (Prot) has a very nice video on writing foreign languages with Emacs. The main problem for Latin languages are the diacritical marks. Other languages, such as Greek, Russian, and Chinese, have completely different alphabets. In either case, Emacs has us covered.

Prot writes Greek, English, French, and (possibly) Spanish so being able to handle all these languages easily is important to him. His video shows us how he does it. The video is in two parts:

  1. Using the Emacs input method mechanism and
  2. Multilingual spellchecking.

In the first part, Prot demonstrates how to switch between the normal input method—that is, the characters your keyboard normally sends—and another input method that maps to characters from another language.

He uses French as an example and shows one way (the postfix method) to add the diacritical marks that French uses. I use the same method for Spanish and like it. It’s easy and natural. The only thing that takes a bit of getting used to is using an accent character in a non-diacritical way. For example, when writing with the spanish-postfix method, e' results in é but if you want to write something like “he’s” you have to input he''s .

The second part of the video considers multilingual spellchecking. For that, Prot uses jinx, which is pretty much like the normal spell checking in Emacs except you can check multiple languages. It will underline spelling errors as usual and you can have it offer suggestions for correcting those errors.

I wish I’d seen Prot’s video before I started studying Spanish. It would have saved me a lot of time figuring things out on my own. If you have a need to use Emacs to write in another language, you should definitely take a look at Prot’s video.

Posted in General | Tagged | Leave a comment

Breaking Version Changes Coming To MELPA

Jonas Bernoulli (tarsius) has a long post announcing new channels and versioning on MELPA. Why a long post? And, really, why should we care? It turns out that the process is much more complicated than you’d think it would be and will, eventually, require nontrivial action on the part of MELPA users.

The first question is, Why is MELPA introducing new channels and why are they changing the versioning? The new (experimental) channels are a vehicle for testing the new versioning. The two new channels are Snapshots—that corresponds to the current Regular releases—and Releases—that corresponds to the current Stable releases. The plan is for these new channels to replace the Regular and Stable channels.

The reasons for changing the versioning are technical and you can read about them in Tarsius’ post but the reason we care is that when the official switchover happens, MELPA users are going to have to take certain actions to ensure their ELPA distributions are consistent with the new versioning. Otherwise, the new versioning could make a new version of a package look older than previous versions. Doubtless, when the time comes the MELPA team will provide a script to automate the changeover.

As I said at the beginning, there’s a lot of complicated details involved so you should definitely read Tarsius’ post. He recommends that you get in front of things by changing to the new channels now. His post explains everything you have to do. The official changeover probably won’t be for another year so you have time to prepare.

Update [2026-07-04 Sat 13:33]: Fixed title typo.

Posted in General | Tagged | Leave a comment

Automatically Signing And Encrypting Email With Mu4e

Nicolas Cavigneaux has an excellent post on signing and optionally encrypting emails sent with mu4e. The idea is to sign each email you send and if you have a GPG key for every recipient, encrypt it was well. As Cavigneaux says, it’s pretty easy to sign and/or encrypt messages with mu4e but you have to remember to do it and most people, including him, don’t always remember.

The solution, of course, is to automate the process so that you don’t have to remember. That turns out to be pretty easy to do. Cavigneaux has the necessary code in his post. The basic flow is to check if you have everyone’s encryption key and, if so, encrypt the message. Regardless of whether or not everyone’s encryption key is available sign the message. There are calls available for both the signing and encryption. The process is kicked off with the send-message-hook every time you send a message.

There was a time when encrypting all your messages was the thing to do but difficulties with key distribution have pretty much put an end to the encrypt all emails movement. Most people don’t have keys and those who do will probably be annoyed to receive mundane emails that are encrypted. For those sensitive emails being sent to people you know have keys, you pretty much automatically remember to encrypt them.

That leaves signing. It mostly doesn’t hurt anything1 so it probably doesn’t matter if you always sign your messages, especially if you have reasons to suspect that their contents might come into dispute. I’ve stopped doing even that because, as I say, no one has any idea what it means.

So my takeaway is that if you’re paranoid about certifying the content of your emails or you regularly deal with people who want to ensure themselves that they’re communication with you, it may make sense to automatically sign your emails. Except in special circumstances, I don’t see any reason to encrypt all your emails.

Footnotes:

1

Although I do remember being queried about those unreadable binary blobs at the end of my emails.

Posted in General | Tagged | Leave a comment

Magit 4.6 Is Released

Jonas Bernoulli is announcing the release of Magit 4.6. It includes, he says, over 300 commits since the last release 6 months ago. You can check Bernoulli’s post for the details but an overview is that the main changes were in

  • Blob handling. Working with blobs should be easier and make more sense with this release.
  • Experimental syntax highlighting in diffs.
  • Improved hook handling that allows for the calling of Elisp hooks from Git hooks.
  • Improved commit message processing. List of changed definitions in a diff are now available for composing a git commit message.

As I’ve said before, Magit and Org Mode are responsible for luring many new users into the Emacs event horizon so these improvements are important. Moreover, they raise again the need for supporting this effort. Bernoulli spends full time on Magit on a few other open source projects and depends on contributors for his livelihood Take a look at his support page to see how you can help out.

Posted in General | Tagged | Leave a comment

Deleting To Trash Redux

Over at Emacs Dwelling there’s a nice post on why you should set Emacs to delete files by moving them to trash. That’s easy to do by setting delete-by-moving-to-trash to t. The post has a story illustrating why you should do that: it’s very easy to accidentally delete a file with Dired and if you do it to a file with changes that haven’t been committed to version control you can lose a few hours work. If you don’t use version control, the story is even worse.

The post seemed to me to be a worthy cautionary tale and I thought it would make a good Irreal post but when I began the writing process by entering a file name for the post, delete-to-trash.org, I discovered that such a file already existed from 2022. Even worse, for my blogging plans, it said everything I was planning to say in this post. Nevertheless, that was 4 years ago and the lesson, it seems, is evergreen so it’s worth making the point again. It costs you nothing and in those rare occasions where errant muscle memory causes you to delete a file, it can save the day. So rather than repeat the story I’ll just suggest that you check out the Emacs Dwelling post or my previous effort.

Posted in General | Tagged | Leave a comment

The CBS Report On The Unix v4 Recovery

Today (Monday) on the Unix Heritage Society mailing list, Thalia Archibald reports on a CBS report on the Unix v4 recovery at the University of Utah. Sadly, the report misses the two most important things about the recovery.

The first, that v4 was the first release written in C, was perhaps too much in the weeds for most non-geeks so CBS can be forgiven for not mentioning it. The second point, though, is the most important thing about the recovery: It was a recovery. Until the discovery of the tape in the University of Utah closet, there was no known copy of the release or source code and it was widely considered lost.

In a sense, v4 was the link between the early Unix versions written in assembly language and the more modern versions written in C. Viewed that way, v4 could be seen in the same way as archaeology’s famous missing link.

One point the CBS report does make is that the descendants of v4 are running everywhere today. Every Mac is running a direct descendant and those running Linux are running an OS derived from the same ancestor. Likewise, every Android phone and iPhone is also running software derived from v4.

In any event, if you’re interested in this sort of thing take a look at the CBS clip. It’s only 2 minutes, 36 seconds long so it won’t take you long.

Posted in General | Tagged | Leave a comment

Chen On Red Squiggles

All of us are familiar with the red squiggles that appear under spelling errors when we’re writing text. They appear in Emacs buffers and probably most other applications as well. One place they certainly appear is in Microsoft Word documents. Word is, in fact, where they were born.

Raymond Chen from Microsoft has an entertaining post that examines the history of those squiggles. In early versions of Word, spell checking was a blocking operation that had to be initiated by the user. Later, the spelling check ran in the background so that the results would be available when the user asked for them but that background operation was also blocking so users tended to turn it off. Tony Krueger who worked on many of the early versions of Word was the first to implement on-the-fly spell checking—what we Emacsers call “flyspell”—in Word. To indicate misspellings, he underlined the misspelled words with the red squiggle that we’re familiar with today.

Chen also relates a story involving Penn & Teller and Weird Al Yankovic who were fans of the squiggles and autographed pictures for Krueger. They were, reportedly, cherished by Krueger.

None of this really matters, of course, but it’s a nice piece of our shared history and the story behind a ubiquitous notation that we’re all familiar with but probably didn’t know the origin of.

Posted in General | Tagged | Leave a comment