Xah Talk Show 2022-09-28 emacs lisp. extract html links, insert to each page

Xah Talk Show 2022-09-28 emacs lisp. extract html links, insert to each page
(defun xah-html-copy-topic-box ()
  "Extract all links in current text block, then open each file, then insert the same text block into it at the bottom.
The links are assumed to be local file path links.

Return the list of extracted file paths.

Version 2022-09-28"
  (interactive)
  (save-excursion
    (let (($p0 (point)) $p1 $p2 $text $fpaths
          ($currentFPath buffer-file-name))
      (search-backward "\n\n")
      (setq $p1 (match-end 0))
      (goto-char $p0)

      (search-forward "\n\n")
      (setq $p2 (match-beginning 0))

      (setq $fpaths (xah-html-extract-url $p1 $p2))
      (setq $text (buffer-substring-no-properties $p1 $p2))

      (mapcar
       (lambda (x)
         (if (string-equal $currentFPath x)
             nil
           (progn
             (find-file x)
             (goto-char (point-min))
             (search-forward "</main>")
             (goto-char (match-beginning 0))
             (insert $text "\n\n")
             (message "Copied block to: %s" x))
           $fpaths))
       $fpaths))))