;;; -*- lexical-binding: t -*- ;; ;; -------------------------------------------------------------------------------- (require 'luki-lisp) ;; -------------------------------------------------------------------------------- (-> '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 initially do (goto-char beg) with delim = ". " with lns = (count-lines beg end) with pad = (--- (number-to-string lns)) 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))) ;; -------------------------------------------------------------------------------- (<- 'll-enum)