Xah Talk Show 2024-08-30 Ep581, Emacs Lisp Coding, Command to Rename Variables, Paul Graham Website Tech 1999

Xah Talk Show 2024-08-30 Ep581

hot china girl lisp 2024-08-30 sqDDB
hot china girl lisp 2024-08-30 sqDDB
paul graham invalid html 2024-08-30 BZtqm
paul graham invalid html 2024-08-30 BZtqm
unicode search 2024-08-30 QhX5r
unicode search 2024-08-30 QhX5r
emacs command names 2024-08-30 XzYfW
emacs command names 2024-08-30 XzYfW
(defun xah-rename-elisp-var ()
  "Rename variables xp1 xp2 to xbeg xend, in current defun.

if var name xbeg already exist, it's renamed to xbeg888.
if var name xend already exist, it's renamed to xend888.

Created: 2024-08-30
Version: 2024-08-30"
  (interactive)
(let ((case-fold-search nil)
      (xbeg-new "xbeg888")
      (xend-new "xend888"))
  (save-restriction
    (narrow-to-defun)

    (progn
      (goto-char (point-min))
      (while (re-search-forward "\\_<xbeg\\_>" nil t)
        (replace-match xbeg-new t t))

      (goto-char (point-min))
      (while (re-search-forward "\\_<xp1\\_>" nil t)
        (replace-match "xbeg" t t)))

    (progn

      (goto-char (point-min))
      (while (re-search-forward "\\_<xend\\_>" nil t)
        (replace-match xend-new t t))

      (goto-char (point-min))
      (while (re-search-forward "\\_<xp2\\_>" nil t)
        (replace-match "xend" t t))))))