Emacs Command From Outside Emacs

Sometimes it’s convenient to execute an Emacs command from outside Emacs. The traditional way of doing that is to run Emacs in server mode and use emacsclient like this:

emacsclient --eval "(some-emacs-command)"

You can, of course, execute several Emacs commands in a row by wrapping everything in a progn.

The problem comes when the command you want to execute is interactive. If the function you’re calling needs some user input, it’s going to have to open an Emacs window and you’re going to have to change focus to that window. You might just as well have done the whole thing in Emacs to begin with.

Isa Mert Gurbuz has posted a nice way to handle some of those situations. The goal is to call the command and handle all the interaction from the command line without having to change focus to Emacs. His two examples show how to pick a choice from a list as with completing read, and how to read an arbitrary string. Reading an arbitrary string isn’t too useful, of course, but it can be an important building block for more complex functionality.

When I’m not in Emacs, I can’t wait to get back so I’ve never felt the need for this sort of thing but Gurbuz’s example of controlling MPV from Emacs when you’re not in Emacs is compelling. In any event, if you’ve ever felt the need to invoke an Emacs function when you’re not in Emacs, take a look at Gurbuz’s post. It’s got a lot of good ideas.

Posted in General | Tagged | Leave a comment

Webjump

How could I not know about this? It’s been in Emacs since Emacs 19.31 so it’s been around for at least 26 years. In case you, too, aren’t familiar with it, Bhaskar Chowdhury has a video that explains and demonstrates it.

The TL;DR is that Webjump allows you to call your default browser and jump to any of several preconfigured Web sites directly from Emacs. Webjump comes with several sites already defined but you can, of course, add your own or otherwise edit the list. You can even specify a function to build a site’s URL for complicated situations. See the National Weather Service entry in the default list for an example of this.

I get similar functionality with bookmark+. I’ve been using it for years since I read about it on abo-abo’s blog. It allows you to set a bookmark for any Website you like. I use it to quickly open the Irreal site all the time. Of course, bookmark+ is a separate package while Webjump is built in.

If you already have bookmark+ installed and don’t need complex processing, like the National Weather Service example, I’d just stick with that. It’s quick and easy and doesn’t involve a menu. If your needs are more complex or you don’t want to install another package, Webjump is flexible and simple to use.

Posted in General | Tagged | Leave a comment

Emacs 28.0.92

Some good news from Eli. The third pretest for Emacs 28.1, Emacs 28.0.92, is now available for testing. As usual, if you can help with the testing by installing and using the pretest, please do so. The heroes who selflessly labor on our behalf will thank you and you’ll be helping speed the release of Emacs 28.

Posted in General | Tagged | Leave a comment

Twenty Two Years With Emacs

Arjen Wiersma has been an Emacs user for a long time: twenty two years. He has a lengthy post about that time that describes those years and also his current set up.

It all started for Wiersma when, after drifting among several editors for a while, his mentor told him to pick one and devote sustained effort into mastering it. He chose Emacs and all these years later he’s glad he did. The story of those years is an entertaining read and worth your time.

The last half of his post is about Wiersma’s favorite packages. No real surprises there; his list is pretty much like mine. It includes the big two—Org mode and Magit—of course but he also uses Org-roam, MU4E, Which-key, Eglot, and Projectile. Those are all packages that can have a huge influence of programmer productivity. Wiersma makes a case for each so if you were wondering if you should try one or more of them, take a look at his post for some reasons you should.

Wiersma’s closing thoughts include one that I’m always pushing: Emacs, far from being defunct, is getting better and better. As he says, “Here’s to another 22 years [of] Emacs.”

Posted in General | Tagged | Leave a comment

Good and Bad Tags

In response to my post How To Use Tags describing Karl Voit’s perspective on the use of tags, Christian Tietze pointed me to a post by Sascha Fast on The Difference Between Good and Bad Tags. Fast makes a good point. The TL;DR is that you should use object tags instead of topic tags.

Fast illustrates the difference with the “diet” tag. If you think of it as a topic, you get all sorts of things thrown into the bin. If it’s in any way related or might be related to a diet, the diet tag will apply. The problem is that it’s not very useful. The category is way too broad and when you search on your “diet” tag you get too many entries, most of which are not what you’re looking for.

If, on the other hand, you treat your tags as naming an object, anything thing with that tag is in some way a diet. So “The Scarsdale Diet” would get that tag because it’s an actual diet but “high glycemic foods” would not because although it’s concerned with dietary matters it doesn’t actually describe a diet.

Take a look at Fast’s post for more detail on the distinction. Tagging can be a big help in searching for items but it’s important to assign them intelligently. Voit and Fast’s posts can help you devise an effective tagging strategy.

Posted in General | Tagged | Leave a comment

Stevey’s Guided Tour of Emacs

Steve Yegge, who is always interesting, has a nice video that he describes as a guided tour of Emacs. Yegge characterizes it as covering “roughly 12 features of Emacs, out of approximately 18 billion hillion jillion total”.

