Doom Emacs: Opening a project in dired instead of having to pick a file

So, I thought that “feghoot” and “shaggy dog story” were interchangeable. They are not. This section of today’s daily post, while possibly qualifying as a shaggy dog story, will not end with a pun. If you’d like I am happy to do a Zoom call or meet for coffee or lunch and share one or two of the three feghoots I cherish. If there is anything more fun than telling one of them and seeing how long I can prolong your agony, I don’t know what it is.

Actually, I do: It’s being stuck in a room with a bunch of directors all sitting around awkwardly awaiting the CEO’s arrival having exhausted all their small talk, and telling three feghoots in a row. The first one elicits uneasy and nervous grins, but what the hell: It’s Mike and he does things like this and also we’re out of small talk.

Rounding into the second one, the smiles are more forced. Is he going to prolong the telling? Is this one perhaps more efficient? Has anyone checked Slack to see where Yvonne is?

The third one, and you’re out of “nervous grin” territory, and into the family of facial expressions that pair well with “rictus.” Except for the one or two people who are completely here for the performance. Your people.

And it’s completely a race against time. The CEO could turn up at any time. Three feghoots in a row is a punishing exercise, so getting them all in without betraying the form with efficiency and then quietly packing up your wagon and riding out of town/slipping back into the mien of your accustomed station … it’s a craft. You know you’re good at it when you start any conversation over the next six months with “so … " and people wince.

Anyhow:

By default, Doom’s projectile project switcher command (SPC p p) uses projectile-switch-project to take you to another project. That means you hit SPC p p and it presents a list of known projects, you select one, and then it asks for a file. If you don’t want to open a file, you just want to be in a project directory, and if you’re using Helm, you can use CTRL d to open a given project directory in dired at the point in the workflow where you have a list of projects.

This is fine, and I think I actually may have seen a testy Stack Overflow exchange about the matter, because one would-be answerer could not understand for the life of them why you’d not want to get to a specific file in a project right away … do you not know why you’re going there?

I do, but I’ve got my reasons. One is very straightforward: I want to go to the project so I can do magit stuff with it, and it is weird to me to have to open a file. Another is just a personal tic: When I switch to a project, opening its directory is sort of like pulling a project’s folder out of the filing cabinet and opening it on my desk. It’s a small mental reset. “I was there doing that, I am now here doing this.”

Anyhow, I’m using Vertico instead of Helm. Vertico does not, as near as I can tell, have a way to open a directory in dired from the Projectile picker.

So …

(defun my-vertico-project-dired ()
  (interactive)
  (let* ((collection (projectile-relevant-known-projects))
         (project (completing-read "Open project in dired: " collection)))
    (dired (expand-file-name project))))

(map! :leader
      :desc "Open project in dired" "p p" #'my-vertico-project-dired)
      :desc "Select project and file" "p P" #'projectile-switch-project)

That just remaps SPC p p to a function that opens a given projectile project in dired, and then moves the original command to SPC p P if I ever want to go that way.

But that made me think about what problem I was really trying to solve initially, which was just opening my blog project in magit right away while in another project. So:

(defun my-magit-start-in-hugo ()
  (interactive)
  (magit-status "~/src/hugo"))

(map! :leader
      :desc "Start Magit in ~/src/hugo"
      "g h" #'my-magit-start-in-hugo)

SPC p p is so wired into my muscle memory after just a few months of Doom use that I can imagine I won’t use the shortcut that routes through the Hugo submenus that much. But it’s there.

Anyhow, once I went through all that I asked myself why I had my blog.org file over in my ~/org/ hierarchy to begin with. I remember why I did it that way, but realized I didn’t need to do it like that. So I moved it over into my Hugo repo/project where it can just travel around with the project it belongs in, anyhow.

But I can open any project straight into its directory using Vertico now!

My tiger rock

Nine or ten years ago our house got broken into. Al came home to do the front door jimmied open, all of our small electronics crammed into suitcases, and our bikes moved out of the garage and into the living room. She closed the door, turned around, and walked across the street, where she sat on the curb and called me. Given that everything was sitting there in the living room, it stood to reason someone was, perhaps, still upstairs.

So I left work early, picked Ben up from his art camp, and came home. I poked my head in the house, saw the situation, and yelled up the stairs that it’d be best, were anyone to still be up there, to get out, and that if they wanted to do that I’d be across the street and not in their way. I don’t know if that strategy made a ton of sense, but I wasn’t going to commit to going in the house and cornering someone, and I wanted to offer them an out that might avert eventual violence.

So we all sat on the curb across the street from the house, unsure of how to proceed. Nobody had come out for over an hour, so it seemed unlikely they were still upstairs. Eventually, when I checked my mail, I realized that UPS had dropped a package off about an hour before Al got home. UPS always bangs on the door when they drop something off, so we reasoned that the UPS person had dropped off a package, pounded on the door, and frightened off the thieves. I poked my head back in, saw that the back sliding door was slightly ajar, and realized they’d gone out the back.

The police eventually turned up, took the crowbar into custody in case there were prints, and told us it was sort of a nothingburger situation because nothing had been stolen. We had to pay to repair the door. It was sort of gross, once we took stock, to see how they’d gone through drawers, dumped out boxes, tossed underwear around, etc.

So, we got an alarm system. It’s a common kind, not super expensive, easy to set up, has an app, and it will call a dispatcher if you don’t disable a triggered alarm within a minute.

It has worked fine for the last decade, but a few months ago we were told it needed to have its cellular module upgraded, and we settled into a routine of the alarm system telling us it would soon be useless if we didn’t open the manila envelope the vendor sent us and do brain surgery and us ignoring it and the increasingly insistent emails.

Maybe it’s complacency, but we’ve lived through the several years since that incident and we have formed an impression: We’ve called 911 a few times over neighborhood shootings, a brutal assault in the park across the street from our house, a brush fire on the Springwater, an attempt to get help for a Spanish-speaking guy who’d been mugged on the trail, and Al’s shattered elbow joint from a longboarding accident. One of the faster responses we ever got was to the longboarding accident, which involved a three-jurisdiction squabble over who should come get her. The fire response wasn’t bad. The violent crimes took over an hour, and on one of them no reports were collected even though we had a license number and description.

“Should we even bother calling next time?”

“Yeah, tell your state representatives to give the police more money. We’re not going to investigate it.”

Literally.

This is, theoretically, the same agency that the alarm system dispatchers would contact were someone to break in.

So as I sat at the kitchen table with a tiny screw driver, carefully removing the old cell module and screwing in the new one, I rationalized the use of my time by remembering that the one time we have had a break-in, a loud noise is probably what frightened off the burglar, and that the alarm system does make a super loud noise. And also that if we had an alarm, and someone broke in, we’d at least know it because we’d get a ping from the app or an SMS and there’d be less chance of anyone walking in on someone.

But the police part? There’s always the Simpsons.

They Live

… is showing at the Hollywood this week and next.

GIF of Roddy Rowdy Piper in They Live - I'm all outta bubblegum

Its time was then. Its time is now.