Bending Emacs 4: Batch Renaming Of Files

Álvaro Ramírez has a new video up. This one, Bending Emacs 4, demonstrates several ways of batch renaming files. The secret sauce in most of these methods is the ability of the Dired buffer to become writable and have the changes reflected in the underlying file system. Every time I use it, it seems like magic.

Ramírez’s video shows several ways of performing bulk renamings in the Dired environment. Probably the easiest—or the most natural to me—is simply using a keyboard macro. For instance, if you have a directory full of files ending in .org and want them all to end in .txt, you simply start recording a macro, change the first file, move to the next line, and close the macro. Then you can run the macro on the rest of the buffer to rename all the files. After the renaming, all you need do is type C-c C-c to instantiate the changes into the file system.

Ramírez’s favored way of making the changes is to use Magnor Sveen’s wonderful Multiple Cursors package. It’s a bit more flexible than a keyboard macro because you have finer control over which lines will be changed. Once you’ve got the desired files marked, you simple make the change on one and they are all affected.

The video is only 6 minutes, 42 seconds long so it should be easy to fit in. Ramírez even includes a DWIM command line method of renaming the files. The nice thing about using Dired is that you can arrange for Git to be aware of the renaming. Take a look at the video for the details.

Posted in General | Tagged | Leave a comment

Red Meat Friday: AWS Is Down, I Can’t Sleep

Farce comes to the Internet. All right, farce comes to the Internet again. With the failure of AWS this week, many, many services were interrupted, including my Spanish learning app. It was annoying but, after all, you can always practice Spanish or do your banking, or whatever a little bit later.

But one group of users is especially aggrieved. It turns out that some people actually have their mattress connected to the Internet. What could go wrong? Apparently, a bunch of people found out with the AWS outage. So called “smart mattresses” monitor your sleep patterns and can adjust the mattress temperature on the fly.

Imagine the consternation from the purchasers of these $2000 mattresses when their sleeping temperature is disrupted. How can one possibly get a decent night’s sleep if the mattress isn’t adjusting the temperature according to our sleep patterns? Of course, the vast majority of the world knows the answer to that question and deals with it every night. They raise or lower the covers, put a leg outside the blankets, or do any of a number of things to adjust their sleep temperature.

Of course, all of this is in good fun. I doubt even the people—or at least most of them—who own these smart mattresses are taking this very seriously but it does make a point: we are—more and more—relying on a stable Internet connection for many aspects of our lives but that connection is extremely fragile. A large part of the problem is that a huge number of these services depend on Amazon, Google, or Microsoft to provide those services. That’s a lot of eggs in every few baskets.

Posted in General | Tagged , , | Leave a comment

A Simple Emacs Dashboard

Randy Ridenour, whom I’ve written about before, has an interesting post on customizing the Emacs Dashboard. The Dashboard is something that appears when Emacs starts. It typically shows recently visited files and the current agenda items.

It’s configurable—of course, it’s Emacs—but Ridenour wasn’t happy with the default configurations. Emacs being Emacs, it was pretty easy to get things just the way he liked them. Part of that was displaying the agenda in a the usual way rather than just a list of activities. In particular, he like having the current time displayed—the way it is in grid view—and even arranged for it to appear in red so that it would stand out. He also arranged to have the agenda updated every minute so the time would always be up to date.

In addition to the agenda, he has a list of links that he wants to appear in the Dashboard so he has an Org file with a table of those links that he imports and then activates the links. At the end, he has a Dashboard with exactly the information he wants.

To be honest, I’ve never seen the point of Emacs Dashboards. My Emacs is always running so startup Dashboards don’t make any sense to me. I know you can start them whenever you like but, again, I’ve never seen the point. When I start Emacs, the first thing I do is start the agenda and mu4e. I could easily automate that but it’s so easy to start them by hand and I start Emacs so infrequently that it’s not worthwhile.

In any event, if you’re one of the many people who do like an Emacs Dashboard, Ridenour’s post may have some ideas that you can use.

Update [2025-10-24 Fri 14:12]: Added link.

Posted in General | Tagged , | Leave a comment

Mistakes Startups Make

Over at Reddit, MeirDavid has a truly terrifying post on why startups fail. He presents himself as a troubleshooter and his post is based on common problems startups in extremis experience. Like everything on the Internet these days, it’s hard to know how true his story is but it does have the sound of truth. If you’ve been around for a while, you’ve doubtless seen the type of basic mistakes that he describes.

