Reasons For and Against Emacs

Matthew Weber is a Vim guy. He really loves Vim and finds it the ideal editor for him. Still, he’s not dogmatic about it and acknowledges its shortcomings. He’s tried Emacs several times and could never make it stick but, again, he’s not dogmatic about it.

Although I somehow missed it, Sacha pointed me at one of Weber’s recent videos in which he gives five reasons to use Emacs and one reason not to. It’s a fair summary and although some Emacsers and some Vimmers will argue with some of his points, the presentation is balanced with plenty for each side to agree and disagree with.

I agree with all his reasons to use Emacs although I wouldn’t call them the best reasons to do so. I also agree that there are reasons not to use Emacs but not the one Weber gives. That reason boils down to Emacs has more “stuff” in it than you’ll use and even though you have to enable it, it’s still there and that’s bad for some reason. It’s bad even if one of those unused capabilities turns out to be just what you need as your workflow evolves.

Although Weber doesn’t make the point explicitly, he believes, as do I, that the choice between Emacs and Vim depends on what you want. If you’re looking for a fast, powerful editor and don’t care about having it do other chores for you, Vim is the best choice. If you’re looking for a computing environment that can perform a myriad of chores in a unified way and, by the way, also has an excellent editor, then Emacs is for you. As I often say, Emacs is for the type of person who really wants a Lisp machine even if they don’t know it or even if they don’t know or care about Lisp.

Regardless, it’s an interesting video and worth a few minutes of your time. The run time is just shy of 16 minutes so plan accordingly.

Posted in General | Tagged | Leave a comment

Another Take On Rss

I’ve written numerous posts—the latest one here—about my admiration for RSS and how I use it to deliver interesting posts directly to my Emacs. I’m an unabashed fan and have never understood those who claim it died when Google Reader was discontinued. I don’t feel the need to have my technology choices validated by Google and neither, apparently, do scores of over people who continue to use and benefit from RSS.

Jake Zimmerman has a contrary take. He wasn’t around when Google Reader was extant and everyone agreed that RSS was the way to curate your blog reading. He’s a newcomer who has only been using it for a week and he has some gripes.

He has two main problems. The first is that it can be difficult to find a link to a feed or even determine if there is one. Many sites have a link embedded in the HTML but browsers don’t reveal it so unless the site has an RSS button or link, the user is reduced to making a guess at the feed name and trying to add it to their RSS client. I can’t remember ever having this problem. Every site I visit either has an RSS link or it’s easily discoverable with a DuckDuckGo search.

His second problem is with RSS clients. He can’t find one that works the way that he likes. His requirements are pretty specific: he wants to do everything in the browser and he wants to be able to read his feeds on his phone. I, of course, don’t have either of those problems. I read my feeds in Emacs with Elfeed, which is very configurable and being written in Elisp is easy customize. That means, of course, that I can’t read my feeds on my iPhone or iPad but I’ve never felt the need to do that.

Finally Zimmerman complains that he’s finding it hard to discover a good set of feeds. He either gets feeds that give him too much or not enough. I suspect that this is an operational matter. I generally get about 90 links a day but I don’t read them all. Many are obviously about something I’m not interested in so I just skip them. For the rest, I either read the post in Elfeed if it’s given or press a single key to pop the post up in my browser if not.

I take Zimmerman’s point that RSS can be a little fussy to use but not nearly so much as the alternative of checking each blog periodically to discover if there’s anything new worth reading. Still, Zimmerman has some points and his post is worth reading.

Posted in General | Tagged , | Leave a comment

Happy New Year

The Irreal staff is still recovering from our virtual Bacchanalia1 last night so today we’ll just say

Happy New Year!

Footnotes:

1

Actually, it was just a matter of staying up until midnight and toasting the new year in with a bit of champagne.

Posted in General | Leave a comment

Checking A Word List

Daniel Lemire has a post that poses an interesting challenge. Suppose you have a list of words—Lemire uses “ftp”, “file”, “http”, “https”, “ws”, “wss”—and want to check if some other word is in the list.

