A Beautiful On-line Version of SICP

If, like me, you’re a lover of SICP (Structure and Interpretation of Computer Programs) you’ll be happy to know that there’s a beautiful on-line version of it available. Years ago, MIT generously put up a version but some of the figures were hard to read and the typography was pretty much what you’d expect from an automatic rendering of the $\LaTeX$ from that era.

This text is rendered in HTML5 and the figures drawn in vector graphics. You can read about the evolution of this project in the UTF Introduction in the book. A lot of loving work went into this and it shows. The introduction says that this was completed in 2014 but I am just now seeing it. If you’re interested in the source or an epub version, the project’s web page has an an announcement of this version along with links to the source and other renderings of it. Take a look and see if you don’t agree that it’s a beautiful rendering of one of the most important books in CS.

I think that last judgment (about SICP being one of the most important CS books) is even more true today since, sadly, the approach taken by SICP is no longer popular. It’s been abandoned—even at MIT, where the whole thing began—in favor of plugging black boxes, in the form of libraries, together to build a program. Perhaps, as even the authors of SICP say, that’s necessary in today’s environment but students are missing out by not being immersed in the view of our profession offered by SICP.

Query on mbsync for macOS

The wheels grind slowly here at Irreal but they do grind. I’m in the final stages of moving my email to Emacs in my neverending quest to run everything in Emacs. My specific intent is to run mu4e as my client and have mbsync take care of retrieving and syncing emails for my Apple mail account.

Sadly, I can’t get mbsync to connect with the Apple IMAP server. The relevant part of my .mbsyncrc is

IMAPAccount icloud
Host IMAP.mail.me.com
User XXX
Port 993
SSLType IMAPS
SSLVersions TLSv1.2
#CertificateFile /usr/local/share/certs/ca-bundle.crt


when I run this with mbsync -D icloud, I get

...
Logging in...
1 NO [AUTHENTICATIONFAILED] Authentication failed
IMAP command 'LOGIN <user> <pass>' returned an error: NO [AUTHENTICATIONFAILED] Authentication failed


It makes no difference whether or not the CertificateFile line in the configuration is commented out. The security function on the PassCmd line does return my icloud password and even entering the password itself on a PASS line doesn’t work. It makes no difference whether the USER line is just my user name or my full email address.

I’ve consulted DuckDuckGo but I can’t find any examples of setting things up for macOS. If anyone has a working mbsync configuration for talking to Apple’s IMAP server, I’d really like to hear from you. Please leave a comment if you have any wisdom to impart.

Posted in General | Tagged | 7 Comments

Dired Sorting

If you like to manage your files with Dired and tend to rely on the Dired listing rather than, say, ls, Ben Maughan has an excellent suggestion: dired-quick-sort. Take a look at the Github site to get an idea of what the package can do.

Reproducible Journalism?

Longtime readers know that we here at Irreal do not generally hold journalists in high regard. Putting the best light on things, they are all too often ignorant and lazy. Still, Irreal is nothing if not dedicated to the scientific method so we’re always interested in contrary evidence. Wilfred Hughes offers this example of such evidence:

For an article entitled Wages rise on California farms. Americans still don’t want the job, the Los Angeles Times performed an analysis of California crop production wages as an IPython notebook. The analysis was done by Ben Welsh of the LA Times Data Desk, which appears to be an internal LA Times group dedicated to such matters. The byline on the article itself was Natalie Kitroeff and Geoffrey Mohan.

I really like this because:

1. Rather than rely on anecdotal evidence, the Times did an actual analysis of the data.
2. The analysis was done in a reproducible research manner. The data source is identified and all the calculations are shown in the notebook.

The article links to the analysis so that any interested readers can see for themselves how the analysis was done. Kudos to the LA Times and their reporters for an excellent example of reproducible research in Journalism and for making the data and the analysis of it public.

Posted in General | Tagged | 1 Comment

Stein's Emacs Productivity Series

Gregory Stein over at Caches to Caches has a nice series on how he uses Emacs to increase his productivity. I’ve written about a couple of those articles (1, 2) already but it’s useful to see the whole series.

As I’ve said before, Stein is a Ph.D student at MIT and like all such students his time is at a premium. These posts discuss how he leverages Emacs to organize his time and tasks and even optimize his email. There are (currently) four articles and none of them are very long so it’s very much worth your while to take a look if you’d like to make your own workflow at little more frictionless.

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.