155
|
1 ;;; $Id: hm--html.el,v 1.8 1997/06/06 00:57:04 steve Exp $
|
2
|
2 ;;;
|
98
|
3 ;;; Copyright (C) 1993 - 1997 Heiko Muenkel
|
0
|
4 ;;; email: muenkel@tnt.uni-hannover.de
|
|
5 ;;;
|
|
6 ;;; This program is free software; you can redistribute it and/or modify
|
|
7 ;;; it under the terms of the GNU General Public License as published by
|
|
8 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
9 ;;; any later version.
|
|
10 ;;;
|
|
11 ;;; This program is distributed in the hope that it will be useful,
|
|
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 ;;; GNU General Public License for more details.
|
|
15 ;;;
|
|
16 ;;; You should have received a copy of the GNU General Public License
|
|
17 ;;; along with this program; if not, write to the Free Software
|
|
18 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19 ;;;
|
|
20 ;;;
|
|
21 ;;; Description:
|
|
22 ;;;
|
|
23 ;;; Defines functions for the file hm--html-menu.el.
|
|
24 ;;;
|
|
25 ;;; Installation:
|
|
26 ;;;
|
|
27 ;;; Put this file in one of your load path directories.
|
|
28 ;;;
|
|
29
|
98
|
30 (defun hm--html-set-marker-at-position (&optional position)
|
|
31 "Creates a new marker and set the marker at the POSITION.
|
|
32 If POSITION is nil, then the marker is set at the current point.
|
|
33 The return value is the marker."
|
|
34 (let ((marker (make-marker)))
|
|
35 (if position
|
|
36 (set-marker marker position)
|
|
37 (set-marker marker (point)))))
|
0
|
38
|
|
39 ;;; Functions for adding html commands which consists of a start and a
|
|
40 ;;; end tag and some text between them. (Basicfunctions)
|
|
41
|
|
42 (defun hm--html-add-tags (function-insert-start-tag
|
|
43 start-tag
|
2
|
44 &optional
|
|
45 function-insert-end-tag
|
|
46 end-tag
|
|
47 function-insert-middle-start-tag
|
|
48 middle-start-tag
|
|
49 function-insert-middle-end-tag
|
|
50 middle-end-tag)
|
0
|
51 "Adds the start and the end html tag at point.
|
|
52 The first parameter specifies the funtion which insert the start tag
|
|
53 and the third parameter specifies the function which insert the end tag.
|
|
54 The second parameter is the string for the start tag and the fourth parameter
|
|
55 is the string for the end tag. The third and fourth parameters are optional.
|
|
56 The fifth parameter is optional. If it exists, it specifies a function which
|
98
|
57 inserts the sixth parameter (the middle-start-tag) between the start and the
|
|
58 end tag."
|
0
|
59 (eval (list function-insert-start-tag start-tag))
|
2
|
60 (if function-insert-middle-start-tag
|
|
61 (eval (list function-insert-middle-start-tag middle-start-tag)))
|
98
|
62 (let ((position (hm--html-set-marker-at-position (point))))
|
2
|
63 (if function-insert-middle-end-tag
|
|
64 (eval (list function-insert-middle-end-tag middle-end-tag)))
|
|
65 (if function-insert-end-tag
|
|
66 (eval (list function-insert-end-tag end-tag)))
|
|
67 (goto-char position)))
|
0
|
68
|
|
69
|
|
70 (defun hm--html-add-tags-to-region (function-insert-start-tag
|
|
71 start-tag
|
|
72 function-insert-end-tag
|
|
73 end-tag
|
98
|
74 &optional
|
|
75 function-insert-middle-tag
|
|
76 middle-tag)
|
0
|
77 "Adds the start and the end html tag to the active region.
|
|
78 The first parameter specifies the funtion which insert the start tag
|
|
79 and the third parameter specifies the function which insert the end tag.
|
|
80 The second parameter is the string for the start tag and the fourth parameter
|
|
81 is the string for the end tag.
|
|
82 The fifth parameter is optional. If it exists, it specifies a function which
|
|
83 inserts the sixth parameter (the middle-tag) between the start and the end
|
|
84 tag."
|
|
85 (save-window-excursion
|
98
|
86 (let ((start (hm--html-set-marker-at-position (region-beginning)))
|
0
|
87 (end (region-end)))
|
|
88 (goto-char end)
|
|
89 (eval (list function-insert-end-tag end-tag))
|
|
90 (goto-char start)
|
|
91 (eval (list function-insert-start-tag start-tag))
|
|
92 (if function-insert-middle-tag
|
|
93 (eval (list function-insert-middle-tag middle-tag)))
|
|
94 )))
|
|
95
|
|
96
|
|
97 (defun hm--html-insert-start-tag (tag)
|
|
98 "Inserts the HTML start tag 'tag' without a Newline.
|
|
99 The parameter must be a string (i.e. \"<B>\")"
|
|
100 (let ((start (point)))
|
|
101 (insert tag)
|
2
|
102 (hm--html-indent-region start (point))))
|
0
|
103
|
|
104
|
|
105 (defun hm--html-insert-end-tag (tag)
|
|
106 "Inserts the HTML end tag 'tag' without a Newline.
|
|
107 The parameter must be a string (i.e. \"</B>\")"
|
|
108 (let ((start (point)))
|
|
109 (insert tag)
|
2
|
110 (hm--html-indent-region start (point))))
|
0
|
111
|
|
112
|
|
113 (defun hm--html-insert-start-tag-with-newline (tag)
|
|
114 "Inserts the HTML start tag 'tag' with a Newline.
|
|
115 The parameter must be a string (i.e. \"<PRE>\")"
|
|
116 (let ((start (point)))
|
|
117 (insert tag)
|
2
|
118 (hm--html-indent-region start (point))
|
|
119 )
|
0
|
120 (insert "\n"))
|
|
121
|
|
122
|
|
123 (defun hm--html-insert-end-tag-with-newline (tag)
|
|
124 "Inserts the HTML end tag 'tag' with a Newline.
|
|
125 The parameter must be a string (i.e. \"</PRE>\")"
|
|
126 (insert "\n")
|
|
127 (let ((start (point)))
|
|
128 (insert tag)
|
2
|
129 (hm--html-indent-region start (point))))
|
0
|
130
|
|
131
|
|
132
|
|
133 ;;; Functions which add simple tags of the form <tag>
|
|
134
|
2
|
135 (defun hm--html-add-list-or-menu-item-separator ()
|
|
136 "Adds a list or menu item. Assume we're at the end of the last item."
|
|
137 (interactive)
|
|
138 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline "<LI> "))
|
|
139
|
|
140 (defun hm--html-add-list-or-menu-item ()
|
|
141 "Adds the tags for a menu item at the point in the current buffer."
|
|
142 (interactive)
|
|
143 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline "<LI> "
|
|
144 'hm--html-insert-end-tag " </LI>"))
|
|
145
|
|
146 (defun hm--html-add-list-or-menu-item-to-region ()
|
|
147 "Adds the tags for a menu item to the region in the current buffer."
|
|
148 (interactive)
|
|
149 (hm--html-add-tags-to-region 'hm--html-insert-start-tag "<LI> "
|
|
150 'hm--html-insert-end-tag " </LI>"))
|
|
151
|
100
|
152 (defun hm--html-add-basefont (size)
|
|
153 "Adds the HTML tag for a basefont."
|
|
154 (interactive (list (hm--html-read-font-size t)))
|
|
155 (hm--html-add-tags 'hm--html-insert-start-tag
|
116
|
156 (concat "<BASEFONT SIZE=" size ">")))
|
100
|
157
|
0
|
158 (defun hm--html-add-line-break ()
|
|
159 "Adds the HTML tag for a line break."
|
|
160 (interactive)
|
|
161 (hm--html-add-tags 'hm--html-insert-start-tag "<BR>"))
|
|
162
|
|
163
|
|
164 (defun hm--html-add-horizontal-rule ()
|
|
165 "Adds the HTML tag for a horizontal rule (line)."
|
|
166 (interactive)
|
|
167 (hm--html-add-tags 'hm--html-insert-start-tag "<HR>"))
|
|
168
|
|
169
|
|
170 (defun hm--html-add-paragraph ()
|
|
171 "Adds the HTML tags for a paragraph at the point in the current buffer."
|
|
172 (interactive)
|
|
173 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
174 "<P>"
|
|
175 'hm--html-insert-end-tag-with-newline
|
|
176 "</P>"))
|
|
177
|
|
178
|
|
179 (defun hm--html-add-paragraph-to-region ()
|
|
180 "Adds the HTML tags for a paragraph to the region."
|
|
181 (interactive)
|
|
182 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
183 "<P>"
|
|
184 'hm--html-insert-end-tag-with-newline
|
|
185 "</P>"))
|
|
186
|
|
187
|
|
188 (defun hm--html-add-paragraph-separator ()
|
|
189 "Adds the tag for a paragraph seperator."
|
|
190 (interactive)
|
|
191 (hm--html-add-tags 'hm--html-insert-start-tag "<P>"))
|
|
192
|
100
|
193 (defun hm--html-add-doctype ()
|
|
194 "Adds the tag with the doctype."
|
|
195 (interactive)
|
|
196 (goto-char (point-min))
|
|
197 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
198 (concat "<!DOCTYPE HTML PUBLIC \""
|
|
199 hm--html-html-doctype-version
|
|
200 "\">"))
|
|
201 (newline))
|
|
202
|
|
203 (defun hm--html-search-place-for-element-in-head (end-point)
|
|
204 "Searches the point for inserting an element between the head tags."
|
|
205 (let ((point (point)))
|
|
206 (if (and end-point (< (point) end-point))
|
|
207 (point)
|
|
208 (goto-char (point-min))
|
|
209 (if (re-search-forward
|
116
|
210 (concat ;"\\(<title\\)\\|\\(<head\\)\\|\\(<html\\)\\|"
|
|
211 "\\(<title\\)\\|"
|
|
212 "\\(<isindex\\)\\|\\(<base\\)\\|\\(<link\\)\\|"
|
|
213 "\\(<meta\\)")
|
100
|
214 end-point
|
|
215 t)
|
|
216 (beginning-of-line)
|
116
|
217 end-point))))
|
100
|
218
|
|
219 (defun hm--html-add-isindex (prompt)
|
|
220 "Inserts the isindex tag. PROMPT is the value of the prompt attribute."
|
|
221 (interactive "sPrompt: ")
|
|
222 (save-excursion
|
|
223 (let ((point (point))
|
|
224 (case-fold-search t)
|
|
225 (head-end-point))
|
|
226 (goto-char (point-min))
|
|
227 (setq head-end-point (when (re-search-forward
|
|
228 "\\(</head\\)\\|\\(<body\\)\\|\\(</html\\)")
|
|
229 (beginning-of-line)
|
116
|
230 (point)))
|
|
231 (goto-char (point-min))
|
|
232 (cond ((re-search-forward "<isindex[^>]*>" head-end-point t)
|
|
233 (delete-region (match-beginning 0) (match-end 0)))
|
|
234 (t (goto-char point)
|
|
235 (hm--html-search-place-for-element-in-head head-end-point)))
|
|
236 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
237 (concat "<ISINDEX "
|
|
238 (if (and prompt
|
|
239 (not (string= prompt "")))
|
|
240 (concat " PROMPT=\"" prompt "\">")
|
|
241 ">"))))))
|
100
|
242
|
|
243 (defun hm--html-add-base (href)
|
|
244 "Inserts the base tag. HREF is the value of the href attribute."
|
|
245 (interactive (list (hm--html-read-url "URL of this document: "
|
|
246 nil
|
|
247 nil
|
|
248 t
|
|
249 nil)))
|
|
250 (save-excursion
|
|
251 (let ((point (point))
|
|
252 (case-fold-search t)
|
|
253 (head-end-point))
|
|
254 (goto-char (point-min))
|
|
255 (setq head-end-point (when (re-search-forward
|
|
256 "\\(</head\\)\\|\\(<body\\)\\|\\(</html\\)")
|
|
257 (beginning-of-line)
|
116
|
258 (point)))
|
|
259 (goto-char (point-min))
|
|
260 (cond ((re-search-forward "<base[^>]*>" head-end-point t)
|
|
261 (delete-region (match-beginning 0) (match-end 0)))
|
|
262 (t (goto-char point)
|
|
263 (hm--html-search-place-for-element-in-head head-end-point)))
|
|
264 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
265 (concat "<BASE "
|
|
266 (if (and href
|
|
267 (not (string= href "")))
|
|
268 (concat " HREF=\"" href "\">")
|
|
269 ">"))))))
|
100
|
270
|
|
271 (defun hm--html-add-meta (name content &optional name-instead-of-http-equiv)
|
|
272 "Inserts the meta tag."
|
|
273 (interactive (list (completing-read "Name: " hm--html-meta-name-alist)
|
|
274 (read-string "Content: ")))
|
|
275 (save-excursion
|
|
276 (let ((point (point))
|
|
277 (case-fold-search t)
|
|
278 (head-end-point))
|
|
279 (goto-char (point-min))
|
|
280 (setq head-end-point (when (re-search-forward
|
|
281 "\\(</head\\)\\|\\(<body\\)\\|\\(</html\\)")
|
|
282 (beginning-of-line)
|
102
|
283 (point)))
|
|
284 (goto-char point)
|
|
285 (hm--html-search-place-for-element-in-head head-end-point)
|
116
|
286 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
102
|
287 (concat "<META "
|
|
288 (if name-instead-of-http-equiv
|
|
289 "NAME=\""
|
|
290 "HTTP-EQUIV=\"")
|
|
291 name
|
|
292 "\" CONTENT=\""
|
|
293 content
|
|
294 "\">")))))
|
0
|
295
|
|
296
|
|
297 ;;; Functions which include something in HTML- documents
|
|
298
|
|
299 (defvar hm--html-url-history-list nil
|
|
300 "History list for the function 'hm--html-read-url'")
|
|
301
|
|
302
|
|
303 (defun hm--html-read-url-predicate (table-element-list usagesymbol)
|
|
304 "Predicatefunction for hm--html-read-url."
|
|
305 (hm--html-read-url-predicate-1 (cdr table-element-list) usagesymbol))
|
|
306
|
|
307
|
|
308 (defun hm--html-read-url-predicate-1 (table-element-list usagesymbol)
|
|
309 "Internal function of hm--html-read-url-predicate."
|
|
310 (cond ((not table-element-list) nil)
|
|
311 ((eq (car table-element-list) usagesymbol))
|
|
312 (t (hm--html-read-url-predicate-1 (cdr table-element-list)
|
|
313 usagesymbol))))
|
|
314
|
|
315
|
|
316 (defun hm--html-read-url (prompt &optional
|
|
317 table
|
|
318 predicate
|
|
319 require-match
|
|
320 initial-contents)
|
|
321 "Function prompts for a URL string.
|
|
322 TABLE is an alist whose elements' cars are URL's.
|
|
323 PREDICATE limits completion to a subset of TABLE.
|
|
324 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless
|
|
325 the input is (or completes to) an element of TABLE.
|
|
326 INITIAL-CONTENTS is a string to insert in the minibuffer before reading.
|
|
327 If INITIAL-CONTENTS is nil, the car of the 'hm--html-url-history-list'
|
|
328 is used instead."
|
|
329 (if table
|
|
330 (completing-read prompt
|
|
331 table
|
|
332 predicate
|
|
333 require-match
|
|
334 initial-contents
|
|
335 hm--html-url-history-list)
|
|
336 (read-string prompt
|
|
337 (if initial-contents
|
|
338 initial-contents
|
|
339 (car hm--html-url-history-list))
|
|
340 hm--html-url-history-list)))
|
|
341
|
|
342
|
|
343 (defun hm--html-read-altenate (url)
|
|
344 "Function reads the value for the \"ALT\"- attribute in IMG tags.
|
|
345 URL will be used as the default URL for the external viewer."
|
|
346 (let ((alttype
|
|
347 (string-to-int
|
|
348 (completing-read
|
|
349 "0: No ALT atribute, 1: ALT=\"\", 2: ALT=Text: "
|
|
350 '(("0") ("1") ("2"))
|
|
351 nil
|
|
352 t
|
|
353 "2"))))
|
|
354 (cond ((= alttype 0) nil)
|
|
355 ((= alttype 1) "")
|
|
356 ((= alttype 2) (read-string
|
|
357 "Text for the ALT attribute: "
|
|
358 (substring (file-name-nondirectory url)
|
|
359 0
|
|
360 (string-match
|
|
361 "\\."
|
|
362 (file-name-nondirectory url)))))
|
|
363 )))
|
|
364
|
100
|
365 (defun hm--html-read-alignment (prompt)
|
|
366 "Read the value for the align attribute."
|
|
367 (upcase (completing-read prompt
|
|
368 '(("left") ("right") ("top") ("bottom") ("middle"))
|
|
369 nil
|
|
370 t
|
|
371 "left")))
|
|
372
|
|
373 (defvar hm--html-shape-history nil
|
|
374 "History variable for reading the shape of an image map.")
|
|
375
|
|
376 (defun hm--html-read-shape ()
|
|
377 "Reads the shap for an area element."
|
|
378 (upcase(completing-read "The shape of the area: "
|
|
379 '(("rect") ("circle") ("poly"))
|
|
380 nil
|
|
381 t
|
|
382 (or (car hm--html-shape-history) "rect")
|
|
383 'hm--html-shape-history)))
|
|
384
|
|
385 (defun hm--html-read-rect-coords ()
|
|
386 "Reads rectangle coordinates for the area element."
|
|
387 (concat (read-string "Left x position of the rectangle: ") ", "
|
|
388 (read-string "Top y position of the rectangle: ") ", "
|
|
389 (read-string "Right x position of the rectangle: ") ", "
|
|
390 (read-string "Bottom y position of the rectangle: ")))
|
|
391
|
|
392 (defun hm--html-read-circle-coords ()
|
|
393 "Reads circle coordinates for the area element."
|
|
394 (concat (read-string "x position of the center of the circle: ") ", "
|
|
395 (read-string "y position of the center of the circle: ") ", "
|
|
396 (read-string "Radius: ")))
|
|
397
|
|
398 (defun hm--html-read-one-poly-coordinate (&optional empty-string-prompt)
|
|
399 "Reads one poly coordinate pair."
|
|
400 (let* ((x (read-string (concat "x coordinate"
|
|
401 (or empty-string-prompt "")
|
|
402 ": ")))
|
|
403 (y (unless (string= "" x)
|
|
404 (read-string "y coordinate: "))))
|
|
405 (if (string= "" x)
|
|
406 ""
|
|
407 (concat x ", " y))))
|
|
408
|
|
409 (defun hm--html-read-more-poly-coordinates ()
|
|
410 "Reads poly coordinates until an empty string is given."
|
|
411 (let ((coord (hm--html-read-one-poly-coordinate
|
|
412 " (Empty string for no further coords!)")))
|
|
413 (cond ((string= "" coord) "")
|
|
414 (t (concat ", " coord (hm--html-read-more-poly-coordinates))))))
|
|
415
|
|
416 (defun hm--html-read-poly-coords ()
|
|
417 "Reads poly coordinates for the area element."
|
|
418 (concat (hm--html-read-one-poly-coordinate) ", "
|
|
419 (hm--html-read-one-poly-coordinate) ", "
|
|
420 (hm--html-read-one-poly-coordinate)
|
|
421 (hm--html-read-more-poly-coordinates)))
|
|
422
|
|
423 (defun hm--html-add-area (href alt shape coords)
|
|
424 "Adds the tags for an area at the current point."
|
|
425 (interactive (let* ((href (hm--html-read-url "Url for the image area: "))
|
|
426 (alt (hm--html-read-altenate href))
|
|
427 (shape (hm--html-read-shape))
|
|
428 (coords (cond ((string= shape "RECT")
|
|
429 (hm--html-read-rect-coords))
|
|
430 ((string= shape "CIRCLE")
|
|
431 (hm--html-read-circle-coords))
|
|
432 ((string= shape "POLY")
|
|
433 (hm--html-read-poly-coords))
|
|
434 (t (error "No function to read \""
|
|
435 shape
|
|
436 "\" coordinates!")))))
|
|
437 (list href alt shape coords)))
|
|
438 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline
|
|
439 (concat "<AREA"
|
|
440 " HREF=\"" href "\""
|
|
441 (if alt
|
|
442 (concat "\nALT=\"" alt "\"")
|
|
443 "")
|
|
444 "\nSHAPE=" shape
|
|
445 "\nCOORDS=\"" coords "\""
|
|
446 ">")))
|
|
447
|
116
|
448
|
|
449 (when (adapt-emacs19p)
|
|
450 (defvar :ask ':ask))
|
|
451
|
100
|
452 (defvar hm--html-use-image-as-map ':ask
|
|
453 "Internal variable of `hm--html-add-image'.
|
|
454 nil => insert the image element without an usemap attribute.
|
|
455 t => insert the image element with an usemap attribute.
|
|
456 :ask => ask, if the image element should have an usemap attribute.")
|
|
457
|
|
458 (defun hm--html-add-image (href alt alignment mapname)
|
|
459 "Add an image."
|
|
460 (interactive (let* ((href (hm--html-read-url "Image URL: "))
|
|
461 (alt (hm--html-read-altenate href))
|
|
462 (alignment (hm--html-read-alignment
|
|
463 "Alignment of the image: "))
|
|
464 (use-as-map (if (eq hm--html-use-image-as-map ':ask)
|
|
465 (y-or-n-p
|
|
466 "Use the image as a map with links? ")
|
|
467 hm--html-use-image-as-map))
|
|
468 (mapname (and use-as-map (hm--html-read-mapname))))
|
|
469 (list href alt alignment mapname)))
|
|
470 (hm--html-add-tags
|
|
471 'hm--html-insert-start-tag
|
|
472 (concat "<IMG ALIGN=" alignment
|
|
473 "\nHREF=\"" href "\""
|
|
474 (if alt
|
|
475 (concat "\nALT=\"" alt "\"")
|
|
476 "")
|
|
477 (if mapname
|
|
478 (concat "\nUSEMAP=\"#" mapname "\"")
|
|
479 "")
|
|
480 ">")))
|
|
481
|
0
|
482
|
|
483 (defun hm--html-add-image-bottom (href alt)
|
|
484 "Add an image, bottom aligned."
|
|
485 (interactive (let ((url (hm--html-read-url "Image URL: ")))
|
|
486 (list url (hm--html-read-altenate url))))
|
2
|
487 (hm--html-add-tags
|
|
488 'hm--html-insert-start-tag
|
|
489 (concat "<IMG ALIGN=BOTTOM SRC=\""
|
|
490 href
|
|
491 (when alt
|
|
492 (concat "\" ALT=\"" alt))
|
|
493 "\">")))
|
0
|
494
|
|
495
|
|
496 (defun hm--html-add-image-middle (href alt)
|
|
497 "Add an image, middle aligned."
|
|
498 (interactive (let ((url (hm--html-read-url "Image URL: ")))
|
|
499 (list url (hm--html-read-altenate url))))
|
2
|
500 (hm--html-add-tags
|
|
501 'hm--html-insert-start-tag
|
|
502 (concat "<IMG ALIGN=MIDDLE SRC=\""
|
|
503 href
|
|
504 (when alt
|
|
505 (concat "\" ALT=\"" alt))
|
|
506 "\">")))
|
0
|
507
|
|
508
|
|
509 (defun hm--html-add-image-top (href alt)
|
|
510 "Add an image, top aligned."
|
|
511 (interactive (let ((url (hm--html-read-url "Image URL: ")))
|
|
512 (list url (hm--html-read-altenate url))))
|
2
|
513 (hm--html-add-tags
|
|
514 'hm--html-insert-start-tag
|
|
515 (concat "<IMG ALIGN=TOP SRC=\""
|
|
516 href
|
|
517 (when alt
|
|
518 (concat "\" ALT=\"" alt))
|
|
519 "\">")))
|
|
520
|
|
521
|
|
522 (defun hm--html-add-applet (name code width height)
|
|
523 "Add an applet."
|
|
524 (interactive (let ((name (read-string "Applet Name: " "applet"))
|
|
525 (code (read-file-name "Applet Class File: "))
|
|
526 (width (read-number "Width (i.e.: 100): " t))
|
|
527 (height (read-number "Height (i.e.: 100): " t)))
|
|
528 (list name code width height)))
|
|
529 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
530 (concat "<APPLET "
|
|
531 (if (string= name "")
|
|
532 ""
|
|
533 (concat "NAME=\"" name "\"\n"))
|
|
534 "CODE=\""
|
|
535 code
|
|
536 "\"\n"
|
|
537 "WIDTH=\""
|
|
538 width
|
|
539 "\"\n"
|
|
540 "HEIGHT=\""
|
|
541 height
|
|
542 "\">")
|
|
543 'hm--html-insert-start-tag-with-newline
|
|
544 "</APPLET>"))
|
|
545
|
|
546 (defun hm--html-add-applet-parameter (name value)
|
|
547 "Adds the tag for an applet parameter at the current point.
|
|
548 This tag must be added between <APPLET> and </APPLET>."
|
|
549 (interactive "sParameter Name: \nsParameter Value: ")
|
|
550 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
551 (concat "<PARAM "
|
|
552 "NAME=\""
|
|
553 name
|
|
554 "\" VALUE=\""
|
|
555 value
|
|
556 "\">")))
|
|
557
|
0
|
558
|
|
559
|
|
560 ;;; Functions, which adds tags of the form <starttag> ... </endtag>
|
|
561
|
2
|
562 (defun hm--html-add-big ()
|
|
563 "Adds the HTML tags for Big at the point in the current buffer."
|
|
564 (interactive)
|
|
565 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
566 "<BIG>"
|
|
567 'hm--html-insert-end-tag
|
|
568 "</BIG>"))
|
|
569
|
|
570
|
|
571 (defun hm--html-add-big-to-region ()
|
|
572 "Adds the HTML tags for Big to the region."
|
|
573 (interactive)
|
|
574 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
575 "<BIG>"
|
|
576 'hm--html-insert-end-tag
|
|
577 "</BIG>"))
|
|
578
|
|
579
|
|
580 (defun hm--html-add-small ()
|
|
581 "Adds the HTML tags for Small at the point in the current buffer."
|
|
582 (interactive)
|
|
583 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
584 "<SMALL>"
|
|
585 'hm--html-insert-end-tag
|
|
586 "</SMALL>"))
|
|
587
|
|
588
|
|
589 (defun hm--html-add-small-to-region ()
|
|
590 "Adds the HTML tags for Small to the region."
|
|
591 (interactive)
|
|
592 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
593 "<SMALL>"
|
|
594 'hm--html-insert-end-tag
|
|
595 "</SMALL>"))
|
|
596
|
|
597
|
0
|
598 (defun hm--html-add-bold ()
|
|
599 "Adds the HTML tags for Bold at the point in the current buffer."
|
|
600 (interactive)
|
|
601 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
602 "<B>"
|
|
603 'hm--html-insert-end-tag
|
|
604 "</B>"))
|
|
605
|
|
606
|
|
607 (defun hm--html-add-bold-to-region ()
|
|
608 "Adds the HTML tags for Bold to the region."
|
|
609 (interactive)
|
|
610 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
611 "<B>"
|
|
612 'hm--html-insert-end-tag
|
|
613 "</B>"))
|
|
614
|
|
615
|
|
616 (defun hm--html-add-italic ()
|
|
617 "Adds the HTML tags for Italic at the point in the current buffer."
|
|
618 (interactive)
|
|
619 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
620 "<I>"
|
|
621 'hm--html-insert-end-tag
|
|
622 "</I>"))
|
|
623
|
|
624
|
|
625 (defun hm--html-add-italic-to-region ()
|
|
626 "Adds the HTML tags for Italic to the region."
|
|
627 (interactive)
|
|
628 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
629 "<I>"
|
|
630 'hm--html-insert-end-tag
|
|
631 "</I>"))
|
|
632
|
|
633
|
|
634 (defun hm--html-add-underline ()
|
|
635 "Adds the HTML tags for Underline at the point in the current buffer."
|
|
636 (interactive)
|
|
637 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
638 "<U>"
|
|
639 'hm--html-insert-end-tag
|
|
640 "</U>"))
|
|
641
|
|
642
|
|
643 (defun hm--html-add-underline-to-region ()
|
|
644 "Adds the HTML tags for Underline to the region."
|
|
645 (interactive)
|
|
646 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
647 "<U>"
|
|
648 'hm--html-insert-end-tag
|
|
649 "</U>"))
|
|
650
|
|
651
|
|
652 (defun hm--html-add-definition ()
|
|
653 "Adds the HTML tags for Definition at the point in the current buffer."
|
|
654 (interactive)
|
|
655 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
656 "<DFN>"
|
|
657 'hm--html-insert-end-tag
|
|
658 "</DFN>"))
|
|
659
|
|
660
|
|
661 (defun hm--html-add-definition-to-region ()
|
|
662 "Adds the HTML tags for Definition to the region."
|
|
663 (interactive)
|
|
664 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
665 "<DFN>"
|
|
666 'hm--html-insert-end-tag
|
|
667 "</DFN>"))
|
|
668
|
|
669
|
|
670 (defun hm--html-add-code ()
|
|
671 "Adds the HTML tags for Code at the point in the current buffer."
|
|
672 (interactive)
|
|
673 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
674 "<CODE>"
|
|
675 'hm--html-insert-end-tag
|
|
676 "</CODE>"))
|
|
677
|
|
678
|
|
679 (defun hm--html-add-code-to-region ()
|
|
680 "Adds the HTML tags for Code to the region."
|
|
681 (interactive)
|
|
682 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
683 "<CODE>"
|
|
684 'hm--html-insert-end-tag
|
|
685 "</CODE>"))
|
|
686
|
|
687
|
2
|
688 (defun hm--html-add-citation ()
|
|
689 "Adds the HTML tags for Citation."
|
|
690 (interactive)
|
|
691 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
692 "<CITE>"
|
|
693 'hm--html-insert-end-tag
|
|
694 "</CITE>"))
|
|
695
|
0
|
696 (defun hm--html-add-citation-to-region ()
|
|
697 "Adds the HTML tags for Citation to the region."
|
|
698 (interactive)
|
|
699 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
700 "<CITE>"
|
|
701 'hm--html-insert-end-tag
|
|
702 "</CITE>"))
|
|
703
|
|
704
|
2
|
705 (defun hm--html-add-emphasized ()
|
|
706 "Adds the HTML tags for Emphasized."
|
|
707 (interactive)
|
|
708 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
709 "<EM>"
|
|
710 'hm--html-insert-end-tag
|
|
711 "</EM>"))
|
|
712
|
|
713
|
0
|
714 (defun hm--html-add-emphasized-to-region ()
|
|
715 "Adds the HTML tags for Emphasized to the region."
|
|
716 (interactive)
|
|
717 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
718 "<EM>"
|
|
719 'hm--html-insert-end-tag
|
|
720 "</EM>"))
|
|
721
|
|
722
|
2
|
723 (defun hm--html-add-fixed ()
|
|
724 "Adds the HTML tags for Fixed."
|
|
725 (interactive)
|
|
726 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
727 "<TT>"
|
|
728 'hm--html-insert-end-tag
|
|
729 "</TT>"))
|
|
730
|
|
731
|
0
|
732 (defun hm--html-add-fixed-to-region ()
|
|
733 "Adds the HTML tags for Fixed to the region."
|
|
734 (interactive)
|
|
735 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
736 "<TT>"
|
|
737 'hm--html-insert-end-tag
|
|
738 "</TT>"))
|
|
739
|
|
740
|
2
|
741 (defun hm--html-add-keyboard ()
|
|
742 "Adds the HTML tags for Keyboard."
|
|
743 (interactive)
|
|
744 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
745 "<KBD>"
|
|
746 'hm--html-insert-end-tag
|
|
747 "</KBD>"))
|
|
748
|
|
749
|
0
|
750 (defun hm--html-add-keyboard-to-region ()
|
|
751 "Adds the HTML tags for Keyboard to the region."
|
|
752 (interactive)
|
|
753 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
754 "<KBD>"
|
|
755 'hm--html-insert-end-tag
|
|
756 "</KBD>"))
|
|
757
|
|
758
|
2
|
759 (defun hm--html-add-sample ()
|
|
760 "Adds the HTML tags for Sample."
|
|
761 (interactive)
|
|
762 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
763 "<SAMP>"
|
|
764 'hm--html-insert-end-tag
|
|
765 "</SAMP>"))
|
|
766
|
0
|
767 (defun hm--html-add-sample-to-region ()
|
|
768 "Adds the HTML tags for Sample to the region."
|
|
769 (interactive)
|
|
770 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
771 "<SAMP>"
|
|
772 'hm--html-insert-end-tag
|
|
773 "</SAMP>"))
|
|
774
|
|
775
|
2
|
776 (defun hm--html-add-strong ()
|
|
777 "Adds the HTML tags for Strong."
|
|
778 (interactive)
|
|
779 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
780 "<STRONG>"
|
|
781 'hm--html-insert-end-tag
|
|
782 "</STRONG>"))
|
|
783
|
|
784
|
0
|
785 (defun hm--html-add-strong-to-region ()
|
|
786 "Adds the HTML tags for Strong to the region."
|
|
787 (interactive)
|
|
788 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
789 "<STRONG>"
|
|
790 'hm--html-insert-end-tag
|
|
791 "</STRONG>"))
|
|
792
|
|
793
|
2
|
794 (defun hm--html-add-variable ()
|
|
795 "Adds the HTML tags for Variable."
|
|
796 (interactive)
|
|
797 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
798 "<VAR>"
|
|
799 'hm--html-insert-end-tag
|
|
800 "</VAR>"))
|
|
801
|
0
|
802 (defun hm--html-add-variable-to-region ()
|
|
803 "Adds the HTML tags for Variable to the region."
|
|
804 (interactive)
|
|
805 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
806 "<VAR>"
|
|
807 'hm--html-insert-end-tag
|
|
808 "</VAR>"))
|
|
809
|
|
810
|
|
811 (defun hm--html-add-comment ()
|
|
812 "Adds the HTML tags for Comment at the point in the current buffer."
|
|
813 (interactive)
|
|
814 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
815 "<!-- "
|
|
816 'hm--html-insert-end-tag
|
|
817 " -->"))
|
|
818
|
|
819
|
|
820 (defun hm--html-add-comment-to-region ()
|
|
821 "Adds the HTML tags for Comment to the region."
|
|
822 (interactive)
|
|
823 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
824 "<!-- "
|
|
825 'hm--html-insert-end-tag
|
|
826 " -->"))
|
|
827
|
|
828
|
100
|
829 (defun hm--html-add-document-division (alignment)
|
|
830 "Adds the HTML tags for document division at the current point."
|
|
831 (interactive (list (hm--html-read-alignment "Alignment of the division: ")))
|
|
832 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
833 (concat "<DIV ALIGN=\"" alignment "\">")
|
|
834 'hm--html-insert-end-tag-with-newline
|
|
835 "</DIV>"))
|
|
836
|
|
837
|
116
|
838 (defun hm--html-add-document-division-to-region (alignment)
|
100
|
839 "Adds the HTML tags for document division to the region."
|
|
840 (interactive (list (hm--html-read-alignment "Alignment of the division: ")))
|
|
841 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
842 (concat "<DIV ALIGN=\"" alignment "\">")
|
|
843 'hm--html-insert-end-tag-with-newline
|
|
844 "</DIV>"))
|
|
845
|
0
|
846
|
142
|
847 (defun hm--html-add-preformatted ()
|
153
|
848 "Adds the HTML tags for preformatted text at the current point."
|
0
|
849 (interactive)
|
|
850 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
851 "<PRE>"
|
|
852 'hm--html-insert-end-tag-with-newline
|
|
853 "</PRE>"))
|
153
|
854
|
|
855 (define-obsolete-function-alias 'hm--html-add-preformated
|
142
|
856 'hm--html-add-preformatted)
|
|
857
|
|
858 (defun hm--html-add-preformatted-to-region ()
|
|
859 "Adds the HTML tags for preformatted text to the region."
|
0
|
860 (interactive)
|
|
861 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
862 "<PRE>"
|
|
863 'hm--html-insert-end-tag-with-newline
|
|
864 "</PRE>"))
|
153
|
865
|
|
866 (define-obsolete-function-alias 'hm--html-add-preformated-to-region
|
142
|
867 'hm--html-add-preformatted-to-region)
|
0
|
868
|
2
|
869 (defun hm--html-add-blockquote ()
|
|
870 "Adds the HTML tags for blockquote."
|
|
871 (interactive)
|
|
872 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
873 "<BLOCKQUOTE>"
|
|
874 'hm--html-insert-end-tag-with-newline
|
|
875 "</BLOCKQUOTE>"))
|
|
876
|
|
877
|
0
|
878 (defun hm--html-add-blockquote-to-region ()
|
|
879 "Adds the HTML tags for blockquote to the region."
|
|
880 (interactive)
|
|
881 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
882 "<BLOCKQUOTE>"
|
|
883 'hm--html-insert-end-tag-with-newline
|
|
884 "</BLOCKQUOTE>"))
|
|
885
|
102
|
886 (defun hm--html-add-script ()
|
|
887 "Adds the HTML tags for script."
|
0
|
888 (interactive)
|
|
889 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
102
|
890 "<SCRIPT>"
|
0
|
891 'hm--html-insert-end-tag-with-newline
|
102
|
892 "</SCRIPT>"))
|
|
893
|
|
894
|
|
895 (defun hm--html-add-script-to-region ()
|
|
896 "Adds the HTML tags for script to the region."
|
0
|
897 (interactive)
|
|
898 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
102
|
899 "<SCRIPT>"
|
0
|
900 'hm--html-insert-end-tag-with-newline
|
102
|
901 "</SCRIPT>"))
|
|
902
|
|
903 (defun hm--html-add-style ()
|
|
904 "Adds the HTML tags for style."
|
|
905 (interactive)
|
|
906 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
907 "<STYLE>"
|
|
908 'hm--html-insert-end-tag-with-newline
|
|
909 "</STYLE>"))
|
|
910
|
|
911
|
|
912 (defun hm--html-add-style-to-region ()
|
|
913 "Adds the HTML tags for style to the region."
|
|
914 (interactive)
|
|
915 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
916 "<STYLE>"
|
|
917 'hm--html-insert-end-tag-with-newline
|
|
918 "</STYLE>"))
|
0
|
919
|
|
920 (defun hm--html-add-strikethru ()
|
|
921 "Adds the HTML tags for Strikethru at the point in the current buffer."
|
|
922 (interactive)
|
|
923 (hm--html-add-tags 'hm--html-insert-start-tag
|
100
|
924 "<STRIKE>"
|
0
|
925 'hm--html-insert-end-tag
|
100
|
926 "</STRIKE>"))
|
0
|
927
|
|
928
|
|
929 (defun hm--html-add-strikethru-to-region ()
|
|
930 "Adds the HTML tags for Strikethru to the region."
|
|
931 (interactive)
|
|
932 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
102
|
933 "<STRIKE>"
|
0
|
934 'hm--html-insert-end-tag
|
102
|
935 "</STRIKE>"))
|
0
|
936
|
|
937
|
|
938 (defun hm--html-add-superscript ()
|
|
939 "Adds the HTML tags for Superscript at the point in the current buffer."
|
|
940 (interactive)
|
|
941 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
942 "<SUP>"
|
|
943 'hm--html-insert-end-tag
|
|
944 "</SUP>"))
|
|
945
|
|
946
|
|
947 (defun hm--html-add-superscript-to-region ()
|
|
948 "Adds the HTML tags for Superscript to the region."
|
|
949 (interactive)
|
|
950 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
951 "<SUP>"
|
|
952 'hm--html-insert-end-tag
|
|
953 "</SUP>"))
|
|
954
|
|
955
|
|
956 (defun hm--html-add-subscript ()
|
|
957 "Adds the HTML tags for Subscript at the point in the current buffer."
|
|
958 (interactive)
|
|
959 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
960 "<SUB>"
|
|
961 'hm--html-insert-end-tag
|
|
962 "</SUB>"))
|
|
963
|
|
964
|
|
965 (defun hm--html-add-subscript-to-region ()
|
|
966 "Adds the HTML tags for Subscript to the region."
|
|
967 (interactive)
|
|
968 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
969 "<SUB>"
|
|
970 'hm--html-insert-end-tag
|
|
971 "</SUB>"))
|
|
972
|
|
973
|
|
974 (defun hm--html-add-option ()
|
|
975 "Adds the HTML tags for Option at the point in the current buffer."
|
|
976 (interactive)
|
|
977 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
978 "<OPT>"
|
|
979 'hm--html-insert-end-tag
|
|
980 "</OPT>"))
|
|
981
|
|
982
|
|
983 (defun hm--html-add-option-to-region ()
|
|
984 "Adds the HTML tags for Option to the region."
|
|
985 (interactive)
|
|
986 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
987 "<OPT>"
|
|
988 'hm--html-insert-end-tag
|
|
989 "</OPT>"))
|
|
990
|
|
991
|
100
|
992 (defun hm--html-read-font-size (&optional only-absolute-size)
|
|
993 "Reads the size for the FONT element.
|
|
994 It returns nil, if the size should not be changed."
|
|
995 (let ((size
|
|
996 (if only-absolute-size
|
|
997 (completing-read "The absolute font size (1 .. 7): "
|
|
998 '(("7") ("6") ("5") ("4") ("3") ("2") ("1"))
|
|
999 nil
|
|
1000 t
|
|
1001 "4")
|
|
1002 (completing-read "The relative (+/-) or absolute font size: "
|
|
1003 '(("-7") ("-6") ("-5") ("-4") ("-3") ("-2") ("-1")
|
|
1004 ("+7") ("+6") ("+5") ("+4") ("+3") ("+2") ("+1")
|
|
1005 ("7") ("6") ("5") ("4") ("3") ("2") ("1")
|
|
1006 ("use-basefont"))
|
|
1007 nil
|
|
1008 t
|
|
1009 "use-basefont-size"))))
|
|
1010 (if (string= size "use-basefont-size")
|
|
1011 nil
|
|
1012 size)))
|
|
1013
|
|
1014 (defun hm--html-read-font-color ()
|
|
1015 "Reads the size for the FONT element.
|
|
1016 It returns nil, if the color should not be changed."
|
|
1017 (let ((color
|
|
1018 (completing-read "The font color: "
|
|
1019 '(("Black") ("Silver") ("Gray") ("White") ("Maroon")
|
|
1020 ("Green") ("Lime") ("Olive") ("Yellow") ("Navy")
|
|
1021 ("Red") ("Purple") ("Fuchsia") ("Blue") ("Teal")
|
|
1022 ("Aqua") ("dont-set-color"))
|
|
1023 nil
|
|
1024 nil
|
|
1025 "dont-set-color")))
|
|
1026 (if (string= color "dont-set-color")
|
|
1027 nil
|
|
1028 color)))
|
|
1029
|
|
1030
|
|
1031 (defun hm--html-add-font (size color)
|
|
1032 "Adds the HTML tags for Font at the point in the current buffer."
|
|
1033 (interactive (list (hm--html-read-font-size)
|
|
1034 (hm--html-read-font-color)))
|
|
1035 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1036 (concat "<FONT"
|
|
1037 (if size
|
|
1038 (concat " SIZE=" size)
|
|
1039 "")
|
|
1040 (if color
|
|
1041 (concat " COLOR=" color)
|
|
1042 "")
|
|
1043 ">")
|
|
1044 'hm--html-insert-end-tag-with-newline
|
|
1045 "</FONT>"))
|
|
1046
|
|
1047
|
116
|
1048 (defun hm--html-add-font-to-region (size color)
|
100
|
1049 "Adds the HTML tags for Font to the region."
|
|
1050 (interactive (list (hm--html-read-font-size)
|
|
1051 (hm--html-read-font-color)))
|
|
1052 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1053 (concat "<FONT"
|
|
1054 (if size
|
|
1055 (concat " SIZE=" size)
|
|
1056 "")
|
|
1057 (if color
|
|
1058 (concat " COLOR=" color)
|
|
1059 "")
|
|
1060 ">")
|
|
1061 'hm--html-insert-end-tag-with-newline
|
|
1062 "</FONT>"))
|
0
|
1063
|
|
1064
|
|
1065 ;;; Lists
|
|
1066
|
|
1067
|
2
|
1068 (defun hm--html-add-center ()
|
|
1069 "Adds the HTML tags for center at the current point."
|
|
1070 (interactive)
|
|
1071 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1072 "<CENTER>"
|
|
1073 'hm--html-insert-end-tag-with-newline
|
|
1074 "</CENTER>"))
|
|
1075
|
|
1076 (defun hm--html-add-center-to-region ()
|
|
1077 "Adds the HTML tags for center to the region."
|
|
1078 (interactive)
|
|
1079 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1080 "<CENTER>"
|
|
1081 'hm--html-insert-end-tag-with-newline
|
|
1082 "</CENTER>"))
|
0
|
1083
|
100
|
1084
|
|
1085 (defvar hm--html-mapname-history nil
|
|
1086 "The history variable for the function `hm--html-read-mapname'.")
|
|
1087
|
|
1088 (defun hm--html-read-mapname ()
|
|
1089 "Reads the name of an image map."
|
|
1090 (let ((name (read-string "The name of the image map: "
|
|
1091 (or (car hm--html-mapname-history)
|
|
1092 "map")
|
|
1093 'hm--html-mapname-history)))
|
|
1094 name))
|
|
1095
|
|
1096 (defun hm--html-add-image-map ()
|
|
1097 "Adds an image and a map element."
|
|
1098 (interactive)
|
|
1099 (let* ((href (hm--html-read-url "Image URL: "))
|
|
1100 (alt (hm--html-read-altenate href))
|
|
1101 (alignment (hm--html-read-alignment
|
|
1102 "Alignment of the image: "))
|
|
1103 (mapname (hm--html-read-mapname)))
|
|
1104 (hm--html-add-image href alt alignment mapname)
|
|
1105 (newline)
|
|
1106 (hm--html-add-map mapname)
|
|
1107 (call-interactively 'hm--html-add-area)))
|
|
1108
|
|
1109 (defun hm--html-add-map (name)
|
|
1110 "Adds the HTML tags for map at the current point."
|
|
1111 (interactive (list (hm--html-read-mapname)))
|
|
1112 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1113 (concat "<MAP NAME=\"" name "\">")
|
|
1114 'hm--html-insert-end-tag
|
|
1115 "</MAP>")
|
|
1116 (end-of-line 0))
|
|
1117
|
|
1118 (defun hm--html-add-map-to-region (name)
|
|
1119 "Adds the HTML tags for map to the region."
|
|
1120 (interactive (list (hm--html-read-mapname)))
|
|
1121 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1122 (concat "<MAP NAME=\"" name "\">")
|
|
1123 'hm--html-insert-end-tag-with-newline
|
|
1124 "</MAP>"))
|
|
1125
|
|
1126
|
0
|
1127 (defun hm--html-add-numberlist ()
|
|
1128 "Adds the HTML tags for a numbered list at the point in the current buffer."
|
|
1129 (interactive)
|
|
1130 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1131 "<OL>"
|
|
1132 'hm--html-insert-end-tag-with-newline
|
|
1133 "</OL>"
|
|
1134 'hm--html-insert-start-tag
|
98
|
1135 "<LI> "
|
|
1136 'hm--html-insert-end-tag
|
|
1137 " </LI>"))
|
0
|
1138
|
|
1139 (defun hm--html-add-numberlist-to-region ()
|
|
1140 "Adds the HTML tags for a numbered list to the region."
|
|
1141 (interactive)
|
|
1142 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1143 "<OL>"
|
|
1144 'hm--html-insert-end-tag-with-newline
|
98
|
1145 "</OL>"))
|
0
|
1146
|
|
1147
|
|
1148 (defun hm--html-add-directory-list ()
|
|
1149 "Adds the HTML tags for a directory list at the point in the current buffer."
|
|
1150 (interactive)
|
|
1151 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1152 "<DIR>"
|
|
1153 'hm--html-insert-end-tag-with-newline
|
|
1154 "</DIR>"
|
|
1155 'hm--html-insert-start-tag
|
98
|
1156 "<LI> "
|
|
1157 'hm--html-insert-end-tag
|
|
1158 " </LI>"))
|
0
|
1159
|
|
1160 (defun hm--html-add-directorylist-to-region ()
|
|
1161 "Adds the HTML tags for a directory list to the region."
|
|
1162 (interactive)
|
|
1163 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1164 "<DIR>"
|
|
1165 'hm--html-insert-end-tag-with-newline
|
98
|
1166 "</DIR>"))
|
0
|
1167
|
|
1168
|
2
|
1169 (defun hm--html-add-list ()
|
|
1170 "Adds the HTML tags for a (unnumbered) list to the region."
|
|
1171 (interactive)
|
|
1172 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1173 "<UL>"
|
|
1174 'hm--html-insert-end-tag-with-newline
|
|
1175 "</UL>"
|
|
1176 'hm--html-insert-start-tag
|
98
|
1177 "<LI> "
|
|
1178 'hm--html-insert-end-tag
|
|
1179 " </LI>"))
|
2
|
1180
|
|
1181
|
0
|
1182 (defun hm--html-add-list-to-region ()
|
|
1183 "Adds the HTML tags for a (unnumbered) list to the region."
|
|
1184 (interactive)
|
|
1185 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1186 "<UL>"
|
|
1187 'hm--html-insert-end-tag-with-newline
|
98
|
1188 "</UL>"))
|
2
|
1189
|
|
1190
|
|
1191 (defun hm--html-add-menu ()
|
|
1192 "Adds the HTML tags for a menu."
|
|
1193 (interactive)
|
|
1194 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1195 "<MENU>"
|
|
1196 'hm--html-insert-end-tag-with-newline
|
|
1197 "</MENU>"
|
|
1198 'hm--html-insert-start-tag
|
|
1199 "<LI> "
|
|
1200 'hm--html-insert-end-tag
|
|
1201 " </LI>"))
|
|
1202
|
|
1203
|
0
|
1204 (defun hm--html-add-menu-to-region ()
|
|
1205 "Adds the HTML tags for a menu to the region."
|
|
1206 (interactive)
|
|
1207 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1208 "<MENU>"
|
|
1209 'hm--html-insert-end-tag-with-newline
|
2
|
1210 "</MENU>"))
|
|
1211
|
|
1212
|
|
1213 (defun hm--html-add-description-title-and-entry ()
|
|
1214 "Adds a definition title and entry.
|
|
1215 Assumes we're at the end of a previous entry."
|
|
1216 (interactive)
|
|
1217 (hm--html-add-description-title)
|
98
|
1218 (let ((position (point))
|
|
1219 (case-fold-search t))
|
|
1220 (search-forward "</dt>")
|
|
1221 (hm--html-add-description-entry)
|
2
|
1222 (goto-char position)))
|
|
1223
|
|
1224
|
|
1225 (defun hm--html-add-description-list ()
|
|
1226 "Adds the HTML tags for a description list.
|
|
1227 It also inserts a tag for the description title."
|
|
1228 (interactive)
|
|
1229 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1230 "<DL>"
|
|
1231 'hm--html-insert-end-tag-with-newline
|
|
1232 "</DL>"
|
|
1233 'hm--html-insert-start-tag
|
|
1234 "<DT> "
|
|
1235 'hm--html-insert-end-tag
|
|
1236 " </DT>"))
|
|
1237
|
0
|
1238
|
|
1239 (defun hm--html-add-description-list-to-region ()
|
|
1240 "Adds the HTML tags for a description list to a region.
|
|
1241 It also inserts a tag for the description title."
|
|
1242 (interactive)
|
|
1243 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1244 "<DL>"
|
|
1245 'hm--html-insert-end-tag-with-newline
|
2
|
1246 "</DL>"))
|
0
|
1247
|
|
1248
|
|
1249 (defun hm--html-add-description-title ()
|
2
|
1250 "Adds the HTML tags for a description title at current point in the buffer."
|
|
1251 (interactive)
|
|
1252 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline
|
|
1253 "<DT> "
|
|
1254 'hm--html-insert-end-tag
|
|
1255 " </DT>"))
|
|
1256
|
|
1257
|
|
1258 (defun hm--html-add-description-title-to-region ()
|
|
1259 "Adds the HTML tags for a description title to the region in the buffer."
|
|
1260 (interactive)
|
|
1261 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
1262 "<DT> "
|
|
1263 'hm--html-insert-end-tag
|
|
1264 " </DT>"))
|
|
1265
|
|
1266
|
|
1267 (defun hm--html-add-description-entry ()
|
|
1268 "Adds the HTML tags for a description entry at current point in the buffer."
|
0
|
1269 (interactive)
|
|
1270 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline
|
2
|
1271 "<DD> "
|
|
1272 'hm--html-insert-end-tag
|
|
1273 " </DD>"))
|
|
1274
|
|
1275
|
|
1276 (defun hm--html-add-description-entry-to-region ()
|
|
1277 "Adds the HTML tags for a description entry to the region in the buffer."
|
0
|
1278 (interactive)
|
2
|
1279 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
1280 "<DD> "
|
|
1281 'hm--html-insert-end-tag
|
|
1282 " </DD>"))
|
|
1283
|
|
1284
|
|
1285 (defun hm--html-add-address ()
|
|
1286 "Adds the HTML tags for an address."
|
|
1287 (interactive)
|
|
1288 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
1289 "<ADDRESS>"
|
|
1290 'hm--html-insert-end-tag
|
|
1291 "</ADDRESS>"))
|
0
|
1292
|
|
1293 (defun hm--html-add-address-to-region ()
|
|
1294 "Adds the HTML tags for an address to the region"
|
|
1295 (interactive)
|
|
1296 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
2
|
1297 "<ADDRESS>"
|
0
|
1298 'hm--html-insert-end-tag
|
2
|
1299 "</ADDRESS>"))
|
0
|
1300
|
|
1301
|
|
1302 (defvar hm--html-signature-reference-name "Signature"
|
|
1303 "The signature reference name.")
|
|
1304
|
|
1305
|
|
1306 (defun hm--html-make-signature-link-string (signature-file-name)
|
|
1307 "Returns a string which is a link to a signature file."
|
|
1308 (concat
|
100
|
1309 "<A NAME=\""
|
0
|
1310 hm--html-signature-reference-name
|
100
|
1311 "\"\nHREF=\""
|
0
|
1312 signature-file-name
|
|
1313 "\">"))
|
100
|
1314
|
0
|
1315
|
|
1316 (defun hm--html-delete-old-signature ()
|
|
1317 "Searches for the old signature and deletes it, if the user want it"
|
|
1318 (save-excursion
|
|
1319 (goto-char (point-min))
|
98
|
1320 (let ((case-fold-search t))
|
100
|
1321 (if (re-search-forward (concat "<address>[ \t\n]*"
|
|
1322 "<a[ \t\n]+name=[ \t\n]*\"?"
|
|
1323 hm--html-signature-reference-name
|
|
1324 "\"?[ \t\n]+href=[ \t\n]*\"")
|
|
1325 nil
|
|
1326 t)
|
98
|
1327 (let ((signature-start (match-beginning 0))
|
|
1328 (signature-end (progn
|
100
|
1329 (re-search-forward "</address>[ \t]*[\n]?"
|
|
1330 nil
|
|
1331 t)
|
98
|
1332 (point))))
|
100
|
1333 (when (yes-or-no-p "Delete the old signature (yes or no) ?")
|
|
1334 (delete-region signature-start signature-end)
|
|
1335 (hm--html-indent-line)))))))
|
0
|
1336
|
|
1337
|
|
1338 (defun hm--html-set-point-for-signature ()
|
|
1339 "Searches and sets the point for inserting the signature.
|
|
1340 It searches from the end to the beginning of the file. At first it
|
|
1341 tries to use the point before the </body> tag then the point before
|
|
1342 the </html> tag and the the end of the file."
|
|
1343 (goto-char (point-max))
|
98
|
1344 (let ((case-fold-search t))
|
|
1345 (cond ((search-backward "</body>" nil t)
|
|
1346 (end-of-line 0)
|
|
1347 (if (> (current-column) 0)
|
100
|
1348 (newline 1)))
|
98
|
1349 ((search-backward "</html>" nil t)
|
|
1350 (end-of-line 0)
|
|
1351 (if (> (current-column) 0)
|
|
1352 (newline 2)))
|
|
1353 ((> (current-column) 0)
|
|
1354 (newline 2))
|
|
1355 (t))))
|
0
|
1356
|
|
1357
|
|
1358 (defun hm--html-add-signature ()
|
|
1359 "Adds the owner's signature at the end of the buffer."
|
|
1360 (interactive)
|
|
1361 (if hm--html-signature-file
|
|
1362 (progn
|
|
1363 (if (not hm--html-username)
|
|
1364 (setq hm--html-username (user-full-name)))
|
|
1365 (save-excursion
|
|
1366 (hm--html-delete-old-signature)
|
|
1367 (hm--html-set-point-for-signature)
|
100
|
1368 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1369 "<ADDRESS>"
|
0
|
1370 'hm--html-insert-end-tag
|
100
|
1371 "</A>\n</ADDRESS>"
|
0
|
1372 'hm--html-insert-start-tag
|
|
1373 (hm--html-make-signature-link-string
|
|
1374 hm--html-signature-file)
|
|
1375 )
|
|
1376 (insert hm--html-username)))
|
|
1377 (error "ERROR: Define your hm--html-signature-file first !")))
|
|
1378
|
|
1379
|
|
1380 (defun hm--html-add-header (size &optional header)
|
|
1381 "Adds the HTML tags for a header at the point in the current buffer."
|
|
1382 (interactive "nSize (1 .. 6; 1 biggest): ")
|
|
1383 (if (or (< size 1) (> size 6))
|
|
1384 (message "The size must be a number from 1 to 6 !")
|
|
1385 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
1386 (format "<H%d>" size)
|
|
1387 'hm--html-insert-start-tag-with-newline
|
|
1388 (format "</H%d>" size))
|
|
1389 (if header
|
|
1390 (insert header))))
|
|
1391
|
|
1392
|
|
1393 (defun hm--html-add-header-to-region (size)
|
|
1394 "Adds the HTML tags for a header to the region.
|
|
1395 The parameter 'size' specifies the size of the header."
|
|
1396 (interactive "nSize (1 .. 6; 1 biggest): ")
|
|
1397 (if (or (< size 1) (> size 6))
|
|
1398 (message "The size must be a number from 1 to 6 !")
|
|
1399 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
1400 (format "<H%d>" size)
|
|
1401 'hm--html-insert-end-tag
|
|
1402 (format "</H%d>" size))))
|
|
1403
|
|
1404
|
|
1405 (defun hm--html-set-point-for-title ()
|
|
1406 "Searches and sets the point for inserting the HTML element title.
|
|
1407 The functions start at the beginning of the file and searches first
|
|
1408 for the HTML tag <ISINDEX>. If such a tag exists, the point is set to the
|
|
1409 position after the tag. If not, the function next searches for the
|
|
1410 tag <HEAD> and sets the point after the tag, if it exists, or searches for
|
|
1411 the tag <HTML>. If this tag exists, the point is set to the position after
|
|
1412 this tag or the beginning of the file otherwise."
|
|
1413 (goto-char (point-min))
|
98
|
1414 (let ((case-fold-search t))
|
100
|
1415 (cond ((search-forward-regexp "<isindex[^>]*>" nil t) (newline))
|
|
1416 ((search-forward-regexp "<head[^>]*>" nil t) (newline))
|
|
1417 ((search-forward-regexp "<html[^>]*>" nil t) (newline))
|
98
|
1418 (t))))
|
0
|
1419
|
|
1420
|
|
1421 (defun hm--html-add-title (title)
|
|
1422 "Adds the HTML tags for a title at the beginning of the buffer."
|
|
1423 (interactive "sTitle: ")
|
|
1424 (save-excursion
|
|
1425 (goto-char (point-min))
|
98
|
1426 (let ((case-fold-search t))
|
|
1427 (if (search-forward "<title>" nil t)
|
|
1428 (let ((point-after-start-tag (point)))
|
|
1429 (if (not (search-forward "</title>" nil t))
|
153
|
1430 nil
|
98
|
1431 (goto-char (- (point) 8))
|
|
1432 (delete-backward-char (- (point) point-after-start-tag))
|
|
1433 (let ((start (point)))
|
153
|
1434 (if hm--html-automatic-create-title-date
|
|
1435 (insert title " (" (hm--date) ")")
|
|
1436 (insert title))
|
98
|
1437 (goto-char start))))
|
|
1438 ;; Noch kein <TITLE> im Buffer vorhanden
|
|
1439 (hm--html-set-point-for-title)
|
|
1440 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
1441 "<TITLE>"
|
|
1442 'hm--html-insert-end-tag
|
|
1443 "</TITLE>"
|
153
|
1444 'insert
|
|
1445 (if hm--html-automatic-create-title-date
|
|
1446 (concat title " (" (hm--date) ")")
|
|
1447 title))
|
98
|
1448 (forward-char 8)
|
|
1449 (newline 1)
|
|
1450 ))))
|
0
|
1451
|
|
1452
|
|
1453 (defun hm--html-add-title-to-region ()
|
|
1454 "Adds the HTML tags for a title to the region."
|
|
1455 (interactive)
|
98
|
1456 (let ((title (buffer-substring (region-beginning) (region-end)))
|
|
1457 (case-fold-search t))
|
0
|
1458 (save-excursion
|
|
1459 (goto-char (point-min))
|
|
1460 (if (search-forward "<title>" nil t)
|
|
1461 (let ((point-after-start-tag (point)))
|
|
1462 (if (not (search-forward "</title>" nil t))
|
|
1463 nil
|
|
1464 (goto-char (- (point) 8))
|
153
|
1465 (delete-backward-char (- (point) point-after-start-tag))
|
|
1466 (if hm--html-automatic-create-title-date
|
|
1467 (insert title " (" (hm--date) ")")
|
|
1468 (insert title))))
|
0
|
1469 ;; Noch kein <TITLE> im Buffer vorhanden
|
|
1470 (hm--html-set-point-for-title)
|
|
1471 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
1472 "<TITLE>"
|
|
1473 'hm--html-insert-end-tag
|
|
1474 "</TITLE>"
|
153
|
1475 'insert
|
|
1476 (if hm--html-automatic-create-title-date
|
|
1477 (concat title " (" (hm--date) ")")
|
|
1478 title))
|
0
|
1479 (forward-char 8)
|
|
1480 ;(newline 1)
|
|
1481 ))))
|
|
1482
|
|
1483
|
|
1484 (defun hm--html-add-html ()
|
|
1485 "Adds the HTML tags <HTML> and </HTML> in the buffer.
|
100
|
1486 The tag <HTML> will be inserted at the beginning (after the
|
|
1487 <!DOCTYPE ...>, if it is already there.) and </HTML> at the
|
0
|
1488 end of the file."
|
|
1489 (interactive)
|
98
|
1490 (let ((new-cursor-position nil)
|
|
1491 (case-fold-search t))
|
0
|
1492 (save-excursion
|
|
1493 (goto-char (point-min))
|
|
1494 (if (search-forward "<html>" nil t)
|
|
1495 (error "There is an old tag <HTML> in the current buffer !")
|
100
|
1496 (re-search-forward "<!DOCTYPE[^>]*>[ \t\n]*" nil t)
|
0
|
1497 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline "<HTML>")
|
|
1498 ; (newline 1)
|
|
1499 )
|
|
1500 (setq new-cursor-position (point))
|
|
1501 (goto-char (point-max))
|
|
1502 (if (search-backward "</html>" nil t)
|
|
1503 (error "There is an old tag </HTML> in the current buffer !")
|
|
1504 (newline 1)
|
|
1505 (hm--html-add-tags 'hm--html-insert-end-tag "</HTML>")))
|
|
1506 (goto-char new-cursor-position)))
|
|
1507
|
|
1508
|
|
1509 (defun hm--html-add-head ()
|
|
1510 "Adds the HTML tags <HEAD> and </HEAD> in the buffer.
|
100
|
1511 The tags will be inserted after <HTML> or at the beginning
|
|
1512 of the file after <DOCTYPE...> (if it is already there).
|
0
|
1513 The function also looks for the tags <BODY> and </TITLE>."
|
|
1514 (interactive)
|
98
|
1515 (let ((case-fold-search t))
|
0
|
1516 (goto-char (point-min))
|
100
|
1517 (re-search-forward "<!DOCTYPE[^>]*>[ \t\n]*" nil t)
|
0
|
1518 (if (search-forward "<html>" nil t)
|
|
1519 (if (search-forward "<head>" nil t)
|
|
1520 (error "There is an old tag <HEAD> in the current buffer !")
|
|
1521 (if (search-forward "</head>" nil t)
|
|
1522 (error "There is an old tag </HEAD> in the current buffer !")
|
|
1523 (newline 1))))
|
|
1524 (let ((start-tag-position (point)))
|
|
1525 (if (search-forward "<body>" nil t)
|
|
1526 (progn
|
|
1527 (forward-line 0)
|
|
1528 (forward-char -1)
|
|
1529 (if (= (point) (point-min))
|
|
1530 (progn
|
|
1531 (newline)
|
|
1532 (forward-line -1)))
|
|
1533 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline
|
|
1534 "</HEAD>")
|
|
1535 (goto-char start-tag-position)
|
|
1536 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1537 "<HEAD>")
|
|
1538 )
|
|
1539 (if (search-forward "</title>" nil t)
|
|
1540 (progn
|
|
1541 (newline 1)
|
|
1542 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline
|
|
1543 "</HEAD>")
|
|
1544 (goto-char start-tag-position)
|
|
1545 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1546 "<HEAD>"))
|
|
1547 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1548 "<HEAD>"
|
|
1549 'hm--html-insert-end-tag-with-newline
|
98
|
1550 "</HEAD>"))))))
|
0
|
1551
|
|
1552
|
|
1553 (defun hm--html-add-head-to-region ()
|
|
1554 "Adds the HTML tags <HEAD> and </HEAD> to the region."
|
|
1555 (interactive)
|
|
1556 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1557 "<HEAD>"
|
|
1558 'hm--html-insert-end-tag-with-newline
|
|
1559 "</HEAD>"))
|
|
1560
|
|
1561
|
|
1562 (defun hm--html-add-body ()
|
|
1563 "Adds the HTML tags <BODY> and </BODY> in the buffer.
|
|
1564 The tags will be inserted before </HTML> or at the end of the file."
|
|
1565 (interactive)
|
98
|
1566 (let ((case-fold-search t))
|
0
|
1567 (goto-char (point-max))
|
|
1568 (if (search-backward "</html>" nil t)
|
|
1569 (progn
|
|
1570 (if (search-backward "</body>" nil t)
|
|
1571 (error "There is an old tag </BODY> in the current buffer !")
|
|
1572 (if (search-backward "<body>" nil t)
|
|
1573 (error "There is an old tag <BODY> in the current buffer !")))
|
|
1574 (forward-char -1)))
|
100
|
1575 (let ((end-tag-position (set-marker (make-marker) (point))))
|
0
|
1576 (if (search-backward "</head>" nil t)
|
|
1577 (progn
|
|
1578 (forward-char 7)
|
|
1579 (newline 1)
|
|
1580 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
1581 "<BODY>")
|
|
1582 (let ((cursor-position (point)))
|
100
|
1583 (goto-char end-tag-position)
|
0
|
1584 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline
|
|
1585 "</BODY>")
|
|
1586 (goto-char cursor-position)
|
|
1587 ))
|
|
1588 (if (not (= (current-column) 0))
|
|
1589 (newline))
|
|
1590 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline "<BODY>"
|
98
|
1591 'hm--html-insert-end-tag-with-newline "</BODY>")))))
|
0
|
1592
|
|
1593
|
|
1594 (defun hm--html-add-body-to-region ()
|
|
1595 "Adds the HTML tags <BODY> and </BODY> to the region."
|
|
1596 (interactive)
|
|
1597 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
1598 "<BODY>"
|
|
1599 'hm--html-insert-end-tag-with-newline
|
|
1600 "</BODY>"))
|
|
1601
|
|
1602
|
|
1603 (defun hm--html-add-title-and-header (title)
|
|
1604 "Adds the HTML tags for a title and a header in the current buffer."
|
|
1605 (interactive "sTitle and Header String: ")
|
98
|
1606 (let ((case-fold-search t))
|
|
1607 (hm--html-add-title title)
|
|
1608 (save-excursion
|
|
1609 (goto-char (point-min))
|
|
1610 (search-forward "</title>" nil t)
|
|
1611 (if (search-forward "</head>" nil t)
|
|
1612 (progn
|
|
1613 (search-forward "<body>" nil t)
|
|
1614 (newline 1))
|
|
1615 (if (search-forward "<body>" nil t)
|
|
1616 (newline 1)
|
|
1617 (if (string= (what-line) "Line 1")
|
|
1618 (progn
|
|
1619 (end-of-line)
|
|
1620 (newline 1)))))
|
|
1621 (hm--html-add-header 1 title))))
|
0
|
1622
|
|
1623
|
|
1624 (defun hm--html-add-title-and-header-to-region ()
|
|
1625 "Adds the HTML tags for a title and a header to the region."
|
|
1626 (interactive)
|
|
1627 (let ((title (buffer-substring (region-beginning) (region-end))))
|
|
1628 (hm--html-add-header-to-region 1)
|
|
1629 (hm--html-add-title title)))
|
|
1630
|
|
1631
|
|
1632 (defun hm--html-add-full-html-frame (title)
|
|
1633 "Adds a full HTML frame to the current buffer.
|
|
1634 The frame consists of the elements html, head, body, title,
|
|
1635 header and the signature. The parameter TITLE specifies the
|
|
1636 title and the header of the document."
|
|
1637 (interactive "sTitle and Header String: ")
|
98
|
1638 (let ((case-fold-search t))
|
100
|
1639 (hm--html-add-doctype)
|
98
|
1640 (hm--html-add-html)
|
|
1641 (hm--html-add-head)
|
|
1642 (hm--html-add-body)
|
|
1643 (hm--html-add-title-and-header title)
|
153
|
1644 (when hm--html-signature-file
|
|
1645 (hm--html-add-signature))
|
98
|
1646 (goto-char (point-min))
|
|
1647 (search-forward "</h1>" nil t)
|
|
1648 (forward-line 1)
|
153
|
1649 (when hm--html-automatic-created-comment
|
|
1650 (hm--html-insert-created-comment))
|
|
1651 (when hm--html-automatic-create-modified-line
|
|
1652 (hm--html-insert-modified-line))))
|
0
|
1653
|
|
1654
|
|
1655 (defun hm--html-add-full-html-frame-with-region ()
|
|
1656 "Adds a full HTML frame to the current buffer with the use of a region.
|
|
1657 The frame consists of the elements html, head, body, title,
|
|
1658 header and the signature. The function uses the region as
|
|
1659 the string for the title and the header of the document."
|
|
1660 (interactive)
|
|
1661 (hm--html-add-title-and-header-to-region)
|
100
|
1662 (hm--html-add-doctype)
|
0
|
1663 (hm--html-add-html)
|
|
1664 (hm--html-add-head)
|
|
1665 (hm--html-add-body)
|
|
1666 (hm--html-add-signature)
|
153
|
1667 (when hm--html-automatic-created-comment
|
|
1668 (hm--html-insert-created-comment))
|
|
1669 (when hm--html-automatic-create-modified-line
|
|
1670 (hm--html-insert-modified-line)))
|
0
|
1671
|
|
1672
|
2
|
1673 (defun hm--html-add-link-target-to-region (name)
|
|
1674 "Adds the HTML tags for a link target to the region."
|
|
1675 (interactive "sName: ")
|
|
1676 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
1677 (concat "<A NAME=\"" name "\">")
|
|
1678 'hm--html-insert-end-tag
|
|
1679 "</A>"))
|
|
1680
|
0
|
1681 (defun hm--html-add-link-target (name)
|
|
1682 "Adds the HTML tags for a link target at point in the current buffer."
|
|
1683 (interactive "sName: ")
|
|
1684 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
1685 (concat "<A NAME=\"" name "\">")
|
|
1686 'hm--html-insert-end-tag
|
|
1687 "</A>"))
|
|
1688
|
|
1689
|
|
1690 ;;; Functions which add links
|
|
1691
|
|
1692 (defun hm--html-mark-example (parameter-list)
|
|
1693 "Marks the example of the parameterlist in the current buffer.
|
|
1694 It returns the example extent."
|
98
|
1695 (let ((case-fold-search t))
|
|
1696 (if (hm--html-get-example-from-parameter-list parameter-list)
|
|
1697 (progn
|
|
1698 (search-forward (hm--html-get-example-from-parameter-list
|
|
1699 parameter-list))
|
|
1700 (let ((extent (make-extent (match-beginning 0)
|
|
1701 (match-end 0))))
|
|
1702 (set-extent-face extent 'hm--html-help-face)
|
|
1703 extent)))))
|
0
|
1704
|
|
1705
|
|
1706 (defun hm--html-unmark-example (extent)
|
|
1707 "Unmarks the example for the current question."
|
|
1708 (if extent
|
|
1709 (delete-extent extent)))
|
|
1710
|
|
1711
|
|
1712 (defun hm--html-write-alist-in-buffer (alist)
|
|
1713 "The function writes the contents of the ALIST in the currentbuffer."
|
|
1714 (cond ((car alist)
|
|
1715 (insert (int-to-string (car (car alist))) ":\t" (cdr (car alist)))
|
|
1716 (newline)
|
|
1717 (hm--html-write-alist-in-buffer (cdr alist)))))
|
|
1718
|
|
1719
|
|
1720 (defun hm--html-select-directory (alist default)
|
|
1721 "The function selects one of the directories of the ALIST,
|
|
1722 or the DEFAULT or the 'default-directory' by number. See also the
|
|
1723 documentation of the function hm--html-read-filename."
|
|
1724 (if (or (string= default "") (not default))
|
|
1725 (setq default default-directory))
|
|
1726 (if alist
|
|
1727 (save-window-excursion
|
|
1728 (let ((buffername (generate-new-buffer "*html-directories*")))
|
|
1729 (set-buffer buffername)
|
|
1730 (insert "Select one of the following directories by number !")
|
|
1731 (newline)
|
|
1732 (insert "===================================================")
|
|
1733 (newline)
|
|
1734 (insert "0:\t" default)
|
|
1735 (newline)
|
|
1736 (hm--html-write-alist-in-buffer alist)
|
|
1737 (goto-char (point-min))
|
|
1738 (pop-to-buffer buffername))
|
|
1739 (let ((dirnumber (read-number
|
|
1740 "Select directory prefix by number: "
|
|
1741 t)))
|
|
1742 (kill-buffer "*html-directories*")
|
|
1743 (expand-file-name (or (cdr (assoc dirnumber alist)) default))))
|
|
1744 (expand-file-name default))
|
|
1745 )
|
|
1746
|
|
1747
|
|
1748 (defun hm--html-delete-wrong-path-prefix-1 (filename prefix-list)
|
|
1749 "The function deletes wrong path prefixes."
|
|
1750 (cond (prefix-list (if (string-match (car prefix-list) filename)
|
|
1751 (substring filename (match-end 0))
|
|
1752 (hm--html-delete-wrong-path-prefix-1 filename
|
|
1753 (cdr prefix-list)
|
|
1754 )))
|
|
1755 (t filename)))
|
|
1756
|
|
1757
|
|
1758 (defun hm--html-delete-wrong-path-prefix (filename)
|
|
1759 "The function deletes wrong path prefixes.
|
|
1760 The path prefixes are specified by the variable
|
|
1761 `hm--html-delete-wrong-path-prefix'."
|
|
1762 (if (not hm--html-delete-wrong-path-prefix)
|
|
1763 filename
|
|
1764 (if (listp hm--html-delete-wrong-path-prefix)
|
|
1765 (hm--html-delete-wrong-path-prefix-1 filename
|
|
1766 hm--html-delete-wrong-path-prefix)
|
|
1767 (hm--html-delete-wrong-path-prefix-1 filename
|
|
1768 (list
|
|
1769 hm--html-delete-wrong-path-prefix))
|
|
1770 )))
|
|
1771
|
|
1772
|
|
1773 (defun hm--html-read-filename (parameter-list)
|
|
1774 "The function reads a filename with its directory path,
|
|
1775 if PARAMETER-LIST is not nil. If the PARAMETER-LIST is nil, only an empty
|
|
1776 string will be returned.
|
|
1777 The PARAMETER-LIST consists of the following elements:
|
|
1778 PROMPT, ALIST, DEFAULT, REQUIRE-MATCH, EXAMPLE.
|
|
1779 If the ALIST is nil and DEFAULT is nil, then the function only reads
|
|
1780 a filename (without path). These precede the following.
|
|
1781 If the ALIST isn't nil, the function lists the contents of the ALIST
|
|
1782 in a buffer and reads a number from the minbuffer, which selects one
|
|
1783 of the directories (lines) of the buffer. Therefore the ALIST must look
|
|
1784 like the following alist:
|
|
1785 ((1 . \"/appl/gnu/\") (2 . \"/\"))
|
|
1786 If only ALIST is nil, or if you type a number which is not in the ALIST,
|
|
1787 the DEFAULT directory is selected. If the DEFAULT is nil or \"\" the
|
|
1788 'default-directory' is selected.
|
|
1789 After that the function reads the name of the file from the minibuffer.
|
|
1790 Therefore the PROMPT is printed in the minibuffer and the selected directory
|
|
1791 is taken as the start of the path of the file.
|
|
1792 If REQUIRE-MATCH is t, the filename with path must match an existing file."
|
|
1793 (if parameter-list
|
|
1794 (let ((marked-object (hm--html-mark-example parameter-list))
|
|
1795 (prompt (hm--html-get-prompt-from-parameter-list parameter-list))
|
|
1796 (alist (hm--html-get-alist-from-parameter-list parameter-list))
|
|
1797 (default (hm--html-get-default-from-parameter-list parameter-list))
|
|
1798 (require-match (hm--html-get-require-match-from-parameter-list
|
|
1799 parameter-list))
|
|
1800 (filename nil))
|
|
1801 (if (or alist default)
|
|
1802 (let ((directory (hm--html-select-directory alist default)))
|
|
1803 (setq filename (read-file-name prompt
|
|
1804 directory
|
|
1805 directory
|
|
1806 require-match
|
|
1807 nil)))
|
|
1808 (setq filename (read-file-name prompt
|
|
1809 ""
|
|
1810 ""
|
|
1811 require-match
|
|
1812 nil)))
|
|
1813 (hm--html-unmark-example marked-object)
|
|
1814 (hm--html-delete-wrong-path-prefix filename))
|
|
1815 ""))
|
|
1816
|
|
1817
|
|
1818 (defun hm--html-completing-read (parameter-list)
|
|
1819 "Reads a string with completing-read, if alist is non nil.
|
|
1820 The PARAMETER-LIST consists of the following elements:
|
|
1821 PROMPT, ALIST, DEFAULT, REQUIRE-MATCH, EXAMPLE.
|
|
1822 If ALIST is nil, it returns the DEFAULT, or if the DEFAULT is
|
|
1823 also nil it returns an empty string."
|
|
1824 (let ((marked-object (hm--html-mark-example parameter-list))
|
|
1825 (string
|
|
1826 (if (hm--html-get-alist-from-parameter-list parameter-list)
|
|
1827 (completing-read
|
|
1828 (hm--html-get-prompt-from-parameter-list parameter-list)
|
|
1829 (hm--html-get-alist-from-parameter-list parameter-list)
|
|
1830 nil
|
|
1831 (hm--html-get-require-match-from-parameter-list
|
|
1832 parameter-list)
|
|
1833 (hm--html-get-default-from-parameter-list
|
|
1834 parameter-list))
|
|
1835 (if (hm--html-get-default-from-parameter-list parameter-list)
|
|
1836 (hm--html-get-default-from-parameter-list parameter-list)
|
|
1837 ""))))
|
|
1838 (hm--html-unmark-example marked-object)
|
|
1839 string))
|
|
1840
|
|
1841
|
|
1842 (defvar hm--html-faces-exist nil)
|
|
1843
|
|
1844
|
|
1845 (defun hm--html-generate-help-buffer-faces ()
|
|
1846 "Generates faces for the add-link-help-buffer."
|
|
1847 (if (not (facep 'hm--html-help-face))
|
|
1848 (progn
|
|
1849 (setq hm--html-faces-exist t)
|
|
1850 (make-face 'hm--html-help-face)
|
2
|
1851 (if hm--html-help-foreground
|
|
1852 (set-face-foreground 'hm--html-help-face hm--html-help-foreground))
|
|
1853 (if hm--html-help-background
|
|
1854 (set-face-background 'hm--html-help-face hm--html-help-background))
|
|
1855 (set-face-font 'hm--html-help-face hm--html-help-font)
|
0
|
1856 )))
|
|
1857
|
|
1858
|
|
1859 (defun hm--html-get-prompt-from-parameter-list (parameter-list)
|
|
1860 "Returns the prompt from the PARAMETER-LIST."
|
|
1861 (car parameter-list))
|
|
1862
|
|
1863
|
|
1864 (defun hm--html-get-alist-from-parameter-list (parameter-list)
|
|
1865 "Returns the alist from the PARAMETER-LIST."
|
|
1866 (car (cdr parameter-list)))
|
|
1867
|
|
1868
|
|
1869 (defun hm--html-get-default-from-parameter-list (parameter-list)
|
|
1870 "Returns the default from the PARAMETER-LIST."
|
|
1871 (car (cdr (cdr parameter-list))))
|
|
1872
|
|
1873
|
|
1874 (defun hm--html-get-require-match-from-parameter-list (parameter-list)
|
|
1875 "Returns the require-match from the PARAMETER-LIST."
|
|
1876 (car (cdr (cdr (cdr parameter-list)))))
|
|
1877
|
|
1878
|
|
1879 (defun hm--html-get-example-from-parameter-list (parameter-list)
|
|
1880 "Returns the example from the PARAMETER-LIST."
|
|
1881 (car (cdr (cdr (cdr (cdr parameter-list))))))
|
|
1882
|
|
1883
|
|
1884 (defun hm--html-get-anchor-seperator-from-parameter-list (parameter-list)
|
|
1885 "Returns the anchor-seperator from the PARAMETER-LIST."
|
|
1886 (car (cdr (cdr (cdr (cdr (cdr parameter-list)))))))
|
|
1887
|
|
1888
|
|
1889 (defun hm--html-generate-add-link-help-buffer (scheme-parameter-list
|
|
1890 host-name:port-parameter-list
|
|
1891 servername:port-parameter-list
|
|
1892 path+file-parameter-list
|
|
1893 anchor-parameter-list)
|
|
1894 "Generates and displays a help buffer with an example for adding a link."
|
|
1895 (let ((buffername (generate-new-buffer "*Link-Example*")))
|
|
1896 (pop-to-buffer buffername)
|
|
1897 (shrink-window (- (window-height) 5))
|
|
1898 (insert "Example:")
|
|
1899 (newline 2)
|
|
1900 (if (hm--html-get-example-from-parameter-list scheme-parameter-list)
|
|
1901 (progn
|
|
1902 (insert (hm--html-get-example-from-parameter-list
|
|
1903 scheme-parameter-list))
|
|
1904 (if (hm--html-get-example-from-parameter-list
|
|
1905 scheme-parameter-list)
|
|
1906 (progn
|
|
1907 (insert ":")
|
|
1908 (if (hm--html-get-example-from-parameter-list
|
|
1909 host-name:port-parameter-list)
|
|
1910 (insert "//"))))))
|
|
1911 (if (hm--html-get-example-from-parameter-list
|
|
1912 host-name:port-parameter-list)
|
|
1913 (progn
|
|
1914 (insert (hm--html-get-example-from-parameter-list
|
|
1915 host-name:port-parameter-list))
|
|
1916 (if (and (hm--html-get-example-from-parameter-list
|
|
1917 servername:port-parameter-list)
|
|
1918 (not (string= "/"
|
|
1919 (substring
|
|
1920 (hm--html-get-example-from-parameter-list
|
|
1921 servername:port-parameter-list)
|
|
1922 0
|
|
1923 1))))
|
|
1924 (insert "/"))))
|
|
1925 (if (hm--html-get-example-from-parameter-list
|
|
1926 servername:port-parameter-list)
|
|
1927 (progn
|
|
1928 (insert (hm--html-get-example-from-parameter-list
|
|
1929 servername:port-parameter-list))
|
|
1930 (if (hm--html-get-example-from-parameter-list
|
|
1931 path+file-parameter-list)
|
|
1932 (insert "/"))))
|
|
1933 (if (hm--html-get-example-from-parameter-list path+file-parameter-list)
|
|
1934 (progn
|
|
1935 (insert (hm--html-get-example-from-parameter-list
|
|
1936 path+file-parameter-list))))
|
|
1937 (if (hm--html-get-example-from-parameter-list anchor-parameter-list)
|
|
1938 (progn
|
|
1939 (insert (hm--html-get-anchor-seperator-from-parameter-list
|
|
1940 anchor-parameter-list))
|
|
1941 (insert (hm--html-get-example-from-parameter-list
|
|
1942 anchor-parameter-list))))
|
|
1943 (goto-char (point-min))
|
|
1944 buffername
|
|
1945 ))
|
|
1946
|
|
1947
|
|
1948 (defun hm--html-add-link (function-add-tags
|
|
1949 scheme-parameter-list
|
|
1950 host-name:port-parameter-list
|
|
1951 servername:port-parameter-list
|
|
1952 path+file-parameter-list
|
|
1953 anchor-parameter-list)
|
|
1954 "The function adds a link in the current buffer.
|
|
1955 The parameter FUNCTION-ADD-TAGS determines the function which adds the tag
|
|
1956 in the buffer (for example: 'hm--html-add-tags or
|
|
1957 'hm--html-add-tags-to-region).
|
|
1958 The parameters SCHEME-PARAMETER-LIST, HOST-NAME:PORT-PARAMETER-LIST,
|
|
1959 SERVERNAME:PORT-PARAMETER-LIST, PATH+FILE-PARAMETER-LIST and
|
|
1960 ANCHOR-PARAMETER-LIST are lists with a prompt string, an alist, a default
|
|
1961 value and an example string. The ANCHOR-PARAMETER-LIST has as an additional
|
|
1962 element an anchor seperator string. All these elements are used to read and
|
|
1963 construct the link."
|
116
|
1964 ; (let ((point nil))
|
|
1965 (save-window-excursion
|
|
1966 (let ((html-buffer (current-buffer))
|
|
1967 (html-help-buffer (hm--html-generate-add-link-help-buffer
|
|
1968 scheme-parameter-list
|
|
1969 host-name:port-parameter-list
|
|
1970 servername:port-parameter-list
|
|
1971 path+file-parameter-list
|
|
1972 anchor-parameter-list))
|
|
1973 (scheme (hm--html-completing-read scheme-parameter-list))
|
|
1974 (hostname:port (hm--html-completing-read
|
|
1975 host-name:port-parameter-list))
|
|
1976 (servername:port (hm--html-completing-read
|
|
1977 servername:port-parameter-list))
|
|
1978 (path+file (hm--html-read-filename path+file-parameter-list))
|
|
1979 (anchor (hm--html-completing-read anchor-parameter-list))
|
|
1980 ; (hrefname (setq html-link-counter (1+ html-link-counter)))
|
|
1981 (anchor-seperator
|
|
1982 (hm--html-get-anchor-seperator-from-parameter-list
|
|
1983 anchor-parameter-list)))
|
|
1984 (if (not (string= scheme ""))
|
|
1985 (if (string= hostname:port "")
|
|
1986 (setq scheme (concat scheme ":"))
|
|
1987 (setq scheme (concat scheme "://"))))
|
|
1988 (if (and (not (string= hostname:port ""))
|
|
1989 (not (string= servername:port ""))
|
|
1990 (not (string= (substring servername:port 0 1) "/")))
|
|
1991 (setq servername:port (concat "/" servername:port)))
|
|
1992 (if (and (not (string= path+file ""))
|
|
1993 (not (string= "/" (substring path+file 0 1))))
|
|
1994 (setq path+file (concat "/" path+file)))
|
|
1995 (if (not (string= anchor ""))
|
|
1996 (setq anchor (concat anchor-seperator anchor)))
|
|
1997 (kill-buffer html-help-buffer)
|
|
1998 (pop-to-buffer html-buffer)
|
|
1999 (eval (list function-add-tags
|
|
2000 ''hm--html-insert-start-tag
|
|
2001 (concat "<A"
|
0
|
2002 ; "<A Name="
|
|
2003 ; hrefname
|
116
|
2004 " HREF=\""
|
|
2005 scheme
|
|
2006 hostname:port
|
|
2007 servername:port
|
|
2008 path+file
|
|
2009 anchor
|
|
2010 "\">")
|
|
2011 ''hm--html-insert-end-tag
|
|
2012 "</A>")))
|
|
2013 ; (setq point (point))))
|
|
2014 ; (goto-char (point)))
|
|
2015 ))
|
0
|
2016
|
|
2017 (defun hm--html-add-info-link-1 (function-add-tags)
|
|
2018 "Internal function. Adds the HTML tags for a link on a GNU Info file."
|
|
2019 (hm--html-add-link function-add-tags
|
|
2020 (list ; scheme
|
|
2021 ""
|
|
2022 nil
|
|
2023 "http"
|
|
2024 t
|
|
2025 "http")
|
|
2026 (list ; hostname:port
|
|
2027 "Gateway and Port: "
|
|
2028 hm--html-info-hostname:port-alist
|
|
2029 hm--html-info-hostname:port-default
|
|
2030 nil
|
|
2031 "www.tnt.uni-hannover.de:8005")
|
|
2032 (list ; servername:port
|
|
2033 ""
|
|
2034 nil
|
|
2035 ""
|
|
2036 t
|
|
2037 nil)
|
|
2038 (list ; path/file
|
|
2039 "Path/File: "
|
|
2040 hm--html-info-path-alist
|
|
2041 nil
|
|
2042 nil
|
|
2043 "/appl/lemacs/Global/info/dir")
|
|
2044 (list ; anchor
|
|
2045 "Node: "
|
|
2046 '((""))
|
|
2047 nil
|
|
2048 nil
|
|
2049 "emacs"
|
|
2050 ",")))
|
|
2051
|
|
2052
|
|
2053 (defun hm--html-add-info-link ()
|
|
2054 "Adds the HTML tags for a link on a GNU Info file."
|
|
2055 (interactive)
|
|
2056 (hm--html-add-info-link-1 'hm--html-add-tags))
|
|
2057
|
|
2058
|
|
2059 (defun hm--html-add-info-link-to-region ()
|
|
2060 "Adds the HTML tags for a link on a GNU Info file to the region."
|
|
2061 (interactive)
|
|
2062 (hm--html-add-info-link-1 'hm--html-add-tags-to-region))
|
|
2063
|
|
2064
|
|
2065 (defun hm--html-add-wais-link-1 (function-add-tags)
|
|
2066 "Internal function. Adds the HTML tags for a link to a WAIS server."
|
|
2067 (hm--html-add-link function-add-tags
|
|
2068 (list ; scheme
|
|
2069 ""
|
|
2070 nil
|
|
2071 "http"
|
|
2072 t
|
|
2073 "http")
|
|
2074 (list ; hostname:port
|
|
2075 "Gateway and Port: "
|
|
2076 hm--html-wais-hostname:port-alist
|
|
2077 hm--html-wais-hostname:port-default
|
|
2078 nil
|
|
2079 "www.tnt.uni-hannover.de:8001")
|
|
2080 (list ; servername:port
|
|
2081 "Wais Servername and Port: "
|
|
2082 hm--html-wais-servername:port-alist
|
|
2083 hm--html-wais-servername:port-default
|
|
2084 nil
|
|
2085 "quake.think.com:210")
|
|
2086 (list ; path/file
|
|
2087 "Database: "
|
|
2088 hm--html-wais-path-alist
|
|
2089 nil
|
|
2090 nil
|
|
2091 "database")
|
|
2092 (list ; anchor
|
|
2093 "Searchstring: "
|
|
2094 '((""))
|
|
2095 nil
|
|
2096 nil
|
|
2097 "searchstring"
|
|
2098 "?")))
|
|
2099
|
|
2100
|
|
2101 (defun hm--html-add-wais-link ()
|
|
2102 "Adds the HTML tags for a link to a WAIS server."
|
|
2103 (interactive)
|
|
2104 (hm--html-add-wais-link-1 'hm--html-add-tags))
|
|
2105
|
|
2106
|
|
2107 (defun hm--html-add-wais-link-to-region ()
|
|
2108 "Adds the HTML tags for a link to a WAIS server to the region."
|
|
2109 (interactive)
|
|
2110 (hm--html-add-wais-link-1 'hm--html-add-tags-to-region))
|
|
2111
|
|
2112
|
|
2113 (defun hm--html-add-direct-wais-link-1 (function-add-tags)
|
|
2114 "Internal function. Adds the HTML tags for a direct link to a WAIS server.
|
|
2115 This function uses the new direct WAIS support instead of a WAIS gateway."
|
|
2116 (hm--html-add-link function-add-tags
|
|
2117 (list ; scheme
|
|
2118 ""
|
|
2119 nil
|
|
2120 "wais"
|
|
2121 t
|
|
2122 "wais")
|
|
2123 (list ; hostname:port
|
|
2124 "Wais Servername and Port: "
|
|
2125 hm--html-wais-servername:port-alist
|
|
2126 hm--html-wais-servername:port-default
|
|
2127 nil
|
|
2128 "quake.think.com:210")
|
|
2129 (list ; servername:port
|
|
2130 ""
|
|
2131 nil
|
|
2132 ""
|
|
2133 t
|
|
2134 nil)
|
|
2135 (list ; path/file
|
|
2136 "Database: "
|
|
2137 hm--html-wais-path-alist
|
|
2138 nil
|
|
2139 nil
|
|
2140 "database")
|
|
2141 (list ; anchor
|
|
2142 "Searchstring: "
|
|
2143 '((""))
|
|
2144 nil
|
|
2145 nil
|
|
2146 "searchstring"
|
|
2147 "?")))
|
|
2148
|
|
2149
|
|
2150 (defun hm--html-add-direct-wais-link ()
|
|
2151 "Adds the HTML tags for a direct link to a WAIS server.
|
|
2152 This function uses the new direct WAIS support instead of a WAIS gateway."
|
|
2153 (interactive)
|
|
2154 (hm--html-add-direct-wais-link-1 'hm--html-add-tags))
|
|
2155
|
|
2156
|
|
2157 (defun hm--html-add-direct-wais-link-to-region ()
|
|
2158 "Adds the HTML tags for a direct link to a WAIS server to the region.
|
|
2159 This function uses the new direct WAIS support instead of a WAIS gateway."
|
|
2160 (interactive)
|
|
2161 (hm--html-add-direct-wais-link-1 'hm--html-add-tags-to-region))
|
|
2162
|
|
2163
|
|
2164 (defun hm--html-add-html-link-1 (function-add-tags)
|
|
2165 "Internal function. Adds the HTML tags for a link to an HTML page."
|
|
2166 (hm--html-add-link function-add-tags
|
|
2167 (list ; scheme
|
|
2168 ""
|
|
2169 nil
|
|
2170 "http"
|
|
2171 t
|
|
2172 "http")
|
|
2173 (list ; hostname:port
|
|
2174 "Servername and Port: "
|
|
2175 hm--html-html-hostname:port-alist
|
|
2176 hm--html-html-hostname:port-default
|
|
2177 nil
|
|
2178 "www.tnt.uni-hannover.de:80")
|
|
2179 (list ; servername:port
|
|
2180 ""
|
|
2181 nil
|
|
2182 ""
|
|
2183 t
|
|
2184 nil)
|
|
2185 (list ; path/file
|
|
2186 "Path/File: "
|
|
2187 hm--html-html-path-alist
|
|
2188 nil
|
|
2189 nil
|
|
2190 "/data/info/www/tnt/overview.html")
|
|
2191 (list ; anchor
|
|
2192 "Anchor: "
|
|
2193 '((""))
|
|
2194 nil
|
|
2195 nil
|
|
2196 "1"
|
|
2197 "#")))
|
|
2198
|
|
2199
|
|
2200 (defun hm--html-add-html-link ()
|
|
2201 "Adds the HTML tags for a link to an HTML file."
|
|
2202 (interactive)
|
|
2203 (hm--html-add-html-link-1 'hm--html-add-tags))
|
|
2204
|
|
2205
|
|
2206 (defun hm--html-add-html-link-to-region ()
|
|
2207 "Adds the HTML tags for a link to an HTML file to the region."
|
|
2208 (interactive)
|
|
2209 (hm--html-add-html-link-1 'hm--html-add-tags-to-region))
|
|
2210
|
|
2211
|
|
2212 (defun hm--html-add-file-link-1 (function-add-tags)
|
|
2213 "Internal function. Adds the HTML tags for a filegateway link."
|
|
2214 (hm--html-add-link function-add-tags
|
|
2215 (list ; scheme
|
|
2216 ""
|
|
2217 nil
|
|
2218 "file"
|
|
2219 t
|
|
2220 "file")
|
|
2221 (list ; hostname:port
|
|
2222 ""
|
|
2223 nil
|
|
2224 ""
|
|
2225 t
|
|
2226 nil)
|
|
2227 (list ; servername:port
|
|
2228 ""
|
|
2229 nil
|
|
2230 ""
|
|
2231 t
|
|
2232 nil)
|
|
2233 (list ; path/file
|
|
2234 "Path/File: "
|
|
2235 hm--html-file-path-alist
|
|
2236 nil
|
|
2237 nil
|
|
2238 "/data/info/www/tnt/overview.html")
|
|
2239 (list ; anchor
|
|
2240 "Anchor: "
|
|
2241 '((""))
|
|
2242 nil
|
|
2243 nil
|
|
2244 "1"
|
|
2245 "#")))
|
|
2246
|
|
2247
|
|
2248 (defun hm--html-add-file-link ()
|
|
2249 "Adds the HTML tags for a for a filegateway link."
|
|
2250 (interactive)
|
|
2251 (hm--html-add-file-link-1 'hm--html-add-tags))
|
|
2252
|
|
2253
|
|
2254 (defun hm--html-add-file-link-to-region ()
|
|
2255 "Adds the HTML tags for a for a filegateway link to the region."
|
|
2256 (interactive)
|
|
2257 (hm--html-add-file-link-1 'hm--html-add-tags-to-region))
|
|
2258
|
|
2259
|
|
2260 (defun hm--html-add-ftp-link-1 (function-add-tags)
|
|
2261 "Internal function. Adds the HTML tags for a link to an FTP server."
|
|
2262 (hm--html-add-link function-add-tags
|
|
2263 (list ; scheme
|
|
2264 ""
|
|
2265 nil
|
|
2266 "ftp"
|
|
2267 t
|
|
2268 "ftp")
|
|
2269 (list ; hostname:port
|
|
2270 "FTP Servername: "
|
|
2271 hm--html-ftp-hostname:port-alist
|
|
2272 hm--html-ftp-hostname:port-default
|
|
2273 nil
|
|
2274 "ftp.rrzn.uni-hannover.de")
|
|
2275 (list ; servername:port
|
|
2276 ""
|
|
2277 nil
|
|
2278 ""
|
|
2279 t
|
|
2280 nil)
|
|
2281 (list ; path/file
|
|
2282 "Path/File: "
|
|
2283 hm--html-ftp-path-alist
|
|
2284 nil
|
|
2285 nil
|
|
2286 "/pub/gnu/gcc-2.4.5.tar.gz")
|
|
2287 (list ; anchor
|
|
2288 ""
|
|
2289 nil
|
|
2290 ""
|
|
2291 t
|
|
2292 nil
|
|
2293 nil)))
|
|
2294
|
|
2295
|
|
2296 (defun hm--html-add-ftp-link ()
|
|
2297 "Adds the HTML tags for a link to an FTP server."
|
|
2298 (interactive)
|
|
2299 (hm--html-add-ftp-link-1 'hm--html-add-tags))
|
|
2300
|
|
2301
|
|
2302 (defun hm--html-add-ftp-link-to-region ()
|
|
2303 "Adds the HTML tags for a link to an FTP server to the region."
|
|
2304 (interactive)
|
|
2305 (hm--html-add-ftp-link-1 'hm--html-add-tags-to-region))
|
|
2306
|
|
2307
|
|
2308 (defun hm--html-add-gopher-link-1 (function-add-tags)
|
|
2309 "Internal function. Adds the HTML tags for a link to a gopher server."
|
|
2310 (hm--html-add-link function-add-tags
|
|
2311 (list ; scheme
|
|
2312 ""
|
|
2313 nil
|
|
2314 "gopher"
|
|
2315 t
|
|
2316 "gopher")
|
|
2317 (list ; hostname:port
|
|
2318 "Gopher Servername: "
|
|
2319 hm--html-gopher-hostname:port-alist
|
|
2320 hm--html-gopher-hostname:port-default
|
|
2321 nil
|
|
2322 "newsserver.rrzn.uni-hannover.de:70")
|
|
2323 (list ; servername:port
|
|
2324 "Documenttype: "
|
|
2325 hm--html-gopher-doctype-alist
|
|
2326 hm--html-gopher-doctype-default
|
|
2327 nil
|
|
2328 "/1")
|
|
2329 nil ; path/file
|
|
2330 (list ; anchor
|
|
2331 "Entrypoint: "
|
|
2332 hm--html-gopher-anchor-alist
|
|
2333 nil
|
|
2334 nil
|
|
2335 "Subject%20Tree"
|
|
2336 "/")))
|
|
2337
|
|
2338
|
|
2339 (defun hm--html-add-gopher-link ()
|
|
2340 "Adds the HTML tags for a link to a gopher server."
|
|
2341 (interactive)
|
|
2342 (hm--html-add-gopher-link-1 'hm--html-add-tags))
|
|
2343
|
|
2344
|
|
2345 (defun hm--html-add-gopher-link-to-region ()
|
|
2346 "Adds the HTML tags for a link to a gopher server to the region."
|
|
2347 (interactive)
|
|
2348 (hm--html-add-gopher-link-1 'hm--html-add-tags-to-region))
|
|
2349
|
|
2350
|
|
2351 (defun hm--html-make-proggate-alist (proggate-allowed-file)
|
|
2352 "Makes a proggate-alist from the PROGGATE-ALLOWED-FILE."
|
|
2353 (if (and (stringp proggate-allowed-file)
|
|
2354 (file-exists-p proggate-allowed-file))
|
|
2355 (save-window-excursion
|
|
2356 (let ((alist nil)
|
98
|
2357 (buffername (find-file-noselect proggate-allowed-file))
|
|
2358 (case-fold-search t))
|
0
|
2359 (set-buffer buffername)
|
|
2360 (toggle-read-only)
|
|
2361 (goto-char (point-min))
|
|
2362 (while (search-forward-regexp "[^ \t\n]+" nil t)
|
|
2363 (setq alist (append (list (list (buffer-substring
|
|
2364 (match-beginning 0)
|
|
2365 (match-end 0))))
|
|
2366 alist)))
|
|
2367 (kill-buffer buffername)
|
|
2368 alist))
|
|
2369 (error "ERROR: Can't find the 'hm--html-progate-allowed-file !")))
|
|
2370
|
|
2371
|
|
2372 (defun hm--html-add-proggate-link-1 (function-add-tags)
|
|
2373 "Internal function. Adds the HTML tags for a link to a program.
|
|
2374 The program is called via the program gateway.
|
|
2375 Email to muenkel@tnt.uni-hannover.de for information over
|
|
2376 this gateway."
|
|
2377 (let ((progname-alist (hm--html-make-proggate-alist
|
|
2378 hm--html-proggate-allowed-file)))
|
|
2379 (hm--html-add-link function-add-tags
|
|
2380 (list ; scheme
|
|
2381 ""
|
|
2382 nil
|
|
2383 "http"
|
|
2384 t
|
|
2385 "http")
|
|
2386 (list ; hostname:port
|
|
2387 "Servername and Port: "
|
|
2388 hm--html-proggate-hostname:port-alist
|
|
2389 hm--html-proggate-hostname:port-default
|
|
2390 nil
|
|
2391 "www.tnt.uni-hannover.de:8007")
|
|
2392 (list ; program
|
|
2393 "Programname: "
|
|
2394 progname-alist
|
|
2395 nil
|
|
2396 nil
|
|
2397 "/usr/ucb/man")
|
|
2398 nil ; path/file
|
|
2399 (list ; Program Parameter
|
|
2400 "Programparameter: "
|
|
2401 '((""))
|
|
2402 nil
|
|
2403 nil
|
|
2404 "8+lpd"
|
|
2405 "+"))))
|
|
2406
|
|
2407
|
|
2408 (defun hm--html-add-proggate-link ()
|
|
2409 "Adds the HTML tags for a link to a program.
|
|
2410 The program is called via the program gateway.
|
|
2411 Email to muenkel@tnt.uni-hannover.de for information over
|
|
2412 this gateway."
|
|
2413 (interactive)
|
|
2414 (hm--html-add-proggate-link-1 'hm--html-add-tags))
|
|
2415
|
|
2416
|
|
2417 (defun hm--html-add-proggate-link-to-region ()
|
|
2418 "Adds the HTML tags for a link to a program to the region.
|
|
2419 The program is called via the program gateway.
|
|
2420 Email to muenkel@tnt.uni-hannover.de for information over
|
|
2421 this gateway."
|
|
2422 (interactive)
|
|
2423 (hm--html-add-proggate-link-1 'hm--html-add-tags-to-region))
|
|
2424
|
|
2425
|
|
2426 (defun hm--html-add-local-proggate-link-1 (function-add-tags)
|
|
2427 "Internal function. Adds the HTML tags for a link to a program.
|
|
2428 The program is called via the local program gateway.
|
|
2429 Email to muenkel@tnt.uni-hannover.de for information over
|
|
2430 this gateway."
|
|
2431 (hm--html-add-link function-add-tags
|
|
2432 (list ; scheme
|
|
2433 ""
|
|
2434 nil
|
|
2435 ""
|
|
2436 t
|
|
2437 nil)
|
|
2438 (list ; hostname:port
|
|
2439 ""
|
|
2440 nil
|
|
2441 ""
|
|
2442 t
|
|
2443 nil)
|
|
2444 (list ; servername:port
|
|
2445 ""
|
|
2446 nil
|
|
2447 ""
|
|
2448 t
|
|
2449 nil)
|
|
2450 (list ; path/file
|
|
2451 "Path/file: "
|
|
2452 hm--html-local-proggate-path-alist
|
|
2453 nil
|
|
2454 nil
|
|
2455 "/data/info/programs/lemacs.evlm")
|
|
2456 (list ; anchor
|
|
2457 ""
|
|
2458 nil
|
|
2459 ""
|
|
2460 t
|
|
2461 nil)))
|
|
2462
|
|
2463
|
|
2464 (defun hm--html-add-local-proggate-link ()
|
|
2465 "Adds the HTML tags for a link to a program.
|
|
2466 The program is called via the local program gateway.
|
|
2467 Email to muenkel@tnt.uni-hannover.de for information over
|
|
2468 this gateway."
|
|
2469 (interactive)
|
|
2470 (hm--html-add-local-proggate-link-1 'hm--html-add-tags))
|
|
2471
|
|
2472
|
|
2473 (defun hm--html-add-local-proggate-link-to-region ()
|
|
2474 "Adds the HTML tags for a link to a program to the region.
|
|
2475 The program is called via the local program gateway.
|
|
2476 Email to muenkel@tnt.uni-hannover.de for information over
|
|
2477 this gateway."
|
|
2478 (interactive)
|
|
2479 (hm--html-add-local-proggate-link-1 'hm--html-add-tags-to-region))
|
|
2480
|
|
2481
|
|
2482 (defvar hm--html-newsgroup-alist nil
|
|
2483 "Alist with newsgroups for the newsgateway.")
|
|
2484
|
|
2485
|
|
2486 (defvar gnus-newsrc-assoc nil)
|
|
2487
|
|
2488
|
|
2489 (defun hm--html-make-newsgroup-alist ()
|
|
2490 "Makes a hm--html-make-newsgroup-alist from a .newsrc.el file.
|
|
2491 The function looks at the environment variable NNTPSERVER.
|
116
|
2492 If this variable exists, it tries to open the file with the Name
|
0
|
2493 ~/$NNTPSERVER.el. If this file exists, the alist of the file is
|
|
2494 returned as the newsgroup-alist. If the file doesn't exist, it
|
|
2495 tries to use the file ~/$NNTPSERVER to make the alist. The function
|
|
2496 returns '((\"\"))"
|
|
2497 (if hm--html-newsgroup-alist
|
|
2498 hm--html-newsgroup-alist
|
|
2499 (if gnus-newsrc-assoc
|
|
2500 (setq hm--html-newsgroup-alist gnus-newsrc-assoc)
|
|
2501 (if (not (getenv "NNTPSERVER"))
|
|
2502 '((""))
|
|
2503 (let ((newsrc-file (expand-file-name (concat "~/.newsrc-"
|
|
2504 (getenv "NNTPSERVER")))))
|
|
2505 (if (file-exists-p (concat newsrc-file ".el"))
|
|
2506 (progn
|
|
2507 (load-file (concat newsrc-file ".el"))
|
|
2508 (setq hm--html-newsgroup-alist gnus-newsrc-assoc))
|
|
2509 (if (not (file-exists-p newsrc-file))
|
|
2510 '((""))
|
|
2511 (save-window-excursion
|
|
2512 (let ((alist nil)
|
98
|
2513 (buffername (find-file-noselect newsrc-file))
|
|
2514 (case-fold-search t))
|
0
|
2515 (set-buffer buffername)
|
|
2516 (toggle-read-only)
|
|
2517 (goto-char (point-min))
|
|
2518 (while (search-forward-regexp "[^:!]+" nil t)
|
|
2519 (setq alist (append (list (list (buffer-substring
|
|
2520 (match-beginning 0)
|
|
2521 (match-end 0))))
|
|
2522 alist))
|
|
2523 (search-forward-regexp "\n"))
|
|
2524 (kill-buffer buffername)
|
|
2525 (setq hm--html-newsgroup-alist alist))))))))))
|
|
2526
|
|
2527
|
|
2528
|
|
2529 (defun hm--html-add-news-link-1 (function-add-tags)
|
|
2530 "Internal function. Adds the HTML tags for a link to a news group."
|
|
2531 (let ((newsgroup-alist (hm--html-make-newsgroup-alist)))
|
|
2532 (hm--html-add-link function-add-tags
|
|
2533 (list ; scheme
|
|
2534 ""
|
|
2535 nil
|
|
2536 "news"
|
|
2537 t
|
|
2538 "news")
|
|
2539 (list ; hostname:port
|
|
2540 ""
|
|
2541 nil
|
|
2542 ""
|
|
2543 t
|
|
2544 nil)
|
|
2545 (list ; servername:port
|
|
2546 "NEWS Group: "
|
|
2547 newsgroup-alist
|
|
2548 nil
|
|
2549 nil
|
|
2550 "comp.emacs.xemacs")
|
|
2551 nil ; path/file
|
|
2552 (list ; anchor
|
|
2553 ""
|
|
2554 nil
|
|
2555 ""
|
|
2556 t
|
|
2557 nil
|
|
2558 nil))))
|
|
2559
|
|
2560
|
|
2561 (defun hm--html-add-news-link ()
|
|
2562 "Adds the HTML tags for a link to a news group."
|
|
2563 (interactive)
|
|
2564 (hm--html-add-news-link-1 'hm--html-add-tags))
|
|
2565
|
|
2566
|
|
2567 (defun hm--html-add-news-link-to-region ()
|
|
2568 "Adds the HTML tags for a link to a news group to the region."
|
|
2569 (interactive)
|
|
2570 (hm--html-add-news-link-1 'hm--html-add-tags-to-region))
|
|
2571
|
|
2572
|
|
2573 (defun hm--html-add-mail-box-link-1 (function-add-tags)
|
|
2574 "Internal function. Adds the HTML tags for a link to a mail box."
|
|
2575 (hm--html-add-link function-add-tags
|
|
2576 (list ; scheme
|
|
2577 ""
|
|
2578 nil
|
|
2579 "http"
|
|
2580 t
|
|
2581 "http")
|
|
2582 (list ; hostname:port
|
|
2583 "Hostname and Port: "
|
|
2584 hm--html-mail-hostname:port-alist
|
|
2585 hm--html-mail-hostname:port-default
|
|
2586 nil
|
|
2587 "www.tnt.uni-hannover.de:8003")
|
|
2588 (list ; servername:port
|
|
2589 ""
|
|
2590 nil
|
|
2591 ""
|
|
2592 t
|
|
2593 nil)
|
|
2594 (list ; path/file
|
|
2595 "Path/File: "
|
|
2596 hm--html-mail-path-alist
|
|
2597 nil
|
|
2598 nil
|
|
2599 "/data/info/mail/mailbox")
|
|
2600 (list ; anchor
|
|
2601 ""
|
|
2602 nil
|
|
2603 ""
|
|
2604 t
|
|
2605 nil
|
|
2606 nil)))
|
|
2607
|
|
2608
|
|
2609 (defun hm--html-add-mail-box-link ()
|
|
2610 "Adds the HTML tags for a link to a mail box."
|
|
2611 (interactive)
|
116
|
2612 (hm--html-add-mail-box-link-1 'hm--html-add-tags))
|
0
|
2613
|
|
2614
|
|
2615 (defun hm--html-add-mail-box-link-to-region ()
|
|
2616 "Adds the HTML tags for a link to a mail box to the region."
|
|
2617 (interactive)
|
116
|
2618 (hm--html-add-mail-box-link-1 'hm--html-add-tags-to-region))
|
0
|
2619
|
|
2620
|
|
2621 (defun hm--html-add-mailto-link-1 (function-add-tags)
|
|
2622 "Internal function. Adds the HTML tags for a mailto link."
|
|
2623 (let ((mailto-alist (if (and (boundp 'user-mail-address)
|
|
2624 user-mail-address)
|
|
2625 (cons (list user-mail-address)
|
|
2626 hm--html-mailto-alist)
|
|
2627 hm--html-mailto-alist)))
|
|
2628 (hm--html-add-link function-add-tags
|
|
2629 (list ; scheme
|
|
2630 ""
|
|
2631 nil
|
|
2632 "mailto"
|
|
2633 t
|
|
2634 "mailto")
|
|
2635 (list ; hostname:port
|
|
2636 ""
|
|
2637 nil
|
|
2638 ""
|
|
2639 t
|
|
2640 nil)
|
|
2641 (list ; servername:port
|
2
|
2642 "Mailaddress: "
|
0
|
2643 mailto-alist
|
|
2644 nil
|
|
2645 nil
|
|
2646 "muenkel@tnt.uni-hannover.de")
|
|
2647 nil ; path/file
|
|
2648 (list ; anchor
|
|
2649 ""
|
|
2650 nil
|
|
2651 ""
|
|
2652 t
|
|
2653 nil
|
|
2654 nil))))
|
|
2655
|
|
2656 (defun hm--html-add-mailto-link ()
|
|
2657 "Adds the HTML tags for a mailto link."
|
|
2658 (interactive)
|
|
2659 (hm--html-add-mailto-link-1 'hm--html-add-tags))
|
|
2660
|
|
2661
|
|
2662 (defun hm--html-add-mailto-link-to-region ()
|
|
2663 "Adds the HTML tags for a mailto link to the region."
|
|
2664 (interactive)
|
|
2665 (hm--html-add-mailto-link-1 'hm--html-add-tags-to-region))
|
|
2666
|
2
|
2667 (defun hm--html-add-relative-link (relative-file-path)
|
|
2668 "Adds the HTML tags for a relative link at the current point."
|
98
|
2669 (interactive (list (file-relative-name
|
|
2670 (read-file-name "Relative Filename: "
|
|
2671 nil
|
|
2672 nil
|
|
2673 nil
|
|
2674 "")
|
|
2675 default-directory)
|
|
2676 ))
|
2
|
2677 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
2678 (concat "<A HREF=\""
|
|
2679 relative-file-path
|
|
2680 "\">")
|
|
2681 'hm--html-insert-end-tag
|
|
2682 "</A>"))
|
|
2683
|
|
2684 (defun hm--html-add-relative-link-to-region (relative-file-path)
|
|
2685 "Adds the HTML tags for a relative link to the region."
|
98
|
2686 (interactive (list (file-relative-name
|
|
2687 (read-file-name "Relative Filename: "
|
|
2688 nil
|
|
2689 nil
|
|
2690 nil
|
|
2691 ""))))
|
0
|
2692 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
2693 (concat "<A HREF=\""
|
2
|
2694 relative-file-path
|
|
2695 "\">")
|
|
2696 'hm--html-insert-end-tag
|
|
2697 "</A>"))
|
|
2698
|
|
2699 (defun hm--html-add-normal-link (link-object)
|
|
2700 "Adds the HTML tags for a normal general link.
|
|
2701 Single argument LINK-OBJECT is value of HREF in the new anchor.
|
|
2702 Mark is set after anchor."
|
|
2703 (interactive "sNode Link to: ")
|
|
2704 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
2705 (concat "<A HREF=\""
|
|
2706 link-object
|
|
2707 "\">")
|
|
2708 'hm--html-insert-end-tag
|
|
2709 "</A>"))
|
|
2710
|
|
2711 (defun hm--html-add-normal-link-to-region (link-object)
|
|
2712 "Adds the HTML tags for a normal general link to region.
|
|
2713 Single argument LINK-OBJECT is value of HREF in the new anchor.
|
|
2714 Mark is set after anchor."
|
|
2715 (interactive "sNode Link to: ")
|
|
2716 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
2717 (concat "<A HREF=\""
|
|
2718 link-object
|
0
|
2719 "\">")
|
|
2720 'hm--html-insert-end-tag
|
|
2721 "</A>"))
|
|
2722
|
|
2723
|
|
2724 (defun hm--html-add-normal-node-link ()
|
|
2725 "Adds the HTML tags for a normal node link (<LINK...>) at the point."
|
|
2726 (interactive)
|
|
2727 (hm--html-insert-start-tag (concat "<LINK HREF=\""
|
|
2728 (read-string "Node Link to: ")
|
|
2729 "\">")
|
|
2730 ))
|
|
2731
|
|
2732 ;;; Functions to update the date and the changelog entries
|
|
2733
|
|
2734
|
|
2735 (defun hm--html-maybe-new-date-and-changed-comment ()
|
|
2736 "Hook function which updates the date in the title line, if
|
153
|
2737 'hm--html-automatic-update-title-date' is t and which inserts a
|
0
|
2738 \"changed comment\" line, if 'hm--html-automatic-changed-comment' is t."
|
153
|
2739 (when hm--html-automatic-update-title-date
|
|
2740 (hm--html-new-date))
|
|
2741 (when hm--html-automatic-changed-comment
|
|
2742 (hm--html-insert-changed-comment t))
|
|
2743 (when hm--html-automatic-update-modified-line
|
|
2744 (hm--html-insert-modified-line)))
|
0
|
2745
|
|
2746
|
|
2747 (defun hm--html-new-date ()
|
|
2748 "The function sets the date in the title line up."
|
|
2749 (interactive)
|
|
2750 (save-excursion
|
|
2751 (goto-char (point-min))
|
|
2752 (let ((case-fold-search t)
|
|
2753 (end-of-head (if (search-forward "</head>" nil t)
|
|
2754 (point)
|
|
2755 (if (search-forward "<body>" nil t)
|
|
2756 (point)
|
|
2757 (point-max)))))
|
|
2758 (goto-char (point-min))
|
|
2759 (if (re-search-forward
|
|
2760 (concat
|
|
2761 "\\((\\)"
|
102
|
2762 "\\([ \t]*[0-3]?[0-9]-[A-Z][a-z][a-z]-[0-9][0-9][0-9][0-9]"
|
|
2763 "[ \t]*\\)"
|
0
|
2764 "\\()[ \t\n]*</title>\\)")
|
|
2765 end-of-head
|
|
2766 t)
|
|
2767 (progn
|
|
2768 (delete-region (match-beginning 2) (match-end 2))
|
|
2769 (goto-char (match-beginning 2))
|
|
2770 (insert (hm--date)))))))
|
|
2771
|
|
2772
|
|
2773 (defun hm--html-insert-created-comment (&optional noerror)
|
|
2774 "The function inserts a \"created comment\".
|
|
2775 The comment looks like <!-- Created by: Heiko Münkel, 10-Dec-1993 -->.
|
|
2776 The comment will be inserted after the title line.
|
|
2777 An error message is printed, if there is no title line and if
|
|
2778 noerror is nil."
|
|
2779 (interactive)
|
|
2780 (save-excursion
|
|
2781 (goto-char (point-min))
|
|
2782 (let ((case-fold-search t)
|
|
2783 (end-of-head (if (search-forward "</head>" nil t)
|
|
2784 (point)
|
|
2785 (if (search-forward "<body>" nil t)
|
|
2786 (point)
|
153
|
2787 (point-max))))
|
|
2788 (comment-infix (or hm--html-comment-infix
|
|
2789 (concat (or hm--html-username (user-full-name))
|
|
2790 ", "))))
|
0
|
2791 (goto-char (point-min))
|
|
2792 (if (not (search-forward "</title>" end-of-head t))
|
|
2793 (if (not noerror)
|
|
2794 (error "ERROR: Please insert a title in the document !"))
|
116
|
2795 ; (let ((end-of-title-position (point)))
|
153
|
2796 (if (search-forward (concat "<!-- "
|
|
2797 hm--html-created-comment-prefix)
|
|
2798 end-of-head
|
|
2799 t)
|
116
|
2800 (if (yes-or-no-p
|
153
|
2801 (concat "Replace the old comment \"<!-- "
|
|
2802 hm--html-created-comment-prefix
|
|
2803 "\" "))
|
116
|
2804 (progn
|
|
2805 (goto-char (match-beginning 0))
|
|
2806 (kill-line)
|
|
2807 (hm--html-add-comment)
|
153
|
2808 (insert hm--html-created-comment-prefix
|
|
2809 comment-infix
|
|
2810 ; (or hm--html-username (user-full-name))
|
|
2811 ; ", "
|
116
|
2812 (hm--date))))
|
|
2813 (newline)
|
|
2814 (hm--html-add-comment)
|
153
|
2815 (insert hm--html-created-comment-prefix
|
|
2816 comment-infix
|
|
2817 ; (insert "Created by: "
|
|
2818 ; (or hm--html-username (user-full-name))
|
|
2819 ; ", "
|
116
|
2820 (hm--date)
|
|
2821 ))))))
|
0
|
2822
|
|
2823
|
153
|
2824 (defun hm--html-insert-changed-comment-1 (newline)
|
0
|
2825 "Internal function of 'hm--html-insert-changed-comment'.
|
153
|
2826 Inserts a newline if NEWLINE is t, before the comment is inserted."
|
0
|
2827 (if newline
|
|
2828 (progn
|
|
2829 (newline)))
|
|
2830 (hm--html-add-comment)
|
153
|
2831 (insert hm--html-changed-comment-prefix
|
|
2832 (or hm--html-comment-infix
|
|
2833 (concat (or hm--html-username (user-full-name)) ", "))
|
|
2834 (hm--date)))
|
0
|
2835
|
|
2836 (defun hm--html-insert-changed-comment (&optional noerror)
|
|
2837 "The function inserts a \"changed comment\".
|
153
|
2838 The comment looks by default like
|
|
2839 <!-- Changed by: Heiko Münkel, 10-Dec-1993 -->.
|
0
|
2840 The comment will be inserted after the last \"changed comment\" line, or,
|
|
2841 if there isn't such a line, after the \"created comment\" line, or,
|
|
2842 after the title line. If there is no title and NOERROR is nil, an error
|
|
2843 message is generated. The line is not inserted after the end of the head
|
|
2844 or the beginning of the body.
|
|
2845 If the last \"changed line\" is from the same author, it is only replaced
|
|
2846 by the new one.
|
|
2847
|
153
|
2848 Look at the variables `hm--html-changed-comment-prefix' and
|
|
2849 `hm--html-comment-infix', if you'd like to change the
|
|
2850 inserted comments. You should not use different values for this
|
|
2851 variables in the same HTML file.
|
|
2852
|
|
2853 Attention: Don't write anything else in such a line!"
|
0
|
2854 (interactive)
|
|
2855 (save-excursion
|
|
2856 (goto-char (point-min))
|
|
2857 (let ((case-fold-search t)
|
|
2858 (end-of-head (if (search-forward "</head>" nil t)
|
|
2859 (point)
|
|
2860 (if (search-forward "<body>" nil t)
|
|
2861 (point)
|
|
2862 (point-max))))
|
153
|
2863 (comment-infix (or hm--html-comment-infix
|
|
2864 hm--html-username
|
|
2865 (user-full-name))))
|
|
2866 ; (username (or hm--html-username (user-full-name))))
|
0
|
2867 (goto-char end-of-head)
|
153
|
2868 ; (if (search-backward "<!-- Changed by: " nil t)
|
|
2869 (if (search-backward (concat "<!-- "
|
|
2870 hm--html-changed-comment-prefix)
|
|
2871 nil
|
|
2872 t)
|
|
2873 ; (if (string-match username
|
|
2874 (if (string-match comment-infix
|
0
|
2875 (buffer-substring (point)
|
|
2876 (progn
|
|
2877 (end-of-line)
|
|
2878 (point))))
|
|
2879 ;; exchange the comment line
|
|
2880 (progn
|
|
2881 (beginning-of-line)
|
|
2882 (delete-region (point) (progn
|
|
2883 (end-of-line)
|
|
2884 (point)))
|
153
|
2885 (hm--html-insert-changed-comment-1 nil))
|
0
|
2886 ;; new comment line
|
|
2887 (end-of-line)
|
153
|
2888 (hm--html-insert-changed-comment-1 t))
|
|
2889 ; (if (search-backward "<!-- Created by: " nil t)
|
|
2890 (if (search-backward (concat "<!-- "
|
|
2891 hm--html-created-comment-prefix)
|
|
2892 nil
|
|
2893 t)
|
0
|
2894 (progn
|
|
2895 (end-of-line)
|
153
|
2896 (hm--html-insert-changed-comment-1 t))
|
0
|
2897 (if (search-backward "</title>" nil t)
|
|
2898 (progn
|
|
2899 (goto-char (match-end 0))
|
|
2900 (if (not (looking-at "\n"))
|
|
2901 (progn
|
|
2902 (newline)
|
|
2903 (forward-char -1)))
|
153
|
2904 (hm--html-insert-changed-comment-1 t))
|
0
|
2905 (if (not noerror)
|
|
2906 (error
|
|
2907 "ERROR: Insert at first a title in the document !"))))))))
|
|
2908
|
153
|
2909 (defun hm--html-insert-modified-line ()
|
|
2910 "Inserts a modified line.
|
|
2911 By default the line looks like:
|
|
2912 <EM>Modified: 23-May-1997</EM>
|
|
2913
|
|
2914 Look at the variables `hm--html-automatic-create-modified-line',
|
|
2915 `hm--html-automatic-update-modified-line', `hm--html-modified-prefix',
|
|
2916 `hm--html-modified-start-tag', `hm--html-modified-end-tag' and
|
|
2917 `hm--html-modified-insert-before' to change the behaviour of this
|
|
2918 feature."
|
|
2919 (interactive)
|
|
2920 (save-excursion
|
|
2921 (goto-char (point-max))
|
|
2922 (if (search-backward-regexp (concat hm--html-modified-start-tag
|
|
2923 "[ \t\n]*"
|
|
2924 hm--html-modified-prefix)
|
|
2925 nil
|
|
2926 t)
|
|
2927 (progn ; old modified line exists
|
|
2928 (goto-char (match-end 0))
|
|
2929 (if (search-forward-regexp (concat "\\([ \t\n]*\\)"
|
|
2930 "\\([^ \t\n<]+\\)"
|
|
2931 "\\([ \t\n]*"
|
|
2932 hm--html-modified-end-tag
|
|
2933 "\\)"))
|
|
2934 (progn
|
|
2935 (delete-region (match-beginning 2) (match-end 2))
|
|
2936 (goto-char (match-beginning 2))
|
|
2937 (insert (hm--date)))
|
|
2938 ; (replace-match (concat "\\1" (hm--date)))
|
|
2939 (error "Destroyed \"Modified line\" found!")))
|
|
2940 (search-backward hm--html-modified-insert-before nil t)
|
|
2941 (search-backward "</html>" nil t)
|
|
2942 (search-backward "</body>" nil t)
|
|
2943 (newline)
|
|
2944 (indent-according-to-mode)
|
|
2945 (forward-line -1)
|
|
2946 (unless (= (util-return-end-of-line) (point))
|
|
2947 (end-of-line)
|
|
2948 (newline))
|
|
2949 (newline)
|
|
2950 (indent-according-to-mode)
|
|
2951 (insert hm--html-modified-start-tag
|
|
2952 hm--html-modified-prefix
|
|
2953 (hm--date)
|
|
2954 hm--html-modified-end-tag))))
|
|
2955
|
0
|
2956
|
|
2957 ;;; Functions to insert templates
|
|
2958
|
|
2959 (defvar hm--html-template-file-history nil
|
98
|
2960 "Historyvariable for the template files in the `hm--html-mode'.")
|
0
|
2961
|
|
2962 (defun hm--html-insert-template (filename)
|
98
|
2963 "Inserts a templatefile.
|
|
2964 It uses `tmpl-insert-template-file' to insert
|
|
2965 the templates. The variables `tmpl-template-dir-list',
|
|
2966 `tmpl-automatic-expand' and `tmpl-history-variable-name' are
|
|
2967 overwritten by `hm--html-template-dir',
|
|
2968 `hm--html-automatic-expand-templates' and `hm--html-template-file-history'."
|
|
2969 (interactive (list nil))
|
|
2970 (let ((tmpl-template-dir-list (if (listp hm--html-template-dir)
|
|
2971 hm--html-template-dir
|
|
2972 (list hm--html-template-dir)))
|
|
2973 (tmpl-automatic-expand hm--html-automatic-expand-templates)
|
|
2974 (tmpl-history-variable-name 'hm--html-template-file-history))
|
|
2975 (if filename
|
|
2976 (tmpl-insert-template-file filename)
|
|
2977 (call-interactively 'tmpl-insert-template-file))
|
|
2978 ))
|
|
2979
|
|
2980 (defun hm--html-insert-template-from-fixed-dirs (filename)
|
|
2981 "Inserts a templatefile.
|
|
2982 It uses `tmpl-insert-template-file-from-fixed-dirs' to insert
|
|
2983 the templates. The variables `tmpl-template-dir-list',
|
|
2984 `tmpl-automatic-expand', `tmpl-filter-regexp' and
|
|
2985 `tmpl-history-variable-name' are overwritten by
|
|
2986 `hm--html-template-dir', `hm--html-automatic-expand-templates',
|
|
2987 `hm--html-template-filter-regexp' and `hm--html-template-file-history'."
|
|
2988 (interactive (list nil))
|
|
2989 (let ((tmpl-template-dir-list (if (listp hm--html-template-dir)
|
|
2990 hm--html-template-dir
|
|
2991 (list hm--html-template-dir)))
|
|
2992 (tmpl-automatic-expand hm--html-automatic-expand-templates)
|
|
2993 (tmpl-filter-regexp hm--html-template-filter-regexp)
|
|
2994 (tmpl-history-variable-name 'hm--html-template-file-history))
|
|
2995 (if filename
|
|
2996 (tmpl-insert-template-file-from-fixed-dirs filename)
|
|
2997 (call-interactively 'tmpl-insert-template-file-from-fixed-dirs))
|
|
2998 ))
|
|
2999
|
0
|
3000
|
|
3001 ;;; Functions for font lock mode
|
|
3002
|
2
|
3003 (if (adapt-emacs19p)
|
0
|
3004 (progn
|
|
3005 (make-face 'font-lock-comment-face)
|
|
3006 (make-face 'font-lock-doc-string-face)
|
|
3007 (make-face 'font-lock-string-face)
|
|
3008 (or (face-differs-from-default-p 'font-lock-doc-string-face)
|
|
3009 (copy-face 'font-lock-comment-face 'font-lock-doc-string-face))
|
|
3010 (or (face-differs-from-default-p 'font-lock-comment-face)
|
|
3011 (copy-face 'italic 'font-lock-comment-face))
|
|
3012 (or (face-differs-from-default-p 'font-lock-string-face)
|
|
3013 (progn
|
|
3014 (copy-face 'font-lock-doc-string-face 'font-lock-string-face)
|
|
3015 (set-face-underline-p 'font-lock-string-face t)))
|
|
3016 (setq font-lock-comment-face 'font-lock-comment-face)
|
|
3017 (setq font-lock-string-face 'font-lock-string-face)))
|
|
3018
|
|
3019
|
|
3020 ;;; Functions to insert forms
|
|
3021
|
|
3022 (defun hm--html-form-read-method ()
|
|
3023 "Reads the method for a form."
|
|
3024 (completing-read "Method of the form: "
|
|
3025 '(("POST") ("GET"))
|
|
3026 nil
|
|
3027 t
|
|
3028 "POST"))
|
|
3029
|
|
3030
|
|
3031 (defun hm--html-form-read-action (method)
|
|
3032 "Reads the URL for the action attribute of a form.
|
|
3033 It returns nil if no action attribute is wanted.
|
|
3034 METHOD is the method of the form."
|
|
3035 (if (y-or-n-p "Current document URL as action attribute ? ")
|
|
3036 nil
|
|
3037 (hm--html-read-url "Query server URL: "
|
|
3038 hm--html-url-alist
|
|
3039 (function
|
|
3040 (lambda (table-element-list)
|
|
3041 (hm--html-read-url-predicate table-element-list
|
|
3042 (car
|
|
3043 (read-from-string
|
|
3044 method)))))
|
|
3045 nil
|
|
3046 nil)))
|
|
3047
|
|
3048
|
|
3049 (defun hm--html-add-form (&optional method)
|
|
3050 "Adds the HTML tags for a form.
|
|
3051 The function asks only for a method, if METHOD is nil, otherwise
|
|
3052 the METHOD must have one of the values \"GET\" or \"POST\"."
|
|
3053 (interactive)
|
|
3054 (let* ((method (or method (hm--html-form-read-method)))
|
|
3055 (action (hm--html-form-read-action method)))
|
|
3056 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
3057 (concat "<FORM METHOD=\""
|
|
3058 method
|
|
3059 "\""
|
|
3060 (if action
|
|
3061 (concat " ACTION=\""
|
|
3062 action
|
|
3063 "\"")
|
|
3064 "")
|
|
3065 ">")
|
|
3066 'hm--html-insert-end-tag-with-newline
|
|
3067 "</FORM>")))
|
|
3068
|
|
3069
|
|
3070 (defun hm--html-add-form-to-region (&optional method)
|
|
3071 "Adds the HTML tags for a form to a region.
|
|
3072 The function asks only for a method, if METHOD is nil, otherwise
|
|
3073 the METHOD must have one of the values \"GET\" or \"POST\"."
|
|
3074 (interactive)
|
|
3075 (let* ((method (or method (hm--html-form-read-method)))
|
|
3076 (action (hm--html-form-read-action method)))
|
|
3077 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
3078 (concat "<FORM METHOD=\""
|
|
3079 method
|
|
3080 "\""
|
|
3081 (if action
|
|
3082 (concat " ACTION=\""
|
|
3083 action
|
|
3084 "\"")
|
|
3085 "")
|
|
3086 ">")
|
|
3087 'hm--html-insert-end-tag-with-newline
|
|
3088 "</FORM>")))
|
|
3089
|
|
3090
|
|
3091 (defun hm--html-form-read-name (&optional last-name)
|
|
3092 "Reads the name for an input tag."
|
|
3093 (read-string "Symbolic name: " last-name))
|
|
3094
|
|
3095
|
|
3096 (defun hm--html-form-read-value (prompt &optional initial-contents)
|
|
3097 "Reads the value for an input tag."
|
|
3098 (read-string prompt initial-contents))
|
|
3099
|
|
3100
|
|
3101 (defun hm--html-form-read-checked ()
|
|
3102 "Reads whether a button is checked by default or not."
|
|
3103 (y-or-n-p "Should the button be checked by default ? "))
|
|
3104
|
|
3105
|
|
3106 (defun hm--html-form-read-size ()
|
|
3107 "Reads the size of text entry fields of input tags."
|
|
3108 (if (y-or-n-p "Defaultsize of the Inputfield ? ")
|
|
3109 nil
|
|
3110 (format "%d,%d"
|
|
3111 (read-number "Width of the input field: " t)
|
|
3112 (read-number "Height of the input field: " t))))
|
|
3113
|
|
3114
|
|
3115 (defun hm--html-form-read-maxlength ()
|
|
3116 "Reads the maxlength of text entry fields of input tags."
|
|
3117 (let ((maxlength (read-number "Maximum number of chars (0 = unlimited): "
|
|
3118 t)))
|
|
3119 (if (<= maxlength 0)
|
|
3120 nil
|
|
3121 (int-to-string maxlength))))
|
|
3122
|
|
3123
|
|
3124 (defun hm--html-form-read-src (prompt &optional initial-contents)
|
|
3125 "Reads the src for an input tag."
|
|
3126 (read-string prompt initial-contents))
|
|
3127
|
|
3128
|
|
3129 (defun hm--html-form-add-input (type
|
|
3130 name
|
|
3131 value
|
|
3132 checked
|
|
3133 size
|
|
3134 maxlength
|
|
3135 &optional src)
|
|
3136 "Adds the HTML tags for an input tag to the buffer."
|
|
3137 (hm--html-insert-start-tag (concat "<INPUT TYPE=\""
|
|
3138 type
|
|
3139 "\""
|
|
3140 (if (and name (not (string= name "")))
|
|
3141 (concat " NAME=\"" name "\""))
|
|
3142 (if (and value (not (string= value "")))
|
|
3143 (concat " VALUE=\"" value "\""))
|
|
3144 (if checked " CHECKED")
|
|
3145 (if (and size (not (string= size "")))
|
|
3146 (concat " SIZE=" size))
|
|
3147 (if (and maxlength
|
|
3148 (not (string= maxlength "")))
|
|
3149 (concat " MAXLENGTH="
|
|
3150 maxlength
|
|
3151 ))
|
|
3152 (if (and src
|
|
3153 (not (string= src "")))
|
|
3154 (concat " SRC=\""
|
|
3155 src
|
|
3156 "\""))
|
|
3157 ">")))
|
|
3158
|
|
3159
|
|
3160 (defun hm--html-form-add-input-text (name value size maxlength)
|
|
3161 "Adds the HTML tags for a text input field."
|
|
3162 (interactive (list (hm--html-form-read-name)
|
|
3163 (hm--html-form-read-value "Defaultvalue: ")
|
|
3164 (hm--html-form-read-size)
|
|
3165 (hm--html-form-read-maxlength)))
|
|
3166 (hm--html-form-add-input "text" name value nil size maxlength))
|
|
3167
|
|
3168
|
|
3169 (defun hm--html-form-add-input-password (name value size maxlength)
|
|
3170 "Adds the HTML tags for a password input field."
|
|
3171 (interactive (list (hm--html-form-read-name)
|
|
3172 (hm--html-form-read-value "Defaultvalue: ")
|
|
3173 (hm--html-form-read-size)
|
|
3174 (hm--html-form-read-maxlength)))
|
|
3175 (hm--html-form-add-input "password" name value nil size maxlength))
|
|
3176
|
|
3177
|
|
3178 (defun hm--html-form-add-input-integer (name value size maxlength)
|
|
3179 "Adds the HTML tags for a integer input field."
|
|
3180 (interactive (list (hm--html-form-read-name)
|
|
3181 (hm--html-form-read-value "Defaultvalue: ")
|
|
3182 (hm--html-form-read-size)
|
|
3183 (hm--html-form-read-maxlength)))
|
|
3184 (hm--html-form-add-input "int" name value nil size maxlength))
|
|
3185
|
|
3186
|
|
3187 (defun hm--html-form-add-input-float (name value size maxlength)
|
|
3188 "Adds the HTML tags for a float input field."
|
|
3189 (interactive (list (hm--html-form-read-name)
|
|
3190 (hm--html-form-read-value "Defaultvalue: ")
|
|
3191 (hm--html-form-read-size)
|
|
3192 (hm--html-form-read-maxlength)))
|
|
3193 (hm--html-form-add-input "float" name value nil size maxlength))
|
|
3194
|
|
3195
|
|
3196 (defun hm--html-form-add-input-date (name value size maxlength)
|
|
3197 "Adds the HTML tags for a date input field."
|
|
3198 (interactive (list (hm--html-form-read-name)
|
|
3199 (hm--html-form-read-value "Defaultvalue: ")
|
|
3200 (hm--html-form-read-size)
|
|
3201 (hm--html-form-read-maxlength)))
|
|
3202 (hm--html-form-add-input "date" name value nil size maxlength))
|
|
3203
|
|
3204
|
|
3205 (defun hm--html-form-add-input-url (name value size maxlength)
|
|
3206 "Adds the HTML tags for a url input field."
|
|
3207 (interactive (list (hm--html-form-read-name)
|
|
3208 (hm--html-form-read-value "Defaultvalue: ")
|
|
3209 (hm--html-form-read-size)
|
|
3210 (hm--html-form-read-maxlength)))
|
|
3211 (hm--html-form-add-input "url" name value nil size maxlength))
|
|
3212
|
|
3213
|
|
3214 (defun hm--html-form-add-input-scribble (name value size maxlength)
|
|
3215 "Adds the HTML tags for a scribble input field."
|
|
3216 (interactive (list (hm--html-form-read-name)
|
|
3217 (hm--html-form-read-value "Defaultvalue: ")
|
|
3218 (hm--html-form-read-size)
|
|
3219 (hm--html-form-read-maxlength)))
|
|
3220 (hm--html-form-add-input "scribble" name value nil size maxlength))
|
|
3221
|
|
3222
|
|
3223 (defun hm--html-form-add-input-checkbox (name value checked)
|
|
3224 "Adds the HTML tags for a checkbox button."
|
|
3225 (interactive (list (hm--html-form-read-name)
|
|
3226 (hm--html-form-read-value "Checkbox value: ")
|
|
3227 (hm--html-form-read-checked)))
|
|
3228 (hm--html-form-add-input "checkbox" name value checked nil nil))
|
|
3229
|
|
3230
|
|
3231 (defvar hm--html-last-radio-button-name nil
|
|
3232 "Name of the last radio button.")
|
|
3233
|
|
3234
|
|
3235 (defun hm--html-form-add-input-radio (name value checked)
|
|
3236 "Adds the HTML tags for a radio button."
|
|
3237 (interactive (list (hm--html-form-read-name hm--html-last-radio-button-name)
|
|
3238 (hm--html-form-read-value "Radiobutton value: ")
|
|
3239 (hm--html-form-read-checked)))
|
|
3240 (setq hm--html-last-radio-button-name name)
|
|
3241 (hm--html-form-add-input "radio" name value checked nil nil))
|
|
3242
|
|
3243
|
|
3244 (defun hm--html-form-add-input-submit (value)
|
|
3245 "Adds the HTML tags for a submit input field."
|
|
3246 (interactive (list (hm--html-form-read-value
|
|
3247 "Label of the submit button: "
|
|
3248 "Submit")))
|
|
3249 (hm--html-form-add-input "submit" nil value nil nil nil))
|
|
3250
|
|
3251
|
|
3252 (defun hm--html-form-add-input-image (name src)
|
|
3253 "Adds the HTML tags for an image input field."
|
|
3254 (interactive (list (hm--html-form-read-name)
|
|
3255 (hm--html-read-url "Image URL: "
|
|
3256 hm--html-url-alist
|
|
3257 (function
|
|
3258 (lambda (table-element-list)
|
|
3259 (hm--html-read-url-predicate
|
|
3260 table-element-list
|
|
3261 'IMAGE)))
|
|
3262 nil
|
|
3263 nil)))
|
|
3264 (hm--html-form-add-input "IMAGE"
|
|
3265 name
|
|
3266 nil
|
|
3267 nil
|
|
3268 nil
|
|
3269 nil
|
|
3270 src))
|
|
3271
|
|
3272
|
|
3273 (defun hm--html-form-add-input-audio (name src)
|
|
3274 "Adds the HTML tags for an audio input field."
|
|
3275 (interactive (list (hm--html-form-read-name)
|
|
3276 (hm--html-read-url "Audio URL: "
|
|
3277 hm--html-url-alist
|
|
3278 (function
|
|
3279 (lambda (table-element-list)
|
|
3280 (hm--html-read-url-predicate
|
|
3281 table-element-list
|
|
3282 'AUDIO)))
|
|
3283 nil
|
|
3284 nil)))
|
|
3285 (hm--html-form-add-input "AUDIO"
|
|
3286 name
|
|
3287 nil
|
|
3288 nil
|
|
3289 nil
|
|
3290 nil
|
|
3291 src))
|
|
3292
|
|
3293
|
|
3294 (defun hm--html-form-add-input-reset (value)
|
|
3295 "Adds the HTML tags for a reset input field."
|
|
3296 (interactive (list (hm--html-form-read-value
|
|
3297 "Label of the reset button: "
|
|
3298 "Reset")))
|
|
3299 (hm--html-form-add-input "reset" nil value nil nil nil))
|
|
3300
|
|
3301
|
|
3302 (defun hm--html-form-add-input-isindex (size)
|
|
3303 "Adds the HTML tags for an isindex input field.
|
|
3304 Size is the value of the input field wide."
|
|
3305 (interactive "nWidth of the input field (i.e: 20): ")
|
|
3306 (hm--html-insert-start-tag (concat "<INPUT NAME=\"isindex\""
|
|
3307 (if (= size 20)
|
|
3308 ">"
|
|
3309 (format
|
|
3310 " SIZE=%d>"
|
|
3311 size)))))
|
|
3312
|
|
3313
|
|
3314 (defun hm--html-form-add-select-option-menu (name)
|
|
3315 "Adds the HTML tags for a select option menu to the buffer."
|
|
3316 (interactive (list (hm--html-form-read-name)))
|
|
3317 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
3318 (concat "<SELECT NAME=\"" name "\">")
|
|
3319 'hm--html-insert-end-tag-with-newline
|
|
3320 "</SELECT>"
|
|
3321 'hm--html-insert-start-tag
|
|
3322 "<OPTION> "))
|
|
3323
|
|
3324
|
|
3325 (defun hm--html-form-add-select-scrolled-list (name listsize multiple)
|
|
3326 "Adds the HTML tags for a select scrolled list to the buffer."
|
|
3327 (interactive (list (hm--html-form-read-name)
|
|
3328 (read-number "No of visible items (>1): " t)
|
|
3329 (y-or-n-p "Multiple selections allowed ? ")))
|
|
3330 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
3331 (concat "<SELECT NAME=\""
|
|
3332 name
|
|
3333 "\" SIZE="
|
|
3334 (int-to-string listsize)
|
|
3335 (if multiple
|
|
3336 " MULTIPLE")
|
|
3337 ">")
|
|
3338 'hm--html-insert-end-tag-with-newline
|
|
3339 "</SELECT>"
|
|
3340 'hm--html-insert-start-tag
|
|
3341 "<OPTION> "))
|
|
3342
|
|
3343
|
|
3344 (defun hm--html-form-add-select-option (selected-by-default)
|
|
3345 "Adds the tags for an option in a select form menu."
|
|
3346 (interactive (list (y-or-n-p "Select this option by default ? ")))
|
|
3347 (hm--html-insert-end-tag-with-newline (concat "<OPTION"
|
|
3348 (if selected-by-default
|
|
3349 " SELECTED")
|
|
3350 "> ")))
|
|
3351
|
|
3352
|
|
3353 (defun hm--html-form-add-textarea (name rows columns)
|
|
3354 "Adds the tags for a textarea tag."
|
|
3355 (interactive (list (hm--html-form-read-name)
|
|
3356 (read-number "Number of Rows of the Textarea: " t)
|
|
3357 (read-number "Number of Columns of the Textarea: " t)))
|
|
3358 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
3359 (concat "<TEXTAREA NAME=\""
|
|
3360 name
|
|
3361 "\" ROWS="
|
|
3362 (int-to-string rows)
|
|
3363 " COLS="
|
|
3364 (int-to-string columns)
|
|
3365 ">")
|
|
3366 'hm--html-insert-end-tag
|
|
3367 "</TEXTAREA>"))
|
|
3368
|
|
3369
|
|
3370 ;;; Functions to insert tables
|
|
3371
|
|
3372 (defun hm--html-add-table (border compact)
|
|
3373 "Add the HTML tags for a table frame.
|
|
3374 If BORDER is t, then the table should be drawn with a border.
|
|
3375 If COMPACT is t, then the table should be drawn in a smaller size."
|
|
3376 (interactive (list (y-or-n-p "Use a table with a border? ")
|
|
3377 (y-or-n-p "Use a small table? ")))
|
|
3378 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline
|
|
3379 (concat "<TABLE"
|
|
3380 (if border " border" "")
|
|
3381 (if compact " compact" "")
|
|
3382 ">")
|
|
3383 'hm--html-insert-start-tag-with-newline
|
|
3384 "</TABLE>")
|
|
3385 (backward-char))
|
|
3386
|
|
3387
|
|
3388 (defun hm--html-add-table-to-region (border compact)
|
|
3389 "Add the HTML tags for a table frame.
|
|
3390 If BORDER is t, then the table should be drawn with a border.
|
|
3391 If COMPACT is t, then the table should be drawn in a smaller size."
|
|
3392 (interactive (list (y-or-n-p "Use a table with a border? ")
|
|
3393 (y-or-n-p "Use a small table? ")))
|
|
3394 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline
|
|
3395 (concat "<TABLE"
|
|
3396 (if border " border" "")
|
|
3397 (if compact " compact" "")
|
|
3398 ">")
|
|
3399 'hm--html-insert-start-tag-with-newline
|
|
3400 "</TABLE>"))
|
|
3401
|
|
3402
|
|
3403 (defun hm--html-add-table-title (top)
|
|
3404 "Adds the HTML tag for a table title at the current point.
|
|
3405 If TOP is t, then the title will positioned at the top instead of the
|
|
3406 bottom of the table."
|
|
3407 (interactive (list (y-or-n-p "Put the title at the table top? ")))
|
|
3408 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
3409 (concat "\n<CAPTION"
|
|
3410 (if top " align=top" " align=bottom")
|
|
3411 "> ")
|
|
3412 'hm--html-insert-end-tag
|
|
3413 " </CAPTION>"))
|
|
3414
|
|
3415
|
|
3416 (defun hm--html-add-table-title-to-region (top)
|
|
3417 "Adds the HTML tag for a table title to the region.
|
|
3418 If TOP is t, then the title will positioned at the top instead of the
|
|
3419 bottom of the table."
|
|
3420 (interactive (list (y-or-n-p "Put the title at the table top? ")))
|
|
3421 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
3422 (concat "<CAPTION"
|
|
3423 (if top " align=top" " align=bottom")
|
|
3424 "> ")
|
|
3425 'hm--html-insert-end-tag
|
|
3426 " </CAPTION>"))
|
|
3427
|
|
3428
|
|
3429 (defvar hm--html-table-alignment-alist '(("default")
|
|
3430 ("left")
|
|
3431 ("right")
|
|
3432 ("center"))
|
|
3433 "Alist with table alignments.")
|
|
3434
|
|
3435 (defun hm--html-table-read-cell-entries-and-alignments (cell-no
|
|
3436 no-of-cells
|
|
3437 &optional
|
|
3438 alignment-list)
|
|
3439 "Reads the alignments and the entries for NO-OF-CELLS cells.
|
|
3440 The return is a list with strings of the form: \"align=left> entry\".
|
|
3441 CELL-NO is the current cell no.
|
|
3442 If (car ALIGNMENT-LIST) is non-nil, then it is used as alignment."
|
|
3443 (if (> cell-no no-of-cells)
|
|
3444 nil
|
|
3445 (let ((alignment
|
|
3446 (or (car alignment-list)
|
|
3447 (completing-read (format "Alignment of the %d. cell: "
|
|
3448 cell-no)
|
|
3449 hm--html-table-alignment-alist
|
|
3450 nil
|
|
3451 t
|
|
3452 "default")))
|
|
3453 (entry (read-string (format "Entry of the %d. cell: " cell-no))))
|
|
3454 (if (string= "default" alignment)
|
|
3455 (setq alignment "")
|
|
3456 (setq alignment (concat " align=" alignment)))
|
|
3457 (cons (concat alignment "> " entry)
|
|
3458 (hm--html-table-read-cell-entries-and-alignments (1+ cell-no)
|
|
3459 no-of-cells
|
|
3460 (cdr
|
|
3461 alignment-list))
|
|
3462 ))))
|
|
3463
|
|
3464 (defun hm--html-add-table-header (no-of-cells)
|
|
3465 "Adds the HTML tags for a complete simple table header line.
|
|
3466 It asks for the number of cells and the allignment of the cells.
|
|
3467 The number of cells can also be given as prefix argument."
|
|
3468 (interactive "NNo of cells in a row: ")
|
|
3469 (if (< no-of-cells 1)
|
|
3470 (error "ERROR: There must be at least one cell in a row!"))
|
|
3471 (hm--html-add-tags
|
|
3472 'hm--html-insert-end-tag-with-newline
|
98
|
3473 (concat "<TR>"
|
|
3474 (mapconcat '(lambda (entry)
|
|
3475 (concat "<TH" entry))
|
|
3476 (hm--html-table-read-cell-entries-and-alignments
|
|
3477 1
|
|
3478 no-of-cells)
|
|
3479 " </TH>")
|
|
3480 " </TH></TR>")))
|
0
|
3481
|
|
3482
|
|
3483 (defun hm--html-add-first-table-row (no-of-cells)
|
|
3484 "Adds the HTML tags for a table row.
|
|
3485 It asks for the number of cells and the allignment of the cells.
|
|
3486 The number of cells can also be given as prefix argument."
|
|
3487 (interactive "NNo of cells in a row: ")
|
|
3488 (if (< no-of-cells 1)
|
|
3489 (error "ERROR: There must be at least one cell in a row!"))
|
|
3490 (hm--html-add-tags
|
|
3491 'hm--html-insert-end-tag-with-newline
|
98
|
3492 (concat "<TR><TD"
|
|
3493 (car (hm--html-table-read-cell-entries-and-alignments 1 1))
|
|
3494 " </TD>"
|
0
|
3495 (if (<= no-of-cells 1)
|
98
|
3496 "</TR>"
|
0
|
3497 (concat
|
|
3498 (mapconcat '(lambda (entry)
|
|
3499 (concat "<TD" entry))
|
|
3500 (hm--html-table-read-cell-entries-and-alignments
|
|
3501 2 no-of-cells)
|
98
|
3502 " </TD>")
|
|
3503 " </TD></TR>")))))
|
0
|
3504
|
|
3505
|
|
3506 (defun hm--html-table-get-previous-alignments ()
|
|
3507 "Returns a list with the alignments of the previous table row.
|
|
3508 The row must be a data row and not a header row!
|
|
3509 An example for the return list: '(\"left\" \"default\" \"center\" \"right\")"
|
|
3510 (save-excursion
|
|
3511 (let* ((point-of-view (point))
|
98
|
3512 (case-fold-search t)
|
|
3513 (end-of-last-row (search-backward "</tr>" (point-min) t))
|
|
3514 (begin-of-last-row (progn (search-backward "<tr" (point-min) t)
|
|
3515 (re-search-forward "<t[dh]"
|
|
3516 point-of-view t)
|
0
|
3517 (match-beginning 0)))
|
|
3518 (alignment-list nil))
|
98
|
3519 (goto-char begin-of-last-row)
|
|
3520 (if (not (re-search-forward "<t[dh]" end-of-last-row t))
|
0
|
3521 (error "Error: No previous data row found!")
|
|
3522 (goto-char end-of-last-row)
|
|
3523 (while (> (point) begin-of-last-row)
|
|
3524 (let ((cell-start
|
|
3525 (search-backward-regexp "\\(<td[^>]*>\\)\\|\\(<th[^>]*>\\)"
|
|
3526 begin-of-last-row
|
|
3527 t)))
|
|
3528 (if (not cell-start)
|
|
3529 (goto-char begin-of-last-row)
|
|
3530 (setq alignment-list
|
|
3531 (cons
|
|
3532 (if (search-forward-regexp "\\(align=\\)\\([^ \t\n>]*\\)"
|
|
3533 (match-end 0)
|
|
3534 t)
|
|
3535 (buffer-substring (match-beginning 2)
|
|
3536 (match-end 2))
|
|
3537 "default")
|
|
3538 alignment-list))
|
|
3539 (goto-char cell-start))))
|
|
3540 alignment-list))))
|
|
3541
|
|
3542
|
|
3543 (defun hm--html-add-additional-table-row ()
|
|
3544 "Adds the HTML tags for a table row.
|
|
3545 It tries to detect the number of cells and their alignments
|
|
3546 from existing rows of the table."
|
|
3547 (interactive)
|
|
3548 (let* ((old-alignment-list (hm--html-table-get-previous-alignments))
|
|
3549 (no-of-cells (length old-alignment-list)))
|
|
3550 (hm--html-add-tags
|
|
3551 'hm--html-insert-end-tag-with-newline
|
98
|
3552 (concat "<TR><TD" (car (hm--html-table-read-cell-entries-and-alignments
|
|
3553 1
|
|
3554 1
|
|
3555 old-alignment-list))
|
|
3556 " </TD>"
|
0
|
3557 (if (<= no-of-cells 1)
|
98
|
3558 "</TR>"
|
0
|
3559 (concat
|
|
3560 (mapconcat '(lambda (entry)
|
|
3561 (concat "<TD" entry))
|
|
3562 (hm--html-table-read-cell-entries-and-alignments
|
|
3563 2
|
|
3564 no-of-cells
|
|
3565 (cdr old-alignment-list))
|
98
|
3566 " </TD>")
|
|
3567 " </TD></TR>"))))))
|
0
|
3568
|
|
3569
|
|
3570 (defun hm--html-add-row-entry (alignment)
|
|
3571 "Adds the HTML tag for a table row entry at the current point."
|
|
3572 (interactive (list (completing-read "Alignment of the cell: "
|
|
3573 hm--html-table-alignment-alist
|
|
3574 nil
|
|
3575 t
|
|
3576 "default")))
|
|
3577 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
3578 (concat "<TD"
|
|
3579 (if (string= "default" alignment)
|
|
3580 "> "
|
|
3581 (concat " align=" alignment "> ")))))
|
|
3582
|
|
3583
|
|
3584 (defun hm--html-add-header-entry (alignment)
|
|
3585 "Adds the HTML tag for a table header entry at the current point."
|
|
3586 (interactive (list (completing-read "Alignment of the cell: "
|
|
3587 hm--html-table-alignment-alist
|
|
3588 nil
|
|
3589 t
|
|
3590 "default")))
|
|
3591 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
3592 (concat "<TH"
|
|
3593 (if (string= "default" alignment)
|
|
3594 "> "
|
|
3595 (concat " align=" alignment "> ")))))
|
|
3596
|
|
3597
|
|
3598 (defun hm--html-add-row-frame (alignment)
|
|
3599 "Adds the HTML tags for a table row start and end at the current point."
|
|
3600 (interactive (list (completing-read "Alignment of the start cell: "
|
|
3601 hm--html-table-alignment-alist
|
|
3602 nil
|
|
3603 t
|
|
3604 "default")))
|
|
3605 (hm--html-add-tags 'hm--html-insert-start-tag
|
|
3606 (concat "<TD"
|
|
3607 (if (string= "default" alignment)
|
|
3608 "> "
|
|
3609 (concat " align=" alignment "> ")))
|
|
3610 'hm--html-insert-end-tag
|
|
3611 "<TR>"))
|
|
3612
|
|
3613
|
|
3614 (defun hm--html-add-row-frame-to-region (alignment)
|
|
3615 "Adds the HTML tags for a table row start and end to the current region."
|
|
3616 (interactive (list (completing-read "Alignment of the start cell: "
|
|
3617 hm--html-table-alignment-alist
|
|
3618 nil
|
|
3619 t
|
|
3620 "default")))
|
|
3621 (hm--html-add-tags-to-region 'hm--html-insert-start-tag
|
|
3622 (concat "<TD"
|
|
3623 (if (string= "default" alignment)
|
|
3624 "> "
|
|
3625 (concat " align=" alignment "> ")))
|
|
3626 'hm--html-insert-end-tag
|
|
3627 " <TR>"))
|
|
3628
|
|
3629
|
|
3630 (defun hm--html-table-add-colspan-attribute (columns)
|
|
3631 "Adds a colspawn attribute to a table cell.
|
|
3632 A prefix arg is used as no of COLUMNS."
|
|
3633 (interactive "NNo of columns, spaned by this cell: ")
|
98
|
3634 (let ((case-fold-search t))
|
|
3635 (save-excursion
|
|
3636 (if (and (search-backward "<" nil t)
|
|
3637 (search-forward-regexp "<[ \t\n]*\\(th\\)\\|\\(td\\)" nil t))
|
|
3638 (if (search-forward-regexp "\\([ \t\n]+colspan=\\)\\([^ \t\n>]*\\)"
|
|
3639 nil
|
|
3640 t)
|
|
3641 (progn
|
|
3642 (delete-region (match-beginning 2) (match-end 2))
|
|
3643 (insert (format "\"%d\"" columns)))
|
|
3644 (insert (format " colspan=\"%d\"" columns)))
|
|
3645 (error "ERROR: Point not in a table cell!")))))
|
0
|
3646
|
|
3647
|
|
3648 (defun hm--html-table-add-rowspan-attribute (rows)
|
|
3649 "Adds a rowspan attribute to a table cell.
|
|
3650 A prefix arg is used as no of ROWS."
|
|
3651 (interactive "NNo of rows, spaned by this cell: ")
|
98
|
3652 (let ((case-fold-search t))
|
|
3653 (save-excursion
|
|
3654 (if (and (search-backward "<" nil t)
|
|
3655 (search-forward-regexp "<[ \t\n]*\\(th\\)\\|\\(td\\)" nil t))
|
|
3656 (if (search-forward-regexp "\\([ \t\n]+rowspan=\\)\\([^ \t\n>]*\\)"
|
|
3657 nil
|
|
3658 t)
|
|
3659 (progn
|
|
3660 (delete-region (match-beginning 2) (match-end 2))
|
|
3661 (insert (format "\"%d\"" rows)))
|
|
3662 (insert (format " rowspan=\"%d\"" rows)))
|
|
3663 (error "ERROR: Point not in a table cell!")))))
|
0
|
3664
|
|
3665
|
|
3666 ;;; ISO-Characters for Emacs HTML-mode (Berthold Crysmann)
|
2
|
3667 ;(setq buffer-invisibility-spec '(hm--html-iso-entity-invisible-flag))
|
|
3668
|
|
3669 ;(defvar hm--html-iso-entity-invisible-flag t
|
|
3670 ; "Controls the visibility of the iso entities.")
|
|
3671
|
|
3672 ;(defvar hm--html-iso-glyph-invisible-flag nil
|
|
3673 ; "Controls the visibility of the iso character glyphs.")
|
|
3674
|
|
3675 ;(defvar hm--html-glyph-cache nil
|
|
3676 ; "Internal variable. An assoc list with the already created glyphs.")
|
|
3677
|
|
3678 ;(defun hm--html-create-glyph (string)
|
|
3679 ; "Creates a glyph from the string or returns an existing one.
|
|
3680 ;The glyph is stored in `hm--html-glyph-cache'."
|
|
3681 ; (if nil ;(assoc string hm--html-glyph-cache)
|
|
3682 ; (cdr (assoc string hm--html-glyph-cache))
|
|
3683 ; (let ((glyph (make-glyph string)))
|
|
3684 ; (setq hm--html-glyph-cache (cons (cons string glyph)
|
|
3685 ; hm--html-glyph-cache))
|
|
3686 ; glyph)))
|
|
3687
|
|
3688 ;(defun hm--html-attach-glyph-to-region (start
|
|
3689 ; end
|
|
3690 ; string
|
|
3691 ; region-invisible-flag
|
|
3692 ; glyph-invisible-flag)
|
|
3693 ; "Make the region invisible and attach a glyph STRING.
|
|
3694 ;The invisible flags could be used, to toggle the visibility."
|
|
3695 ; (mapcar 'delete-annotation (annotations-at end)) ; delete old anotations
|
|
3696 ; ;; delete old extents
|
|
3697 ; (let ((extent (make-extent start end))
|
|
3698 ; (annotation nil))
|
|
3699 ; (set-extent-property extent 'invisible region-invisible-flag)
|
|
3700 ; (set-extent-property extent 'end-open t)
|
|
3701 ; (set-extent-property extent 'start-open t)
|
|
3702 ; (set-extent-property extent 'intangible t)
|
|
3703 ; (setq annotation (make-annotation "Hallo Du da" ;(hm--html-create-glyph string)
|
|
3704 ; end
|
|
3705 ; 'text))
|
|
3706 ; (goto-char end)))
|
|
3707
|
|
3708
|
|
3709 ;(defun hm--html-insert-iso-char-as-entity-and-glyph (char entity)
|
|
3710 ; "Inserts an iso char as html ENTITY and displays a glyph.
|
|
3711 ;The glyph is created from the string CHAR."
|
|
3712 ; (let ((start (point)))
|
|
3713 ; (insert entity)
|
|
3714 ; (hm--html-attach-glyph-to-region start
|
|
3715 ; (point)
|
|
3716 ; char
|
|
3717 ; 'hm--html-iso-entity-invisible-flag
|
|
3718 ; 'hm--html-iso-glyph-invisible-flag)))
|
|
3719
|
|
3720 ;(defun hm--html_ue ()
|
|
3721 ; (interactive)
|
|
3722 ; (hm--html-insert-iso-char-as-entity-and-glyph "ü" "ü"))
|
|
3723
|
|
3724
|
|
3725 ;(defun hm--html-insert-iso-char-as-entity-and-glyph (char entity)
|
|
3726 ; (let ((start (point))
|
|
3727 ; (end nil)
|
|
3728 ; (extent nil))
|
|
3729 ; (insert entity)
|
|
3730 ; (setq end (point))
|
|
3731 ; (setq extent (make-extent start end))
|
|
3732 ; (set-extent-begin-glyph extent char)
|
|
3733 ; (set-extent-property extent 'invisible t)))
|
|
3734
|
|
3735 ;(defun hm--html_ue ()
|
|
3736 ; (interactive)
|
|
3737 ; (hm--html-insert-iso-char-as-entity-and-glyph ?ü "ü"))
|
0
|
3738
|
|
3739 (defun hm--html_ue ()
|
|
3740 "Insert the character 'ue'."
|
|
3741 (interactive)
|
|
3742 (insert "ü"))
|
|
3743
|
|
3744 (defun hm--html_oe ()
|
|
3745 "Insert the character 'oe'."
|
|
3746 (interactive)
|
|
3747 (insert "ö"))
|
|
3748
|
|
3749 (defun hm--html_ae ()
|
|
3750 "Insert the character 'ae'."
|
|
3751 (interactive)
|
|
3752 (insert "ä"))
|
|
3753
|
|
3754 (defun hm--html_aa ()
|
|
3755 "Insert the character 'aa'."
|
|
3756 (interactive)
|
|
3757 (insert "å"))
|
|
3758
|
|
3759 (defun hm--html_Ue ()
|
|
3760 "Insert the character 'Ue'."
|
|
3761 (interactive)
|
|
3762 (insert "Ü"))
|
|
3763
|
|
3764 (defun hm--html_Oe ()
|
|
3765 "Insert the character 'Oe'."
|
|
3766 (interactive)
|
|
3767 (insert "Ö"))
|
|
3768
|
|
3769 (defun hm--html_Ae ()
|
|
3770 "Insert the character 'Ae'."
|
|
3771 (interactive)
|
|
3772 (insert "Ä"))
|
|
3773
|
|
3774 (defun hm--html_Aa ()
|
|
3775 "Insert the character 'Aa'."
|
|
3776 (interactive)
|
|
3777 (insert "Å"))
|
|
3778
|
|
3779 (defun hm--html_sz ()
|
|
3780 "Insert the character 'sz'."
|
|
3781 (interactive)
|
|
3782 (insert "ß"))
|
|
3783
|
|
3784 (defun hm--html_aacute ()
|
|
3785 "Insert the character 'aacute'."
|
|
3786 (interactive)
|
|
3787 (insert "á"))
|
|
3788
|
|
3789 (defun hm--html_eacute ()
|
|
3790 "Insert the character 'eacute'."
|
|
3791 (interactive)
|
|
3792 (insert "é"))
|
|
3793
|
|
3794 (defun hm--html_iacute ()
|
|
3795 "Insert the character 'iacute'."
|
|
3796 (interactive)
|
|
3797 (insert "í"))
|
|
3798
|
|
3799 (defun hm--html_oacute ()
|
|
3800 "Insert the character 'oacute'."
|
|
3801 (interactive)
|
|
3802 (insert "ó"))
|
|
3803
|
|
3804 (defun hm--html_uacute ()
|
|
3805 "Insert the character 'uacute'."
|
|
3806 (interactive)
|
|
3807 (insert "ú"))
|
|
3808
|
|
3809 (defun hm--html_Aacute ()
|
|
3810 "Insert the character 'Aacute'."
|
|
3811 (interactive)
|
|
3812 (insert "á"))
|
|
3813
|
|
3814 (defun hm--html_Eacute ()
|
|
3815 "Insert the character 'Eacute'."
|
|
3816 (interactive)
|
|
3817 (insert "é"))
|
|
3818
|
|
3819 (defun hm--html_Iacute ()
|
|
3820 "Insert the character 'Iacute'."
|
|
3821 (interactive)
|
|
3822 (insert "í"))
|
|
3823
|
|
3824 (defun hm--html_Oacute ()
|
|
3825 "Insert the character 'Oacute'."
|
|
3826 (interactive)
|
|
3827 (insert "ó"))
|
|
3828
|
|
3829 (defun hm--html_Uacute ()
|
|
3830 "Insert the character 'Uacute'."
|
|
3831 (interactive)
|
|
3832 (insert "ú"))
|
|
3833
|
|
3834 (defun hm--html_agrave ()
|
|
3835 "Insert the character 'agrave'."
|
|
3836 (interactive)
|
|
3837 (insert "à"))
|
|
3838
|
|
3839 (defun hm--html_egrave ()
|
|
3840 "Insert the character 'egrave'."
|
|
3841 (interactive)
|
|
3842 (insert "è"))
|
|
3843
|
|
3844 (defun hm--html_igrave ()
|
|
3845 "Insert the character 'igrave'."
|
|
3846 (interactive)
|
|
3847 (insert "ì"))
|
|
3848
|
|
3849 (defun hm--html_ograve ()
|
|
3850 "Insert the character 'ograve'."
|
|
3851 (interactive)
|
|
3852 (insert "ò"))
|
|
3853
|
|
3854 (defun hm--html_ugrave ()
|
|
3855 "Insert the character 'ugrave'."
|
|
3856 (interactive)
|
|
3857 (insert "ù"))
|
|
3858
|
|
3859 (defun hm--html_Agrave ()
|
|
3860 "Insert the character 'Agrave'."
|
|
3861 (interactive)
|
|
3862 (insert "À"))
|
|
3863
|
|
3864 (defun hm--html_Egrave ()
|
|
3865 "Insert the character 'Egrave'."
|
|
3866 (interactive)
|
|
3867 (insert "È"))
|
|
3868
|
|
3869 (defun hm--html_Igrave ()
|
|
3870 "Insert the character 'Igrave'."
|
|
3871 (interactive)
|
|
3872 (insert "Ì"))
|
|
3873
|
|
3874 (defun hm--html_Ograve ()
|
|
3875 "Insert the character 'Ograve'."
|
|
3876 (interactive)
|
|
3877 (insert "Ò"))
|
|
3878
|
|
3879 (defun hm--html_Ugrave ()
|
|
3880 "Insert the character 'Ugrave'."
|
|
3881 (interactive)
|
|
3882 (insert "Ù"))
|
|
3883
|
|
3884 (defun hm--html_ccedilla ()
|
|
3885 "Insert the character 'ccedilla'."
|
|
3886 (interactive)
|
|
3887 (insert "çla;"))
|
|
3888
|
|
3889 (defun hm--html_Ccedilla ()
|
|
3890 "Insert the character 'Ccedilla'."
|
|
3891 (interactive)
|
|
3892 (insert "Çla;"))
|
|
3893
|
|
3894 (defun hm--html_atilde ()
|
|
3895 "Insert the character 'atilde'."
|
|
3896 (interactive)
|
|
3897 (insert "ã"))
|
|
3898
|
|
3899 (defun hm--html_otilde ()
|
|
3900 "Insert the character 'otilde'."
|
|
3901 (interactive)
|
|
3902 (insert "õ"))
|
|
3903
|
|
3904 (defun hm--html_ntilde ()
|
|
3905 "Insert the character 'ntilde'."
|
|
3906 (interactive)
|
|
3907 (insert "ñ"))
|
|
3908
|
|
3909 (defun hm--html_Atilde ()
|
|
3910 "Insert the character 'Atilde'."
|
|
3911 (interactive)
|
|
3912 (insert "Ã"))
|
|
3913
|
|
3914 (defun hm--html_Otilde ()
|
|
3915 "Insert the character 'Otilde'."
|
|
3916 (interactive)
|
|
3917 (insert "Õ"))
|
|
3918
|
|
3919 (defun hm--html_Ntilde ()
|
|
3920 "Insert the character 'Ntilde'."
|
|
3921 (interactive)
|
|
3922 (insert "Ñ"))
|
|
3923
|
|
3924 (defun hm--html_acircumflex ()
|
|
3925 "Insert the character 'acircumflex'."
|
|
3926 (interactive)
|
153
|
3927 (insert "â"))
|
0
|
3928
|
|
3929 (defun hm--html_ecircumflex ()
|
|
3930 "Insert the character 'ecircumflex'."
|
|
3931 (interactive)
|
153
|
3932 (insert "ê"))
|
0
|
3933
|
|
3934 (defun hm--html_icircumflex ()
|
|
3935 "Insert the character 'icircumflex'."
|
|
3936 (interactive)
|
153
|
3937 (insert "î"))
|
0
|
3938
|
|
3939 (defun hm--html_ocircumflex ()
|
|
3940 "Insert the character 'ocircumflex'."
|
|
3941 (interactive)
|
153
|
3942 (insert "ô"))
|
0
|
3943
|
|
3944 (defun hm--html_ucircumflex ()
|
|
3945 "Insert the character 'ucircumflex'."
|
|
3946 (interactive)
|
153
|
3947 (insert "û"))
|
0
|
3948
|
|
3949 (defun hm--html_Acircumflex ()
|
|
3950 "Insert the character 'Acircumflex'."
|
|
3951 (interactive)
|
153
|
3952 (insert "Â"))
|
0
|
3953
|
|
3954 (defun hm--html_Ecircumflex ()
|
|
3955 "Insert the character 'Ecircumflex'."
|
|
3956 (interactive)
|
153
|
3957 (insert "Ê"))
|
0
|
3958
|
|
3959 (defun hm--html_Icircumflex ()
|
|
3960 "Insert the character 'Icircumflex'."
|
|
3961 (interactive)
|
153
|
3962 (insert "Î"))
|
0
|
3963
|
|
3964 (defun hm--html_Ocircumflex ()
|
|
3965 "Insert the character 'Ocircumflex'."
|
|
3966 (interactive)
|
153
|
3967 (insert "Ô"))
|
0
|
3968
|
|
3969 (defun hm--html_Ucircumflex ()
|
|
3970 "Insert the character 'Ucircumflex'."
|
|
3971 (interactive)
|
153
|
3972 (insert "Û"))
|
0
|
3973
|
|
3974 (defun hm--html_ediaeresis ()
|
|
3975 "Insert the character 'ediaeresis'."
|
|
3976 (interactive)
|
|
3977 (insert "ë"))
|
|
3978
|
|
3979 (defun hm--html_idiaeresis ()
|
|
3980 "Insert the character 'idiaeresis'."
|
|
3981 (interactive)
|
|
3982 (insert "ï"))
|
|
3983
|
|
3984 (defun hm--html_Ediaeresis ()
|
|
3985 "Insert the character 'Ediaeresis'."
|
|
3986 (interactive)
|
|
3987 (insert "Ë"))
|
|
3988
|
|
3989 (defun hm--html_Idiaeresis ()
|
|
3990 "Insert the character 'Idiaeresis'."
|
|
3991 (interactive)
|
|
3992 (insert "Ï"))
|
|
3993
|
|
3994 (defun hm--html_thorn ()
|
|
3995 "Insert the character 'thorn'."
|
|
3996 (interactive)
|
|
3997 (insert "þ"))
|
|
3998
|
|
3999 (defun hm--html_Thorn ()
|
|
4000 "Insert the character 'Thorn'."
|
|
4001 (interactive)
|
|
4002 (insert "Þ"))
|
|
4003
|
|
4004 (defun hm--html_eth ()
|
|
4005 "Insert the character 'eth'."
|
|
4006 (interactive)
|
|
4007 (insert "ð"))
|
|
4008
|
|
4009 (defun hm--html_Eth ()
|
|
4010 "Insert the character 'Eth'."
|
|
4011 (interactive)
|
|
4012 (insert "Ð"))
|
|
4013
|
|
4014
|
|
4015 ;;;
|
|
4016 ;
|
|
4017 ; smart functions
|
|
4018
|
|
4019 (defvar hm--just-insert-less-than nil
|
|
4020 "Internal variable.")
|
|
4021
|
2
|
4022 (defun hm--html-less-than ()
|
|
4023 "Inserts the entity '>'."
|
|
4024 (interactive)
|
|
4025 (insert "<"))
|
|
4026
|
0
|
4027 (defun hm--html-smart-less-than ()
|
|
4028 "Insert a '<' or the entity '<' if you execute this command twice."
|
|
4029 (interactive)
|
|
4030 (if (and (eq last-command 'hm--html-smart-less-than)
|
|
4031 hm--just-insert-less-than)
|
|
4032 (progn
|
|
4033 (delete-char -1)
|
2
|
4034 (hm--html-less-than)
|
0
|
4035 (setq hm--just-insert-less-than nil))
|
|
4036 (insert ?<)
|
|
4037 (setq hm--just-insert-less-than t)))
|
|
4038
|
|
4039 (defvar hm--just-insert-greater-than nil
|
|
4040 "Internal variable.")
|
|
4041
|
2
|
4042 (defun hm--html-greater-than ()
|
|
4043 "Inserts the entity '>'."
|
|
4044 (interactive)
|
|
4045 (insert ">"))
|
|
4046
|
0
|
4047 (defun hm--html-smart-greater-than ()
|
|
4048 "Insert a '>' or the entity '>' if you execute this command twice."
|
|
4049 (interactive)
|
|
4050 (if (and (eq last-command 'hm--html-smart-greater-than)
|
|
4051 hm--just-insert-greater-than)
|
|
4052 (progn
|
|
4053 (delete-char -1)
|
2
|
4054 (hm--html-greater-than)
|
0
|
4055 (setq hm--just-insert-greater-than nil))
|
|
4056 (insert ?>)
|
155
|
4057 ;; Next line added by Bob Weiner, Altrasoft, 11/21/96.
|
|
4058 #+infodock (if id-html-auto-indent (indent-according-to-mode))
|
0
|
4059 (setq hm--just-insert-greater-than t)))
|
|
4060
|
|
4061
|
2
|
4062 (defvar hm--just-insert-ampersand nil
|
|
4063 "Internal variable.")
|
|
4064
|
|
4065 (defun hm--html-ampersand ()
|
|
4066 "Inserts the entity '&'."
|
|
4067 (interactive)
|
|
4068 (insert "&"))
|
|
4069
|
|
4070 (defun hm--html-smart-ampersand ()
|
|
4071 "Insert a '&' or the entity '&' if you execute this command twice."
|
|
4072 (interactive)
|
|
4073 (if (and (eq last-command 'hm--html-smart-ampersand)
|
|
4074 hm--just-insert-ampersand)
|
|
4075 (progn
|
|
4076 (delete-char -1)
|
|
4077 (hm--html-ampersand)
|
|
4078 (setq hm--just-insert-ampersand nil))
|
|
4079 (insert ?&)
|
|
4080 (setq hm--just-insert-ampersand t)))
|
|
4081
|
|
4082
|
0
|
4083 ;;;
|
|
4084 ; sending the contents of a html buffer to netscape
|
|
4085 ; (Thanks to Adrian Aichner for providing this function)
|
|
4086
|
|
4087 (defun hm--html-send-buffer-to-netscape (buffer
|
|
4088 &optional new-netscape new-window)
|
|
4089 "View html buffer with Netscape.
|
|
4090 This should be changed in the fututure, so that it doesn't need vm."
|
|
4091 (interactive)
|
|
4092 (require 'vm)
|
|
4093 (if new-netscape
|
|
4094 (vm-run-background-command vm-netscape-program buffer-file-name)
|
|
4095 (or (equal 0
|
|
4096 (vm-run-command vm-netscape-program
|
|
4097 "-remote"
|
|
4098 (concat "openURL(file://localhost"
|
|
4099 buffer-file-name
|
|
4100 (if new-window ", new-window" "")
|
|
4101 ")")))
|
|
4102 (hm--html-send-buffer-to-netscape buffer t new-window))))
|
|
4103
|
|
4104
|
|
4105
|
|
4106 ;;;
|
|
4107 ; some other usefull functions
|
|
4108 ;
|
|
4109
|
|
4110 (defun hm--html-remove-numeric-names ()
|
|
4111 "Remove the number in numbered links in the current buffer.
|
|
4112 Eg: the string \"Name=3\". The function asks the user every time whether
|
|
4113 the number should be removed."
|
|
4114 (interactive)
|
|
4115 (save-excursion
|
|
4116 (goto-char (point-min))
|
|
4117 (query-replace-regexp "name=\"?[0-9]+\"?+[ \t]*" "")))
|
|
4118
|
|
4119 ;;This should be extended in the future to use also other viewers.
|
|
4120 (defun hm--html-view-www-package-docu ()
|
|
4121 "View the WWW documentation of the package."
|
|
4122 (interactive)
|
102
|
4123 (w3-fetch (concat "http://www.tnt.uni-hannover.de"
|
|
4124 "/~muenkel/software/own/hm--html-menus/overview.html")))
|
|
4125
|
0
|
4126
|
|
4127 ;;;
|
|
4128 ; Bug reporting
|
|
4129 ;
|
|
4130
|
|
4131 (defun hm--html-submit-bug-report ()
|
|
4132 "Submit via mail a bug report on hm--html-menus."
|
|
4133 (interactive)
|
|
4134 (require 'reporter)
|
|
4135 (let ((reporter-prompt-for-summary-p t))
|
|
4136 (reporter-submit-bug-report
|
|
4137 hm--html-menus-package-maintainer
|
|
4138 (concat hm--html-menus-package-name
|
|
4139 " "
|
|
4140 hm--html-menus-package-version)
|
|
4141 (list 'emacs-version
|
|
4142 'major-mode
|
|
4143 'hm--html-automatic-changed-comment
|
|
4144 'hm--html-automatic-created-comment
|
153
|
4145 'hm--html-automatic-create-modified-line
|
0
|
4146 'hm--html-automatic-expand-templates
|
153
|
4147 'hm--html-automatic-update-modified-line
|
|
4148 'hm--html-automatic-update-title-date
|
|
4149 'hm--html-changed-comment-prefix
|
|
4150 'hm--html-comment-infix
|
|
4151 'hm--html-created-comment-prefix
|
0
|
4152 'hm--html-expert
|
|
4153 'hm--html-favorite-http-server-host-name
|
|
4154 'hm--html-file-path-alist
|
|
4155 'hm--html-ftp-hostname:port-alist
|
|
4156 'hm--html-ftp-hostname:port-default
|
|
4157 'hm--html-ftp-path-alist
|
|
4158 'hm--html-gopher-anchor-alist
|
|
4159 'hm--html-gopher-doctype-alist
|
|
4160 'hm--html-gopher-doctype-default
|
|
4161 'hm--html-gopher-hostname:port-alist
|
|
4162 'hm--html-gopher-hostname:port-default
|
|
4163 'hm--html-html-hostname:port-alist
|
|
4164 'hm--html-html-hostname:port-default
|
|
4165 'hm--html-html-path-alist
|
|
4166 'hm--html-info-hostname:port-alist
|
|
4167 'hm--html-info-hostname:port-default
|
|
4168 'hm--html-info-path-alist
|
|
4169 'hm--html-local-proggate-path-alist
|
|
4170 'hm--html-mail-hostname:port-alist
|
|
4171 'hm--html-mail-hostname:port-default
|
|
4172 'hm--html-mail-path-alist
|
|
4173 'hm--html-marc
|
|
4174 'hm--html-menu-load-hook
|
153
|
4175 'hm--html-modified-end-tag
|
|
4176 'hm--html-modified-insert-before
|
|
4177 'hm--html-modified-prefix
|
|
4178 'hm--html-modified-start-tag
|
0
|
4179 'hm--html-proggate-allowed-file
|
|
4180 'hm--html-proggate-hostname:port-alist
|
|
4181 'hm--html-proggate-hostname:port-default
|
|
4182 'hm--html-server-side-include-command-alist
|
|
4183 'hm--html-server-side-include-command-with-parameter-alist
|
|
4184 'hm--html-signature-file
|
|
4185 'hm--html-template-dir
|
|
4186 'hm--html-url-alist
|
|
4187 'hm--html-user-config-file
|
98
|
4188 'hm--html-site-config-file
|
0
|
4189 'hm--html-username
|
|
4190 'hm--html-wais-hostname:port-alist
|
|
4191 'hm--html-wais-hostname:port-default
|
|
4192 'hm--html-wais-path-alist
|
|
4193 'hm--html-wais-servername:port-alist
|
|
4194 'hm--html-wais-servername:port-default
|
|
4195 'html-document-previewer
|
2
|
4196 'hm--html-region-mode
|
0
|
4197 'html-sigusr1-signal-value
|
|
4198 )
|
|
4199 nil
|
|
4200 nil
|
|
4201 "Decribe your Bug: "
|
|
4202 )))
|
|
4203
|
|
4204
|
|
4205 ;;;
|
|
4206 ; hook adding functions
|
|
4207 ;
|
|
4208
|
|
4209 (if (adapt-xemacsp)
|
|
4210 (progn
|
|
4211
|
2
|
4212 (add-hook 'zmacs-activate-region-hook
|
|
4213 'hm--html-switch-region-modes-on)
|
0
|
4214
|
|
4215 (add-hook 'zmacs-deactivate-region-hook
|
2
|
4216 'hm--html-switch-region-modes-off)
|
0
|
4217
|
|
4218 )
|
|
4219
|
|
4220 (transient-mark-mode t)
|
|
4221
|
|
4222 (add-hook 'activate-mark-hook
|
2
|
4223 'hm--html-switch-region-modes-on)
|
0
|
4224
|
|
4225 (add-hook 'deactivate-mark-hook
|
2
|
4226 'hm--html-switch-region-modes-off)
|
0
|
4227
|
|
4228 )
|
|
4229
|
|
4230
|
|
4231 ;;;
|
|
4232 ; Environment loading
|
|
4233 ;
|
|
4234
|
|
4235 (defun hm--html-load-config-files ()
|
|
4236 "Load the html configuration files.
|
|
4237 First, the system config file (detemined by the environment variable
|
98
|
4238 HTML_CONFIG_FILE; normaly hm--html-configuration.el(c)) is loaded.
|
|
4239 At second a site config file is loaded, if the environment variable
|
|
4240 HTML_SITE_CONFIG_FILE or the lisp variable `hm--html-site-config-file'
|
|
4241 is set to such a file.
|
|
4242 At least the user config file (determined by the environment variable
|
0
|
4243 HTML_USER_CONFIG_FILE; normaly the file ~/.hm--html-configuration.el(c)).
|
|
4244 If no HTML_CONFIG_FILE exists, then the file hm--html-configuration.el(c)
|
|
4245 is searched in one of the lisp load path directories.
|
|
4246 If no HTML_USER_CONFIG_FILE exists, then the variable
|
|
4247 `hm--html-user-config-file' is checked. If this variable is nil or the file
|
|
4248 also doesn't exist, then the file ~/.hm--html-configuration.el(c) is used."
|
|
4249 (interactive)
|
|
4250 ;; at first the system config file
|
|
4251 (if (and (stringp (getenv "HTML_CONFIG_FILE"))
|
|
4252 (file-exists-p
|
|
4253 (expand-file-name
|
|
4254 (getenv "HTML_CONFIG_FILE"))))
|
|
4255 (load-library (expand-file-name (getenv "HTML_CONFIG_FILE")))
|
|
4256 (load-library "hm--html-configuration"))
|
98
|
4257
|
|
4258 ;; at second the site config file
|
|
4259 (if (and (stringp (getenv "HTML_SITE_CONFIG_FILE"))
|
|
4260 (file-exists-p
|
|
4261 (expand-file-name
|
|
4262 (getenv "HTML_SITE_CONFIG_FILE"))))
|
|
4263 (load-file (expand-file-name (getenv "HTML_SITE_CONFIG_FILE")))
|
|
4264 (when (and (boundp 'hm--html-site-config-file)
|
|
4265 (stringp hm--html-site-config-file)
|
|
4266 (file-exists-p (expand-file-name hm--html-site-config-file)))
|
|
4267 (load-file (expand-file-name hm--html-site-config-file))))
|
0
|
4268
|
|
4269 ;; and now the user config file
|
|
4270 (cond ((and (stringp (getenv "HTML_USER_CONFIG_FILE"))
|
|
4271 (file-exists-p
|
|
4272 (expand-file-name
|
|
4273 (getenv "HTML_USER_CONFIG_FILE"))))
|
|
4274 (load-file (expand-file-name (getenv "HTML_USER_CONFIG_FILE"))))
|
|
4275 ((and (boundp 'hm--html-user-config-file)
|
|
4276 (stringp hm--html-user-config-file)
|
|
4277 (file-exists-p (expand-file-name hm--html-user-config-file)))
|
|
4278 (load-file (expand-file-name hm--html-user-config-file)))
|
|
4279 ((file-exists-p (expand-file-name "~/.hm--html-configuration.elc"))
|
|
4280 (load-file (expand-file-name "~/.hm--html-configuration.elc")))
|
|
4281 ((file-exists-p (expand-file-name "~/.hm--html-configuration.el"))
|
|
4282 (load-file (expand-file-name "~/.hm--html-configuration.el")))
|
|
4283 (t
|
|
4284 (message (concat "WARNING: No HTML User Config File ! "
|
|
4285 "Look at hm--html-load-config-files !")))
|
|
4286 )
|
|
4287 )
|
|
4288
|
|
4289
|
2
|
4290 ;;; quotify href
|
|
4291
|
|
4292 (defvar hm--html-quotify-href-regexp
|
|
4293 "<[aA][ \t\n]+\\([nN][aA][mM][eE]=[a-zA-Z0-9]+[ \t\n]+\\)?[hH][rR][eE][fF]="
|
|
4294 "Regular expression used for searching hrefs.")
|
|
4295
|
|
4296 (defun hm--html-quotify-hrefs ()
|
|
4297 "Insert quotes around all HREF and NAME attribute value literals.
|
|
4298
|
|
4299 This remedies the problem with old HTML files that can't be processed
|
|
4300 by SGML parsers. That is, changes <A HREF=foo> to <A HREF=\"foo\">.
|
|
4301
|
|
4302 Look also at the variable `hm--html-quotify-href-regexp'."
|
|
4303 (interactive)
|
|
4304 (save-excursion
|
|
4305 (goto-char (point-min))
|
|
4306 (while
|
|
4307 (re-search-forward hm--html-quotify-href-regexp
|
|
4308 (point-max)
|
|
4309 t)
|
|
4310 (cond
|
|
4311 ((null (looking-at "\""))
|
|
4312 (insert "\"")
|
|
4313 (re-search-forward "[ \t\n>]" (point-max) t)
|
|
4314 (forward-char -1)
|
|
4315 (insert "\""))))))
|
|
4316
|
|
4317
|
|
4318
|
|
4319 (provide 'hm--html)
|