Unless you believe in Zawinski’s law, you might choose regular expressions, especially if you’re writing in Elisp. But as Lemire points out, that’s going to be pretty slow. My first thought was to use regexp-opt to generate an optimized regular expression. For the list above, regexp-opt returns the regex "\\(?:f\\(?:ile\\|tp\\)\\|https?\\|wss?\\)", which will be faster than the obvious regexp but probably still not that fast if the check is going to be made many times.

Lemire offers some other solutions—in C++—including the obvious one of just sequentially checking the list. For a longer list, that could be sped up with a binary search but probably wouldn’t help much with the short list we have. He also offers some other solutions based on padding the input string. He has some benchmark results if you’re interested in the relative times.

One solution that he doesn’t mention is the one I would think of first: check inclusion with some sort of hashing operation. The obvious solution of that sort is to just put the list words in a hash table and check the input word by looking it up. That’s going to be very fast, especially if the list is long.

Perfect hashing seems like another good solution for a short list and will be fast to eliminate a candidate word but if you get a hit, you still have to check for a match. In any event, since the word list is known beforehand, you can adjust whatever hashing strategy you use to be as fast as possible. String comparisons are probably going to be the bottle neck is any reasonable solution so it’s important that the solution minimize those as much as possible.

It’s a nice problem and well worth thinking about.

Posted in Programming | Tagged | Leave a comment

Using RE-Builder

Tony Aldon has a nice follow on to his video on regular expression string replacement. In that first video, he mentioned the visual-regexp package as a way of building a regular expression interactively. At the time, I thought that it as pretty much what you get from the builtin re-builder command but maybe a little easier to use.

In his latest video, Aldon shows how to use re-builder to help build a function that searches with a semi-complicated regular expression and replaces parts of the matched strings. The details of the strings and their replacements don’t matter; they’re just a convenient vehicle to illustrate the process.

One of the really nice things about re-builder is that you can easily change the input method and re-builder will automatically translate the regex back to standard notation when you save it. If you get confused by multiple backslashes and when to use them, this can make working with Emacs regular expressions easier.

Likewise, it’s easy to toggle whether or not the regular expression should ignore case. It’s a simple keystroke; you don’t need to manually change the value of case-fold-search.

Aldon demonstrates all this in his video. The shortcuts he uses—other than the one to start re-builder itself—are the default ones so it’s a good way to learn the package.

The video is just shy of 32 minutes so plan accordingly.

Posted in General | Tagged | Leave a comment

Emacs From Scratch

Torstein Johansen has an interesting post on his new Emacs configuration. He’s a long time Emacs user and his old configuration was 20 years old and 1617 lines long. After he refactored his configuration it was down to 368 lines. A lot of the refactoring was simply a matter of removing packages whose functionality had been superseded by core Emacs.

One thing he does in the video is to number each section of the configuration and then add (occur "^;; [0-9]+") at the top. Executing that expression generates a table of contents for the file. That seems like a nice feature but it’s not in his final configuration, which may mean that there’s a problem when Emacs starts.

My own configuration is currently 2461 lines long so I’m sure it could also do with some refactoring. It’s a bit over 15 years old now so there’s bound to be some cruft in there. One comfort that I took away from Johansen’s video is that he keeps almost everything in a single file.

The current conventional practice is to separate discrete functionality into separate files. Johansen finds this hard to navigate and I agree. I get a lot of pushback whenever I say that but it’s still true. It’s nice to know that at least one other person agrees with me.

If you like seeing what other people are doing with their configuration, Johansen’s video is worth watching. The video is 27 minutes, 50 seconds long so you’ll need to schedule some time for it.

Posted in General | Tagged | Leave a comment

Lisp: Advantages and Myths

Lately, I do almost all my programming in Lisp. That might be Scheme, Emacs Lisp, or Common Lisp. I’ve written many times on why I prefer Lisp as a development environment. I like the syntax, and most importantly that it enables what I’ve described as experimental or incremental programming. It’s easy to try bits of code as small as an expression. My go to example of this is Kris Jenkins’ using the technique to build a Spotify client in Elisp that runs in Emacs in less than 16 minutes.

