Xah Talk Show 2022-01-20 emacs lisp coding plus tutorial, xah-add-space-after-comma

xah talk show 2022-01-20 emacs lisp coding plus tutorial, xah-add-space-after-comma
(defun xah-add-space-after-comma ()
  "Add a space after comma of current block or selection.
and highlight changes it made.
Version 2022-01-20"
  (interactive)
  (let ($p1 $p2)
    (if (region-active-p)
        (progn
          (setq $p1 (region-beginning) $p2 (region-end)))
      (progn
        (save-excursion
          (if (re-search-backward "\n[ \t]*\n" nil "move")
              (progn (re-search-forward "\n[ \t]*\n")
                     (setq $p1 (point)))
            (setq $p1 (point)))
          (if (re-search-forward "\n[ \t]*\n" nil "move")
              (progn (re-search-backward "\n[ \t]*\n")
                     (setq $p2 (point)))
            (setq $p2 (point))))))
    (save-restriction
      (narrow-to-region $p1 $p2)
      (goto-char (point-min))
      (while
          (re-search-forward ",\\b" nil t)
        (replace-match ", ")
        ;; highlight changes made
        (overlay-put
         (make-overlay
          (match-beginning 0)
          (match-end 0)) 'face 'highlight)))
    ;;
    ))

xah_talk_show_2022-01-20.txt