A Spelling Transient

Over at DyerDwelling there’s another nice example of using a transient menu to capture the keystrokes for a set of packages. This time it’s for some spelling related packages. The author couldn’t make up his mind on what keystrokes he wanted for the various commands so he decided to implement a menu instead.

If you’ve been reading Irreal lately, you know that I’m a big fan of this approach, especially as realized by Charles Chou’s Casual Suite. Nonetheless, I’m not sure that a menu is the best solution here. At least not for commands that do things like correct the last misspelling. I use commands like that constantly and want them instantly available without having to wade through a menu.

Still, we can have it both ways. There’s no reason to restrict yourself to one approach. You can have a menu as described in the DyerDwelling post and still specify keybindings for the commands you use all the time. And to be fair, you can also think of the sequence to invoke the menu and the option choice as a single, slightly longer, key sequence.

I’m again impressed at how easy it is to set up a transient menu. Take a look at the code in the DyerDwelling post to see for yourself.

Posted in General | Tagged | Leave a comment

Org Template Fundamentals

Forward

Does anyone know what happened to Emacs Elements? As I was getting ready to publish this post, I notices that the below linked video was gone and that Google said it had been deleted by the author. On further investigation, I see that the entire playlist is gone.

I did find this post on the Emacs subreddit but it doesn’t have any information: just others wondering what happened to the site, and mourning its loss. If you know anything, please leave a comment.

My original post is below but, of course, none of the links lead anywhere interesting.

Original Post

Emacs Elements has a nice video up on Org mode capture templates. This video concentrates on the structure and meaning of the templates.

Org templates are one of the most useful ways of using Org to capture and record various types of data. I use them to capture tax, health, journal, TODO, email, and blogging data. They’re easy to adapt for capturing data in several formats and to annotate the captured information.

Building the templates is a bit fussy and you have to get them just right or they won’t work. That said, they have a reasonable format and aren’t too hard to learn. Even if you don’t want to build them yourself you can still use the Emacs configure subsystem.

The video is relatively short—7 minutes, 37 seconds—so there’s no point in recapitulating it here. Spend a few minutes with it to find out the sorts of things that are possible and use the excellent Org documentation to fill in any blanks.

Posted in General | Tagged | Leave a comment

🥩 Red Meat Friday: Is C Useful For Understanding How Computers Work

This post didn’t start as a Red Meat Friday item but as I worked on it, I got so exercised I decided it really should be one. For me, the question of whether C helps with understanding how computers work always evokes the response, “Well, Duh! Of course. Why are you even asking?” Anyone who has actually programmed in C—programmed, not just written hello_world.c or other such toy programs—will have the same response.

Negative responses mostly come from users of languages like Python, Java, Ruby, or one of the many other higher level languages that abstract away all of the low level details of what’s actually going on in the hardware. These people invariably argue that, really, C isn’t a low level language either because it doesn’t address such low level details as pipelining or speculative execution. Those arguments merely prove that these people have no idea what they’re talking about. No programming language addresses those issues. C is a low-level programming language because it maps reasonably well to the assembly language of a generalized model of a machine with registers, a stack, and a flat memory model. Even X86 CPUs in real mode can be represented by that model so it’s a useful concept.

Yet the question gets asked over and over again and the comments invariably bring up the same silliness. A huge amount of useful code gets written in Python and the other higher order languages so programmers who write only in those languages are by no means a lesser breed but it’s certainly true that most of them probably have no more idea of what’s going on under the hood than the average homemaker has about the physics of cooking. Both produce useful results but it’s silly to believe that their understanding of the underlying processes is as good as that of professional chefs or C programmers.

The TL;DR is that you can be a great programmer who sticks to, say, Python and produce extraordinary useful programs but if you only know Python, you probably don’t have much idea of how computers work. If you want to find out, programming in C is a good way to do that.

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

A N00b Reminisces

Over at the Emacs subreddit, Ok-Machine-6265 is a new(ish) Emacs user who has some thoughts after using Emacs for about a year and a half. His experience has been good. He loves the power that Emacs gives him and lists some of its many benefits:

  • Configurability
  • Visibility into all aspects of Emacs’ code and data
  • Keyboard centricity: no mouse required
  • Stability: core functions just work

