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

Zamansky 33: Projectile and Dumb Jump

Mike Zamansky has video number 33 up in his Using Emacs series. This video discusses Projectile and dumb-jump. As most of you probably know, Projectile is Bozhidar Batsov’s project interaction package for Emacs. It provides handy features for using Emacs at the project level. I’ve always thought of it as a tool for developers working with large projects who need a way of navigating around the project files easily. Zamansky’s video shows that it’s also appropriate for people who have a number of groups of related files that they wish to deal with as a whole even if they aren’t really projects. Even if you aren’t dealing, strictly speaking, with “projects,” you may find it handy so you should take a look at the video to see if it will work for you.

The other package that Zamansky discusses is dumb-jump. It performs the same basic function has the various TAGS systems but without having to generate or maintain a TAGS file. It’s a bit slower because it uses The Silver Searcher, ripgrep, or grep to locate the desired targets. From Zamansky’s video, it appears to work pretty quickly with The Silver Server.

I’m pretty impressed with the idea of dumb-jump and will probably give it a try. Early on in my career I developed a dislike for TAGS systems because it was such a pain to maintain the TAGS files. That’s probably easier now but my prejudice prevails. Dumb-jump seems like a nice compromise. It supports all the languages that I use regularly and there’s virtually no configuration after you include the use-package in your init.el.

The video is just short of 11 and a half minutes so you should easily be able to find time to watch it. If you aren’t familiar with Projectile and dumb-jump, it’s definitely worth your while.

Posted in General | Tagged | Leave a comment

The Value of Source Code in Emacs

Arun Isaac makes a nice point. Most of us support open source and insist on our right to have source code available but we hardly ever look at that source. Except for Emacs. Isaac observes that when the documentation is missing or ambiguous, he simply follows the link to the source to see what’s really going on.

Of course, you have to know some Elisp but the point is that the source is instantly available without leaving Emacs. You can check it and then return to your original buffer with your new knowledge. It’s life changing in a way that even the best of most open source software is not.

As I’ve said before, it’s because Emacs (sort of) recapitulates the Lisp Machines of yore. There are no secrets and everything is available in your chosen environment. This, more than anything, is why I am moving as much as possible into Emacs.

Posted in General | Tagged | 1 Comment