Window Placement When Using Dired

Courtesy of JTR from The Art Of Not Asking Why, here’s a handy tip for dealing with window placement when bringing up a Dired buffer. There are two problems.

The first doesn’t really concern window placement. Most often JTR wants to bring up a Dired buffer for whatever directory he’s already in. The easy way to do that is to use dired-jump (bound to Ctrl+x Ctrl+j) to open a buffer in the same directory as the current file.

The problem with that is that it opens the Dired buffer in the current window. JTR doesn’t want that. He wants to open Dired in some other window so that he can see his current file and the Dired buffer. The answer to that is simple: just ask Emacs to open Dired in another window. There’s a general protocol for doing that. Simply use Ctrl+x 4 Ctrl+J to call Dired. That will open Dired in the same directory as the current file but in another window.

The Ctrl+x 4 … works for a lot of commands. I use it to open files or buffers in another window several times a day. I used to consider it an esoteric maneuver but now I use it all the time. You can also open your windows in another frame by using 5 instead of 4.

The 4/5 protocol doesn’t work for all commands but it does for a lot of them. It’s a real time saver that I use repeatedly. It’s well worth internalizing.

Posted in General | Tagged | Leave a comment

Hiding Buffers

Alec Barreto over at The Wumpus Warehouse has an interesting post on hiding buffers. The idea is that there are some buffers that you just don’t care about and never want to see. There are others that you might want to see but only rarely.

Barreto shows how to deal with both these cases. The first is easy. Just rename the buffer to begin with a space. Most (or all?) of the normal buffer switching commands will ignore such a buffer. The only way of accessing these buffers, says Barreto, is to specify its name exactly in a switch buffer command.

I’m not sure why anyone would want to do this. If you really don’t want to see the buffer, just kill it. Hiding it like this just accumulates a bunch of buffers that you don’t need and don’t want. You can see how this can get out of hand if you’re one of those people who restarts monthly or less.

The part dealing with buffers you only want to see occasionally is more interesting. If you’re like me, you’ll learn something new. It turns out that many—but not all—of the buffer changing commands can be asked to call a function to determine if that buffer should be shown or not. Since you can make that function do anything you like, you very fine control over what buffers are shown. Take a look at Barreto’s post for some examples.

When I read Barreto’s post I wondered why it didn’t resonate with me. I’m always doing things that generate buffers I don’t care about. Sometimes I delete them and sometimes they disappear into my buffer list to get reaped on the next reboot. I realized that the reason this works for me is because I use ivy-switch-buffer to switch buffers and that provides me with a vertical list to pick the buffer I want to switch to. It also offers fuzzy search so I never search down the buffer list. I think the list is ordered by recent use so the buffer I want is almost always near the top of the list.

Of course, that’s my workflow. Yours probably differs and Barreto’s methods may make more sense for you. Regardless, Barreto’s post will teach you about switch-to-prev-buffer-skip in case, like me, you didn’t already know about it.

Posted in General | Leave a comment

Loading The Emacs Init File

Charles Choi makes an astute observation about the Emacs initialization file from the point of view of the new user: there’s no obvious way of loading it or even knowing that it exists. The problem is especially acute on the Mac where the File → Open menu uses the Mac file loading routines that don’t show dot files. Not very helpful even if you know the name of the file.

Choi is surprised that this far on the problem hasn’t been fixed. It’s hard to argue. On the other hand, I don’t remember having this problem. I have no memory at all of how I overcame it but I and thousands of others have. That doesn’t mean that the problem isn’t real, though.

Choi offers a solution. It’s a simple function that loads the init file even if it hasn’t been created yet. His idea is that the function would be builtin and automatically available to the new user.

Of course, the problem is how does the new user discover this function, or for that matter, what to do with the init file once it’s loaded. It seems to me that at the very least there needs to be some instructions on the startup screen—you know, that screen we all turn off as soon as we learn how. That would help but it’s probably not enough.

What’s really needed is a new-user file that explains how to get started. It could be linked from the startup screen. It wouldn’t need to be long or complicated; just enough to bootstrap the new users and point them to the tutorial.

