1 ;;; autostart.el --- Load nxhtml
3 ;; Author: By: Lennart Borgman
4 ;; Created: Fri Dec 15 2006
6 ;; Last-Updated: 2009-04-30 Thu
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23 ;; This program is free software; you can redistribute it and/or modify
24 ;; it under the terms of the GNU General Public License as published by
25 ;; the Free Software Foundation; either version 2, or (at your option)
28 ;; This program is distributed in the hope that it will be useful,
29 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ;; GNU General Public License for more details.
33 ;; You should have received a copy of the GNU General Public License
34 ;; along with this program; see the file COPYING. If not, write to the
35 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
36 ;; Boston, MA 02111-1307, USA.
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42 ;; Fix-me: Split out the definitions from this file so it can be
43 ;; loaded during byte compilation.
45 ;;(eval-when-compile (require 'web-vcs nil t))
46 ;;(eval-when-compile (require 'nxhtml-web-vcs nil t))
48 (message "Nxml/Nxhtml Autostart.el loading ...")
50 (defconst nxhtml-autostart-trace nil)
51 (defsubst nxhtml-autostart-trace (format-string &rest args)
52 (when nxhtml-autostart-trace
53 (apply 'message format-string args)))
55 (defconst nxhtml-load-time-start (float-time))
57 ;; Add this dir to load-path
58 (add-to-list 'load-path
59 (file-name-directory (or load-file-name
60 (when (boundp 'bytecomp-filename) bytecomp-filename)
63 (require 'nxhtml-base)
64 (eval-and-compile (when (fboundp 'nxml-mode)
65 (load (expand-file-name "etc/schema/schema-path-patch"
66 nxhtml-install-dir))))
68 ;; (defun nxhtml-custom-load-and-get-value (symbol)
69 ;; (custom-load-symbol symbol)
70 ;; (symbol-value symbol))
72 (defun nxhtml-list-loaded-features (use-message)
73 (interactive (list t))
74 (let ((buf (when use-message ;(called-interactively-p)
75 (get-buffer-create "*nXhtml loaded features*"))))
77 (with-current-buffer buf (erase-buffer))
79 (message "=== Loaded at nxhtml/autostart.el end:"))
106 (when (featurep feature)
108 (with-current-buffer buf
109 (insert (format "(feature '%s)=%s\n" feature (featurep feature))))
110 (message "(feature '%s)=%s" feature (featurep feature)))))
115 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
116 ;;; Code that will run on loading this file
118 (if (< emacs-major-version 23)
119 (unless (featurep 'autostart22)
120 (load (expand-file-name "autostart22" nxhtml-install-dir)))
121 ;; Check that the nxml-mode included with Emacs is used. There
122 ;; has been some problems on Debian with this.
123 (let ((nxml-mode-file (locate-library "nxml-mode"))
124 (help-file (locate-library "help")))
125 (unless (string= (expand-file-name ".." help-file)
126 (expand-file-name "../.." nxml-mode-file))
127 (error "Wrong nxml-mode=%s used, please use the one that comes with Emacs" nxml-mode-file))))
129 (let* ((util-dir (file-name-as-directory (expand-file-name "util" nxhtml-install-dir)))
130 (related-dir (file-name-as-directory (expand-file-name "related" nxhtml-install-dir)))
131 (nxhtml-dir (file-name-as-directory (expand-file-name "nxhtml" nxhtml-install-dir)))
132 ;;(company-dir (file-name-as-directory (expand-file-name "util/nxhtml-company-mode" nxhtml-install-dir)))
133 (tests-dir (file-name-as-directory (expand-file-name "tests" nxhtml-install-dir))))
134 (add-to-list 'load-path nxhtml-dir)
135 (add-to-list 'load-path related-dir)
136 (add-to-list 'load-path util-dir)
137 (add-to-list 'load-path nxhtml-install-dir)
138 ;;(add-to-list 'load-path company-dir)
139 (add-to-list 'load-path tests-dir)
141 (nxhtml-autostart-trace "... nXhtml loading %.1f seconds elapsed ..." (- (float-time) nxhtml-load-time-start))
144 ;; (unless (featurep 'web-vcs)
145 ;; (load (expand-file-name "web-vcs" nxhtml-install-dir) (not nxhtml-autoload-web)))
147 ;; (when (catch 'miss
148 ;; (dolist (file nxhtml-basic-files)
149 ;; (let ((dl-file (expand-file-name file nxhtml-install-dir)))
150 ;; (unless (file-exists-p dl-file)
151 ;; (throw 'miss t))))
153 ;; (nxhtml-setup-auto-download nxhtml-install-dir))
155 (unless (featurep 'web-autoload)
156 (load (expand-file-name "web-autoload" nxhtml-install-dir) (not nxhtml-autoload-web)))
158 (when nxhtml-autoload-web
159 (ad-activate 'require t))
161 ;; Fix-me: Why must as-external be loaded? Why doesn't it work in batch?
162 ;;(unless noninteractive (require 'as-external))
164 (unless (featurep 'nxhtml-loaddefs)
165 (load (expand-file-name "nxhtml-loaddefs" nxhtml-install-dir) nxhtml-autoload-web))
166 (nxhtml-autostart-trace "... nXhtml loading %.1f seconds elapsed ..." (- (float-time) nxhtml-load-time-start))
168 ;; Turn on `nxhtml-menu-mode' unconditionally
169 (nxhtml-autostart-trace "Turn on `nxhtml-menu-mode' unconditionally")
171 (nxhtml-autostart-trace "... nXhtml loading %.1f seconds elapsed ..." (- (float-time) nxhtml-load-time-start))
173 ;; Patch the rnc include paths
174 (when (fboundp 'rncpp-patch-xhtml-loader) (rncpp-patch-xhtml-loader))
175 (nxhtml-autostart-trace "... nXhtml loading %.1f seconds elapsed ..." (- (float-time) nxhtml-load-time-start))
178 (unless (featurep 'nxhtml-autoload)
179 (load (expand-file-name "nxhtml/nxhtml-autoload" nxhtml-install-dir))))
180 (nxhtml-autostart-trace "... nXhtml loading %.1f seconds elapsed ..." (- (float-time) nxhtml-load-time-start))
183 (unless (featurep 'nxhtml-autostart)
184 ;; Provide the feature here to avoid loading looping on error.
185 (provide 'nxhtml-autostart)
187 ;; Tell what have been loaded of nXhtml:
188 (when nxhtml-autostart-trace (nxhtml-list-loaded-features nil))
190 ;; How long time did it all take?
191 (message "Nxml/Nxhtml Autostart.el loaded in %.1f seconds" (- (float-time) nxhtml-load-time-start)))
193 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
194 ;;; autostart.el ends here