|Checking Emacs buffers for broken links
||[13 May 2008|02:23pm]
This was a quick effort to write a command for checking the current buffer for
broken links. Thoughts, feelings and improvements welcome.
(defun campaigns/check-buffer-urls ()
"Checks the current buffer for broken links, skipping those
that match entries in the `no-check' list."
(let ((matches '())
(re-search-forward thing-at-point-url-regexp nil t)
(add-to-list 'matches (match-string-no-properties 0)) t))
(pop-to-buffer "*Link checking results*")
(insert "Checking your links...\n\n")
(let ((parsed (url-generic-parse-url url)))
(insert (format "* %s ..." url))
(if (member (elt parsed 0) no-check)
(if (url-http-file-exists-p url)
(setq fails (1+ fails)))
(error (insert "ERROR!\n")
(setq fails (1+ fails)))))))
(insert (format "\nFinish checking %d links. There were %d problems.\n"
(length matches) fails))))