Elisp as a drug

Table of Contents

A correspondent (dare I say homie) of mine, Brett Gilio of org-webring, recently posted this on Mastodon:

Emacs Lisp isn't a language, it's a drug addiction. It isn't healthy, it will divide your family. You don't love it, yet you can't refuse it. However, when it works it works just right. https://mstdn.social/@brettgilio/104826971647671358

Now, this is obviously a joke… right? Of course, I initially thought of it as such – I had a wee chuckle, and then went about my day. But now, as I'm hacking away on my little Elisp projects, I can't help but consider that there may be some truth in these words.

I've been sick for the last week-and-a-half or so, and I've got shit to do: watch my lectures, write my essays, practice my pieces, etc. But I have to admit I've been wasting more time than I should on Elisp. In the span of two days, I wrote three packages just as a form of procrastination.

My new packages

lex-hl

A package I've been wanting to write for a while now, I always wanted something to highlight local variables. 208 lines.

org-el-index

While writing lex-hl, I decided I wanted to create a list of commands for the readme. I knew that org-webring had one, so I looked around for something to generate such a list. Alas, people just do it manually. What the heck.

I couldn't be bothered copying docstrings and function names for two whole minutes. So of course I decided it'd be worthwhile to spend a few hours making an automatic version. Well, it works, and I can now press C-c M-i to insert an index1. 265 lines.

insert-date

I version all my Elisp packages with the format %Y.%m.%d. This is very convenient, because I don't need to worry about making up a "real" version number – I can just press C-c =2 every time I make a commit and make sure that the date is updated.

While writing org-el-index, I decided to tag significant commits. But there's no way I'd waste 3 seconds3 copying the version just to paste it into the minibuffer. So, again, I wrote another package to make this easier. Very good, now I can press C-c d v and insert a timestamp in the format I wanted. 83 lines. By far the least wasteful of the three.

But it's worth it! Think about the WoRKfLoW gains!

Fuck no it isn't!

Emacs, in all its extensible, introspectable, hackable, blah blah blah glory, has made me its goddamn slave. I wish with all my heart that I could just put up with the fact that it takes an extra couple of seconds to copy the version into the magit tag prompt. That is how humans are supposed to work.

I shouldn't be wasting my time writing Elisp. I just want to be able to do my work, and not worry about whether a repetitive sequences of keypresses can be turned into its own program. Unfortunately, this seems to be damn near impossible.

Footnotes:

1

In fact, org-el-index provides three functions depending on how much you want to index:

  • Function: (org-el-index-file-large (file))

    Generate a large org mode index for the definitions in FILE. This includes all supported definitions.

  • Function: (org-el-index-file-medium (file))

    Generate a medium org mode index for the definitions in FILE. This includes all definitions unless their name contains "–"

  • Function: (org-el-index-file-small (file))

    Generate a small org mode index for the definitions in FILE. This includes only custom options and interactive commands.

2

Update version, in my package selime:

(defun selime-insert-version ()
  "Update or insert a version number in an Elisp file.
Uses the current date formatted as %Y.%m.%d (e.g. 1970.01.01)."
  (interactive)
  (declare (interactive-only t))
  (let ((new-version (format-time-string " %Y.%m.%d")))
    (save-excursion
      (save-restriction
        (widen)
        (goto-char (point-min))
        (or (re-search-forward "^;; Version:" nil t)
            (when (y-or-n-p "Add a version? ")
              (goto-char (point-min))
              (or (re-search-forward "^;; Author:" nil t)
                  (user-error "No version or author statement found.  Try `auto-insert'"))
              (forward-line 1)
              (insert ";; Version:\n\n")
              (forward-char -2)))
        (kill-line)
        (insert new-version)))))
3

Seriously, this would only take 3 seconds:

M-< C-s RET version: RET C-M-SPC M-w

Author: Jamie Beardslee

Date: 2020-09-16 (modified 2020-09-16)

Top: The Yeet Log