MeirDavid begins by saying he’s audited the code base of 47 failed startups and has found the same patterns in all of them. He are some of the things he found:

  • 89% didn’t bother indexing their databases. I don’t know how this is possible. The whole point of databases is indexes that make it easy to access data. Otherwise, why not use a flat file?
  • 76% were over provisioned. They typically were using only 13% of the resources they were paying for. One of the points of renting virtual servers is that you can spin them up as you need them. Why in the world would you have eight times the number you need?
  • 68% had auth vulnerabilities. That, at least, is understandable. It’s notoriously difficult that get security right but there are, after all, out of the box solutions for that sort of thing.
  • 91% had no automated tests. This is all too common and a really serious mistake. My enlightenment came when I read that Walter Bright, known for his C and C++ compilers and for the development of the D language and its compilers, has a test for every single error his compilers have ever made and that he runs those tests with every change to the compilers. That’s the sort of thing that helps you not revisit previous errors.

MeirDavid expands on these themes and the lessons to be learned from them so you should definitely take a look at his post.There’s really no reason to be making these mistakes but they are depressingly common.

Posted in General | Tagged | Leave a comment

Rendering SVG Images In Org Generated HTML

I’ve recently discovered to my surprise that rendering an SVG image in HTML from Org mode is difficult or at least poorly documented. It comes as news to me because the images that I want to render are always JPEGs so I’ve never stumbled on the problem.

It turns out that there are two solutions. The first, from Norman Walsh, converts the Org mode link to the SVG file into an HTML div containing the image. Unfortunately, Walsh doesn’t give any details.

The second solution, from tusharhero, leverages the Org Babel interface to make and display an SVG image. I like his solution better but that’s probably because it seems more familiar. It’s certainly what I would try to do if I didn’t have the advantage of Walsh’s and tusharhero’s wisdom.

As I said, I never deal with SVG images so there may be better ways of handling all this but here, at least, are two solutions in case you are having the same problem.

Posted in General | Tagged , | Leave a comment

World Clock Improved

In the old days, World Clocks were a sort of curiosity. There wasn’t a lot of need for them because most folks communicated with distant friends and colleagues with snail mail and later, I suppose, with email. In any event you didn’t need to know what time it was at the destination unless you were making an almost certainly hideously expensive phone call.

Now, of course, you can instantly message someone—or even call them in many circumstances—with no charge and it’s best to know that it’s not 3 AM where they are. That’s why, today, a world clock is almost a necessity. You can always ask the Duck or whatever you use but if you’re communicating with several people, it’s convenient to have your own world clock with all the appropriate times.

Emacs, as usual, has us covered. There’s the world-clock command that gives you the current time in a few cities but if you’re parochial like me, knowing what time it is in London doesn’t help much if I want to talk to someone in, say Glasgow. Maybe it’s the same time zone; maybe it isn’t. I have no idea. Like most things in Emacs, the cities displayed are configurable but it’d be pretty inconvenient to add cities on the fly.

The other problem is that only the current time is displayed. What if you’re trying to set up a meeting and want to know what time it will be sometime in the future? It would be nice to be able to adjust both the cities and the time displayed.

Álvaro Ramírez had these problems and being Ramírez he wrote a package that solves both of them. You can add cities on the fly and adjust the base time forward and backward. Right now, the package is only on GitHub so you have to get it from his GitHub repository but he’ll probably put it up on Melpa eventually.

This is a great package that makes figuring out what time it is/will be/was in some arbitrary place in the world easy. Take a look. It may be something you didn’t realize you needed.

Posted in General | Tagged | Leave a comment

Emacs On The Go

It’s Sunday and nobody—especially me—feels like working so here’s a short interlude while we’re waiting for the new week to begin. The subject of today’s post falls in the broad category of what could be called “mobile Emacs”.

Most of us have wished for a way to take Emacs with us when we’re out and about. Certainly, no one would want to do any serious editing on a smart phone—although Po Lu has produced an Android port—but it’s not hard to imagine using it on an iPad or other powerful tablet.

Then there’s this guy who literally wears his computer complete with a heads up display so that he always has access to his Emacs. When I saw the video, I immediately thought of Neal Stephenson’s gargoyles from Snow Crash. It’s the exact same idea: people wearing computers—and looking odd—so they can stay continuously connected to the metaverse or what we in this world call “the net”.

