1 ;;; html-chklnk.el --- Check links in local HTML sites
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: Wed Mar 15 14:46:17 2006
5 (defconst html-chklnk:version "0.2") ;; Version:
6 ;; Last-Updated: Tue Apr 10 04:12:32 2007 (7200 +0200)
10 ;; Features that might be required by this library:
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 ;; This program is free software; you can redistribute it and/or modify
28 ;; it under the terms of the GNU General Public License as published by
29 ;; the Free Software Foundation; either version 2, or (at your option)
32 ;; This program is distributed in the hope that it will be useful,
33 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
34 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 ;; GNU General Public License for more details.
37 ;; You should have received a copy of the GNU General Public License
38 ;; along with this program; see the file COPYING. If not, write to the
39 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
40 ;; Boston, MA 02111-1307, USA.
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (eval-when-compile (add-to-list 'load-path default-directory load-path))
48 (when (> emacs-major-version 22)
49 (let* ((load-path load-path)
50 (this-file (or load-file-name
51 (when (boundp 'bytecomp-filename) bytecomp-filename)
53 (this-dir (file-name-directory this-file)))
54 (add-to-list 'load-path (expand-file-name "../../lisp" this-dir))
55 (require 'w32shell nil t))))
58 (eval-when-compile (require 'html-site nil t))
62 (defgroup html-chklnk nil
63 "Customization group for html-chklnk."
66 (defcustom html-chklnk-dir
67 (file-name-as-directory
71 (if load-file-name load-file-name buffer-file-name))))
73 "Directory where the tools needed are located.
78 (defun html-chklnk-check-site-links (start-file)
79 "Check local file web site links.
80 Currently only internal links are checked."
83 (html-site-current-ensure-site-defined)
84 (if (y-or-n-p "Start from a given file and check links from there? ")
85 (let* ((default-start (if (html-site-current-contains buffer-file-name)
87 (car (directory-files (html-site-current-site-dir)
91 (read-file-name "Start checking from file: "
92 (html-site-current-site-dir)
96 (unless (html-site-dir-contains (html-site-current-site-dir) start-file)
97 (error "File %s is not in the site %s" start-file html-site-current))
100 (let* ((default-directory html-chklnk-dir)
101 (compile-cmd (concat "perl link_checker.pl "
103 ;;(html-chklnk-convert-file-name
104 (html-site-current-site-dir)
108 ;;(html-chklnk-convert-file-name
113 (compilation-buffer-name-function
114 '(lambda (dummy) (concat "** Checking links in site "
115 html-site-current " **")))
116 (compilation-scroll-output t)
117 (compilation-error-regexp-alist-alist
120 "^\\(.*\\)\\s-+at line \\([0-9]+\\):"
124 (compilation-error-regexp-alist '(html-chklnk))
125 ;;(shell-file-name "cmd")
126 ;;(explicit-shell-file-name "cmd")
127 ;;(shell (concat exec-directory "cmdproxy.exe"))
130 ;; There are trouble with perl paths
131 ;; (when (featurep 'w32shell)
132 ;; (when w32shell-current-shell-path
133 ;; (setq old-w32shell w32shell-current-shell-path)
134 ;; (w32shell-set-shell "cmd")))
135 ;;(message "uses-cygwin=%s" uses-cygwin)(sit-for 8)
137 (if (fboundp 'w32shell-save-shell)
140 (compile compile-cmd))
141 (compile compile-cmd))
143 ;; (when old-w32shell
144 ;; (cond ((string= old-w32shell w32shell-cygwin-bin)
145 ;; (w32shell-set-shell "cygwin"))
146 ;; ((string= old-w32shell w32shell-msys-bin)
147 ;; (w32shell-set-shell "msys"))))
150 (defun html-chklnk-convert-file-name (filename)
151 (let ((uses-cygwin (and (featurep 'w32shell)
152 (string= w32shell-current-shell-path
153 w32shell-cygwin-bin)))
158 (string-match "^\\([a-z]\\):" filename))
159 (concat "/cygdrive/" (match-string 1 filename)
160 (substring filename 2))
166 (provide 'html-chklnk)
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
168 ;;; html-chklnk.el ends here