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.

then, you need people working with such languages aware of this correspondence. The typical Lisp hacker type of past 2 decades don't understand this, in fact, they often insist hard-coded formatting.

For example, lisp communities often tell you where closing paranthesis should be placed. 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. Coding Conventions (ELISP Manual) )

[see Automatic Formatting Emacs Lisp Code]

Google's new language golang, is a good one in this respect. Because:

(1) it enforce using tab for indentation, not spaces. [see Programing: Tab vs Space in Source Code]

(2) 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.

Is ParEdit Useful?

it's not that paredit isn't useful. paredit is useful.

it's that paredit violates fundamental principle, that it encourages manual formatting on every line.

more seriously, see

Emacs: narrow-to-defun, eval-defun, bug

when lisp code is not formatted line by line by convention, the command eval-defun eval wrong part of the code. How bad can it be?

this is a very serious bug. It's not fixed or known, because vast majority of programers adhere to the format code by line habit. In particular, the hacker types, who will insist and tell other people to format lines so.

That is the problem. Do you see?