(require 'cl)
(require 'cl-19)
(setq tiedostoalku "Lu")
(setq aputiedosto "apu")
(defun teeviitteet ()
(interactive)
(progn
(set-buffer aputiedosto)
(setq bold (search-forward " "))
(while bold
(progn
(setq kaksoispiste (search-forward ":"))
(setq luku (buffer-substring bold (- kaksoispiste 1)))
(setq kohta (search-forward ""))
(goto-char kaksoispiste)
(if (search-forward "-" kohta t)
(setq jae (buffer-substring kaksoispiste (- (point) 1)))
(setq jae (buffer-substring kaksoispiste (- kohta 4))))
(setq loppu (- (search-forward "
") 4))
(let ((oldbuf (current-buffer)))
(save-excursion
(setq tiedosto (concat "Lu." luku ".html"))
(set-buffer (find-file-noselect tiedosto))
(goto-char (point-min))
(setq haettava (concat ""))
(search-forward haettava)
(insert "")
(search-forward jae)
(insert "")))
(setq bold (search-forward " " nil t))))))