One thing for sure: Choi is right. It’s really harder than it should be for a new user to learn enough to get up to speed with Emacs.

Posted in General | Tagged | Leave a comment

Toggling Narrowing

Over at the Emacs subreddit, sebhoagie has a short post that some of you may find useful. Sebhoagie really likes narrowing and uses it all the time. Sometimes, though, the narrowed code refers to code outside the narrowed region and he occasionally wants to reference it and then return to the narrowed region.

That’s not a big problem of course. Just widen, search for the referenced code, highlight the original narrowed code, and renarrow. Of course there’s a bit of friction and if you need to do it often it can become a burden.

Sebhoagie has a writeup that explains his solution. The TL;DR is that he wrote a function that narrows to a region but when you widen, it remembers the narrowed region. If you narrow again (using his function) it will renarrow to the previous region and forget the saved region parameters. If you think it through, that does exactly what you want. When you’re finished with the narrowed region you simply widen in the normal way (with widen) and everything is reset.

My solution is to use Artur Malabarba’s narrow-or-widen-dwim that almost always does exactly what I want. Take a look at Malabarba’s post to see how it works. If you’re not using it, you’re definitely working too hard. Still, you may find sebhoagie’s useful. If you have a similar need, his code is a nice companion to Malabarba’s.

Narrowing really can be a superpower as sebhoagie says and it’s worthwhile making its use as easy as possible.

Posted in General | Tagged | Leave a comment

The Apple Decision

By now, everyone knows about Judge Yvonne Gonzalez Rogers’ decision that Apple can no longer refuse to let apps link to payment methods outside of the iOS app system. The idea was that if you ordered anything through an iOS app, Apple would get a percentage of the sale. Everybody but Apple hated the policy.

I’m conflicted on the matter. My inclination is to side with Apple. After all, they built the iOS app platform—without which, by the way, those complaining wouldn’t even exist—and they should get to set the rules. I think it’s a huge stretch to claim that setting those rules is somehow an antitrust issue. Others obviously disagree.

I don’t write iOS apps so my perspective is that of a user. One aspect of that use is the iOS Kindle app. Often, when I finish reading a book, there’s a recommendation for the next book in the series. If I liked the book, I will usually order the next book to read later. It’s not a seamless process. I have to leave the Kindle app, go to the browser, bring up the Amazon site, search for the book, and, finally, order it.

Now, happily, that has changed. The Kindle app now has a button that allows you to go to the book’s Amazon page and order it right from the app. I’m really happy about that but I can’t help thinking that it’s not right. It’s almost as if I’m abetting theft from Apple. As I said, Apple built the platform and others came along and claimed rights to it.

I get that app developers are living on the edge and I do think that Apple can afford to and should let them suggest other payment options. And really, most of us are going to take the easy option and order through the app anyway. Still, it’s Apple’s platform and they should get to set the rules. If you don’t like the rules, build your own platform. If you don’t think that’s possible, ask Steve Jobs or Jeff Besos.

Posted in General | Tagged | Leave a comment

A Small Git Improvement For Elisp Files

James Cherti has a quick tip on configuring Git to provide more meaningful diffs for Elisp files. The problem, he says, is that by default Git diffs simply provide a line-by-line difference with no added context such as what functions are involved. It turns out that it’s pretty easy to provide that context.

The process is pretty simple. First you have to provide a regular expression that recognizes the various def constructs such as defun and defmacro. Then you tell Git to associate that regex with Elisp files. After doing that, you get a bit more context in your Git diffs.

Take a look at Cherti’s post for the details. It’s a small thing but easy to do and it may make your change analysis a bit easier.

Posted in General | Tagged , | Leave a comment

Emacs For Non-Programmers

MarchZealousideal543 over at the Emacs subreddit asks a familiar question: Is it really feasible or even possible for a non-programmer to use Emacs productively? I know I write about this a lot but I find the subject fascinating. MarchZealousideal543 got steered onto Emacs by asking some AI for suggestions and apparently Emacs was the overwhelming recommendation.

There’s nothing very interesting about such questions, of course; the interest is in the comments. There’s the usual ankle biting and nonsense but a lot of the comments are excellent and tell stories of how people from all walks of life—even someone in construction—use Emacs to run their lives, careers, or businesses.

