Devil Mode

Lots of people recommend Evil mode or switching to a Dvorak keyboard because it allows for more efficient editing. Evil mode is probably more efficient and, more importantly, helps with RSI problems. As a long term Vi/Vim user, those bindings were burned into my muscle memory and when I switched to Emacs and decided to use the vanilla keybindings, it was hard to give them up. Still, the default Emacs binding are also pretty efficient and the ability to easily implement my own editing commands more than makes for the loss of composability. The bottom line is that I’m pretty much agnostic concerning Evil mode.

Then there’s Dvorak and similar keyboard layouts. After suffering the pain of learning to touch type with QWERTY, I have no desire to start again for a possible gain of a few words a minute. I’m pretty efficient with QWERTY and if I needed to up my speed, there are plenty of videos and tutorials to help with that. The bottom line is that I’m not going to adopt some new keyboard layout and the associated pain for a small, putative increase in typing speed.

That brings us to Devil Mode. The idea is to get rid of the modifier keys while avoiding modal editing. To do that, the comma key is used instead of the Ctrl key so that you would open a file with , x , f. There are, of course, ways of dealing with the Meta modifier as well.

Your first question is, undoubtedly, how do you type a comma? The common cases of a comma followed by a Space or Return work normally but you can use , , for the edge cases. Follow the link for all the details.

If you really really want to eliminate the modifier keys without embracing modal editing, Devil Mode may be worth checking out. For me, it seems more like moving to Dvorak: whatever gain you might get isn’t worth the pain.

Posted in General | Tagged | Leave a comment

The Second Emacs 29.1 Pretest

Eli Zaretskii writes to say that the second pretest of Emacs 29.1 is available for testing. If you don’t mind living a bit on the edge, Zaretskii would be grateful for your testing and letting the developers know of any problems you find.

As always, thanks to Eli and the other developers for their hard work in readying this latest release for our use. They are truly heroes and we owe them all our gratitude and, should the opportunity arise, a beer.

Posted in General | Tagged | Leave a comment

Adding C-DEL To The macOS Keybindings

One of the little known but great features of macOS is their support of Emacs keybindings. Although most people don’t know it, this support comes in two parts. The first is that some of the common Emacs bindings such as Ctrl+a, Meta+b, and similar motion commands are defined by default and work in all macOS apps.

Less well known is that macOS allows you to install your own bindings for all their editing commands. In particular, you can install many of the common Emacs editing commands so that you can leverage your Emacs muscle memory with all the apps on your Mac.

I write about this periodically—last time here—when I see an Emacs user discover macOS’s rudimentary support for Emacs motion commands. But this post is not one of my periodic reminders. Rather, it about a missing binding and how easy it is to edit the extended bindings.

For as long as I can remember, I have used both Ctrl+Delete and Meta+Delete to delete the previous word in the manner recommended by Steve Yegge. Most of the time, it’s more convenient to use Ctrl+Delete for this but, sadly, that’s not supported by the DefaultKeyBinding.dict that I recommended.

Happily, it’s easy to add the desired binding. Here’s the new entry:

"^\U007F"   = "deleteWordBackward:";            /* C-DEL        Delete word backward */

Just add it to DefaultKeyBinding.dict and restart macOS to have it take effect. Pay particular attention to the punctuation after deleteWordBackward. It’s fussy and easy to get wrong.

This is a small thing and maybe nobody but me cares but it has made my life a little bit easier. As usual with these things, I wonder why it took me so long.

Posted in General | Tagged , | Leave a comment

Why Blog?

Since you’re reading this, you know that I blog. I blog a lot: everyday for several years now. You might wonder why. Anyone who’s tried it knows that blogging is hard and involves a lot of work. Irreal isn’t monetized but even if it were, it’s unlikely that it would pay me more than a nickel and hour. So why do it?

Every blogger, I’m sure, has their own reasons. Danny Guo certainly does and he’s chosen to share his. It’s an interesting read and if you’re looking for reasons to get started blogging, you may find his post useful.