Recently, I came across an article from LispWorks about the the advantages of Lisp and the myths surrounding it. I’m pretty sure that I’ve seen the article before but I couldn’t find any date on it—or even in the HTML source—and I couldn’t find any Irreal posts about it. In any event, it’s an interesting read and should be very useful to those who aren’t familiar with Lisp and don’t know what a great tool it can be. Or even worse, have heard and believe those stale old myths about Lisp being slow, big, interpreted only, and that it needs special hardware to run well.

None of those myths are true and the article does a good job of debunking them. If you’re not a Lisper, you should take a look at the article to discover why you might want to be. Watch Jenkins’ video and discover how delightful writing in Lisp can be. If you’re an Emacs user, you can experiment with the builtin Emacs Lisp and experience the power of Lisp for yourself.

Posted in General | Tagged | Leave a comment

Regex Search and Replace in Emacs

Tony Aldon has a short video on a couple of alternate ways to do regex search and replace in Emacs. The straightforward way to do that is to use query-replace-regexp (Ctrl+Meta+%) but you can do the same operation in steps by first doing isearch-forward-regexp (Ctrl+Meta+s) to make sure you’re finding the right search object and then calling query-replace-regexp to specify the replacement. That’s not as wasteful as it seems because it will remember the search string from the isearch-forward-regexp and you need only specify the substitution.

Aldon gives an example of this in operation so you can see exactly how it works. Take a look at the video to see the details.

The second method is essentially the same except that it uses the package visual-regexp to get immediate feedback on what the regular expression will match as you type it. That can be pretty handy if Emacs regular expressions are your second choice for regex work and you don’t use them all the time. Again, take a look at the video to see the package in action.

Most of the time you’re probably better off to just use query-replace-regexp but if you’re unsure of the regex, the two step process can make sense. The first method uses functions that are all built-in so it’s always available. If you want to see what’s going to be matched as you enter the regex, the visual-regexp package may be for you.

The video is only 8 minutes so it should be easy to fit in.

Posted in General | Tagged | Leave a comment

Why Emacs Keys Are So Unergonomic

Here’s a blast from the past that I recently came across again. It’s Xah Lee’s post on Why Emacs Keys are Painful. Lee, as most of you probably know, is obsessed with keyboard ergonomics and it is fair, I think, to consider him an expert on the matter. His post considers the question of why—given how painful they can be—Emacs shortcuts are the way they are.

The answer, he says, is pretty simple. First, and probably most important, when Emacs was designed, the implementors were using various Lisp keyboards that mostly had the Ctrl key to the left of the space key and the Meta key to the left of Ctrl. Modern keyboards, of course, have those two keys reversed making Emacs shortcuts less ergonomic.

Secondly, the common shortcuts were chosen to be mnemonic rather than ergonomic. Emacs has so many shortcuts that even with the mnemonic choice they’re hard to remember so it’s not clear it was a bad tradeoff. Except for RSI.

Many Emacs users have developed cases of RSI so bad that they’ve moved to Evil mode for relief. Sometimes this was after years of using the conventional keybindings. I’ve been lucky in that respect. Even though I came from Vi(m), I’ve been using the standard shortcuts for over 15 years without ill effect. But others haven’t been as fortunate so the ergonomics of the bindings is definitely not a trivial complaint.

Of course, in this as in other things, Emacs has you covered. Lee, for example, has his
own set of bindings developed along ergonomic lines. And if reaching for the Ctrl and Meta keys is painful for you, there’s always evil mode.

Posted in General | Tagged | Leave a comment

Vivek Haldar on Emacs 29

Like mbork, Vivek Haldar a short list of some changes he likes in Emacs 29. As with mbork’s list, these aren’t the big things, they’re some small changes that he finds particularly helpful or appealing. You can follow the Twitter thread for the details but the TL;DR is

  • Changing the font size globally
  • Find sibling file
  • Rename the visited file
  • Variable pitch text
  • Pixel scroll precision mode
  • Split root window below or to the right
  • Eval region or buffer
  • Scratch buffer command to switch to or open the scratch buffer
  • Highlight undefined commands in shell buffers
  • A couple of new mouse events

Merry Christmas to everyone from me and the minions.

Posted in General | Tagged | Leave a comment