Dired Async Mode

James Dyer has another useful Emacs discovery. His workflow often involves copying large files, which he does from Emacs using Dired. Even though he’s configured Emacs to use rsync for Dired copies, the transfer can still take some time and Emacs hangs while the copy is in progress..

It turns out that as of Emacs 29 there is a nice solution. You can set dired-async-mode to on and all the Dired operations will happen asynchronously. That includes things like renaming, which, of course, takes no time at all but it really matters mostly for copying.

There isn’t much to say about the post. It boils down to “if you do a lot of copying with Dired, then switch on dired-async-mode.” Check out Dyer’s post for the full story but, as I say, it’s a short story. Nevertheless, it’s a useful tip and well worth knowing about

Posted in General | Tagged | Leave a comment

Bookmark+

Emacs Elements has a new video that takes a quick look at Bookmark+. It serves the same purpose as the builtin bookmark application but is extended in many ways. I’ve been using it for many years ever since abo abo wrote about it and his hack to make jumping to bookmarks easy (I wrote about it here).

The video details some of the additional types of bookmarks that bookmark+ supports. You can, for example, set a bookmark to a URL and bookmark+ will open it in the browser for you. I use that all the time to quickly jump to the Irreal site when I’m working on a post.

Another nice capability is to open a specialized buffer. For example, I have a bookmark to Ibuffer that will open a buffer with the current buffer list. Similarly, you can set a bookmark to a directory. That can be convenient when you have a directory with a long path. For instance, I have a bookmark to the the elpa directory that lives in the (for me) hard to type .emacs.d directory. When you open such a bookmark you get a Dired buffer for the target directory.

The video demonstrates another bookmark type that I don’t use but could be handy: you can mark a region in a file and bookmark that. When you open the bookmark, you jump right to it and it’s highlighted. Similarly, you can bookmark any position in a file although this may be possible with native bookmarks too.

The video is definitely worth a look. It’s 8 minutes, 13 seconds so it should be reasonably easy to find time for it.

Posted in General | Tagged | Leave a comment

Zamansky: Elisp 17

Mike Zamansky is back is back with part 2 of his thesaurus project. In his last video he started a project to explore using Web APIs. He chose to implement a thesaurus to illustrate the concepts and used the Merriam-Webster dictionary interface as his example API.

Once he had a key for the Merriam-Webster API it was a simple matter to retrieve the JSON that Merriam-Webster returns. The current video shows how to parse the JSON, chose a synonym, and replace the target word with it. Again, this turns out to be pretty simple. Once you have the JSON response string and have parsed it with json-parse-string it’s simply a matter of pulling out the required array from the JSON, converting it to a list, presenting it in a completing read, and replacing the target word with the choice from the completing read.

Zamansky finishes the project by turning the code into a minor mode and binding a key shortcut to it. The amazing thing about all this is how simple it is. There’s just a tiny amount of code that implements a reasonably complete thesaurus application. To be sure, a lot of the work is being done by Merriam-Webster but almost all such projects do the same thing with one dictionary provider or another.

This is a very instructive couple of videos that showcase how easy it is to leverage Elisp into a significant application. This last video is 16 minutes, 35 seconds long so you’ll need to schedule some time but it’s definitely worth your time. Be sure to take a look.

Posted in General | Tagged , | Leave a comment

Emacs For Writers

Fedora Magazine has an interesting article in which a journalist, odisej, discovers using Emacs as his writing tool. His article is a sort of perfect case study because odisej has no real technical background so his take on using Emacs for writing is that of someone without expertise in text editors. Of course, he does have experience with “word processors” and has tried a lot of them. He even tried using ancient ones such as WordStar and Word Perfect but none of them clicked for him. Then he tried Emacs and finally discovered his ideal writing environment.

Of course, Emacs is famously idiosyncratic, having existed long before IBM decided what the one true user interface should look like. This means that Emacs is infamous for its steep learning curve and odisej certainly suffered from it but once he learned the basics he knew he had found the perfect writing tool.

What makes it so perfect? He doesn’t say so explicitly but as usual it’s Emacs’ configuration and extensibility that makes the difference. For example, odisej likes wider margins than the default and Emacs makes it easy to set them to his preferred value. Of course, most editors can do that but Emacs makes just about everything configurable.

Then there’s extensibility. Emacs has thousands of packages available that can provide practically any capability the user desires. Odisej added flyspell and wc-mode to his configuration to take care of spelling correction and word counting. Again, most editors provide some flavor of these functions but Emacs has several packages to do them that differ slightly in how they work and how they present their results to the user. As always, Emacs lets you have it your way.

If you want to view Emacs from a writer’s point of view, take a look at odisej’s post.

Posted in General | Tagged | Leave a comment

NASA Coding Standards

In my A Fatal C Error post I talked about how hard it is to write error-free C code. Any large C program is almost guaranteed to have undetected errors. That’s true of all languages—TeX is famous for being the only large programming system that approaches zero errors—but is especially true of C.

Nevertheless, NASA is renowned for writing nearly faultless mission critical software in C. The NASA software developers are so good at this that after the Challenger disaster, the famed physicist Richard Feynman compared the rest of NASA unfavorably to the software team.

That raises the question of how they achieved such excellence. As I mentioned in the Fatal C Error post, part of their secret was a comprehensive and strict set of coding standards. Here they are.

If you’re like me, your first reaction is probably, “But but but…they’ve outlawed all my favorite techniques.” Still, all those favorite techniques are exactly why writing correct C code is so difficult. NASA, of course, is writing software where millions (or billions?) of dollars, not to mention lives, are at stake so there’s little room for error.

