1 ;;; nxhtml-web-vcs.el --- nXhtml things for web-vcs.el
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2010-01-13 Wed
11 ;; Features that might be required by this library:
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;; This program is free software; you can redistribute it and/or
29 ;; modify it under the terms of the GNU General Public License as
30 ;; published by the Free Software Foundation; either version 3, or
31 ;; (at your option) any later version.
33 ;; This program is distributed in the hope that it will be useful,
34 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 ;; General Public License for more details.
38 ;; You should have received a copy of the GNU General Public License
39 ;; along with this program; see the file COPYING. If not, write to
40 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
41 ;; Floor, Boston, MA 02110-1301, USA.
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 (eval-when-compile (require 'cl))
48 (eval-when-compile (require 'nxhtml-base nil t))
49 ;;(eval-when-compile (require 'nxhtmlmaint nil t))
50 (eval-when-compile (require 'web-vcs nil t))
52 (defvar nxhtml-web-vcs-file (or load-file-name
53 (when (boundp 'bytecomp-filename) bytecomp-filename)
57 (defun nxhtml-require-base ()
58 (require 'nxhtml-base nil t)
59 (unless (featurep 'nxhtml-base)
60 ;; At startup, need to load it by hand.
61 (let ((load-path load-path))
62 (add-to-list 'load-path (file-name-directory nxhtml-web-vcs-file))
63 (require 'nxhtml-base))))
65 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
69 ;;(nxhtml-default-download-directory)
70 (defun nxhtml-default-download-directory ()
71 (let* ((ur (expand-file-name "" "~"))
73 (full (if (and (boundp 'nxhtml-install-dir)
76 (file-name-as-directory
78 (web-vcs-default-download-directory)))))
79 (full-len (length full)))
80 (if (and (> full-len ur-len)
81 (string= ur (substring full 0 ur-len)))
82 (concat "~" (substring full ur-len))
86 (defun nxhtml-web-vcs-read-dl-dir (prompt)
87 "Return current nXhtml install dir or read dir."
88 (or (and (boundp 'nxhtml-install-dir)
91 "A directory named 'nxhtml' will be created below the root you give."
94 (root (read-directory-name pr (nxhtml-default-download-directory))))
96 (expand-file-name "nxhtml" root)))))
98 ;;(call-interactively 'nxhtml-setup-install)
99 ;; (read-key "Prompt: ")
100 ;; (y-or-n-p "Prompt")
102 (defun nxhtml-setup-install (way)
103 "Setup and start nXhtml installation.
105 This is for installation and updating directly from the nXhtml
108 There are two different ways to install:
110 (1) Download all at once: `nxhtml-setup-download-all'
111 (2) Automatically download part by part: `nxhtml-setup-auto-download'
113 You can convert between those ways by calling this function again.
114 You can also do this by setting the option `nxhtml-autoload-web' yourself.
116 When you have nXhtml installed you can update it:
118 (3) Update new files in nXhtml: `nxhtml-update-existing-files'
120 To learn more about nXhtml visit its home page at URL
121 `http://www.emacswiki.com/NxhtmlMode/'.
123 If you want to test auto download \(but not use it further) there
124 is a special function for that, you answer T here:
126 (T) Test automatic download part by part: `nxhtml-setup-test-auto-download'
130 If you want to download a zip file with latest released version instead then
131 please see URL `http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html'."
132 (interactive (let ((curr-cfg (current-window-configuration)))
133 (describe-function 'nxhtml-setup-install)
134 (select-window (get-buffer-window (help-buffer)))
135 (delete-other-windows)
138 (has-nxhtml (and (boundp 'nxhtml-install-dir) nxhtml-install-dir))
139 (current-way (if has-nxhtml
140 (if (and (boundp 'nxhtml-autoload-web)
142 "Your current setup is to download part by part from the web."
143 "Your current setup it to download all of nXhtml at once.")
144 "(You have not currently installed nXhtml.)"))
145 (prompt (concat "Setup nXhtml install."
148 "\n(1) Download whole at once, or (2) part by part as needed"
149 (if has-nxhtml "\n(3) Update your existing nXhtml" "")
150 "\n(T) For temporary testing downloading part by part"
152 "\n(? for help, q to quit): "))
153 (allowed-keys (if has-nxhtml
157 (while (not (member key allowed-keys))
158 (if (not (member key '(??)))
161 (setq prompt (concat "Please answer with one of the alternatives.\n\n"
164 (describe-function 'nxhtml-setup-install)
165 (select-window (get-buffer-window (help-buffer)))
166 (delete-other-windows))
167 (setq key (web-vcs-read-key prompt))
168 ;;(message "key = %S" key) (sit-for 1)
171 (7 (set-window-configuration curr-cfg)
175 (?3 'update-existing)
176 (?T 'test-part-by-part)
180 (whole (call-interactively 'nxhtml-setup-download-all))
181 (part-by-part (call-interactively 'nxhtml-setup-auto-download))
182 (update-existing (call-interactively 'nxhtml-update-existing-files))
183 (test-part-by-part (call-interactively 'nxhtml-setup-test-auto-download))
185 (t (error "Unknown way = %S" way))))
187 (defvar nxhtml-basic-files '(
191 "etc/schema/schema-path-patch.el"
192 "nxhtml/nxhtml-autoload.el"
197 (defun nxhtml-setup-auto-download (dl-dir)
198 "Set up to autoload nXhtml files from the web.
200 This function will download some initial files and then setup to
201 download the rest when you need them.
203 Files will be downloaded under the directory root you specify in
206 Note that files will not be upgraded automatically. The auto
207 downloading is just for files you are missing. (This may change a
208 bit in the future.) If you want to upgrade those files that you
209 have downloaded you can just call `nxhtml-update-existing-files'.
211 You can easily switch between this mode of downloading or
212 downloading the whole of nXhtml by once. To switch just call the
213 command `nxhtml-setup-install'.
215 See also the command `nxhtml-setup-download-all'.
217 Note: If your nXhtml is to old you can't use this function
218 directly. You have to upgrade first, se the function
219 above. Version 2.07 or above is good for this."
221 (describe-function 'nxhtml-setup-auto-download)
222 (select-window (get-buffer-window (help-buffer)))
223 (delete-other-windows)
224 (nxhtml-check-convert-to-part-by-part)
227 (when (and (boundp 'nxhtml-autoload-web)
228 (not nxhtml-autoload-web))
229 (unless (yes-or-no-p "Convert to updating nXhtml part by part? ")
230 (throw 'command-level nil)))
231 (nxhtml-web-vcs-read-dl-dir "Download nXhtml part by part to directory: ")))))
232 (catch 'command-level
234 (unless (with-no-warnings (called-interactively-p))
235 (error "dl-dir should be a directory"))
236 (nxhtml-check-convert-to-part-by-part)
237 (when (and (boundp 'nxhtml-install-dir)
239 (unless (string= (file-truename dl-dir)
240 (file-truename nxhtml-install-dir))
241 (error "Download dir must be same as nxhtml-install-dir=%S" nxhtml-install-dir)))
242 (let* (;; Need some files:
243 (web-vcs-el-src (concat (file-name-sans-extension web-vcs-el-this) ".el"))
244 (web-vcs-el (expand-file-name (file-name-nondirectory web-vcs-el-src)
247 (base-url (nxhtml-download-root-url nil))
248 (byte-comp (if (boundp 'web-autoload-autocompile)
249 web-autoload-autocompile
251 (has-nxhtml (and (boundp 'nxhtml-install-dir)
253 (web-vcs-folder-cache nil))
254 (setq nxhtml-install-dir dl-dir)
255 (let ((root (file-name-directory dl-dir)))
256 (unless (file-exists-p root)
257 (unless (yes-or-no-p (format "Directory %S does not exist, create it? " root))
258 (error "Aborted by user"))))
259 (make-directory dl-dir t)
260 (setq message-log-max t)
261 (view-echo-area-messages)
264 (web-vcs-message-with-face 'web-vcs-green "==== Starting nXhtml part by part state ====")
265 (message "has-nxhtml=%s" has-nxhtml)
266 ;; Fix-me: First copy this file and web-vcs.el to its destination:
267 (unless (string= (file-truename dl-dir)
268 (file-truename (file-name-directory nxhtml-web-vcs-file)))
269 (dolist (f (list web-vcs-el-src nxhtml-web-vcs-file))
270 (copy-file f (expand-file-name (file-name-nondirectory f) dl-dir)
272 (when byte-comp (web-vcs-byte-compile-newer-file web-vcs-el t))
273 ;; Get basic file list:
274 (catch 'web-autoload-comp-restart
275 ;;(let ((file-mask (regexp-opt nxhtml-basic-files)))
276 ;; (web-vcs-get-missing-matching-files vcs base-url dl-dir file-mask))
277 (dolist (f nxhtml-basic-files)
278 (web-vcs-get-missing-matching-files vcs base-url dl-dir f))
279 ;; Autostart.el has not run yet, add download dir to load-path.
280 (let ((load-path (cons (file-name-directory web-vcs-el) load-path)))
282 (dolist (file nxhtml-basic-files)
283 (let ((el-file (expand-file-name file dl-dir)))
284 (web-vcs-byte-compile-newer-file el-file nil)))))
285 (let ((autostart-file (expand-file-name "autostart" dl-dir)))
286 ;;(ad-deactivate 'require)
287 (web-vcs-set&save-option 'nxhtml-autoload-web t)
288 (web-vcs-log nil nil "* nXhtml: Download Part by Part as Needed\n")
289 (load autostart-file)
290 (unless (ad-is-active 'require) (ad-activate 'require))
292 (web-vcs-message-with-face 'web-vcs-green "==== Basic files for nXhtml part by part are now installed ====")
293 (web-vcs-display-messages t)
294 (unless has-nxhtml (nxhtml-add-loading-to-custom-file autostart-file t))))))))
296 ;;(call-interactively 'nxhtml-download)
298 (defun nxhtml-setup-download-all (dl-dir)
299 "Download or update all of nXhtml.
301 You can download all if nXhtml with this command.
303 To update existing files use `nxhtml-update-existing-files'.
305 If you want to download only those files you are actually using
306 then call `nxhtml-setup-auto-download' instead.
308 See the command `nxhtml-setup-install' for a convenient way to
311 For more information about auto download of nXhtml files see
312 `nxhtml-setup-auto-download'."
314 (describe-function 'nxhtml-setup-auto-download)
315 (select-window (get-buffer-window (help-buffer)))
316 (delete-other-windows)
317 ;;(nxhtml-check-convert-to-part-by-part)
319 (nxhtml-web-vcs-read-dl-dir "Download whole nXhtml to directory: "))))
321 (let ((root (file-name-directory dl-dir)))
322 (unless (file-exists-p root)
323 (unless (yes-or-no-p (format "Directory %S does not exist, create it? " root))
324 (error "Aborted by user"))))
325 (make-directory dl-dir t)
326 (let ((msg (concat "Downloading nXhtml through Launchpad web interface will take rather long\n"
327 "time (5-15 minutes) so you may want to do it in a separate Emacs session.\n\n"
328 "Do you want to download using this Emacs session? "
330 (if (not (y-or-n-p msg))
332 (setq message-log-max t)
333 (let ((do-byte (y-or-n-p "Do you want to byte compile the files after downloading? ")))
334 (nxhtml-download-1 dl-dir nil do-byte)))))
337 (defun nxhtml-download-1 (dl-dir revision do-byte)
338 "Download nXhtml to directory DL-DIR.
339 If REVISION is nil download latest revision, otherwise the
342 If DO-BYTE is non-nil byte compile nXhtml after download."
343 (let* ((has-nxhtml (and (boundp 'nxhtml-install-dir)
345 (base-url nxhtml-web-vcs-base-url)
346 (files-url (concat base-url "files/"))
347 ;;(revs-url (concat base-url "changes/"))
348 (rev-part (if revision (number-to-string revision) "head%3A/"))
349 (full-root-url (concat files-url rev-part))
350 (web-vcs-folder-cache nil)
351 (web-autoload-paranoid nil))
352 ;;(nxhtml-require-base)
353 (when (web-vcs-get-files-from-root 'lp full-root-url dl-dir)
354 (web-vcs-display-messages t)
355 (web-vcs-log nil nil "* nXhtml: Download All\n")
356 (web-vcs-set&save-option 'nxhtml-autoload-web nil)
358 (web-vcs-message-with-face 'web-vcs-green "==== Starting downloading whole nXhtml ====")
359 (let ((autostart-file (expand-file-name "autostart" dl-dir)))
360 (load autostart-file)
362 (web-vcs-message-with-face 'web-vcs-green "==== All files for nXhtml are now installed ====")
363 (nxhtmlmaint-byte-recompile)
364 (unless has-nxhtml (nxhtml-add-loading-to-custom-file autostart-file nil))))))
366 (defun nxhtml-check-convert-to-part-by-part ()
367 (when (and (boundp 'nxhtml-install-dir)
369 (unless (and (boundp 'nxhtml-autoload-web)
371 (if (not (boundp 'nxhtml-menu:version))
372 (error "nxhtml-install-dir set but no version found")
373 (unless (string-match "[\.0-9]+" nxhtml-menu:version)
374 (error "Can't find current version nxhtml-menu:version=%S" nxhtml-menu:version))
375 (let* ((ver-str (match-string 0 nxhtml-menu:version))
376 (ver-num (string-to-number ver-str)))
377 (when (< ver-num 2.07)
378 (web-vcs-message-with-face 'web-vcs-red "Too old nXhtml for download part by part.")
379 (throw 'command-level nil)))))))
382 ;;(directory-files default-directory nil "\\el$")
383 ;;(directory-files default-directory nil "[^#~]$")
385 (defun nxhtml-update-existing-files ()
386 "Update existing nXhtml files from the development sources.
387 Only files you already have will be updated.
389 Note that this works both if you have setup nXhtml to auto
390 download files as you need them or if you have downloaded all of
393 For more information about installing and updating nXhtml see the
394 command `nxhtml-setup-install'."
395 ;; Fix-me: download new files too if you are not auto downloading.
397 (when (y-or-n-p "Do you want to update your nXhtml files? ")
399 (web-vcs-display-messages t)
400 (web-vcs-message-with-face 'web-vcs-yellow "*\nStarting updating your nXhtml files.\n*\n")
402 (web-vcs-clear-folder-cache)
404 (base-url (nxhtml-download-root-url nil))
405 (dl-dir nxhtml-install-dir)
406 web-vcs-folder-cache)
407 (setq dl-dir (file-name-as-directory dl-dir))
408 (web-vcs-update-existing-files vcs base-url dl-dir dl-dir)
409 (web-vcs-clear-folder-cache))
410 (display-buffer (get-buffer-create "*Compile-Log*"))
411 (nxhtmlmaint-byte-recompile)
413 (web-vcs-message-with-face 'web-vcs-yellow "*\nFinished updating your nXhtml files.\n*\n")
417 ;;(nxhtml-maybe-download-files (expand-file-name "nxhtml/doc/img/" nxhtml-install-dir) nil)
419 (defun nxhtml-get-missing-files (sub-dir file-name-list)
421 (root-url (nxhtml-download-root-url nil))
423 (full-dir (expand-file-name sub-dir nxhtml-install-dir))
427 (dolist (f file-name-list)
428 (let ((full-f (expand-file-name f full-dir)))
429 (unless (file-exists-p full-f)
430 (setq miss-names (cons f miss-names)))))
431 (setq files-regexp (regexp-opt miss-names)))
432 (setq files-regexp ".*"))
433 ;;(unless (file-exists-p full-dir) (make-directory full-dir t))
435 (concat (file-relative-name (file-name-as-directory full-dir)
438 (let ((web-vcs-folder-cache nil))
439 (web-vcs-get-missing-matching-files 'lp root-url nxhtml-install-dir
442 ;; Fix-me: Does not work, Emacs Bug
443 ;; Maybe use wget? http://gnuwin32.sourceforge.net/packages/wget.htm
444 ;; http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=5103
445 ;; (nxhtml-get-release-revision)
446 (defun nxhtml-get-release-revision ()
447 "Get revision number for last release."
448 (let* ((all-rev-url "http://code.launchpad.net/%7Enxhtml/nxhtml/main")
449 (url-buf (url-retrieve-synchronously all-rev-url))
450 (vcs-rec (or (assq 'lp web-vcs-links-regexp)
451 (error "Does not know web-vcs 'lp")))
452 (rel-ver-regexp (nth 6 vcs-rec))
454 (message "%S" url-buf)
455 (with-current-buffer url-buf
456 (when (re-search-forward rel-ver-regexp nil t)
460 (defun nxhtml-byte-compile-file (file &optional load)
461 (let ((extra-load-path (when nxhtml-install-dir
463 (file-name-as-directory
464 (expand-file-name p nxhtml-install-dir)))
465 '("tests" "related" "nxhtml" "util" ".")))))
466 ;; (message "nxhtml-byte-compile-file:extra-load-path=%s" extra-load-path)
467 (web-vcs-byte-compile-file file load extra-load-path)))
469 ;; fix-me: change web-vcs-byte-compile-file instead
471 (defun nxhtml-byte-recompile-file (file &optional load)
472 "Byte recompile FILE file if necessary.
473 For more information see `nxhtml-byte-compile-file'.
474 Loading is done if recompiled and LOAD is t."
475 (interactive (list (buffer-file-name)
477 (let ((elc-file (byte-compile-dest-file file)))
478 (if (file-newer-than-file-p file elc-file)
479 (nxhtml-byte-compile-file file load)
480 (message "Byte compilation of this file is up to date."))))
482 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
483 ;;; Add to custom file
486 (defvar nxhtml-handheld-wincfg nil)
487 (defun nxhtml-handheld-restore-wincg ()
488 (when nxhtml-handheld-wincfg
489 (set-window-configuration nxhtml-handheld-wincfg)
490 (setq nxhtml-handheld-wincfg nil)))
492 ;;(nxhtml-handheld-add-loading-to-custom-file "TEST-ME")
493 (defun nxhtml-handheld-add-loading-to-custom-file (file-to-load)
494 (setq nxhtml-handheld-wincfg (current-window-configuration))
495 (delete-other-windows)
496 (let ((info-buf (get-buffer-create "Information about how to add nXhtml to (custom-file)"))
497 (load-str (format "(load %S)" file-to-load)))
498 (with-current-buffer info-buf
499 (add-hook 'kill-buffer-hook 'nxhtml-handheld-restore-wincg nil t)
500 (insert "Insert the following line to (custom-file), ie the file in the other window:\n\n")
501 (let ((here (point)))
503 (propertize load-str 'face 'secondary-selection)
505 (copy-region-as-kill here (point))
506 (insert "\nThe line above is in the clipboard so you can just paste it where you want it.\n")
507 (insert "When ready kill this buffer.")
509 (setq buffer-read-only t)
510 (set-buffer-modified-p nil))
511 (set-window-buffer (selected-window) info-buf)
512 (find-file-other-window (custom-file))))
514 ;; (nxhtml-add-loading-to-custom-file "test-file")
515 (defun nxhtml-add-loading-to-custom-file (file-to-load part-by-part)
518 (if (not (condition-case nil (custom-file) (error nil)))
521 (web-vcs-message-with-face
523 (concat "Since you have started this Emacs session without running your init files"
524 "\nthey are unknown and the installation can not add the statement below."
525 "\nTo finish the setup of nXhtml you must add"
527 "\n\nto your custom-file if you have not done it yet."
528 "\nYou must also customize the variable `nxhtml-autoload-web' to tell that"
530 "\nyou want to download nXhml files as you need them."
531 "\nyou do not want to allow automatic downloading of nXhtml files."
536 (web-vcs-display-messages t))
537 (let ((prompt (concat "Basic setup of nXhtml is done, but it must be loaded from (custom-file)."
538 "\nShould I add loading of nXhtml to (custom-file) for you? ")))
539 (if (yes-or-no-p prompt)
540 (nxhtml-add-loading-to-custom-file-auto file-to-load)
541 (if (yes-or-no-p "Should I guide you through how to do it? ")
542 (nxhtml-handheld-add-loading-to-custom-file file-to-load)
543 (web-vcs-message-with-face 'web-vcs-green
544 "OK. You need to add (load %S) to your init file" file-to-load))))))
546 ;; Fix-me: really do this? Is it safe enough?
547 (defun nxhtml-add-loading-to-custom-file-auto (file-to-load)
548 (unless (file-name-absolute-p file-to-load)
549 (error "nxhtml-add-loading-to-custom-file: Not abs file name: %S" file-to-load))
550 (let ((old-buf (find-buffer-visiting (custom-file)))
551 (full-to-load (expand-file-name file-to-load)))
552 (with-current-buffer (or old-buf (find-file-noselect (custom-file)))
557 (while (progn (skip-chars-forward " \t\n\^l")
561 (let ((start (point))
562 (form (read (current-buffer))))
563 (when (eq (nth 0 form) 'load)
564 (let* ((form-file (nth 1 form))
565 (full-form-file (expand-file-name form-file)))
566 (when (string= full-form-file full-to-load)
568 (when (and (string= (file-name-nondirectory full-form-file)
569 (file-name-nondirectory full-to-load))
570 (not (string= full-form-file full-to-load)))
571 (if (yes-or-no-p "Replace current nXhtml loading in (custom-file)? ")
573 (goto-char start) ;; at form start now
574 (forward-char (length "(load "))
575 (skip-chars-forward " \t\n\^l") ;; at start of string
577 (setq form (read (current-buffer)))
578 (delete-region start (point))
579 (insert (format "%S" full-to-load))
581 (web-vcs-message-with-face 'web-vcs-red "Can't continue then")
582 (web-vcs-display-messages t)
583 (throw 'command-level nil)))))))
585 (insert (format "\n(load %S)\n" file-to-load))
587 (unless old-buf (kill-buffer old-buf))))))
589 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
590 ;;;;;; Start Testing function
591 (defun emacs-Q-no-nxhtml (&rest args)
592 (let* ((old-env-load-path (getenv "EMACSLOADPATH"))
594 (elp-list (or (when old-env-load-path
595 ;;(split-string old-env-load-path ";"))
596 (split-string old-env-load-path path-separator))
600 (this-emacs-exe (locate-file invocation-name
601 (list invocation-directory)
604 (when (file-exists-p p)
605 (unless (string= nxhtml-install-dir p)
606 (let* ((dir (file-name-directory p))
607 (last (file-name-nondirectory p))
608 (last-dir (file-name-nondirectory
609 (directory-file-name dir))))
610 (unless (and (string= "nxhtml" last-dir)
611 (member last '("util" "test" "nxhtml" "related" "alt")))
612 (setq sub-elp-list (cons p sub-elp-list)))))))
613 ;;(setq sub-env-load-path (mapconcat 'identity (reverse sub-elp-list) ";"))
614 (setq sub-env-load-path (mapconcat 'identity (reverse sub-elp-list) path-separator))
615 (setenv "EMACSLOADPATH" sub-env-load-path)
616 (setq ret (apply 'call-process this-emacs-exe nil 0 nil "-Q" args))
617 (setenv "EMACSLOADPATH" old-env-load-path)
620 ;; (call-interactively-p 'nxhtml-setup-test-auto-download)
621 ;; (nxhtml-setup-test-auto-download "c:/test2/")
622 (defun nxhtml-setup-test-auto-download (test-dir)
623 "Test autoload in a new emacs, started with 'emacs -Q'.
624 You can choose where to download the files and just delete them
625 when you have tested enough."
626 (interactive (list (read-directory-name "Directory for test of auto download of nXhtml: ")))
627 (let ((this-dir (file-name-directory web-vcs-el-this))
628 (this-name (file-name-nondirectory web-vcs-el-this))
630 (when (and (file-exists-p test-dir)
631 (not (y-or-n-p (format "Directory %S exists, really test there? " test-dir))))
633 (unless (file-exists-p test-dir) (make-directory test-dir))
634 (setq that-file (expand-file-name this-name test-dir))
635 (when (file-exists-p that-file) (delete-file that-file))
636 (copy-file web-vcs-el-this that-file)
637 (emacs-Q-no-nxhtml "-l" that-file "-f" "nxhtml-setup-test-auto-download-do-it-here")))
639 (defun nxhtml-setup-test-auto-download-do-it-here ()
640 "Helper for `nxhtml-setup-test-auto-down-load'."
641 (let ((this-dir (file-name-directory web-vcs-el-this)))
642 (nxhtml-setup-auto-download this-dir)))
644 (defun web-vcs-check-if-modified ()
646 (t1 (format-time-string "%Y-%m-%dT%T%z" (date-to-time "2010-01-01 18:20")))
647 (t2 (format-time-string "%Y-%m-%dT%T%z" (date-to-time "Mon, 28 Dec 2009 08:57:44 GMT")))
648 (url-request-extra-headers
650 (cons "If-Modified-Since"
653 "%a, %e %b %Y %H:%M:%S GMT"
654 (nth 5 (file-attributes "c:/test/temp.el" )))
657 (setq xb (url-retrieve-synchronously "http://www.emacswiki.org/emacs/download/anything.el"))
658 (switch-to-buffer xb)
660 ;; (emacs-Q-no-nxhtml "web-vcs.el" "-l" "c:/test/d27/web-autostart.el")
661 ;; (emacs-Q-no-nxhtml "web-vcs.el" "-l" "c:/test/d27/autostart.el")
662 ;; (emacs-Q-no-nxhtml "web-vcs.el" "-f" "eval-buffer" "-f" "nxhtml-temp-setup-auto-download")
663 ;; (emacs-Q-no-nxhtml "-l" "c:/test/d27/web-vcs" "-l" "c:/test/d27/nxhtml-web-vcs" "-f" "nxhtml-temp-setup-auto-download")
664 ;; (emacs-Q-no-nxhtml "-l" "c:/test/d27/nxhtml-web-vcs" "-f" "nxhtml-temp-setup-auto-download")
665 ;; (emacs-Q-no-nxhtml "--geometry=200x50+100+100" "-l" "c:/test/d27/web-vcs" "-f" "web-vcs-nxhtml")
666 (defun nxhtml-temp-setup-auto-download ()
667 ;;(when (fboundp 'w32-send-sys-command) (w32-send-sys-command #xf030) (sit-for 2))
668 (set-frame-size (selected-frame)
669 (/ 1024 (frame-char-width))
670 (/ 512 (frame-char-height))
673 (set-frame-position (selected-frame) 100 50)
674 (when (y-or-n-p "Do nXhtml? ")
675 (view-echo-area-messages)
676 (setq truncate-lines t)
677 (split-window-horizontally)
678 (let ((load-path (cons default-directory load-path)))
680 ;(nxhtml-setup-auto-download "c:/test/d27")
681 (call-interactively 'nxhtml-setup-auto-download)
683 ;;;;;; End Testing function
684 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
687 (provide 'nxhtml-web-vcs)
688 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
689 ;;; nxhtml-web-vcs.el ends here