How to Make Swiper Choose the Second or Subsequent Match on a Line

Chanyoung is a Swiper user and asks a question I’ve sometimes wondered about: when using swiper, how do you choose the second or subsequent match on a line? If you follow the above link, you will see that abo-abo himself provides the answer.

What you do is call swiper-avy (bound to Ctrl+) to see tags for every visible match. Then you simply choose the correct tag in the usual Avy way. I’ve known about (and even used) swiper-avy for some time but I always thought of it as a way of choosing the correct line in the minibuffer. That usually brings you to the match you want but not (necessarily) when there is more than one match on the line you want.

It turns out—although I somehow never noticed it—that the visible matches in the searched buffer are also tagged so you can simply choose the tag you want and jump right to the desired match. I know I’ve said it before, but if you aren’t using swiper and counsel you owe it to yourself to give them a try. I’m always learning something new that they can do and they’ve made my navigation a lot more efficient.

Posted in General | Tagged | Leave a comment

Comey and Feinstein At It Again

James Comey and Dianne Feinstein are at it again pressing for legislation to compel device manufacturers to enable law enforcement to bypass device encryption. In a sense, nothing is new. Comey is trotting out the same arguments—many or most of which have been debunked—and uses the abracadabra words “national security” to shut off argument because no one, after all, can be against national security.

The funniest part of their spiel is the oft repeated, “None of us want backdoors” when, of course, that’s exactly what they’re asking for. Feinstein’s last attempt at a bill was so bad even her Senate colleagues understood it couldn’t work and would have devastating unintended consequences. There’s no reason to hope this try will be any better.

Feinstein’s hypocrisy on this subject is especially annoying. She’s fine with having the government pry into every bit of the communications and online activity of citizens who aren’t even suspected of wrongdoing but nearly had a heart attack when the CIA spied on her and her staff. In the linked post I wrote that I thought Feinstein’s tantrum was hilarious. Now I think it’s just disgusting.

Posted in General | Tagged | Leave a comment

Going to the Beginning and End of Special Buffers

Way back in 2013 Magnar Sveen published a nice bit of Elisp for moving to the beginning and end of a dired buffer. By beginning and end, he meant the logical beginning and end: the first and last line of file or directory listings. I immediately stole that and modified it to do the same thing for ibuffer buffers.

Now Fuco has published a set of macros that implements the same thing for a wide variety of other special buffers. The macros are actually nicer because the first time you press Meta+< or Meta+>, you will move to the logical beginning or end of the buffer. If you press it again, you will move to the physical beginning or end so you get the best of both worlds.

Fuco gives several examples of using the macros for various types of buffers so even if you don’t know much Elisp, you can easily implement the behavior for most buffer types that you’re apt to care about.

Oddly, looking at my original post on ripping off Sveen’s code for ibuffer buffers from 2014, I see that Fuco made a comment pointing to these macros. Now he’s posted about them and given examples for anyone who’s interested to use. If you use dired, ibuffer, occur, vc-dir, agenda, or other special buffers a lot, you may be interested in his solution. Be sure to give his post a read.

UPDATE [2017-05-07 Sun 20:33]: Fixed the links.

Posted in General | Tagged | 8 Comments

Email With Notmuch and Astroid

If you’ve been hanging out at Irreal for any time at all you know that I’ve recently moved my email to mu/mu4e. There are two aspects to that. The first, and the one that I’ve mostly written about, is that I can now deal with email from within Emacs.

That’s a boon, of course, but the other advantage is a change in how I deal with mail. I used to do what most people do: I kept mail sorted into folders that roughly reflected their subject matter or originator. Then I read a Ben Maughan post that opened my eyes to another possibility. Rather than manually sorting emails into separate directories that might or might not be their proper resting place, Maughan dumped all his saved emails into a single directory and located what he wanted with a search. I immediately started emulating his system with the Apple mail app. The problem was the search wasn’t all that flexible and involved a lot of clicking and mouse manipulation.

