I’m not a fan of the “parenthesis pileup” tradition of LISP code layout.
Having used a number of different programming languages over
the years, I have evolved a common set layout conventions that has
worked reasonably well across them. So for example, when parentheses
in LISP represent something resembling statement blocks, I like to put
the openers and closers at the same indentation level, which means
putting the closer on a line by itself. This, accompanied by a comment indicating the type of construct being closed, I think helps a lot
with readability. Elisp example:
(defun convert-to-region-codes (beg end)
"converts alphabetic characters in the selection to “region indicator symbols”."
(interactive "*r")
(unless (use-region-p)
(ding)
(keyboard-quit)
) ; unless
(let
(
deactivate-mark
(intext (delete-and-extract-region beg end))
c
)
(dotimes (i (- end beg))
(setq c (elt intext i))
(cond
((and (>= c ?A) (<= c ?Z))
(setq c (+ (- c ?A) #x1F1E6))
)
((and (>= c ?a) (<= c ?z))
(setq c (+ (- c ?a) #x1F1E6))
)
) ; cond
(insert-char c)
) ; dotimes
) ; let
) ; convert-to-region-codes
On 2024-01-02, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
So for example, when parentheses in LISP represent something
resembling statement blocks, I like to put the openers and closers at
the same indentation level, which means putting the closer on a line
by itself.
You forgot a few, for instance:
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 415 |
Nodes: | 16 (2 / 14) |
Uptime: | 48:22:13 |
Calls: | 8,727 |
Files: | 13,276 |
Messages: | 5,957,928 |