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 made.
Created: 2022-01-20
Version: 2025-03-25"
(interactive)
(let (xbeg xend)
(seq-setq (xbeg xend) (if (region-active-p) (list (region-beginning) (region-end)) (list (save-excursion (if (re-search-backward "\n[ \t]*\n" nil 1) (match-end 0) (point))) (save-excursion (if (re-search-forward "\n[ \t]*\n" nil 1) (match-beginning 0) (point))))))
(save-restriction
(narrow-to-region xbeg xend)
(goto-char (point-min))
(while
(re-search-forward ",\\b" nil t)
(replace-match ", ")
(overlay-put
(make-overlay
(match-beginning 0)
(match-end 0)) 'face 'highlight)))))
xah_talk_show_2022-01-20.txt