That all ended when I started letting mu do my searching. It’s fast, extremely flexible, and doesn’t care if I even have a mouse. If that sounds good to you but you’d rather have a GUI based mail user agent, Abhilash Raj has a nice solution for you. He uses notmuch to handle the searching in much the same way that mu does for mu4e. He tried using an Emacs client as his mail user agent but didn’t like it so now he uses astroid, which is a bit more graphically based. Astroid can embed Emacs, Vim, or some other editor—if you must—so he can still write his emails using Emacs.

I really love mu/mu4e and recommend it without hesitation but if it doesn’t meet your needs, you should take a look at Raj’s solution. If you’re not an Emacs user, his setup brings you the benefits of a search-based workflow that can use your preferred editor.

Posted in General | Tagged | 3 Comments

LSP Coming to Emacs?

Those of you who follow the Emacs scene will remember that last year there was a big kerfuffle about whether or not GCC should export its AST so that Emacs, for instance, could use it to provide better syntactic and semantic information about C programs. It seemed like a no-brainer but RMS objected on the grounds that unscrupulous actors could use the information to build proprietary tools.

Now we have this:

Perry Metzger recently made me aware of the Language Server Protocol (LSP) and the advantages it offers to editors. Instead of building in custom language parsers, editors can use LSP to get information about the structure and meaning of programs and thereby offer better information to the programmer.

The good news pointed to by the above tweet is that RMS has endorsed this effort, greatly increasing the probability that it will be implemented in Emacs. Who knows? Perhaps this will provide an answer to all those people saying, “I’d like to use Emacs but I’m working in Java so…”

Posted in General | Tagged | 1 Comment

Storing Secrets

In my never ending crusade to move as many functions as possible into Emacs, I’ve lately been dealing with functions that require a user name and password. For example, part of the mbsync configuration that downloads my emails requires a user name and password. Similarly, org2blog/wp needs the password for my blog.

Here at Irreal, we’ve settled on two strategies:

  • Putting the credentials in the .authinfo file
    This method has the benefit that you can get at the credentials with Elisp. This makes it easy to make passwords and other credentials available to your Emacs configuration without having them displayed in plain text. Take a look at the auth-source info documentation and auth-source.el to see what’s available. Sadly not all the functions are documented so you may have to look at the code. See the Blogging section of Arjen Wiersma’s configuration for an example of using the auth-source package with org2blog/wp.
  • Putting credentials in the macOS keychain
    Obviously, this is Mac specific but the other OS’s have similar functionality. This method is useful when you need to get at the credentials from outside Emacs. For example, my mbsync configuration retrieves the password for the Apple IMAP server from the Mac keychain because Elisp isn’t available to mbsync. Aria Fallah has an excellent post on how to access the Mac keychain. If you’re running on macOS, you need to give it a read.

Lately, I’ve been working on bringing Gmail under the mu4e umbrella. Gmail really wants you to use OAuth2 to authenticate and they make it pretty easy to set up an account to get the tokens but it’s really hard to see how to integrate it into mbsync. There’s some python code on the Web that I think I can have mbsync call to do the OAuth2 but as far as I can tell, most mbsync users simply turn off the OAuth2 authentication to get things working.

That’s not ideal but isn’t a worry for me because I use Gmail only for mailing lists. Still, it would be nice to find a reasonable solution using OAuth2.

Posted in General | Tagged , , | 4 Comments

Arjen Wiersma’s Emacs Configuration

I was trolling through the Emacs tweets when I saw one entitled “Emacs 25.2 Released” with a link to a video. I thought it was going to be a discussion of the new things in Emacs 25.21 but it turned out to be a video by Arjen Wiersma about his Emacs 25.1 configuration.