Writing is a skill and like any other skill the only way to get good at it is to practice. Blogging is ideal for this. Blogging is hardly ever long-form writing so writing posts is a good way to practice in bite-sized chunks. A side benefit of writing is that it’s a necessary component to being a good thinker and writing, as Paul Graham says, is a precursor to thinking. Guo agrees with this and also notes that writing helps him clarify his thinking.

He gives several other reasons to blog including

  • Sharing knowledge
  • Learning things
  • Learning how he’s wrong

and many others.

He also gives some minimal advice on how to get started and mentions some of the various blogging platforms. Unlike Irreal, he doesn’t publish everyday demonstrating the commitment can be as large or as small as you like. If you’re interested in blogging the important thing is to get started. Irreal’s first year or so had only a few (sometimes no) posts per month. Guo says he works on some posts for a year or more.

My advice is to try it. You might find you like it.

Posted in Blogging | Leave a comment

Generating Documents Directly From Elisp

I’ve had this in my blog queue since April but it’s too good to let it fall into the bit bucket. Álvaro Ramírez has a problem with his chatgpt-shell package. He has some documentation in the form of tables, which are easy enough to generate but the package is still under development and the documentation is always changing.

Ramírez realized that Emacs is the self-documenting editor so it should be possible to generate the documentation directly from the Elisp. That way, every time he updates the code, the documentation can be automatically regenerated. He had no idea how to do that but the nice thing about Emacs is that there are no secrets. He checked how the apropos commands gathered this information.

It turned out not to be too hard. The secret is to use the mapatoms command to cycle through the obarray that contains all the symbols in the current Emacs instance. Then it’s just a matter of checking if the symbol is for chatgpt-shell and is a custom variable. Grabbing the documentation for functions is similar. You can check out the code for both in Ramírez’s post.

There’s nothing specific to chatgpt-shell in any of this. You can use the same code, mutatis mutandis, for any package so it’s a worthwhile technique to know. If you’re maintaining a package and have even minimal documentation, you should definitely take a look at Ramírez’s post.

UPDATE [2023-05-12 Fri]: Just noticed that I forgot the link to Ramírez’s post. Fixed.

Posted in Programming | Tagged , | Leave a comment

Diffing With Emacs and Vim

Franco Pasut has an instructive post on how to diff files with Vim and Emacs. Both editors have very nice built-in functions to make diffing files easy. I’ve used them both and can attest to their utility.

Pasut’s post, Notes on resolving differences between two documents with the built-in resources of Vim and Emacs, isn’t a comparison and doesn’t make any value judgments. Rather, it merely shows how to use the two systems. I haven’t used Vimdiff in years but my memory is that it was easier to use than Emacs’ Ediff system.

Regardless of their relative merits, both are easy to use and very powerful. To see this, think about how you would reconcile two files with just the standard Diff program and some random editor. With Vimdiff and Ediff, you see the differences one by one and can choose which variant to keep. With Ediff, you can even edit the file directly.

If you’re not familiar with the two systems, take a look at Pasut’s post. It’s short and tells you more than enough to use either efficiently.

Posted in General | Tagged | Leave a comment

Converting an Excel Spreadsheet to an Org Table

I no longer use spreadsheets and haven’t for a long time. I don’t think there are any spreadsheet instances on any of my computers and if there are, they are relics from the mists of time. Any spreadsheet operations that I need to do are done with Org tables.

Of course, I’m not doing financial forecasting or other complicated calculations which may—I don’t know for sure—be easier with a spread sheet. Still, even for those of us who rely entirely on Org tables, it’s sometimes convenient to import a spreadsheet in the sense of converting it to an org table.

Over at the YouTube Emacs Elements channel there’s a nice video on importing an Excel spreadsheet into an Org table. It’s an elementary operation that just captures the data but not the formulas used to calculate the cells. The TL;DR is that you just highlight the spreadsheet data, copy it to the clipboard, paste it into an Org buffer, and call org-table-create-or-convert-from-region to make it into an Org table.