The one thing that many of them say, though, is that you should expect to spend a few weeks getting up to speed with Emacs. Those of us who have been using Emacs for decades and still consider ourselves barely up to speed can only smile. Nevertheless, they all say that the startup time is worth it and that you will soon become proficient.

The other story that came up more than once was how the secretaries at the MIT were introduced to Emacs and given a small write up on how to configure it. Because they didn’t realize they were programming, they soon were soon automating their workflows.

If, like me, you like reading about non-technical people using Emacs, take a look at this reddit post.

Posted in General | Tagged | Leave a comment

Searching The Web With Emacs

If you’re one of those brave folks who doesn’t mind browsing the Web from within Emacs, I just came across a package that may interest you. It’s emacs-websearch a small utility that lets you specify a term, search for it on the web, choose one of the results, and open that page in your Emacs.

That may sound a little complicated but take a look at the animated GIF at the link. It seems like a pretty nice workflow. Right now, it supports Duck Duck Go and Google but looking at the code, it would be easy to add your favorite. You can choose between using the xwidget toolkit and eaf-open-browser to display the Web page.

This is one of those small packages that mainly scratches the author’s itch but can still be useful to the rest of us. Take a look and see if it might work for you.

Posted in General | Tagged | Leave a comment

Accessing Research You Already Paid For

A long standing source of frustration in the research community has been the locking of research papers behind paywalls. It’s easy to see how detrimental this is to the scientific research enterprise. After all, the purpose of publishing papers is to share the research results among the greater scientific community.

For all of my adult life—and probably longer, maybe even forever—the research behind these papers have been paid for by the government. In modern times, that means you and me. So here’s the consequence: we pay for the research but can’t read the results of that research unless we want to pay substantial fees to the publishers of the associated papers.

You can easily see the problem from the publishers point of view. It’s an existential threat. If the papers were made available without charge, why would anyone (or more specifically, any institution) pay thousands of dollars a year for access to the journals? The journals argue that they do provide added value. They perform curation, editing, and perhaps most importantly, peer revue of the papers.

But here’s the thing. Except for some in-house copy editors, they don’t pay anything for those efforts. They’re all considered necessary public service on the part of academics. So all of that “added value” can be and is provided for open access, on-line journals. Really, the only reason that paid, dead tree journals continue to exist is academic tradition. The journals have always played a huge role in tenure and promotion decisions in academia and many can’t imagine any other way of doing business.

Regardless, for research funded by the US National Institutes of Health, at least, the journal monopoly is coming to an end. Effective July 1, 2025, the results of all NIH supported research will be available without charge. This is a slight acceleration of the previous policy that required public availability by December 31, 2025, but it serves as notice that this long standing rip off of the public will no longer be tolerated.

Of course, research not funded by the government—if there is any—is not affected but it’s hard to imagine there’s enough of it to make it worthwhile to keep charging for it. Maybe the journals will find a way to reconfigure their business model or maybe they’ll simply go out of business. Either way, we’ll be better off. These days, it’s easy to publish on line and for those who want curated papers, there are already open access sites providing that service.

Posted in General | Tagged | Leave a comment

🥩 Red Meet Friday: Parenthesis: Get Over It Already

As you almost certainly know, we here at Irreal have little patience for those constantly whining about parentheses in Lisp. They seem to us like little kids complaining to Mom that “it’s not fair”. Apparently, we’re not the only ones. Joe Marshal, who I’ve mentioned before, is an old time Lisper—so old timey that he worked on the firmware for one of the actual Lisp machines—who also doesn’t have a lot of patience for the whining.

He settled on a unique solution. He asked his AI client, Gemini, to write a rant for him. I have to admit, as much as I dismiss the current AI craze as voodoo, the rant was probably better than I could have written. If you, too, are tired of the jejune whimpering from the ignorati, take a look at Marshall’s post for some well earned relief.

Maybe we can enlist an army of these AIs to beat the whiners into submission or at least into complaining about something else. The Illuminati maybe.

Posted in General | Tagged , | Leave a comment