Emacs: Why I Don't Use paredit

By Xah Lee. Date: . Last updated: .

paredit.el is a popular emacs lisp package among elite hackers for coding lisp. It encourages manual hard-coded formatting.

On the surface, it appears to be a semantic-unit-based editor. Namely, you edit code by the lisp's semantic units. But, at its core, it's really a helper tool for manual hard-formatting. It implicitly encourages you do do manual indentation, line width, formatting line-by-line.

Why is paredit not a semantic unit based editor?

here's a simple test. Supppose you have this emacs lisp code:

(defun insert-p-tag () "Insert <p></p> at cursor point." (interactive) (insert "<p></p>") (backward-char 4))

using paredit, can you press a button and transform it to the following?

(defun insert-p-tag ()
  "Insert <p></p> at cursor point."
  (interactive)
  (insert "<p></p>")
  (backward-char 4))

what language editors can do this? XML editors can, Mathematica can, golang gofmt can.

in order to have such a editor, first of all you need a language whose syntax has a strong structure and corresponds to semantic units. XML, Mathematica, LISP, are such languages. (it needs not be nested. I think APL also qualify.)

then, you need people working with such languages aware of this correspondence. The typical Lisp hacker types of past 2 decades don't understand this, in fact, they often insist hard-coded formatting. For example, lisp communities advertise where closing paranthesis should be positioned. Here's a quote from emacs lisp manual:

Don't make a habit of putting close-parentheses on lines by themselves; Lisp programmers find this disconcerting.

(from Gnu Emacs Lisp Reference Manual. (info "(elisp) Coding Conventions"))

〔➤see Emacs Lisp: Automatic Code Formatting, Auto Indentation

Google's new language golang, is a good one in this respect. Because: ① it enforce using tab for indentation, not spaces. 〔➤see Programing: Tab vs Space in Source Code〕② It has syntax reformat tool (aka lint) builtin, as part of the language platform. See the “Mechanical source transformation” section at http://blog.golang.org/go-fmt-your-code. This point lispers don't get. See: Programing Language: Fundamental Problems of Lisp.

Alternative to ParEdit

See: Emacs: ParEdit, Smartparens, Lispy, and ErgoEmacs, xah-fly-keys.

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from my keyboard store.