Displaying Alerts from Eshell

Jürgen Hötzel has a nice post on solving a problem many of us have. Suppose you start a long running process—a make, say—from Eshell and then go on to do other work. It’s easy to lose track of the process because the original buffer may be buried and nothing might happen for a long time. Hötzel wants to be notified when the process completes or if it terminates abnormally.

It turns out to be absurdly easy to do that by leveraging John Wiegley’s alert package. Hötzel has the alert set up to show in the minibuffer but the alert package supports many different styles of alerts. For example, if you’re a Mac user and have Growl installed, you can send the alert to Growl. Another nice feature of the alert package is that you can add rules to filter the alerts. For example, Hötzel added a rule to not display the alert if the original buffer is visible. That helps cut down on noise.

Hötzel triggers his alerts by hooking into the eshell-kill-hook but it’s easy to see how you could generate many other types of alerts either by using other hooks. Take a look at Hötzel’s code; it’s very minimal and simple and mostly decides whether the alert should have “normal” status (when the process terminate normally) or “urgent” status (when the process terminates abnormally).

Posted in General | Tagged | Leave a comment

Happy Birthday DMR

Today is Dennis Ritchie’s birthday. Take a moment to remember the man who, along with Ken Thompson, invented Unix and changed our world. Those of us in computer related fields would be working in a completely different environment were it not for him and Ken.

Sadly, Ritchie died in 2011. When he was still alive, I used to check in with his home page everyday to see what new splendor he had revealed. Most of the public have no idea who he was or what he did but his work touches their life everyday in a multitude of ways. If you’re doing anything with a computer—using a cell phone, browsing the Web, using a word processor, or whatever—the chances are you are using some of Ritchie’s work.

Geeks everywhere miss him and are grateful for his contributions. This is a good day to remember him and those contributions.

Posted in General | Tagged , | Leave a comment

Firefox’s Plans for Fighting Tracking

The Firefox developers at Mozilla are no longer going to tolerate the miscreants in the Adtech business. On their blog, they lay out their plans for dealing with tracking. Among other things, they will be stripping cookies from tracking sites and not allowing them the use of local storage. Take a look at the post for what they’re doing and why they’re doing it. The Safari browser is also addressing the problem in similar but slightly different ways.

I wish the other browser vendors would also get serious about tracking. What I’d really like to see is fine grained control over cookies. As it stands, I have to manually delete cookies several times a day. Why can’t I specify something like, “Except for sites A, B, and C, delete all cookies at the end of each session or when I push a button.” That would enable innocuous sites like weather or TV Guide to store their configuration between sessions while still getting rid of the riffraff.

Safari makes it particularly difficult to deal with cookies because they store them in a database. When they’re just text files, it’s easy to write shell scripts to get that fine grained control. Still, Firefox’s initiative is welcome and I hope that they and the other vendors will give us still more control over our browsers. There’s no reason that the browser vendors should be enabling the reprehensible behavior of Adtech.

Posted in General | Tagged , | Leave a comment

Emacs → VSCode → Emacs

Bryan Willson Berry over at Hotair.tech recently moved into JavaScript development. Although he is a longtime Emacs user, he didn’t like the JavaScript support in Emacs so he moved to VSCode. VSCode is the new editor hotness, of course, so I was interested in what he had to say. I know a lot n00bs are drawn to VSCode but I wanted the opinion of someone who had experience with a serious editor.

Berry found that VSCode is an excellent editor and that it was especially good for JavaScript programming. He also found that although VSCode was better than Emacs for JavaScript, Emacs was better at almost everything else. That and the fact that he used Emacs key bindings in all his applications and therefore had serious muscle memory issues—See? I’m not the only one—caused him to move back to Emacs.

Happily, he was able to find some tools that helped with his JavaScript programming so the story has a happy ending. He still believes that VSCode is a superior for editing JavaScript but that Emacs is better in so many other ways that it makes sense to stick with it.

It’s always pleasant to have one’s biases confirmed, of course, so we Emacers probably shouldn’t read too much into Berry’s experience. Still, that experience does confirm my preconceived notion that while other editors may do this or that better, all-in-all, you can’t beat Emacs. But then, I would say that, wouldn’t I?

Posted in General | Tagged | Leave a comment

EmacsCast #4

Rakhim Davletkaliyev is back with another Emacs Podcast. He’s got a new website and—in accordance with the cunning plan devised by the Emacs mandarins—has been seduced into using Hugo and Emacs to post to it. The plan was so successful that he’s also moved his other sites over to the same model.

After a brief discussion of the need for all of us to support those selfless souls who labor for free on behalf of Free and Open Source software, he moves on to the podcast’s main topics: Spacemacs and Doom. He gives a very balanced account of the pros and cons of each distribution and discusses why you might want to use one.

His main conclusion is that Spacemacs in particular is aimed at immigrants from the Vim world. It’s certainly possible for a n00b to start with Spacemacs but Davletkaliyev thinks that unless you’re coming from Vim it’s probably better to start with vanilla Emacs. Listen to the podcast for his reasoning about that. Even so, many beginners, after spending some time trying to grow their own configurations, may find the preconfigured environments in Spacemacs or Doom a better fit for their needs and move to one of them.