and finally, Emacs is an editor for hackers and those who want to make it their own. You don’t have to customize it, of course, but if you need special operations, Emacs makes it possible and easy to add then.

As usual, a lot of the wisdom is in the comments. Ok-Machine-6265 had a few complaints:

  • Emacs can be slow to load large files
  • There are so many commands that it’s easy to forget their key bindings.

The commenters suggest many solutions to these problems. For example, the wonderful which-key goes a long way in helping you remember key sequences. It’s a third part app that I’ve been using for a long time but, happily, it will be builtin as of Emacs 30.

One of the things that Ok-Machine-6265 says is that Emacs is 100% configurable and one of the commenters objected to that saying that, for example, changing the behavior of Meta in Org mode is apt to break things. The commenters responded, and I agree, that 100% compatibility is not the same as easily reconfiguarable. It may be easy or it may be hard but at the end of the day, almost everything in Emacs is configurable.

Posted in General | Tagged | Leave a comment

Inlining The Previous Result In Edebug

Álvaro Ramírez has a very nice post about improving the edebug dislay. He starts be recalling the now nearly 10 year old post from Artur Malabarba on why you should learn to use edebug, the source level Elisp debugger. He says he uses it all the time when he wants to tweak some Emacs behavior.

Edebug will, among other things, let you step through a function and display the results of each expression to the minibuffer. That’s really handy but Ramírez finds it jarring to have to repeatedly move his eyes from the code buffer to the minibuffer. Being Ramírez, he decided to do something about it.

The TL;DR is that he advised the function that displays the value so that the result is displayed on the current line. You can see what that looks like from the animated GIFs on his post. It does seem like a much smoother result and I hope he submits a version upstream as a permanent change.

The big takeaway for me, though, is his account of how he tracked down the appropriate code to advise. If you want to tweak Emacs to do things your way, being able to find the code that needs tweaking is a prerequisite. You can learn a lot about how to do that from Ramírez’s post.

The post is definitely worth a few minutes of your time even if you don’t care about how edebug displays its results. It’s a great example of how it’s not that hard to track down the code that needs your attention.

Posted in General | Tagged | Leave a comment

Casual Ibuffer

Charles Choi is back with a new member of his Casual suite. His Casual suite, in case you don’t know, is a collection of transient based menus to make dealing with Emacs major modes and subsystems easier. Choi’s latest addition is for the ibuffer major mode. If you’re like me, you know exactly two commands for this. The first is to change to a named buffer (Ctrl+x b) and the second is to bring up a list of all the active buffers (Ctrl+x Ctrl+b).

Once you have the list of buffers (the ibuffer list), you’re probably aware that you can do some operations on it but, again if you’re like me, you know only a couple of them. One of the things I learned from Choi’s post is that are an astounding 132 commands available in the ibuffer listing. Who knew.

With that many commands, there’s virtually no chance of remembering them all. That’s where Casual Ibuffer comes in. As with the other Casual apps, it doesn’t try to cover every single command but provide easy access to those you’re most likely to use.

As I said, I always thought of the ibuffer list as simply a list and had no idea of all the hidden functionality hiding in it. Just reading through Choi’s announcement will show you how wrong that idea is. The real value, though, is opening our—or at least my—eyes to a whole new set of powerful commands for dealing with buffers, which are, after all, the fundamental Emacs construct.

Posted in General | Tagged | Leave a comment

Is Emacs Bloated?

Icy-Repair8024 says he’s a new Emacs user who started using it believing that Emacs was a “lightweight” editor but upon discovering all its features now believes it’s bloated and wonders if he should give up on it. I have to admit that that’s the first time I’ve ever heard the claim that Emacs is a lightweight editor. You almost always hear the reverse. I suppose that compared to Electron-based editors you could argue that Emacs is comparatively lightweight but no one ever does.

