A Clojure Workflow

Manuel Uberti has a nice post that describes his Clojure workflow. What struck me is how generally applicable it is. Sure, if you aren’t doing Clojure you won’t care about Cider but everyone can profit from packages like, Projectile, Smartparens, Magit, Ivy, and ACUTeX.

Posted in General | Tagged | 2 Comments

Russ Cox on Globbing

If you’re like me, you probably don’t think about globbing very much. It’s just a way of fuzzy matching file names in a manner reminiscent of regular expression matching. We all use it everyday but have you ever thought about its implementation or efficiency?

Russ Cox, of course, has thought about these issues and has posted a really interesting article with his results. He starts with a simple benchmark that measures the time to complete ls (a*)nb in a directory containing the single file a100 where the exponents represent string repetition. He discovered that this resulted in an exponential run time whereas ls | grep (a*)nb ran in \(O(n)\) time.

Of course, globbing is done by the shell so he tried the (non-grep) experiment with different shells. Most shells showed exponential time but csh was linear in \(n\). Cox also discovered that some FTP servers exhibit the same behaviors.

The results are odd because you’d think globbing is a much simpler problem than regex matching. It can be, of course, and Cox gives an example implementation that is both simple and fast.

Be sure to read the article to see all Cox’s results and analysis. As usual with Cox’s posts, it’s really interesting and well worth your time.

UPDATE [2017-05-22 Mon 08:21]: Added link to article.

Posted in General | Tagged | 3 Comments

Quick Check on Files With counsel-ag

The more I use swiper and counsel to more impressed I become. On reddit’s Emacs subreddit, the_whalerus asks how he can take a peak at files he found with counsel-ag to decide which one he wants to work on. As is often the case, abo-abo himself replied with the solution.

He gives two answers. The first and easiest is just to press or hold down Ctrl+Meta+n to check the buffers possibly skipping some with Ctrl+n or Ctrl+v. The other is to use ivy-occur by pressing Ctrl+c Ctrl+o and then choosing the desired files from the occur buffer. See abo-abo’s answer for more details.

You might not think this is worth remembering but to the_whalerus it was the difference between using ivy or switching to helm. If you often find yourself looking at the results of a counsel-ag search and trying to figure out which file(s) you want to visit, this tip could be just what you need.

Posted in General | Tagged | Leave a comment

Dumb-jump in Action

The other day I wrote that I was considering installing dumb-jump and giving it a try. I did that and have been using it since I watched Mike Zamansky’s video on Projectile and Dumb-jump. It really is the sweet spot for me. I never liked TAG files and their associated machinery but dumb-jump doesn’t require any of that: it just works.

Recently, AT&T graciously released the source code for Research Unix v.8, v.9, and v.10. That’s a boon for us Unix aficionados who like to read code. I downloaded v.10 and started browsing. This is the first time I’ve had access to the source code for a modern AT&T Unix so I’m not familiar with the files layout. Fortunately, dumb-jump is just what I needed. All the kernel source files are in the sys directory so I put an empty .dumbjump file in sys and now when I’m looking at a function and it calls some other function in a different file, I can jump directly to it and then return.

I added two additional keybindings to the ones recommended in the README. For those who are interested, here is my configuration:

(use-package dumb-jump
  :ensure t
  :bind (("M-g o" . dumb-jump-go-other-window)
         ("M-g j" . dumb-jump-go)
         ("M-g b" . dumb-jump-back)
         ("M-g q" . dumb-jump-quick-look)
         ("M-g x" . dumb-jump-go-prefer-external)
         ("M-g z" . dumb-jump-go-prefer-external-other-window))
  :config (setq dumb-jump-selector 'ivy))

You really want a binding to return to your jumping off place so I added that. I also added a binding for dumb-jump-quick-look, which gives you a short popup of the definition and some context.

The Unix kernel isn’t the largest project by any means but it is good sized. Nevertheless, dumb-jump found and moved to the target file almost instantaneously. I really like this package a lot.

Posted in General | Tagged | Leave a comment

Org 9.0.7

Org mode has a bug fix out. I track Org on Melpa but if you don’t, now is a good time to update. If you do track Org on Melpa, the new version is there and ready for update.

Posted in General | Tagged , | Leave a comment

If You’re Looking for Another Reason to Despise Journalists…

Here you go.

Posted in General | Tagged , | Leave a comment

The Past Comes Due

Irreal oldtimers know that I have often railed about the activities of the NSA and their domestic spying and about the ever more shrill demands by law enforcement that they be given a back door into our cell phones. As everyone knows by now, the government’s sins have caught up with them.

Here are a couple of tweets from Edward Snowden that illustrate the problem

The NSA developed an exploit for Microsoft Windows and then lost control of the code, which was subsequently published on the Web. Criminals, of course, immediately used it to develop a ransomware worm which, among many other things, shut down several hospitals in the UK. I haven’t yet heard of any deaths resulting from this but it’s probably just a matter of time. In any event, it appears patient records may have been lost.

The US was largely spared but only because a UK security researcher stumbled on a kill switch for the malware and stopped it from spreading. You can read that amazing story in the link from the first tweet. Sadly, it appears that a new version without the kill switch has appeared.

I don’t believe it’s the slightest bit unreasonable to hold the NSA responsible for this mess—including any deaths that result. They wrote the exploit, they didn’t inform Microsoft of the vulnerability that made it possible, and then they let it get stolen. Someone should, at a minimum, lose their job but, of course, no one will.

That brings me to the second point. The government insists it can be trusted with a “golden key” to our smart phones and other devices. They say that of course they won’t abuse the capability and that we can trust them to keep the key out of the hands of criminals and hostile nation states. The WannaCry incident puts the lie to both those claims and justifies my belief that we should never trust the government with the access they desire.

Charlie Stross has an hilarious piece on the incident. He makes the point that if what happened were submitted as a piece of fiction, it would be rejected as unbelievable. He’s got a point.

UPDATE [2017-05-15 Mon 12:23]: Yoni Heisler agrees.

Posted in General | Tagged , | Leave a comment

The Benefits of Reading Code

I’m a big advocate of reading code. A lot of what I know about programming, Unix, and Emacs, I learned from reading code. Chen Bin has a parallel if slightly different take on reading code. He says that mastering Emacs is easy if you read the code. He likes to treat packages as a collection of APIs whose source code he can read and use for his own purposes.

As an example, he considers Samuel Barreto’s excellent post on refactoring with counsel-ag that I wrote about earlier. Chen spent a few minutes looking at how counsel built the wgrep buffer and then leveraged that to do some additional processing before calling wgrep. It’s worth taking a look at what he did. You probably won’t need his code but it perfectly illustrates his point: if you read the Emacs code it’s very easy to extend it to solve your particular problem.

Posted in General | Tagged | Leave a comment

Imenu for Dired

Matus Goljer—Fuco1 of Smartparen fame—blogged a nice bit of Elisp that adds imenu functionality to dired. At first, that doesn’t seem to make sense since an imenu menu would simply have the same information as the dired listing itself. What actually happens is that imenu gives you a list of the subdirectories inserted into the dired listing. You can then jump directly to that subdirectory from imenu

If you think that might be useful, take a look at Fuco1’s post for the details.

Posted in General | Tagged | 1 Comment

A Company-wide Emacs Configuration

Daniel Gopar over at Emacs.el has another of his Emacs chats up. This time he talks to Charles Lowell from Frontside Software. What’s interesting about Frontside is that they have a company-wide, shared Emacs configuration. All the developers use the same configuration, which the company maintains.

My first reaction was one of horror. All developers have preferences—this compiler or that PDF reader—but mostly they’re just that: preferences. If your company doesn’t use your favorite C compiler, you grumble a bit but get on with things. Not so with editors. Every first class developer that I know cares passionately about their editor and wouldn’t dream of using something else. With Emacs, you pretty much build your own editor so you get the same reaction if you have to use a different configuration. Most of us know how painful it can be to use someone else’s Emacs. That’s because their configuration is different from yours. I would, therefore, be very leery of coming into a shop that had a company standard editor.

Still, Lowell makes a reasonable case for their practice and it’s not quite as draconian as I’m making it seem. Nevertheless, having to unlearn my Emacs muscle memory would be extraordinarily painful for me. I’ve seen cogent cases made for insisting on everyone using the same versions of packages and editor—especially in shops doing research and running experiments—but it’s much harder, I think, to make the case for having standardized key sequences. Of course, everyone’s mileage varies and the folks at Frontside seem to like the system so it appears to be working for them.

One interesting aspect of Frontside’s practice is that they package their configuration as an Emacs package. That means that the developers update their configuration the way they would any package and it brings in the changes and updates their other packages automatically. If you’re going to insist on a standard configuration, that’s a very nice way of doing it. It’ quick and easy and no one has an excuse for not staying up to date.

Take a look at the video and see what you think. The running time is 43 minutes, 45 seconds so plan accordingly.

Posted in General | Tagged | 2 Comments