As much as some of us would like to be permanently connected, I doubt that many of us are prepared to embrace the solution suggested in the video. Of course, I could be wrong and it’s just what people are looking for. Let us know what you think.

Posted in General | Tagged | Leave a comment

How To Speed Up Emacs

Over at the Emacs subredit, iinnssdd says he was looking for a guide to speed up Emacs but couldn’t find one. Therefore, he put together his own. This is more than the usual “how to make Emacs load faster” article, which we all know are silly and a waste of time. Although there are some suggestions for making Emacs load faster, the useful parts are how to make Emacs run faster once it’s loaded.

Some of that are compile time options when building Emacs from source. Iinnssdd’s particular options may or may not apply to your situation but they’re worth taking a look at. Another obvious strategy is to make sure that you have native compilation enabled. Iinnssdd has some suggestions for that.

A couple of specific recommendations are applicable to many of us. They’re both pretty simple and easy to implement. The first is a hook function to the find-file function that looks at how many lines the function has and turns off display-lne-numbers-mode when there are more than 1000 lines. It’s easy to see why this would speed things up on large files.

The second speedup is similar. It’s another find-file hook that looks for C files that have more than 1000 lines and turns on simpc-mode when it finds one. Simpc performs minimal syntax highlighting and indentation and, according to its author, is much faster than c-mode, c++-mode, cc-mode, and so on.

Even though I don’t have native compilation enabled on my older MacBook (2019), I still don’t find Emacs insufferably slow. That could be one of the benefits of having grown up with much older computers that were really slow. Regardless, if you’re intent on squeezing every bit of performance from Emacs, Iinnssdd’s post may give you some ideas.

Posted in General | Tagged | Leave a comment

Librephone

I just saw this announcement about the Librephone from the FSF. The idea is to provide a replacement for the Android smartphone operating system that would be free and open and not vacuum up everything you do with your phone the way Google’s Android OS does.

It’s easy to dismiss this. We’re always seeing some startup claiming to be producing the latest iPhone or Android killer but these “killers” always slip beneath the waves unfulfilled and never to be seen again. At the end of the day, we’re left, as always, with the iPhone and the Android phones,

On the other hand, I remember when the GNU project was announced and thinking that it was a pipe dream that would never succeed. We all know how that prediction turned out. GNU has eaten a large part of the software world and even the parts that it hasn’t swallowed whole still depend on software from the GNU project.

GNU really did change the world so only a fool would dismiss their efforts. In a way, they’re perfectly positioned. They don’t have to worry about developing hardware, dealing with cell carriers, and government agencies, or any of the other hard stuff. Their idea, as I understand it, is to provide a drop-in replacement for the existing Android operating system.

To be sure, the entrenched surveillance industry that abuses the Android system will resist these efforts just as Microsoft and others strenuously resisted Linux and the free software movement. Still, it would be foolish to dismiss Librephone’s efforts out of hand. It will be interesting to see how things play out. The FSF has recruited some very talented people to work on the project so the technical aspects are probably well in hand. I’d guess the major problems will be political and marketing. Unlike GNU, Librephone is aimed at a wider market than just the nerds and that may require winning over the man on the street.

Posted in General | Tagged | Leave a comment

Bending Emacs 3: Git Clone

One of the nice things about Emacs is that when you find yourself performing the same set of steps repeatedly, it’s easy to capture those steps into an Emacs function or even a keyboard macro. If you’re like me, you’ll keep repeating those steps over and over until one day you realize that you really should automate them. Álvaro Ramírez has a video showing a nice example of this: cloning a git repository.

Ramírez begins his video by showing his old procedure. It’s really simple. Capture the URL to the clipboard, change into the target directory, paste the URL into a git clone command on the Eshell command line, execute it, and open the directory in Dired. If there’s a README, open it as the last step. It takes longer to write it down than it does to actually do it.

Still, they’re simple steps and easy to automate, which is what Ramírez did. His solution is nice. He just has to capture the URL and call his function. Everything else, including opening the README file is handled automatically. He has a bit of code to allow choosing the target directory if he doesn’t want to use the current directory. You can check out his code in his GitHub repository. It is, as I say, simple but it’s a nice example of removing friction from your workflow: just let Emacs handle the routine chores.

The video is only 6 minutes, 54 seconds long so you should have no problem finding time for it. It’s interesting and worth a few minutes of your time.

Posted in General | Tagged | Leave a comment