If there’s an overreaching theme to the video it’s that everything is a buffer and that therefore all the usual editing functions are available to work with it. The other important point Yegge makes is how easy it is to customize Emacs. Not only for trivial things like binding key sequences but for writing functions to automate your work flow or even writing an entire mode if needed. As he says, this would be an essentially impossible task with something like IntelliJ but is trivial with Elisp.

The video covers things like calc, shells. keyboard macros, and Dired. He also shows opening a gzip file, selecting and opening a file in the archive, editing that file, and saving it back to the archive. That’s always seemed like magic to me but turns out to be useful more often than you’d think.

The thing that stands out about the video is how enthusiastic Yegge is about Emacs. As he says, he’s still using Elisp he wrote 20 or 25 years ago. That shows, he says, that Emacs is a worthwhile investment that will pay dividends over a lifetime.

The video is just over 45 minutes so plan accordingly. It’s definitely worth watching.

Posted in General | Tagged | Leave a comment

Duck Duck Go Becomes Google

Most Irreal readers know I’m not—more precisely, no longer—a fan of Google. The usual reason that I give for that is the fact that Google gobbles up as much of our private information as it can. But there’s another reason that I don’t mention as often: Somewhere along the line, Google decided they should filter the information they present to me to eliminate anything they felt wasn’t good for me. I’m an adult and don’t need anybody deciding what I should and shouldn’t hear based on their opinion of the subject at hand.

I first started using Google because they gave the best search results available. Sure, they ranked the results but in a way that reflected which sites were most popular as reflected by the number of incoming links. Over time, that changed where a major—if not the major—deciding factor was whether the result was in accord with Google’s sense of what was “right and just”. In other words, whether or not a result was in agreement with the prevailing Google politics. Who wants that? It’s like reading Pravda: you get information but have no idea of how complete or truthful it is.

Happily, there was a solution for both problems: Duck Duck Go. They didn’t vacuum up our information and they were pretty much an honest broker giving us whatever data was out there. Now sadly, DDG has apparently decided that Google was right after all:

I get it. Everyone wants to do something to help the mess we find ourselves in but censorship is never the answer. We’re adults and can judge for ourselves what to believe and what to discount. We don’t need unknown functionaries deciding for us. Especially given the results of filtering “misinformation” that we’ve seen over the last couple of years. It’s shocking how many instances of “misinformation” were subsequently rehabilitated to be conventional wisdom. The people responsible for that are the last people I want telling me what to think.

If you’re a DDG user and want to get all the information available so you can make your own informed opinion, let DDG know that you’re not happy with this decision and ask them to reverse it.

Posted in General | Tagged | Leave a comment

Happy Birthday Dark Side of the Moon

This is the day that Irreal celebrates the 49th anniversary of Pink Floyd’s iconic Dark Side of the Moon. It is one of the most successful albums of all time and still has a devoted following. Here at Irreal, it can often be heard making everyone’s day a little brighter.

As I do every year, I’m offering a cut from the album. This time it’s Us and Them.

Of course, as I say every year, the best cuts from the album were the last two: Brain Damage and Eclipse. You can listen to them from the 2019 post.

Posted in General | Tagged , | Leave a comment

Transient Input Method

Marcin Borkowski (mbork) has a short post that brings news of an upcoming feature in Emacs: transient input method. It’s much like toggle-input-method used to switch to another input method but it’s only in effect for the next character. That can be handy if you need to enter, say, a LaTeX character but don’t want to stay in TeX input method all the time. Of course, you can always just toggle the TeX input method off again but that’s a bit of a pain.

I use the TeX input all the time. It’s usually because I want to use --- to enter an em-dash. That works without TeX input method but the Unicode character it uses messes up the RSS feed. The em-dash character used by TeX input method works correctly so I have to switch input methods to use it. The trouble with the TeX input method for me is that my key chords (as defined with the key-chord package) don’t work so I have to either toggle the input method again or use some other way invoking the function bound to the key chord.

Transient input method isn’t available in Emacs 27.2 so I haven’t had a chance to use it yet but it seems like it could really be handy much of the time. As Borkowski points out, transient input method is an example of polishing Emacs to make editing a bit more pleasant and once again puts the lie to the claim that Emacs is old, defunct technology.

Posted in General | Tagged | Leave a comment

Rectangle Mark Mode

Today, I saw this tweet from Tory Anderson:

It reminded me that I used to use it all the time and thought I even had a shortcut for it but when I called describe-function it said there was no binding associated with it. I searched my init.el and found that it was actually defined as part of a hydra dealing with rectangles.

I was happy to rediscover this and am writing about it in case some of you may have forgotten about it too. In a sense, it doesn’t really bring anything new but it does make it much easier to visualize the rectangle and how the text will be affected when you issue a command on it.

I stole the hydra from this post by abo-abo. The thing with rectangles is that most of us don’t use them enough to burn the keystrokes into our muscle memory, so the hydra is really useful. Of course, you still have to remember that you have the hydra and what its keybinding is. Something not all of us, apparently, can do.

Posted in General | Tagged | Leave a comment