You might think I was disappointed by the bait-and-switch2 but I wasn’t. Wiersma steps through many of the most important packages he uses and demonstrates how they work. Although his configuration—with the exception of the Clojure stuff—is pretty much like mine, I did learn a couple of new things. For instance, there is a counsel-imenu command that brings the convenience of swiper to imenu. Similarly, there is a counsel-unicode-char command that makes it really easy to enter Unicode characters if you can come close to their name. I’ve installed both (or, really, just bound key sequences to them) and have already found them useful.

There are lots of other goodies in his configuration, which you can browse here. If you’re looking for a good developer’s configuration, this is an excellent place to start. Wiersma is mostly concerned with Clojure but his setup will work well for any developer. I really recommend that you take a look at it.

Footnotes:

1

Even though 25.2 is mostly a bug-fix release, there are a few new things as described in the NEWS file.

2

Wiersma wasn’t the tweeter so he’s not responsible for the bad title on the tweet.

Posted in General | Tagged | 1 Comment

Blogs and Journals in Science

Blog readers—and since you’re reading this, that includes you—appear to having been doing something right. At least according to Daniel Lakens, an experimental psychologist who publishes the blog The 20% Statistician. In an interesting post, Lakens argues that blogs have higher scientific quality than journals.

That’s a startling claim, especially for those of us trained in the sciences where journals are considered the gold standard for transmitting scientific knowledge. Lakens offers 5 reasons for his assessment1. The first is basically that blogs more closely approximate the ideal of reproducible research whereas Journals are just beginning to embrace the idea.

He also notes that blogs have better error correction. Generally, if an error is discovered in a blog, the poster will correct the error and note the update in the original posting. Journals can’t do that of course even if they are committed to issuing corrections. Almost always the correction gets lost and unseen by readers.

His other reasons boil down to “gatekeeper” issues. Most journals are hesitant (or refuse) to publish articles that go against the common wisdom—the debate on climate change illustrates this nicely: whatever your position on it, there’s no denying that deniers have a hard time getting published.

Anyone can publish a blog so you avoid issues of eminent researchers being given preference and other biases of editors and reviewers. Everything is, in short, out in the open for the reader to judge. Peer review is a useful device—or at least it seems like it should be—for vetting articles so that readers can presume a measure of accuracy in journal articles but the shockingly high irreproducibility of the results in many journal articles casts doubt that it’s actually working as intended.

Lakens’ post is a provocative and interesting read; it’s well worth a few minutes of your time if you’re involved in scientific publishing or just like contrarian views.

Footnotes:

1

Lakens says up front that he’s mostly familiar with journals in Psychology but his arguments seem generally applicable.

Posted in Blogging | Tagged | 3 Comments

Ogbe’s Literate Emacs Configuration

Dennis Ogbe is an EE PhD student at Purdue whom I’ve written about before (1, 2, 3). He’s very good at leveraging Emacs and Org mode in his workflow, both in his studies and his blog. Recently, I saw this tweet:

that pointed to Ogbe’s Emacs configuration. It’s written in Literate form with Org mode and has a ton of good ideas in it. Some of his choices probably aren’t the ones you’d make but if you’re looking for a good go-by for a configuration aimed at someone in the scientific/technical fields, this is an excellent choice. He’s documented everything so you can tell why he made the choices he did.

Even if you’re not looking for a new Emacs configuration, it’s worth taking a look at his just for the ideas. You might find a couple of things to add to your own setup.

Posted in General | Tagged , | Leave a comment

SBCL 1.3.17

I’ve been a little lax about keeping SBCL up to date but when I saw the announcement for SBCL 1.3.17, I downloaded, compiled, and installed it before I forgot. You can get your copy here. I always build from source but there are also binaries (for some systems) available.

I’m happy to report that it builds without problems on my Macs and passes the regression tests with no unexpected failures. As I say with every release, if you’re looking for a really good Common Lisp environment, look no further. SBCL produces excellent native code, is completely open source, and is under constant development and improvement.

Posted in General | Tagged , | Leave a comment