The kv Library

The other day I wrote about Wilfred Hughes’ hash table library. In the comments, Noonian Atall remarked that Nic Ferrier also has a key/value library (kv) that’s worth taking a looking at.

Whereas Hughes’ ht library is primarily concerned with hash tables, Ferrier’s kv library deals primarily with alists, although it does provide functions for converting between alists and hash tables. As with the ht library, kv provides some naming consistency and saves writing simple conversion and access functions. If you work a lot with alists, you should take a look at this library and see if it can save you some time and work.

Posted in General | Tagged | 4 Comments

The Ugliest Editor Theme Ever Conceived?

Betteridge’s law notwithstanding, I’m pretty sure it would be hard to devise a theme uglier than this one. PLEASE NOTE: That is definitely not a challenge.

It looks like something a particularly silly seventh grader would come up with. All that’s missing are little hearts over the ‘i’s.

Yeah, I get that the perpetrator was just fooling around but somethings are too horrible to see the light of day.

Posted in General | Tagged | 1 Comment

Elisp Hash Table Library

If you like the simplicity and regularity that libraries such as s for strings and dash for lists provide, you should take a look at Wilfred Hughes’ ht library for working with hash tables.

Hash tables are, of course, built-in to Emacs Lisp so the library isn’t introducing any new functionality but it does offer these advantages as listed in the README:

A consistent naming scheme
If you aren’t using hash tables all the time, it’s hard to remember the function names because they seem entirely unrelated to each other. In the ht library, the names all have the form ht-X, when X is usually a verb (such as create) that describes what the function does
A natural and consistent argument ordering
Again, this makes it easier to remember how to use the functions. Of course, eldoc can help here too.
The mutation functions return nil
As in Scheme, these functions end in !. Examples are ht-set! to add a key/value pair to the hash table and ht-remove! to remove a key/value pair.
A more comprehensive set of functions for hash table operations
These make common operations more convenient by providing a function for them so you don’t have to write additional code

The library looks pretty nice if you don’t mind using non-standard names for the operations. Of course, that’s part of the point. The names make more sense and help you remember them. My only complaint with the new names is that the predicates (ht-contains?, ht-equal?, …) end with ? rather than the conventional (for Elisp) -p. (Yes, yes, I know; The ? makes more sense but the -p is a long standing convention worth respecting.)

Posted in General | Tagged , | 1 Comment

Happy Birthday Linux

Linux is 26 today. What started as a little hobby project that even Linus didn’t expect to amount to much has grown into one of the most important operating systems in use today and arguably of all time. Our world1 would be vastly different without it.

Footnotes:

1

By “our world,” I mean the world of engineers and technical people but the case could be made that the statement applies to the “world” in general.

Posted in General | Tagged , | Leave a comment

Nist Password Guidelines

As most of you probably know, NIST recently updated their password guidelines. The three big changes are:

  1. Use long easy to remember passwords. Don’t worry so much about mixing in numbers and special characters.
  2. Don’t expire your users’ passwords—it only encourages bad password practices.
  3. For all but low-risk applications, use two-factor authentication.

The IEEE Spectrum has a Q&A with Paul Grassi, the author of the new guidelines. It’s a quick and easy read and will give you some valuable guidance as to dealing with your own passwords. He doesn’t mention password managers, which I still believe the be the best solution for generating high-entropy passwords and managing them safely.

If you want more information, take a look at the actual guidelines. They’re long and detailed and written in bureaucratese but cover all the material.

Posted in General | Tagged | 5 Comments

Marking a Word

Today I learned something new. Or, rather, I got hit in the head with a cluebat. Peter Hwang asked how he could mark the word at point. Manuel Uberti answered that he usually uses Ctrl+Meta+SPC, which I always think of as marking the s-expression at point. Of course, that’s where the cluebat comes in because, duh, an atom is an s-expression too.

On most keyboards, it’s easier to type Ctrl+Meta+SPC that it is to type Meta+@. At least it is for me. The nice thing is you can mark subsequent words by repeating the Ctrl+Meta+SPC.

On the other hand, both methods mark from point to the end of the word so if point is in the middle of the word, you may not get what you want. You can mark the word that the point is in with er/expand-region, Magnar Sveen’s excellent semantic marking utility. The problem with er/expand-region is that it’s usually hard to mark subsequent words because it will look for the smallest enclosing semantic unit, which is probably not the next word.

