## The Silver Searcher, Ivy-occur, and Swiper

I’m stuck in my ways and stubborn so even though I use macOS as my primary platform, I have, for years, insisted on compiling all my tools from source myself. The Mac platform has just enough idiosyncrasies to sometimes make that a challenge. Of course, there’s the excellent Homebrew to solve these problems but as I said: stubborn.

For a long time, I’ve wanted to try out ag (The Silver Searcher) but the make process required a bunch of utilities that I didn’t have installed and it just seemed like too much trouble. Then I watched Mike Zamansky’s video on using Emacs for C++ programming in which he mentioned ag and using it with counsel-ag (part of Ivy) as a particularly nice way of tracking down where identifiers or other symbols are used in a project. There’s also the excellent refactoring workflow using ag and ivy-occur that Samuel Barreto wrote about. That, finally, convinced me to install homebrew so that I could easily install ag and other hard to build tools.

I’ve been really happy with ag since I installed it and have woven it into my workflow. If you have Ivy installed, you can use counsel-ag to call ag from Emacs and have the results put in the minibuffer. That’s what Zamansky showed in his video. You can also put the results in a separate buffer so that you can visit each occurrence separately and conveniently. Although it’s not clear from the video, Zamansky does this by calling ivy-occur with Ctrl+c Ctrl+o.

Once you’ve got the results in a separate buffer, you can toggle on wgrep with Ctrl+x Ctrl+q and then use iedit, multiple-cursors, or query-replace to change all occurrences of some text. It’s a really powerful way of working. Because ag operates recursively, it’s perfect for working with all the files of a project at the same time.

That got me thinking that you could doubtlessly do the same thing with the results of a swiper search. That is, you can move the results of the search from the minibuffer to a separate buffer. There’s no point, of course, in making that buffer writable and making changes because you could do that in the original buffer more easily but it is nice if you want to visit some or all of the results. Since the buffer is an occur buffer you can simply click (or type Return) to visit any particular instance and then change back to the occur buffer to pick another. That’s often very handy.

Posted in General | Tagged | 3 Comments

## Going to the Nth Paragraph in Emacs

The Emacs Stack Exchange has an interesting discussion on how to navigate to the nth paragraph in an Emacs document. The original questioner noted that although there is a function to navigate to the $n^\text{th}$ line, there is no corresponding function to navigate to the $n^\text{th}$ paragraph.

If you’re like me and hardly ever need to do this, the easiest thing is to move to the beginning of the buffer and use Meta+} with a numeric argument of the paragraph number you want to go to. For example, to move to the 7th paragraph you would type Meta+< Meta+7 Meta+}1.

If you do this a lot, one of the answers provides a function, that essentially does the above, that you can bind to a convenient key sequence.

## Footnotes:

1

Or Ctrl+7 Meta+} if you don’t map Meta+n to a numeric argument

## Guile 2.2

The long awaited 2.2.0 version of Guile has been released. This version is a significant update to the Guile system. It includes a new compiler and VM and several other performance enhancing changes. They even boast a complete Elisp emulation. See the announcement, linked above, for a complete list of the changes. Andy Wingo has been working on this upgrade for 6 years and we all owe him a debt of gratitude.

I downloaded, compiled, and installed it without any problems on my MacBook Pro. It takes a while to compile—even on my speedy laptop—but installs cleanly after that. You may remember that I’ve had problems compiling and installing Guile on my Macs before but I had no difficulties this time.

I just got it installed so I haven’t had much time to play with it yet but it seems very nice at a cursory glance. If you’re a Schemer, you should definitely give it a try.

Posted in General | Tagged , | 1 Comment

## Prompting on Exit from Emacs

Coffeecupp_ over at the Emacs reddit asks if there’s a way on macOS to prevent Emacs from quitting when the last window is closed. That’s not a problem I have but I learned a couple of useful things from the discussion.

First, and this applies to all OSes, mbork suggests just setting the confirm-kill-emacs variable:

(setq confirm-kill-emacs #'y-or-n-p) ; or yes-or-no-p is you're really paranoid

For some technical reasons that doesn’t do quite what coffeecupp_ needed but it did solve a problem for me. I have a periodic task in which I need to take data from a Notes app window into Emacs. I do that be positioning my Emacs window over the Notes window so just the data I’m interested in shows. Afterwards, I usually use Cmd+Tab to bring the Notes app to the foreground so I can kill it with Cmd+q. Of course, I usually type Cmd+q first and kill Emacs instead.

I was sure that Emacs had a way to ask for confirmation before killing but I never got around to finding out what it is. Thanks to mbork, I now know so I won’t have that particular problem again. Normally, I hate confirmation messages like that but I kill Emacs on purpose much less frequently than I do by accident so it make sense for my particular workflow.

The other thing I learned is the difference between emacs –daemon and starting server mode in init.el. I always assumed they did pretty much the same thing but it turns out there’s a useful difference. If your goal is to ensure that Emacs keeps running—as opposed to just enabling emacsclient—then you should use emacs --daemon. The answers in the above Stack Overflow question explain this in a little more detail.

So, not bad for a question I didn’t care about in the first place.

UPDATE [2017-03-16 Thu 13:23]: y-or-no-p → y-or-n-p.

Posted in General | Tagged | 2 Comments

## Shell and Comint History

A couple of weeks ago I saw this nice post on advanced Bash shortcuts over at \${me:-whatever}, If you haven’t seen it, be sure to take a look. Even though I’ve been using Bash for more years than I care to contemplate, I still learned a couple of things I didn’t know—or at least a couple of things that I may have known but had forgotten.

I was reminded of that post when I read Mickey’s latest Mastering Emacs offering, Shell & Comint Secrets: History commands. It turns out that many (most) of those Bash shortcuts are available in any comint process. That includes the shell command, of course, but it’s also true of things like the Python shell.

Mickey shows a number of ways to use these shortcuts to ease your workflow. Some of them are probably too much trouble to bother with but some are really useful. For example, you can capture the $n^\text{th}$ argument of the last command and reinsert it in the current command. If you’ve ever had to use a/really/long/path/with/ReallyLongNames in several commands in a row, you can see how this could be a real time saver.

Head on over to Mickey’s post to get the details and see some of the other shortcuts and how you can leverage them. Everything Mickey posts is a must read for Emacsers and this post is no exception.

## An Automated Publishing Pipeline

Dale Karp wanted to publish his activity log and notes so that others could see them and he could view them remotely. To do this, he set up an automated publishing pipeline using Emacs and Org mode. The idea is that he defines a “publishing project” in Org and invokes Emacs via systemd to run the export function on the project.

It’s a nice setup and one you may find handy if you want to regularly publish some Org files. He doesn’t have to do anything other than update his log files and they automatically get published to his GitHub Pages blog once a week. Head on over to his blog for the details.

## Mu/Mu4e 0.9.18

I just downloaded the latest version mu/mu4e and rebuilt it on my system. That’s a pain because Apple insists on shipping a very old version of Emacs—apparently to avoid GPL 3—and mu4e won’t build because it thinks Emacs is too old. I have to figure out how to get around this every time it comes up. This time I just changed the makefile to point at the proper Emacs in /Applications.

In any event, this is a good time to mention Charl Botha’s post on mu4e 0.9.18. There are a some nice enhancements that Botha describes, which I’ll let you read in his post. One of the nice things about the post is that he provides his mu4e configuration. That’s really handy if you’re just setting mu4e up and want a working, reasonable configuration. He comments it well so you should have no problem adjusting it to your liking.

## We Don't Wear Suits

Lots of people love Apple. Others, not so much. But whatever your feelings about the company, you’ve got to give them props for their famous response to AT&Ts suggestion that Steve Jobs wear a suit to an upcoming meeting with AT&Ts board of directors:

We’re Apple. We don’t wear suits. We don’t even own suits.

If you’re a suit—so to speak—that may seem weird and arrogant. If you’re a techie who’s ever been forced to adhere to silly dress conventions from the last century, you can only applaud.

## Happy 44th Birthday Dark Side of the Moon

I almost forgot. Today is the 44th anniversary of Pink Floyd’s Dark Side of the Moon. Somehow I forgot to mention it last year.

Dark Side of the Moon holds the record for the largest (by far) number of weeks on the Billboard 200 (927 weeks) and although it isn’t on the list this week—it pops on and off—it was 193 on the year end list. It’s truly one of the greatest albums of all time.

Posted in General | Tagged , | 1 Comment

## Org and Emacs Resources

Ben Elijah over at Ink and Ben has posted a nice set of Org and Emacs resources. Folks are always asking for basic tutorials and other information on how to take advantage of Emacs and Org mode. Elijah’s list is mostly about Org mode but he does include some Emacs resources on the grounds that you need to know at least a little Emacs to use Org.