;;; -*- lexical-binding: t -*- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'll) (-> 'll-dwim) (-> 'subr-x) (defun enum (&optional beg end) "Enumerate each line from BEG to END, counting from one." (interactive (use-region)) (or beg (setq beg (point-min))) (or end (setq end (point-max))) (cl-loop with delim = ". " with lns = (count-lines beg end) with pad = (--- (number-to-string lns)) initially (goto-char beg) for line from 1 to lns do (goto-char (pos-bol)) (insert (@f "%s%s" (string-pad (number-to-string line) pad nil 'start) delim)) (forward-line) finally (goto-beg))) (<- 'll-enum)