So my (new) strategy is to use er/expand-region to mark the word containing the point and then Ctrl+Meta+SPC to mark subsequent words if I need to. That means I have to switch from Ctrl+=, my binding for er/expand-region, to Ctrl+Meta+SPC, but that doesn’t seem as awkward as the other methods I’ve tried.

Posted in General | Tagged | 4 Comments

Ivy Initial Input String

If you’re an Ivy user—and you should be—you’ve probably noticed that sometimes the Ivy prompt will have an initial “^” so that the search will be anchored at the beginning of line. This happens depending on the command that called the ivy-read routine. If Ivy guesses wrong, you can always remove the “^” or add one.

Sometimes, though, it always guesses wrong for your particular work flow. I’ve just learned from this Emacs subreddit question that you can, to an extent, control when the “^” is appended to the prompt. Actually, you can specify any string to prepend.

The decision as to what to append is controlled by the ivy-initial-inputs-alist. Again, you can easily correct the default action at the time of the call so unless you have a situation where Ivy is always guessing wrong, it’s probably not worth changing the default value of ivy-initial-inputs-alist.

Posted in General | Tagged | Leave a comment

Setting Up a Lisp Development Environment

For a language as old as Lisp, there are a surprising number of queries asking how to set up a Lisp environment. If you’re a Lisper, your answer to this is probably Emacs/Slime/Quicklisp and one of the Lisp systems such as SBCL.

Baggers, who has several videos about Lisp, posted a nice video on setting up an Emacs/Slime/Quicklisp/SBCL system. He does this on a Windows system because it’s the most difficult system to get things going on. If you’re using Linux or macOS, the process is similar but not quite as fiddly. The video covers the whole process starting with downloading a copy of Emacs, setting up slime, downloading SBCL and installing Quicklisp.

I’ve often said that if you’re looking for a great Common Lisp system, it’s hard to do better than SBCL but n00bs may find it difficult to get things set up and working. Baggers’ video is an excellent how-to for setting up a Lisp system from scratch.

Posted in General | Tagged , , | Leave a comment

Emacs Lisp Development Tools

I just stumbled across a video of John Wiegley’s talk at the 2013 Emacs Lisp Development Conference on Elisp development tools. Wiegley covers some of the tools he uses in his own development. Many of those tools will be familiar to most Emacs developers but some were new to me. Three that I especially want to take a look at are redshank, elisp-slime-nav, and workgroups.

The talk is really interesting and helpful but sadly the production values of the video are terrible. Much of the time the screen shots are out of focus or someone is walking between the camera and display. Even so, it’s worth spending the hour watching it. Wiegley, of course, is a master Elisp developer and listening to what he has to say on the matter can help you develop your own skills.

The other interesting thing is how far we’ve come since 2013. Abo-abo’s swiper/ivy/counsel was not yet available, and Wiegley’s use-package was just beginning and not nearly as powerful as it is now. That was only four and a half years ago yet I would be missing half the tools I use every day if we were suddenly teleported back to the time of the conference.

The video is just over an hour so you’ll have to schedule some time but, as I say, it’s very worthwhile.

Posted in General | Tagged , | 5 Comments

An Elisp Introduction

A couple of years ago, I wrote about Aaron Bieber’s talk to the Boston Vim Meetup on why and how he moved from Vim to Emacs. It was a great talk and worth watching if you haven’t already (especially if you’re a Vim user thinking about switching to Emacs). One of the keys to becoming a journeyman Emacs user is gaining a familiarity with Elisp. You don’t have to be an expert but you should feel comfortable doing simple tasks such as configuration.

About a year ago, Bieber wrote a post on getting started with Emacs Lisp. It’s by no means a complete introduction but it does give you a feeling for how you would go about writing a small Elisp function. Without saying so explicitly, Bieber uses an incremental or interactive approach to building the function. That is, he builds and tests a small part of it and then moves on to expanding it, again incrementally.

As I’ve said many times, this is one of the most powerful things about programming with Lisp: you can try out very small parts of your solution without having to worry about building a scaffolding for testing. If, after you read Bieber’s post, you want to learn more Elisp, Xah Lee’s Elisp Tutorial is a good resource.

UPDATE [2017-08-27 Sun 15:01]: Fixed title of Bieber’s post.

Posted in Programming | Tagged , | 2 Comments