He doesn’t discuss one of the major reasons folks experienced with vanilla Emacs move to Evil, Spacemacs, or Doom: RSI problems. There’s no doubt that the Vim keybindings are much easier on your wrists than the Emacs ones are. Still, many of us have used vanilla Emacs for many years without a problem so whether or not this is an issue will vary with the individual.

The podcast is 36 minutes so plan accordingly.

Posted in General | Tagged | Leave a comment

A Swiper Tip

In case you’re a Swiper user and missed it in yesterday’s Languages for Text Processing Post, akirakom’s Emacs subreddit post contained a tip for using Swiper. In the middle of a Swiper search you can type Meta+q to start a query-replace.

I couldn’t find that anywhere in the documentation but you can see the doc string by pulling up the documentation for swiper-query-replace. The code is here but it basically just asks for the replacement string and calls perform-replace just as query-replace does.

Posted in General | Tagged | Leave a comment

Languages for Text Processing

The other day, Xah Lee, as he is wont to do, provoked a spirited debate on Mastodon about the usefulness of Emacs Lisp for text processing. Lee wrote that although he has used Elisp for text processing for many years, he’s lately come to believe that that was a mistake.

His major complaints appear to be Elisp is much slower than, say, Python or Perl and that its regular expression system has a nonstandard syntax that, among other things, requires too much escaping. Lee is undoubtably right; those are shortcomings with Elisp. The question is how much they matter. I’m inclined to agree with Vasilij Schneidermann that they don’t matter. That’s just my opinion, of course, and no more valid than Lee’s that they do matter.

Regardless, that discussion inspired a post over on the Emacs subreddit by akirakom that asks what languages people use for text processing. Most respondents said that their tool of first choice was Emacs—it is the Emacs subreddit after all—but they had a list of other tools ordered by difficulty and power of each tool. The lists were typically something like (Emacs bash sed awk Python C). Some preferred Perl to Python and awk and others substituted some other compiled language for C.

I pretty much agree with the above list except that I would substitute Scheme for Python. Really, though, I almost always just use Emacs and Elisp.

Posted in General | Tagged , | Leave a comment

Fixing an Emacs Lisp Annoyance

Over at emacs ninja, Vasilij Schneidermann talks about his number one annoyance with Emacs Lisp. Schneidermann says there are indeed problems with Elisp but he differs from most folks on what they are. He doesn’t care that it’s not fast and he isn’t worried about Emacs’ regex implementation. He’s got just two big problems with it. The most important of those is the lack of name spaces.

Schneidermann isn’t the first to complain about that, of course, but he did want to do something more than complain. He thought about using one of the packages that mostly resolve the issue but rejected them because they meant another dependency and would break his workflow. What he did instead was a sort of low tech solution that has most of the virtues of name space packages but also is lighter weight and fits in with his workflow.

His solution automates what we all do: he adds a prefix to all his otherwise global identifiers but instead of having to laboriously type them out each time, he wrote a bit of Elisp that guesses the package name from the defgroup macro and inserts it when he presses Ctrl+.. This seems like a nice solution to me, especially if you only infrequently write packages and don’t want to bother installing and dealing with another package to resolve the issue.

Posted in General | Tagged | Leave a comment

Literate Programming for Programming Notes

Over at Arcadian Visions there’s a nice post on using literate programming techniques for making programming notes. The specific problem the post addresses is how to effectively take notes on some piece of programming arcana that you will want to remember later or perhaps share with a colleague. Part of the requirements is to have working code embedded with the note.

An excellent first order solution to this is, of course, Org mode and Babel and I’ve written several posts about that. This poster, though, is seeking a more “reproducible research-like” solution. He wants to be able to reproduce the original solution exactly as he performed it the first time: same code, same libraries, same everything. To restore the original environment he leverages direnv and nix. There is even an Emacs interface to direnv to make things easier.

Even if you don’t need or want to restore your original environment, the post is still worth reading for the Babel examples. Usually such examples are pretty simple but here the examples are more real world and use C++ and Haskell as the target languages. It even demonstrates how to teach Org to run a “new” language.

Anyone who uses or want to use Org Babel should read this post. It’s especially useful for anyone who wants to use Emacs and Org for reproducible research.

Posted in General | Tagged , | Leave a comment

Whitespace and Regexes in Emacs

I’ve always found that specifying whitespace in an Emacs regex was harder than it should be. If I want anything more than a simple space (or spaces) I always have a difficult time remembering the incantation. Over time, I’ve settled on \s-, which seems to work in every case I’m interested in.

Marcin Borkowski (mbork) had similar difficulty and has a great post on what he’s discovered. The situation is more complicated than you might think but it all makes sense once you understand what’s going on. The TL;DR is that in almost every case, \s- is indeed what you want but there are some edge cases worth knowing about. Take a look at Borkowski’s post to see what they are.

Posted in General | Tagged | Leave a comment