💾 Archived View for idiomdrottning.org › lisp-whitespace captured on 2022-04-29 at 12:25:22. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

Whitespace philosophy (for Lisp stuff)

Can people who put in a ton of whitespace in the middle of lines so that (on monospace) bindings or table values match up vertically please lay that off? Thank you.

I don’t want my Lisp to be ASCII art. This isn’t Befunge.

(This isn’t refering to whitespace at the beginning of lines, a.k.a. indentation. That’s fine.)

Befunge on Wikipedia

Update: an example

Let’s say we have this code:

(defcustom straight-hosts '((github    "github.com"    ".git")
                            (gitlab    "gitlab.com"    ".git")
                            (bitbucket "bitbucket.com" ".git")))

First of all, it looks dumb on proportional fonts (where a space isn’t the width of a character) and on screenreaders (where you only can read one line at a time).

Then, let’s say we wanna change this by adding a longer line, like, say, a frobnicate forge.

(defcustom straight-hosts '((github    "github.com"    ".git")
                            (gitlab    "gitlab.com"    ".git")
                            (bitbucket "bitbucket.com" ".git")
                            (frobnicate "frobnicate.example" ".git")))

Now the columns are wack, which, again, you’d need a visual display with monospace characters to see.

This is fiddly AF to try to align, and if you do manage to do it:

(defcustom straight-hosts '((github     "github.com"         ".git")
                            (gitlab     "gitlab.com"         ".git")
                            (bitbucket  "bitbucket.com"      ".git")
                            (frobnicate "frobnicate.example" ".git")))

your diff now has to touch every single line in the sexp.

I really like using Paredit to write code because of how it lets me think of the code in terms of nodes and edges as opposed to how it’s visually represented. I navigate the code like a tree, going in and out of sexps.

But let’s say we do manage to write and commit this code. Then, when we wanna search for a line of code that has, say, frobnicate followed by “frobnicate”, we can’t grep for it unless we use a variable whitespace regex.

Instead, I want the code to look like this:

(defcustom straight-hosts '((github "github.com" ".git")
                            (gitlab "gitlab.com" ".git")
                            (bitbucket "bitbucket.com" ".git")
                            (frobnicate "frobnicate.example" ".git")))

Each inner list is represented as meaningfully its own thing.