initial commit
[emacs-init.git] / nxhtml / nxhtml-base.el
1 ;;; nxhtml-base.el --- The very, very basic vars...
2 ;;
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2010-01-13 Wed
5 ;; Version:
6 ;; Last-Updated:
7 ;; URL:
8 ;; Keywords:
9 ;; Compatibility:
10 ;;
11 ;; Features that might be required by this library:
12 ;;
13 ;;   None
14 ;;
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;
17 ;;; Commentary:
18 ;;
19 ;; Things that always must be loaded and that are often necessary when
20 ;; byte compiling.
21 ;;
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23 ;;
24 ;;; Change log:
25 ;;
26 ;;
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;;
29 ;; This program is free software; you can redistribute it and/or
30 ;; modify it under the terms of the GNU General Public License as
31 ;; published by the Free Software Foundation; either version 3, or
32 ;; (at your option) any later version.
33 ;;
34 ;; This program is distributed in the hope that it will be useful,
35 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
37 ;; General Public License for more details.
38 ;;
39 ;; You should have received a copy of the GNU General Public License
40 ;; along with this program; see the file COPYING.  If not, write to
41 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
42 ;; Floor, Boston, MA 02110-1301, USA.
43 ;;
44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 ;;
46 ;;; Code:
47
48 ;;(eval-when-compile (require 'web-vcs nil t))
49 (eval-when-compile (require 'flymake-js nil t))
50 (eval-when-compile (require 'flymake-css nil t))
51 (eval-when-compile (require 'flymake-java-1 nil t))
52
53 (defconst nxhtml-menu:version "2.08")
54 (setq message-log-max t)
55 (setq debug-on-error t)
56
57 (defconst nxhtml-install-dir
58   (file-name-directory (or load-file-name
59                            (when (boundp 'bytecomp-filename) bytecomp-filename)
60                            buffer-file-name))
61   "Installation directory for nXhtml.")
62
63 (define-minor-mode nxhtml-autoload-web
64   "If on download elisp files from web when they are needed.
65 If t then during `require' nXhtml elisp files can be downloaded
66 from the nXhtml repository on the web.  This will currently
67 download the development sources, latest version.
68
69 Other files that are used by a command may also be downloaded.
70
71 Note that files are not updated automatically.  You have to use
72 `nxhtml-update-existing-files' for that."
73   :global t
74   ;;:lighter (propertize " nX" 'face 'font-lock-comment-face)
75   :lighter " nX"
76   :group 'nxhtml)
77
78 (defun nxhtml-autoload (fun src &optional docstring interactive type)
79   "Generalized `autoload'. May setup autoload from the web.
80 If `nxhtml-autoload-web' is t then setup autoloading from the web.
81 Otherwise setup for normal local autoloading."
82   (if nxhtml-autoload-web
83       (progn
84         ;; Do not require this until we really need it.
85         (require 'web-autoload)
86         (web-autoload fun src docstring interactive type))
87     (let ((file src))
88       (when (listp file)
89         (setq file (file-name-nondirectory (nth 2 file))))
90       (autoload fun file docstring interactive type))))
91
92 ;; Fix-me: web autoload defcustoms.
93 ;;
94 ;; I have no good idea how to fix this. It looks like I have to
95 ;; defadvice `custom-load-symbol'. I thought that should not be
96 ;; necessary since it does (require load) on line 605 but the web
97 ;; autoload does not start. Why? Hm, you never know since it is inside
98 ;; a (condition-case nil ...).
99 ;;
100 ;; Ah, found it. The require is only done if custom loads contains a
101 ;; symbol, not a string. So I changed this to a symbol instead in
102 ;; nxhtml-loaddefs.el. Maybe `load' instead of `require' should be
103 ;; advised?
104
105 ;; What a hell is this below? Have things been rewritten in custom or
106 ;; did I mix somethintg?
107 (defun nxhtml-custom-autoload (symbol load &optional noset)
108   "Like `custom-autoload', but also run :set for defcustoms etc."
109   ;; Fix-me: is-boundp is currently always t because of the order in
110   ;; loaddefs. Hm, so this worked just by chance...
111   (let* ((is-boundp (prog1 (boundp symbol)
112                       (custom-autoload symbol load noset)))
113          (standard (get symbol 'standard-value))
114          (saved (get symbol 'saved-value))
115          ;; Fix-me: property custom-set etc are not available
116          (custom-set (get symbol 'custom-set))
117          (custom-initialize (get symbol 'custom-initialize))
118          (set (or custom-set 'custom-set-default))) ;; Fix-me: initialize
119     (setq custom-set t) ;; Not available here
120     (when (or custom-initialize
121               (and saved
122                    (not (equal (car saved) (symbol-value symbol)))
123                    custom-set))
124       (funcall set symbol (car saved))
125       (custom-load-symbol symbol))))
126
127 (defun flymake-init-load-flymakemsg ()
128   (require 'flymakemsg))
129
130 (define-minor-mode nxhtml-flymake-setup
131   "Let nXhtml add some addtions to flymake.
132 This adds support for CSS and JavaScript files.
133
134 It also adds showing of errors in minibuffer when point is on
135 them.
136
137 If you turn this off you must restart Emacs for it to take
138 effect."
139   :group 'nxhtml
140   :group 'flymake
141   (when nxhtml-flymake-setup
142     (flymake-js-load)
143     (flymake-css-load)
144     (flymake-java-1-load)
145     (add-hook 'flymake-mode-hook 'flymake-init-load-flymakemsg)))
146
147
148 (provide 'nxhtml-base)
149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
150 ;;; nxhtml-base.el ends here