#!/usr/local/bin/emacs -script

(cd "/home/joneworlds/gopher")

(shell-command "rm fridgescan.txt ; ./fridgescan.sh ; ./cleanscan.sh fridgescan.txt")

(with-current-buffer (find-file "fridgescan.txt")
       (replace-string-in-region "~" "" (point-min) (point-max))
       (replace-string-in-region "
       (goto-char (point-min))
       (while (search-forward "###" nil t)
               (goto-char (point-at-bol))
               (newline)
               (newline)
               (beginning-of-line)
               (search-forward "###" nil t)
               (backward-delete-char-untabify 3)
               (insert ":")
               (newline))
       (untabify (point-min) (point-max))
       (goto-char (point-min))
       (insert "--== CIRCUMLUNAR FRIDGE ==--")
       (newline)
       (insert "refreshed ")
       (insert (current-time-string))
       (newline)
       (newline)
       (insert "Circumlunar colonists: to stick something on the fridge,\n")
 (insert "create a file named fridge in your gopher directory.\n\n")
       (goto-char (point-min))
       (set-fill-column 40)
       (while (not (eobp))
               (forward-paragraph)
               (fill-paragraph))
       (write-file "fridgescan_j2.txt"))