The article at the link doesn’t talk about their development process but it is similarly rigorous. All code is gone over line-by-line by the development team and subjected to numerous tests and simulations. I don’t have a link to those at the moment but if I find them, I’ll write another post because the NASA software developers show how it is possible to write safe and efficient code.

Again, if you aren’t terrified when you read about the code running the car you use everyday, you aren’t paying attention.

Afterword

After I wrote this post, I discovered Astroguard, a code auditing and profiling tool that enforces NASA’s coding standards. Take a look at it if you’re interested in such things.

Posted in General | Tagged | Leave a comment

Reinstall Packages

Someone posted a link to an old Bozhidar Batsov post that discusses a nifty little function that automates a simple but annoying manual process. Those of you who use package.el or the use-package macro are probably familiar with the problem. You update a package but it doesn’t load or work correctly. Usually, this is the result of byte compilation problems.

The answer is to uninstall the package and then install it again. It’s not hard but it is a pain. Batsov’s solution is to simply capture the process in a small function. The whole thing amounts to:

  1. Unloading the package
  2. Reinstalling the package
  3. Requiring the package

To make things really easy, he also has an interactive version that does a completing read to specify the package to reinstall. The completing read is populated with the complete package list so it’s easy to get the name right.

If you handle your packages with package.el you should definitely take a look at Batsov’s post. It’s short and easy to read and it’s also easy to just copy his code and insert it right into your init.el.

Posted in General | Tagged | Leave a comment

Lab Notebooks

I love the idea of lab notebooks. I was trained in the sciences but that training was in Mathematics so the idea of lab notebooks didn’t play much of a role. In the experimental sciences and most engineering disciplines, they are not merely crucial but required. If questions arise as to the provenance or precedence of some idea, the lab notebook can be a lifesaver.

When I worked for a computer manufacturer, even the field engineers were required to keep lab notebooks and to turn them in if they left. A crucial aspect of such notebooks is forensics but they can be much more.

Sam Bleckley has a nice post on lab notebooks and why they can be helpful even for software developers. He a software developer but nonetheless keeps a lab notebook for each client. Forensics and proof of precedence are part of that, of course, but as he points out we often try solutions that don’t work out and those experiments aren’t committed anywhere so other developers or our future selves won’t have access to that information and are apt to repeat the failed experiment. By keeping a lab notebook, that information is captured and made available when needed in the future.

I agree with all that but to tell the truth, the thing I liked most about Bleckley’s post is his link to Vela Labnotebooks. These are really beautiful notebooks and have things like numbered pages, a table of contents, and other amenities that make capturing your work easy. I much prefer to keep a digital notebook but for forensic reasons that isn’t always possible. When it isn’t, these Vela notebooks are a great solution.

Posted in General | Tagged | Leave a comment

Hiding Files From Dired Display

Emacs Elements has a short video that explains something I didn’t know. You can tell Dired to not display certain files. My first thought was, “Why would I want that?” After all, if you have a file you probably want to know it’s there when you list a directory.

The justification from the video is that Emacs Elements main computer runs Windows and that OS adds a lot of files and directories whose purpose you may not even know. I was in the middle of feeling sorry for Windows users when I realized that macOS does the same thing and, sure enough, I don’t know what many of them are for.

My mental firmware automatically filters them out so I’m barely aware of them but if the idea of all these files that you never interact with bothers you and you’re a Dired user, the answer is simple. You simply add the file you want to omit to the dired-omit-files variable. It’s a regular expression so you can add file patterns if you need to. On my Emacs, it’s already set to omit ., .., auto-save files, and lock files.

The variable has effect only when dired-omit-mode is t. If you really want to see everything in the buffer you can toggle the hiding with Ctrl+x Meta+o.

The video is only 3 minutes, 34 seconds so you’ll have no problem fitting it in. The problem it describes is a small thing but there’s no reason to clutter up your directory listings and your mind with junk you don’t care about.

Posted in General | Tagged | Leave a comment

Quick Accents

As I mentioned previously, I’m learning Spanish so worrying about accented characters has become a way of life. The above post talks about one of Prot’s videos that discusses how to change the input method for Emacs only rather than at the system level. That’s important because changing the system keyboard can interfere with what Emacs is expecting.

Sometimes, though, you want to enter a single accented character such as with résumé or piña colada in otherwise normal English text. Chris Maiorana has just the thing for this. He has both a post and a video that explains how to do it. They’re definitely worth your attention even if you never need to write in anything besides English. The TL;DR is that you call insert-char and ask for the non-spacing accent mark. Watch the video to see all the details. It’s only 3 minutes and 12 seconds so you slip it in at almost any time.

There are a couple of things worth mentioning about his method:

  1. You don’t need to highlight the character you want to accent. Just put the point immediately after it. That makes it easy to put in the accents as you type.
  2. Rather than using Meta+x insert-char you can simply use Ctrl+x 8 Return and then type the accent you want.

I wish I had known about this method earlier. I always did it by looking up the accented char itself rather than simply adding the accent to whatever character I needed.

Posted in General | Tagged | Leave a comment

Emacs 29.2

Good news from Eli Zaretskii. In a post to the Emacs Devel list he announced that Emacs 29.2 has been released and is ready for downloading. It’s a maintenance release that fixes some bugs but there are no new features. You can read all about the changes in the change logs.

As usual, our greatest thanks to Eli and the other developers who work so hard and selflessly to bring us these updates. They get plenty of abuse but never enough gratitude for their efforts.

Posted in General | Tagged | Leave a comment