It’s interesting to read the comments. Most of them

  1. Scoff at the idea that Emacs could be described as lightweight in any meaningful way, and
  2. Make the point that whatever bloat there is doesn’t matter because most features you don’t use aren’t loaded and don’t take up much space on the disk.

A bigger question, to my mind, is what, exactly, do we mean by bloated. Some of the comments make the point that Emacs is, in fact, more a Lisp Machine than an editor so of course it has a lot of features and the ability to easily add those features is one of its strengths. Its memory and disk storage footprints are modest by today’s standards so Emacs can’t reasonably be said to be a resource hog.

One of the commenters notes that Icy-Repair8024’s account history shows that he’s merely trolling. I don’t know if he is or not but if it was a troll, it didn’t work. There were no angry retorts or denunciations, just reasoned rebuttals that marshal the facts.

My takeaway is that of course Emacs isn’t lightweight in any way that matters and that we should stop obsessing about its so called bloat and instead embrace its many features whether or not we use any particular one.

Posted in General | Tagged | Leave a comment

Moving To The Beg/End Of Structures

Over at the Emacs subreddit, justsellingmykeeb asks for the best way of moving to the beginning or end of various structures such as regions delimited by some sort of brace or HTML tag. I usually use Ctrl+Meta+f, Ctrl+Meta+b, and, when I remember, expand-region for this but those don’t always do exactly what I want.

There are a lot of good answers in the comments and they’re definitely worth reading if you have the same problem. These range from the simple like expand-region to the more complex like paredit. I like the simpler answers—even though I am a paredit user—because I’m terrible at remembering key shortcuts that I don’t use frequently. Maybe Charles Choi should consider a paredit porcelain.

Regardless of your proclivities, there’s probably a suggestion in the comments that will work for you. Take a look and see.

Posted in General | Tagged | Leave a comment

Configuring A Private Ispell Dictionary

Chris Maiorana has a useful piece of information for all Emacs users. If you’ve used Emacs at all for writing you’re doubtlessly familiar with ispell. I’m a terrible speller and absolutely couldn’t live without it. I have it set up with flyspell so that my frequent typos/misspellings are highlighted in the buffer as I make them. All it takes is a single keystroke to correct—or at least suggest a list of corrections to—the error.

You can configure various dictionaries for use with ispell but whatever you choose you will inevitably encounter correctly spelled words that are not in the dictionary. Perhaps it’s your last name, the name of your blog, or a technical term; you’re going to have it pop up as an error every time you use it.

Maiorana tells us how to have a “private dictionary” to which we can add these outliers and have them accepted by ispell. It’s a small thing, I suppose, but it’s nice to be able to write without having a bunch of errors pop up.

It’s pretty easy to set up. All you need to do is specify a file to hold your outlaw words and then add your private words to it. That’s easily done as the errors pop up. A simple keystroke adds the unknown word to your private dictionary and you never have to worry about it again.

It’s a short post and well worth a couple of minutes of your time to read if you’re tired of having special words that you use all the time pop up as errors.

Update [2024-07-06 Sat 16:56]: Added link to Maiorana’s post.

Posted in General | Tagged | Leave a comment

Ready Player Mode

Álvaro Ramirez has announced another of his “ease my workflow” projects. Like many, or perhaps most, of the best projects, this one was conceived to scratch an author’s itch. This particular itch was finding a way of taking a quick look—or listen—to a media file from within Emacs.

It’s pretty easy to launch an external app to display or play a media file but Ramírez wanted to take his quick peek without leaving Emacs. He was inspired by image-mode and used it as a model for his solution. He liked being able to get out of the app quickly by simply pressing q and being able to navigate between media files in a directory easily with n and p. The actual playback is handled by one of mpv, vlc, ffplay, or mplayer according to the user’s configuration or by simply trying each of them in the order listed.

The application is brand new, has been tested only on macOS, and is not yet on Melpa but it is available from his from GitHub repository if it sounds like something you need right now. If it sound intriguing but not urgent you should probably wait a bit until he gets the wrinkles ironed out.

In any event, it’s one more way of staying in Emacs while still performing (non-editing) tasks on your computer.

Posted in General | Tagged | Leave a comment