The video shows how to add a line under the headings, delete some columns, and add a new column with some calculated data from the other columns. It might seem like this is a bit restricted but if you’re importing a spreadsheet, you’re almost certainly just interested in the data and not the formulas used to calculate it. Even so, it’s possible to calculate new data from what you import as the video shows.

My main takeaway from the video is how easy it is to grab the data from a spreadsheet and turn it into an Org table in the obvious way.

Posted in General | Tagged , | Leave a comment

Local Abbreviations

Abbreviations are a useful Emacs feature. They can do anything from inserting a non-ASCII character to changing “latex” into “LaTeX”. If you do a lot of writing they can be a significant timesaver. If you do any coding, you’re probably familiar with YASnippet, which can also do these things.

Regardless of what system you use, all the existing solutions suffer from being global or, at best, restricted to a given major mode. Sometimes, though, it’s convenient to have a set of abbreviations that are local to a given buffer and hidden when you change focus to another buffer. Chander G has recognized the need for local abbreviations and responded with lam—the Local Abbreviation Manager.

It’s a nice application. It’s simple to use and doesn’t require learning a lot of keybindings. One binding does everything you need and you set that to whatever is convenient for you. It also has the ability to run some Elisp after or instead of making the substitution. There’s an animated GIF at the GitHub site that demonstrates this.

It’s still early days for the project. It’s not yet in MELPA, although it is available for downloading. At the end of the README, there’s a list of additional features that Chander G is considering adding. They all seem reasonable and, most importantly, maintain the simplicity of the package.

If you think local abbreviations would be a win for your workflow, take a look at lam. It’s a single, short file so even without MELPA, it’s easy to install and maintain.

Posted in General | Tagged | Leave a comment

Completing Org Links

Jeremy Friesen has an interesting post that may teach you a couple of things you didn’t know. Friesen uses Org mode a lot in his writing and everything he writes and has lots of links—both standard and customized—in that writing. His problem is that he often wants to complete a word or symbol to a link that is already in the buffer.

On the one hand, I’m not at all interested in this post because I try never to link to something more than once in a single post. On the other hand, the post is still interesting to me because it provides a good go-by for how to obtain a list of (Org) links in the current buffer. That turns out to be harder and simpler than you might think. The solution is not to cycle through the buffer looking for the appropriate regex. Rather, the solution involves using org-element-map to find the links and generate propertized strings of the results. It’s a nice example of dealing with an Org buffer without falling back on regexes.

Friesen also presents some other code that shows how he does the actually completion if your interested in duplicating his workflow but even if you’re not the post has lots of good technical information. Even if you don’t have custonized links, you might find it useful.

UPDATE [2023-05-09 Tue 14:28]: In a subsequent post, Friesen explains his need to link to a resource multiple times.

Posted in General | Tagged | Leave a comment

Moving To Elfeed

Michał Sapka has an interesting post that serves as a nice coda to yesterday’s post on Emacs integrating so many productivity tools. One of those tools is the RSS feed reader, Chris Wellons’ Elfeed.

Sapka’s post is about his moving to Elfeed for his RSS feeds. His move is in the context of a larger migration from dedicated packages to those integrated with Emacs. Elfeed needs no justification other than its own excellence. It is, by far, the best RSS reader I have ever used and the fact that it operates under Emacs is just a bonus. You can check Sapka’s post for some of the things he likes about it but the TL;DR is that it’s simple and includes images when appropriate.

Contra Google, RSS is an important tool for many of us and having a first class reader integrated into our editor of choice is a huge win. FortunateDaughter_ from yesterday’s post, wonders if it’s worth it for users to prefer Emacs integrated apps in preference to dedicated applications performing the same functions. The unstated implication is that these dedicated applications are better. Elfeed puts the lie to that. It is, in my opinion, the best RSS reader at the same time it’s integrated into Emacs. It turns out that, sometimes at least, you can have it all.

Posted in General | Tagged | Leave a comment