Mercurial > hg > xemacs-beta
comparison lisp/hm--html-menus/hm--html.el @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 6a22abad6937 |
children | 0d2f883870bc |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
1 ;;; $Id: hm--html.el,v 1.6 1997/03/26 22:42:39 steve Exp $ | 1 ;;; $Id: hm--html.el,v 1.1.1.1 1996/12/18 22:43:20 steve Exp $ |
2 ;;; | 2 ;;; |
3 ;;; Copyright (C) 1993 - 1997 Heiko Muenkel | 3 ;;; Copyright (C) 1993, 1994, 1995, 1996 Heiko Muenkel |
4 ;;; email: muenkel@tnt.uni-hannover.de | 4 ;;; email: muenkel@tnt.uni-hannover.de |
5 ;;; | 5 ;;; |
6 ;;; This program is free software; you can redistribute it and/or modify | 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 | 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) | 8 ;;; the Free Software Foundation; either version 2, or (at your option) |
25 ;;; Installation: | 25 ;;; Installation: |
26 ;;; | 26 ;;; |
27 ;;; Put this file in one of your load path directories. | 27 ;;; Put this file in one of your load path directories. |
28 ;;; | 28 ;;; |
29 | 29 |
30 (defun hm--html-set-marker-at-position (&optional position) | 30 ;(require 'hm--date) |
31 "Creates a new marker and set the marker at the POSITION. | 31 ;(require 'adapt) |
32 If POSITION is nil, then the marker is set at the current point. | 32 |
33 The return value is the marker." | 33 |
34 (let ((marker (make-marker))) | 34 ;;; Indentation |
35 (if position | 35 |
36 (set-marker marker position) | 36 (defun hm--html-indent-region (begin end) |
37 (set-marker marker (point))))) | 37 "Indents the region between BEGIN and END according to the major mode." |
38 (when (< end begin) | |
39 (let ((a end)) | |
40 (setq end start) | |
41 (setq start a))) | |
42 (save-excursion | |
43 (goto-char begin) | |
44 (let ((old-point)) | |
45 (while (and (<= (point) end) | |
46 (not (eq (point) old-point))) | |
47 (setq old-point (point)) | |
48 (indent-according-to-mode) | |
49 (forward-line) | |
50 )))) | |
51 | |
38 | 52 |
39 ;;; Functions for adding html commands which consists of a start and a | 53 ;;; Functions for adding html commands which consists of a start and a |
40 ;;; end tag and some text between them. (Basicfunctions) | 54 ;;; end tag and some text between them. (Basicfunctions) |
41 | 55 |
42 (defun hm--html-add-tags (function-insert-start-tag | 56 (defun hm--html-add-tags (function-insert-start-tag |
52 The first parameter specifies the funtion which insert the start tag | 66 The first parameter specifies the funtion which insert the start tag |
53 and the third parameter specifies the function which insert the end tag. | 67 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 | 68 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. | 69 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 | 70 The fifth parameter is optional. If it exists, it specifies a function which |
57 inserts the sixth parameter (the middle-start-tag) between the start and the | 71 inserts the sixth parameter (the middle-start-tag) between the start and the end |
58 end tag." | 72 tag." |
73 ; (interactive "aFunction, which adds the HTML start tag: \n\ | |
74 ;aFunction, which adds the HTML end tag: \n\ | |
75 ;sThe HTML start tag: \n\ | |
76 ;sThe HTML end tag: ") | |
59 (eval (list function-insert-start-tag start-tag)) | 77 (eval (list function-insert-start-tag start-tag)) |
60 (if function-insert-middle-start-tag | 78 (if function-insert-middle-start-tag |
61 (eval (list function-insert-middle-start-tag middle-start-tag))) | 79 (eval (list function-insert-middle-start-tag middle-start-tag))) |
62 (let ((position (hm--html-set-marker-at-position (point)))) | 80 (let ((position (point))) |
63 (if function-insert-middle-end-tag | 81 (if function-insert-middle-end-tag |
64 (eval (list function-insert-middle-end-tag middle-end-tag))) | 82 (eval (list function-insert-middle-end-tag middle-end-tag))) |
65 (if function-insert-end-tag | 83 (if function-insert-end-tag |
66 (eval (list function-insert-end-tag end-tag))) | 84 (eval (list function-insert-end-tag end-tag))) |
67 (goto-char position))) | 85 (goto-char position))) |
69 | 87 |
70 (defun hm--html-add-tags-to-region (function-insert-start-tag | 88 (defun hm--html-add-tags-to-region (function-insert-start-tag |
71 start-tag | 89 start-tag |
72 function-insert-end-tag | 90 function-insert-end-tag |
73 end-tag | 91 end-tag |
74 &optional | 92 &optional function-insert-middle-tag |
75 function-insert-middle-tag | 93 &optional middle-tag) |
76 middle-tag) | |
77 "Adds the start and the end html tag to the active region. | 94 "Adds the start and the end html tag to the active region. |
78 The first parameter specifies the funtion which insert the start tag | 95 The first parameter specifies the funtion which insert the start tag |
79 and the third parameter specifies the function which insert the end tag. | 96 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 | 97 The second parameter is the string for the start tag and the fourth parameter |
81 is the string for the end tag. | 98 is the string for the end tag. |
82 The fifth parameter is optional. If it exists, it specifies a function which | 99 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 | 100 inserts the sixth parameter (the middle-tag) between the start and the end |
84 tag." | 101 tag." |
102 ; (interactive "aFunction, which adds the html start tag: \n\ | |
103 ;aFunction, which adds the html end tag: \n\ | |
104 ;sThe HTML start tag: \n\ | |
105 ;sThe HTML end tag: ") | |
85 (save-window-excursion | 106 (save-window-excursion |
86 (let ((start (hm--html-set-marker-at-position (region-beginning))) | 107 (let ((start (region-beginning)) |
87 (end (region-end))) | 108 (end (region-end))) |
88 (goto-char end) | 109 (goto-char end) |
89 (eval (list function-insert-end-tag end-tag)) | 110 (eval (list function-insert-end-tag end-tag)) |
90 (goto-char start) | 111 (goto-char start) |
91 (eval (list function-insert-start-tag start-tag)) | 112 (eval (list function-insert-start-tag start-tag)) |
98 "Inserts the HTML start tag 'tag' without a Newline. | 119 "Inserts the HTML start tag 'tag' without a Newline. |
99 The parameter must be a string (i.e. \"<B>\")" | 120 The parameter must be a string (i.e. \"<B>\")" |
100 (let ((start (point))) | 121 (let ((start (point))) |
101 (insert tag) | 122 (insert tag) |
102 (hm--html-indent-region start (point)))) | 123 (hm--html-indent-region start (point)))) |
124 ; (html-maybe-deemphasize-region start (- (point) 1)))) | |
103 | 125 |
104 | 126 |
105 (defun hm--html-insert-end-tag (tag) | 127 (defun hm--html-insert-end-tag (tag) |
106 "Inserts the HTML end tag 'tag' without a Newline. | 128 "Inserts the HTML end tag 'tag' without a Newline. |
107 The parameter must be a string (i.e. \"</B>\")" | 129 The parameter must be a string (i.e. \"</B>\")" |
108 (let ((start (point))) | 130 (let ((start (point))) |
109 (insert tag) | 131 (insert tag) |
110 (hm--html-indent-region start (point)))) | 132 (hm--html-indent-region start (point)))) |
133 ; (html-maybe-deemphasize-region start (- (point) 1)))) | |
111 | 134 |
112 | 135 |
113 (defun hm--html-insert-start-tag-with-newline (tag) | 136 (defun hm--html-insert-start-tag-with-newline (tag) |
114 "Inserts the HTML start tag 'tag' with a Newline. | 137 "Inserts the HTML start tag 'tag' with a Newline. |
115 The parameter must be a string (i.e. \"<PRE>\")" | 138 The parameter must be a string (i.e. \"<PRE>\")" |
116 (let ((start (point))) | 139 (let ((start (point))) |
117 (insert tag) | 140 (insert tag) |
118 (hm--html-indent-region start (point)) | 141 (hm--html-indent-region start (point)) |
119 ) | 142 ) |
143 ; (html-maybe-deemphasize-region start (- (point) 1))) | |
120 (insert "\n")) | 144 (insert "\n")) |
121 | 145 |
122 | 146 |
123 (defun hm--html-insert-end-tag-with-newline (tag) | 147 (defun hm--html-insert-end-tag-with-newline (tag) |
124 "Inserts the HTML end tag 'tag' with a Newline. | 148 "Inserts the HTML end tag 'tag' with a Newline. |
125 The parameter must be a string (i.e. \"</PRE>\")" | 149 The parameter must be a string (i.e. \"</PRE>\")" |
126 (insert "\n") | 150 (insert "\n") |
127 (let ((start (point))) | 151 (let ((start (point))) |
128 (insert tag) | 152 (insert tag) |
129 (hm--html-indent-region start (point)))) | 153 (hm--html-indent-region start (point)))) |
154 ; (html-maybe-deemphasize-region start (- (point) 1)))) | |
130 | 155 |
131 | 156 |
132 | 157 |
133 ;;; Functions which add simple tags of the form <tag> | 158 ;;; Functions which add simple tags of the form <tag> |
134 | 159 |
146 (defun hm--html-add-list-or-menu-item-to-region () | 171 (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." | 172 "Adds the tags for a menu item to the region in the current buffer." |
148 (interactive) | 173 (interactive) |
149 (hm--html-add-tags-to-region 'hm--html-insert-start-tag "<LI> " | 174 (hm--html-add-tags-to-region 'hm--html-insert-start-tag "<LI> " |
150 'hm--html-insert-end-tag " </LI>")) | 175 'hm--html-insert-end-tag " </LI>")) |
151 | |
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 | |
156 (concat "<BASEFONT SIZE=" size ">"))) | |
157 | 176 |
158 (defun hm--html-add-line-break () | 177 (defun hm--html-add-line-break () |
159 "Adds the HTML tag for a line break." | 178 "Adds the HTML tag for a line break." |
160 (interactive) | 179 (interactive) |
161 (hm--html-add-tags 'hm--html-insert-start-tag "<BR>")) | 180 (hm--html-add-tags 'hm--html-insert-start-tag "<BR>")) |
188 (defun hm--html-add-paragraph-separator () | 207 (defun hm--html-add-paragraph-separator () |
189 "Adds the tag for a paragraph seperator." | 208 "Adds the tag for a paragraph seperator." |
190 (interactive) | 209 (interactive) |
191 (hm--html-add-tags 'hm--html-insert-start-tag "<P>")) | 210 (hm--html-add-tags 'hm--html-insert-start-tag "<P>")) |
192 | 211 |
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 | |
210 (concat ;"\\(<title\\)\\|\\(<head\\)\\|\\(<html\\)\\|" | |
211 "\\(<title\\)\\|" | |
212 "\\(<isindex\\)\\|\\(<base\\)\\|\\(<link\\)\\|" | |
213 "\\(<meta\\)") | |
214 end-point | |
215 t) | |
216 (beginning-of-line) | |
217 end-point)))) | |
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) | |
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 ">")))))) | |
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) | |
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 ">")))))) | |
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) | |
283 (point))) | |
284 (goto-char point) | |
285 (hm--html-search-place-for-element-in-head head-end-point) | |
286 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | |
287 (concat "<META " | |
288 (if name-instead-of-http-equiv | |
289 "NAME=\"" | |
290 "HTTP-EQUIV=\"") | |
291 name | |
292 "\" CONTENT=\"" | |
293 content | |
294 "\">"))))) | |
295 | 212 |
296 | 213 |
297 ;;; Functions which include something in HTML- documents | 214 ;;; Functions which include something in HTML- documents |
298 | 215 |
299 (defvar hm--html-url-history-list nil | 216 (defvar hm--html-url-history-list nil |
344 "Function reads the value for the \"ALT\"- attribute in IMG tags. | 261 "Function reads the value for the \"ALT\"- attribute in IMG tags. |
345 URL will be used as the default URL for the external viewer." | 262 URL will be used as the default URL for the external viewer." |
346 (let ((alttype | 263 (let ((alttype |
347 (string-to-int | 264 (string-to-int |
348 (completing-read | 265 (completing-read |
266 ; "0: No ALT atribute, 1: ALT=\"\", 2: ALT=Text, 3: ALT=External Viewer: " | |
349 "0: No ALT atribute, 1: ALT=\"\", 2: ALT=Text: " | 267 "0: No ALT atribute, 1: ALT=\"\", 2: ALT=Text: " |
268 ; '(("0") ("1") ("2") ("3")) | |
350 '(("0") ("1") ("2")) | 269 '(("0") ("1") ("2")) |
351 nil | 270 nil |
352 t | 271 t |
353 "2")))) | 272 "2")))) |
354 (cond ((= alttype 0) nil) | 273 (cond ((= alttype 0) nil) |
358 (substring (file-name-nondirectory url) | 277 (substring (file-name-nondirectory url) |
359 0 | 278 0 |
360 (string-match | 279 (string-match |
361 "\\." | 280 "\\." |
362 (file-name-nondirectory url))))) | 281 (file-name-nondirectory url))))) |
282 ; ((= alttype 3) (concat "<A HREF=\"" | |
283 ; url | |
284 ; "\">" | |
285 ; (file-name-nondirectory url) | |
286 ; "</A>")) | |
363 ))) | 287 ))) |
364 | 288 |
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 | |
448 | |
449 (when (adapt-emacs19p) | |
450 (defvar :ask ':ask)) | |
451 | |
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 | |
482 | 289 |
483 (defun hm--html-add-image-bottom (href alt) | 290 (defun hm--html-add-image-bottom (href alt) |
484 "Add an image, bottom aligned." | 291 "Add an image, bottom aligned." |
485 (interactive (let ((url (hm--html-read-url "Image URL: "))) | 292 (interactive (let ((url (hm--html-read-url "Image URL: "))) |
486 (list url (hm--html-read-altenate url)))) | 293 (list url (hm--html-read-altenate url)))) |
554 "\" VALUE=\"" | 361 "\" VALUE=\"" |
555 value | 362 value |
556 "\">"))) | 363 "\">"))) |
557 | 364 |
558 | 365 |
366 (defun hm--html-add-server-side-include-file (file) | |
367 "This function adds a server side include file directive in the buffer. | |
368 The directive is only supported by the NCSA http daemon." | |
369 (interactive "FInclude File: ") | |
370 (let ((start (point))) | |
371 (if (string= file "") | |
372 (error "ERROR: No filename specified !") | |
373 (insert "<INC SRV \"" file "\">")))) | |
374 ; (html-maybe-deemphasize-region (1+ start) (1- (point)))))) | |
375 | |
376 | |
377 (defun hm--html-add-server-side-include-command-with-isindex-parameter | |
378 (command) | |
379 "This function adds a server side include command directive in the buffer. | |
380 The include command uses the \"isindex\"- parameter for the specified command." | |
381 (interactive (list | |
382 (completing-read "Include Command: " | |
383 hm--html-server-side-include-command-alist))) | |
384 (hm--html-add-server-side-include-command command t)) | |
385 | |
386 | |
387 (defun hm--html-add-server-side-include-command (command &optional srvurl) | |
388 "This function adds a server side include command directive in the buffer. | |
389 The directive is only supported by the NCSA http daemon. | |
390 If SRVURL is t, then the attribute srvurl instead of srv is used for the | |
391 include command. With srvurl, the include command uses the \"isindex\"- | |
392 parameter for the specified command." | |
393 (interactive (list | |
394 (completing-read "Include Command: " | |
395 hm--html-server-side-include-command-alist))) | |
396 (let ((start (point)) | |
397 (attribute (if srvurl "SRVURL" "SRV"))) | |
398 (if (string= command "") | |
399 (error "ERROR: No command specified !") | |
400 (if (= ?| (string-to-char command)) | |
401 (insert "<INC " attribute" \"" command "\">") | |
402 (insert "<INC " attribute " \"|" command "\">"))))) | |
403 ; (html-maybe-deemphasize-region (1+ start) (1- (point))))))) | |
404 | |
405 | |
406 ;(defun hm--html-add-server-side-include-command-with-parameter (command | |
407 ; parameter) | |
408 ; "This function adds a server side include command directive in the buffer. | |
409 ;The directive is only supported by the NCSA http daemon." | |
410 ; (interactive (list | |
411 ; (completing-read | |
412 ; "Include Command: " | |
413 ; hm--html-server-side-include-command-with-parameter-alist) | |
414 ; (read-string "Parameterlist sepearted by '?': "))) | |
415 ; (let ((start (point))) | |
416 ; (if (string= command "") | |
417 ; (error "ERROR: No command specified !") | |
418 ; (if (string= parameter "") | |
419 ; (error "ERROR: No parameter specified !") | |
420 ; (if (= ?| (string-to-char command)) | |
421 ; (if (= ?? (string-to-char parameter)) | |
422 ; (insert "<INC SRVURL \"" command parameter "\">") | |
423 ; (insert "<INC SRVURL \"" command "?" parameter "\">")) | |
424 ; (if (= ?? (string-to-char parameter)) | |
425 ; (insert "<INC SRVURL \"|" command parameter "\">") | |
426 ; (insert "<INC SRVURL \"|" command "?" parameter "\">"))) | |
427 ; (html-maybe-deemphasize-region (1+ start) (1- (point))))))) | |
428 | |
429 | |
559 | 430 |
560 ;;; Functions, which adds tags of the form <starttag> ... </endtag> | 431 ;;; Functions, which adds tags of the form <starttag> ... </endtag> |
561 | 432 |
562 (defun hm--html-add-big () | 433 (defun hm--html-add-big () |
563 "Adds the HTML tags for Big at the point in the current buffer." | 434 "Adds the HTML tags for Big at the point in the current buffer." |
824 "<!-- " | 695 "<!-- " |
825 'hm--html-insert-end-tag | 696 'hm--html-insert-end-tag |
826 " -->")) | 697 " -->")) |
827 | 698 |
828 | 699 |
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 | |
838 (defun hm--html-add-document-division-to-region (alignment) | |
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 | |
846 | 700 |
847 (defun hm--html-add-preformated () | 701 (defun hm--html-add-preformated () |
848 "Adds the HTML tags for preformated text at the point in the current buffer." | 702 "Adds the HTML tags for preformated text at the point in the current buffer." |
849 (interactive) | 703 (interactive) |
850 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 704 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
860 "<PRE>" | 714 "<PRE>" |
861 'hm--html-insert-end-tag-with-newline | 715 'hm--html-insert-end-tag-with-newline |
862 "</PRE>")) | 716 "</PRE>")) |
863 | 717 |
864 | 718 |
719 (defun hm--html-add-plaintext () | |
720 "Adds the HTML tags for plaintext." | |
721 (interactive) | |
722 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | |
723 "<XMP>" | |
724 'hm--html-insert-end-tag-with-newline | |
725 "</XMP>")) | |
726 | |
727 | |
728 (defun hm--html-add-plaintext-to-region () | |
729 "Adds the HTML tags for plaintext to the region." | |
730 (interactive) | |
731 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | |
732 "<XMP>" | |
733 'hm--html-insert-end-tag-with-newline | |
734 "</XMP>")) | |
735 | |
736 | |
865 (defun hm--html-add-blockquote () | 737 (defun hm--html-add-blockquote () |
866 "Adds the HTML tags for blockquote." | 738 "Adds the HTML tags for blockquote." |
867 (interactive) | 739 (interactive) |
868 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 740 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
869 "<BLOCKQUOTE>" | 741 "<BLOCKQUOTE>" |
877 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 749 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
878 "<BLOCKQUOTE>" | 750 "<BLOCKQUOTE>" |
879 'hm--html-insert-end-tag-with-newline | 751 'hm--html-insert-end-tag-with-newline |
880 "</BLOCKQUOTE>")) | 752 "</BLOCKQUOTE>")) |
881 | 753 |
882 (defun hm--html-add-script () | 754 (defun hm--html-add-abstract () |
883 "Adds the HTML tags for script." | 755 "Adds the HTML tags for abstract text at the point in the current buffer." |
884 (interactive) | 756 (interactive) |
885 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 757 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
886 "<SCRIPT>" | 758 "<ABSTRACT>" |
887 'hm--html-insert-end-tag-with-newline | 759 'hm--html-insert-end-tag-with-newline |
888 "</SCRIPT>")) | 760 "</ABSTRACT>")) |
889 | 761 |
890 | 762 |
891 (defun hm--html-add-script-to-region () | 763 (defun hm--html-add-abstract-to-region () |
892 "Adds the HTML tags for script to the region." | 764 "Adds the HTML tags for abstract text to the region." |
893 (interactive) | 765 (interactive) |
894 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 766 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
895 "<SCRIPT>" | 767 "<ABSTRACT>" |
896 'hm--html-insert-end-tag-with-newline | 768 'hm--html-insert-end-tag-with-newline |
897 "</SCRIPT>")) | 769 "</ABSTRACT>")) |
898 | 770 |
899 (defun hm--html-add-style () | 771 |
900 "Adds the HTML tags for style." | |
901 (interactive) | |
902 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | |
903 "<STYLE>" | |
904 'hm--html-insert-end-tag-with-newline | |
905 "</STYLE>")) | |
906 | |
907 | |
908 (defun hm--html-add-style-to-region () | |
909 "Adds the HTML tags for style to the region." | |
910 (interactive) | |
911 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | |
912 "<STYLE>" | |
913 'hm--html-insert-end-tag-with-newline | |
914 "</STYLE>")) | |
915 | 772 |
916 (defun hm--html-add-strikethru () | 773 (defun hm--html-add-strikethru () |
917 "Adds the HTML tags for Strikethru at the point in the current buffer." | 774 "Adds the HTML tags for Strikethru at the point in the current buffer." |
918 (interactive) | 775 (interactive) |
919 (hm--html-add-tags 'hm--html-insert-start-tag | 776 (hm--html-add-tags 'hm--html-insert-start-tag |
920 "<STRIKE>" | 777 "<S>" |
921 'hm--html-insert-end-tag | 778 'hm--html-insert-end-tag |
922 "</STRIKE>")) | 779 "</S>")) |
923 | 780 |
924 | 781 |
925 (defun hm--html-add-strikethru-to-region () | 782 (defun hm--html-add-strikethru-to-region () |
926 "Adds the HTML tags for Strikethru to the region." | 783 "Adds the HTML tags for Strikethru to the region." |
927 (interactive) | 784 (interactive) |
928 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | 785 (hm--html-add-tags-to-region 'hm--html-insert-start-tag |
929 "<STRIKE>" | 786 "<S>" |
930 'hm--html-insert-end-tag | 787 'hm--html-insert-end-tag |
931 "</STRIKE>")) | 788 "</S>")) |
932 | 789 |
933 | 790 |
934 (defun hm--html-add-superscript () | 791 (defun hm--html-add-superscript () |
935 "Adds the HTML tags for Superscript at the point in the current buffer." | 792 "Adds the HTML tags for Superscript at the point in the current buffer." |
936 (interactive) | 793 (interactive) |
965 "<SUB>" | 822 "<SUB>" |
966 'hm--html-insert-end-tag | 823 'hm--html-insert-end-tag |
967 "</SUB>")) | 824 "</SUB>")) |
968 | 825 |
969 | 826 |
827 (defun hm--html-add-quote () | |
828 "Adds the HTML tags for Quote at the point in the current buffer." | |
829 (interactive) | |
830 (hm--html-add-tags 'hm--html-insert-start-tag | |
831 "<Q>" | |
832 'hm--html-insert-end-tag | |
833 "</Q>")) | |
834 | |
835 | |
836 (defun hm--html-add-quote-to-region () | |
837 "Adds the HTML tags for Quote to the region." | |
838 (interactive) | |
839 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
840 "<Q>" | |
841 'hm--html-insert-end-tag | |
842 "</Q>")) | |
843 | |
844 | |
845 (defun hm--html-add-person () | |
846 "Adds the HTML tags for Person at the point in the current buffer." | |
847 (interactive) | |
848 (hm--html-add-tags 'hm--html-insert-start-tag | |
849 "<PERSON>" | |
850 'hm--html-insert-end-tag | |
851 "</PERSON>")) | |
852 | |
853 | |
854 (defun hm--html-add-person-to-region () | |
855 "Adds the HTML tags for Person to the region." | |
856 (interactive) | |
857 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
858 "<PERSON>" | |
859 'hm--html-insert-end-tag | |
860 "</PERSON>")) | |
861 | |
862 | |
863 (defun hm--html-add-instance () | |
864 "Adds the HTML tags for Instance at the point in the current buffer." | |
865 (interactive) | |
866 (hm--html-add-tags 'hm--html-insert-start-tag | |
867 "<INS>" | |
868 'hm--html-insert-end-tag | |
869 "</INS>")) | |
870 | |
871 | |
872 (defun hm--html-add-instance-to-region () | |
873 "Adds the HTML tags for Instance to the region." | |
874 (interactive) | |
875 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
876 "<INS>" | |
877 'hm--html-insert-end-tag | |
878 "</INS>")) | |
879 | |
880 | |
970 (defun hm--html-add-option () | 881 (defun hm--html-add-option () |
971 "Adds the HTML tags for Option at the point in the current buffer." | 882 "Adds the HTML tags for Option at the point in the current buffer." |
972 (interactive) | 883 (interactive) |
973 (hm--html-add-tags 'hm--html-insert-start-tag | 884 (hm--html-add-tags 'hm--html-insert-start-tag |
974 "<OPT>" | 885 "<OPT>" |
983 "<OPT>" | 894 "<OPT>" |
984 'hm--html-insert-end-tag | 895 'hm--html-insert-end-tag |
985 "</OPT>")) | 896 "</OPT>")) |
986 | 897 |
987 | 898 |
988 (defun hm--html-read-font-size (&optional only-absolute-size) | 899 (defun hm--html-add-publication () |
989 "Reads the size for the FONT element. | 900 "Adds the HTML tags for Publication at the point in the current buffer." |
990 It returns nil, if the size should not be changed." | 901 (interactive) |
991 (let ((size | 902 (hm--html-add-tags 'hm--html-insert-start-tag |
992 (if only-absolute-size | 903 "<PUB>" |
993 (completing-read "The absolute font size (1 .. 7): " | 904 'hm--html-insert-end-tag |
994 '(("7") ("6") ("5") ("4") ("3") ("2") ("1")) | 905 "</PUB>")) |
995 nil | 906 |
996 t | 907 |
997 "4") | 908 (defun hm--html-add-publication-to-region () |
998 (completing-read "The relative (+/-) or absolute font size: " | 909 "Adds the HTML tags for Publication to the region." |
999 '(("-7") ("-6") ("-5") ("-4") ("-3") ("-2") ("-1") | 910 (interactive) |
1000 ("+7") ("+6") ("+5") ("+4") ("+3") ("+2") ("+1") | 911 (hm--html-add-tags-to-region 'hm--html-insert-start-tag |
1001 ("7") ("6") ("5") ("4") ("3") ("2") ("1") | 912 "<PUB>" |
1002 ("use-basefont")) | 913 'hm--html-insert-end-tag |
1003 nil | 914 "</PUB>")) |
1004 t | 915 |
1005 "use-basefont-size")))) | 916 |
1006 (if (string= size "use-basefont-size") | 917 (defun hm--html-add-author () |
1007 nil | 918 "Adds the HTML tags for Author at the point in the current buffer." |
1008 size))) | 919 (interactive) |
1009 | 920 (hm--html-add-tags 'hm--html-insert-start-tag |
1010 (defun hm--html-read-font-color () | 921 "<AUTHOR>" |
1011 "Reads the size for the FONT element. | 922 'hm--html-insert-end-tag |
1012 It returns nil, if the color should not be changed." | 923 "</AUTHOR>")) |
1013 (let ((color | 924 |
1014 (completing-read "The font color: " | 925 |
1015 '(("Black") ("Silver") ("Gray") ("White") ("Maroon") | 926 (defun hm--html-add-author-to-region () |
1016 ("Green") ("Lime") ("Olive") ("Yellow") ("Navy") | 927 "Adds the HTML tags for Author to the region." |
1017 ("Red") ("Purple") ("Fuchsia") ("Blue") ("Teal") | 928 (interactive) |
1018 ("Aqua") ("dont-set-color")) | 929 (hm--html-add-tags-to-region 'hm--html-insert-start-tag |
1019 nil | 930 "<AUTHOR>" |
1020 nil | 931 'hm--html-insert-end-tag |
1021 "dont-set-color"))) | 932 "</AUTHOR>")) |
1022 (if (string= color "dont-set-color") | 933 |
1023 nil | 934 |
1024 color))) | 935 (defun hm--html-add-editor () |
1025 | 936 "Adds the HTML tags for Editor at the point in the current buffer." |
1026 | 937 (interactive) |
1027 (defun hm--html-add-font (size color) | 938 (hm--html-add-tags 'hm--html-insert-start-tag |
1028 "Adds the HTML tags for Font at the point in the current buffer." | 939 "<EDITOR>" |
1029 (interactive (list (hm--html-read-font-size) | 940 'hm--html-insert-end-tag |
1030 (hm--html-read-font-color))) | 941 "</EDITOR>")) |
942 | |
943 | |
944 (defun hm--html-add-editor-to-region () | |
945 "Adds the HTML tags for Editor to the region." | |
946 (interactive) | |
947 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
948 "<EDITOR>" | |
949 'hm--html-insert-end-tag | |
950 "</EDITOR>")) | |
951 | |
952 | |
953 (defun hm--html-add-credits () | |
954 "Adds the HTML tags for Credits at the point in the current buffer." | |
955 (interactive) | |
956 (hm--html-add-tags 'hm--html-insert-start-tag | |
957 "<CREDITS>" | |
958 'hm--html-insert-end-tag | |
959 "</CREDITS>")) | |
960 | |
961 | |
962 (defun hm--html-add-credits-to-region () | |
963 "Adds the HTML tags for Credits to the region." | |
964 (interactive) | |
965 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
966 "<CREDITS>" | |
967 'hm--html-insert-end-tag | |
968 "</CREDITS>")) | |
969 | |
970 | |
971 (defun hm--html-add-copyright () | |
972 "Adds the HTML tags for Copyright at the point in the current buffer." | |
973 (interactive) | |
974 (hm--html-add-tags 'hm--html-insert-start-tag | |
975 "<COPYRIGHT>" | |
976 'hm--html-insert-end-tag | |
977 "</COPYRIGHT>")) | |
978 | |
979 | |
980 (defun hm--html-add-copyright-to-region () | |
981 "Adds the HTML tags for Copyright to the region." | |
982 (interactive) | |
983 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
984 "<COPYRIGHT>" | |
985 'hm--html-insert-end-tag | |
986 "</COPYRIGHT>")) | |
987 | |
988 | |
989 (defun hm--html-add-isbn () | |
990 "Adds the HTML tags for ISBN at the point in the current buffer." | |
991 (interactive) | |
992 (hm--html-add-tags 'hm--html-insert-start-tag | |
993 "<ISBN>" | |
994 'hm--html-insert-end-tag | |
995 "</ISBN>")) | |
996 | |
997 | |
998 (defun hm--html-add-isbn-to-region () | |
999 "Adds the HTML tags for ISBN to the region." | |
1000 (interactive) | |
1001 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1002 "<ISBN>" | |
1003 'hm--html-insert-end-tag | |
1004 "</ISBN>")) | |
1005 | |
1006 | |
1007 (defun hm--html-add-acronym () | |
1008 "Adds the HTML tags for Acronym at the point in the current buffer." | |
1009 (interactive) | |
1010 (hm--html-add-tags 'hm--html-insert-start-tag | |
1011 "<ACRONYM>" | |
1012 'hm--html-insert-end-tag | |
1013 "</ACRONYM>")) | |
1014 | |
1015 | |
1016 (defun hm--html-add-acronym-to-region () | |
1017 "Adds the HTML tags for Acronym to the region." | |
1018 (interactive) | |
1019 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1020 "<ACRONYM>" | |
1021 'hm--html-insert-end-tag | |
1022 "</ACRONYM>")) | |
1023 | |
1024 | |
1025 (defun hm--html-add-abbrevation () | |
1026 "Adds the HTML tags for Abbrevation at the point in the current buffer." | |
1027 (interactive) | |
1028 (hm--html-add-tags 'hm--html-insert-start-tag | |
1029 "<ABBREV>" | |
1030 'hm--html-insert-end-tag | |
1031 "</ABBREV>")) | |
1032 | |
1033 | |
1034 (defun hm--html-add-abbrev-to-region () | |
1035 "Adds the HTML tags for Abbrev to the region." | |
1036 (interactive) | |
1037 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1038 "<ABBREV>" | |
1039 'hm--html-insert-end-tag | |
1040 "</ABBREV>")) | |
1041 | |
1042 | |
1043 (defun hm--html-add-command () | |
1044 "Adds the HTML tags for Command at the point in the current buffer." | |
1045 (interactive) | |
1046 (hm--html-add-tags 'hm--html-insert-start-tag | |
1047 "<CMD>" | |
1048 'hm--html-insert-end-tag | |
1049 "</CMD>")) | |
1050 | |
1051 | |
1052 (defun hm--html-add-command-to-region () | |
1053 "Adds the HTML tags for Command to the region." | |
1054 (interactive) | |
1055 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1056 "<CMD>" | |
1057 'hm--html-insert-end-tag | |
1058 "</CMD>")) | |
1059 | |
1060 | |
1061 (defun hm--html-add-argument () | |
1062 "Adds the HTML tags for Argument at the point in the current buffer." | |
1063 (interactive) | |
1064 (hm--html-add-tags 'hm--html-insert-start-tag | |
1065 "<ARG>" | |
1066 'hm--html-insert-end-tag | |
1067 "</ARG>")) | |
1068 | |
1069 | |
1070 (defun hm--html-add-argument-to-region () | |
1071 "Adds the HTML tags for Argument to the region." | |
1072 (interactive) | |
1073 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1074 "<ARG>" | |
1075 'hm--html-insert-end-tag | |
1076 "</ARG>")) | |
1077 | |
1078 | |
1079 (defun hm--html-add-literature () | |
1080 "Adds the HTML tags for Literature at the point in the current buffer." | |
1081 (interactive) | |
1082 (hm--html-add-tags 'hm--html-insert-start-tag | |
1083 "<LIT>" | |
1084 'hm--html-insert-end-tag | |
1085 "</LIT>")) | |
1086 | |
1087 | |
1088 (defun hm--html-add-literature-to-region () | |
1089 "Adds the HTML tags for Literature to the region." | |
1090 (interactive) | |
1091 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1092 "<LIT>" | |
1093 'hm--html-insert-end-tag | |
1094 "</LIT>")) | |
1095 | |
1096 | |
1097 (defun hm--html-add-footnote () | |
1098 "Adds the HTML tags for Footnote at the point in the current buffer." | |
1099 (interactive) | |
1100 (hm--html-add-tags 'hm--html-insert-start-tag | |
1101 "<FOOTNOTE>" | |
1102 'hm--html-insert-end-tag | |
1103 "</FOOTNOTE>")) | |
1104 | |
1105 | |
1106 (defun hm--html-add-footnote-to-region () | |
1107 "Adds the HTML tags for Footnote to the region." | |
1108 (interactive) | |
1109 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1110 "<FOOTNOTE>" | |
1111 'hm--html-insert-end-tag | |
1112 "</FOOTNOTE>")) | |
1113 | |
1114 | |
1115 (defun hm--html-add-margin () | |
1116 "Adds the HTML tags for Margin at the point in the current buffer." | |
1117 (interactive) | |
1118 (hm--html-add-tags 'hm--html-insert-start-tag | |
1119 "<MARGIN>" | |
1120 'hm--html-insert-end-tag | |
1121 "</MARGIN>")) | |
1122 | |
1123 | |
1124 (defun hm--html-add-margin-to-region () | |
1125 "Adds the HTML tags for Margin to the region." | |
1126 (interactive) | |
1127 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | |
1128 "<MARGIN>" | |
1129 'hm--html-insert-end-tag | |
1130 "</MARGIN>")) | |
1131 | |
1132 | |
1133 | |
1134 | |
1135 | |
1136 ;;; Lists | |
1137 | |
1138 | |
1139 (defun hm--html-add-listing () | |
1140 "Adds the HTML tags for listing." | |
1141 (interactive) | |
1031 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1142 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1032 (concat "<FONT" | 1143 "<LISTING>" |
1033 (if size | |
1034 (concat " SIZE=" size) | |
1035 "") | |
1036 (if color | |
1037 (concat " COLOR=" color) | |
1038 "") | |
1039 ">") | |
1040 'hm--html-insert-end-tag-with-newline | 1144 'hm--html-insert-end-tag-with-newline |
1041 "</FONT>")) | 1145 "</LISTING>")) |
1042 | 1146 |
1043 | 1147 |
1044 (defun hm--html-add-font-to-region (size color) | 1148 (defun hm--html-add-listing-to-region () |
1045 "Adds the HTML tags for Font to the region." | 1149 "Adds the HTML tags for listing to the region." |
1046 (interactive (list (hm--html-read-font-size) | 1150 (interactive) |
1047 (hm--html-read-font-color))) | |
1048 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1151 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1049 (concat "<FONT" | 1152 "<LISTING>" |
1050 (if size | |
1051 (concat " SIZE=" size) | |
1052 "") | |
1053 (if color | |
1054 (concat " COLOR=" color) | |
1055 "") | |
1056 ">") | |
1057 'hm--html-insert-end-tag-with-newline | 1153 'hm--html-insert-end-tag-with-newline |
1058 "</FONT>")) | 1154 "</LISTING>")) |
1059 | |
1060 | |
1061 ;;; Lists | |
1062 | |
1063 | 1155 |
1064 (defun hm--html-add-center () | 1156 (defun hm--html-add-center () |
1065 "Adds the HTML tags for center at the current point." | 1157 "Adds the HTML tags for center at the current point." |
1066 (interactive) | 1158 (interactive) |
1067 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1159 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1074 (interactive) | 1166 (interactive) |
1075 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1167 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1076 "<CENTER>" | 1168 "<CENTER>" |
1077 'hm--html-insert-end-tag-with-newline | 1169 'hm--html-insert-end-tag-with-newline |
1078 "</CENTER>")) | 1170 "</CENTER>")) |
1079 | |
1080 | |
1081 (defvar hm--html-mapname-history nil | |
1082 "The history variable for the function `hm--html-read-mapname'.") | |
1083 | |
1084 (defun hm--html-read-mapname () | |
1085 "Reads the name of an image map." | |
1086 (let ((name (read-string "The name of the image map: " | |
1087 (or (car hm--html-mapname-history) | |
1088 "map") | |
1089 'hm--html-mapname-history))) | |
1090 name)) | |
1091 | |
1092 (defun hm--html-add-image-map () | |
1093 "Adds an image and a map element." | |
1094 (interactive) | |
1095 (let* ((href (hm--html-read-url "Image URL: ")) | |
1096 (alt (hm--html-read-altenate href)) | |
1097 (alignment (hm--html-read-alignment | |
1098 "Alignment of the image: ")) | |
1099 (mapname (hm--html-read-mapname))) | |
1100 (hm--html-add-image href alt alignment mapname) | |
1101 (newline) | |
1102 (hm--html-add-map mapname) | |
1103 (call-interactively 'hm--html-add-area))) | |
1104 | |
1105 (defun hm--html-add-map (name) | |
1106 "Adds the HTML tags for map at the current point." | |
1107 (interactive (list (hm--html-read-mapname))) | |
1108 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | |
1109 (concat "<MAP NAME=\"" name "\">") | |
1110 'hm--html-insert-end-tag | |
1111 "</MAP>") | |
1112 (end-of-line 0)) | |
1113 | |
1114 (defun hm--html-add-map-to-region (name) | |
1115 "Adds the HTML tags for map to the region." | |
1116 (interactive (list (hm--html-read-mapname))) | |
1117 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | |
1118 (concat "<MAP NAME=\"" name "\">") | |
1119 'hm--html-insert-end-tag-with-newline | |
1120 "</MAP>")) | |
1121 | |
1122 | 1171 |
1123 (defun hm--html-add-numberlist () | 1172 (defun hm--html-add-numberlist () |
1124 "Adds the HTML tags for a numbered list at the point in the current buffer." | 1173 "Adds the HTML tags for a numbered list at the point in the current buffer." |
1125 (interactive) | 1174 (interactive) |
1126 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1175 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1127 "<OL>" | 1176 "<OL>" |
1128 'hm--html-insert-end-tag-with-newline | 1177 'hm--html-insert-end-tag-with-newline |
1129 "</OL>" | 1178 "</OL>" |
1130 'hm--html-insert-start-tag | 1179 'hm--html-insert-start-tag |
1131 "<LI> " | 1180 "<LI> ")) |
1132 'hm--html-insert-end-tag | |
1133 " </LI>")) | |
1134 | 1181 |
1135 (defun hm--html-add-numberlist-to-region () | 1182 (defun hm--html-add-numberlist-to-region () |
1136 "Adds the HTML tags for a numbered list to the region." | 1183 "Adds the HTML tags for a numbered list to the region." |
1137 (interactive) | 1184 (interactive) |
1138 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1185 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1139 "<OL>" | 1186 "<OL>" |
1140 'hm--html-insert-end-tag-with-newline | 1187 'hm--html-insert-end-tag-with-newline |
1141 "</OL>")) | 1188 "</OL>" |
1189 'hm--html-insert-start-tag | |
1190 "<LI> ")) | |
1142 | 1191 |
1143 | 1192 |
1144 (defun hm--html-add-directory-list () | 1193 (defun hm--html-add-directory-list () |
1145 "Adds the HTML tags for a directory list at the point in the current buffer." | 1194 "Adds the HTML tags for a directory list at the point in the current buffer." |
1146 (interactive) | 1195 (interactive) |
1147 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1196 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1148 "<DIR>" | 1197 "<DIR>" |
1149 'hm--html-insert-end-tag-with-newline | 1198 'hm--html-insert-end-tag-with-newline |
1150 "</DIR>" | 1199 "</DIR>" |
1151 'hm--html-insert-start-tag | 1200 'hm--html-insert-start-tag |
1152 "<LI> " | 1201 "<LI> ")) |
1153 'hm--html-insert-end-tag | |
1154 " </LI>")) | |
1155 | 1202 |
1156 (defun hm--html-add-directorylist-to-region () | 1203 (defun hm--html-add-directorylist-to-region () |
1157 "Adds the HTML tags for a directory list to the region." | 1204 "Adds the HTML tags for a directory list to the region." |
1158 (interactive) | 1205 (interactive) |
1159 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1206 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1160 "<DIR>" | 1207 "<DIR>" |
1161 'hm--html-insert-end-tag-with-newline | 1208 'hm--html-insert-end-tag-with-newline |
1162 "</DIR>")) | 1209 "</DIR>" |
1210 'hm--html-insert-start-tag | |
1211 "<LI> ")) | |
1163 | 1212 |
1164 | 1213 |
1165 (defun hm--html-add-list () | 1214 (defun hm--html-add-list () |
1166 "Adds the HTML tags for a (unnumbered) list to the region." | 1215 "Adds the HTML tags for a (unnumbered) list to the region." |
1167 (interactive) | 1216 (interactive) |
1168 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1217 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1169 "<UL>" | 1218 "<UL>" |
1170 'hm--html-insert-end-tag-with-newline | 1219 'hm--html-insert-end-tag-with-newline |
1171 "</UL>" | 1220 "</UL>" |
1172 'hm--html-insert-start-tag | 1221 'hm--html-insert-start-tag |
1173 "<LI> " | 1222 "<LI> ")) |
1174 'hm--html-insert-end-tag | |
1175 " </LI>")) | |
1176 | 1223 |
1177 | 1224 |
1178 (defun hm--html-add-list-to-region () | 1225 (defun hm--html-add-list-to-region () |
1179 "Adds the HTML tags for a (unnumbered) list to the region." | 1226 "Adds the HTML tags for a (unnumbered) list to the region." |
1180 (interactive) | 1227 (interactive) |
1181 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1228 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1182 "<UL>" | 1229 "<UL>" |
1183 'hm--html-insert-end-tag-with-newline | 1230 'hm--html-insert-end-tag-with-newline |
1184 "</UL>")) | 1231 "</UL>" |
1232 'hm--html-insert-start-tag | |
1233 "<LI> ")) | |
1234 | |
1235 | |
1236 (defun hm--html-add-menu () | |
1237 "Adds the HTML tags for a menu." | |
1238 (interactive) | |
1239 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | |
1240 "<MENU>" | |
1241 'hm--html-insert-end-tag-with-newline | |
1242 "</MENU>" | |
1243 'hm--html-insert-start-tag | |
1244 "<LI> ")) | |
1185 | 1245 |
1186 | 1246 |
1187 (defun hm--html-add-menu () | 1247 (defun hm--html-add-menu () |
1188 "Adds the HTML tags for a menu." | 1248 "Adds the HTML tags for a menu." |
1189 (interactive) | 1249 (interactive) |
1203 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1263 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1204 "<MENU>" | 1264 "<MENU>" |
1205 'hm--html-insert-end-tag-with-newline | 1265 'hm--html-insert-end-tag-with-newline |
1206 "</MENU>")) | 1266 "</MENU>")) |
1207 | 1267 |
1268 ; 'hm--html-insert-start-tag | |
1269 ; "<LI> ")) | |
1270 | |
1208 | 1271 |
1209 (defun hm--html-add-description-title-and-entry () | 1272 (defun hm--html-add-description-title-and-entry () |
1210 "Adds a definition title and entry. | 1273 "Adds a definition title and entry. |
1211 Assumes we're at the end of a previous entry." | 1274 Assumes we're at the end of a previous entry." |
1212 (interactive) | 1275 (interactive) |
1213 (hm--html-add-description-title) | 1276 (hm--html-add-description-title) |
1214 (let ((position (point)) | 1277 (let ((position (point))) |
1215 (case-fold-search t)) | 1278 (search-forward "</DT>") |
1216 (search-forward "</dt>") | 1279 (hm--html-add-only-description-entry) |
1217 (hm--html-add-description-entry) | |
1218 (goto-char position))) | 1280 (goto-char position))) |
1219 | 1281 |
1220 | 1282 |
1221 (defun hm--html-add-description-list () | 1283 (defun hm--html-add-description-list () |
1222 "Adds the HTML tags for a description list. | 1284 "Adds the HTML tags for a description list. |
1238 (interactive) | 1300 (interactive) |
1239 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline | 1301 (hm--html-add-tags-to-region 'hm--html-insert-start-tag-with-newline |
1240 "<DL>" | 1302 "<DL>" |
1241 'hm--html-insert-end-tag-with-newline | 1303 'hm--html-insert-end-tag-with-newline |
1242 "</DL>")) | 1304 "</DL>")) |
1305 | |
1306 ; 'hm--html-insert-start-tag | |
1307 ; "<DT> ")) | |
1243 | 1308 |
1244 | 1309 |
1245 (defun hm--html-add-description-title () | 1310 (defun hm--html-add-description-title () |
1246 "Adds the HTML tags for a description title at current point in the buffer." | 1311 "Adds the HTML tags for a description title at current point in the buffer." |
1247 (interactive) | 1312 (interactive) |
1300 | 1365 |
1301 | 1366 |
1302 (defun hm--html-make-signature-link-string (signature-file-name) | 1367 (defun hm--html-make-signature-link-string (signature-file-name) |
1303 "Returns a string which is a link to a signature file." | 1368 "Returns a string which is a link to a signature file." |
1304 (concat | 1369 (concat |
1305 "<A NAME=\"" | 1370 "<A Name=" |
1306 hm--html-signature-reference-name | 1371 hm--html-signature-reference-name |
1307 "\"\nHREF=\"" | 1372 " HREF=\"" |
1308 signature-file-name | 1373 signature-file-name |
1309 "\">")) | 1374 "\">")) |
1310 | 1375 |
1311 | 1376 |
1312 (defun hm--html-delete-old-signature () | 1377 (defun hm--html-delete-old-signature () |
1313 "Searches for the old signature and deletes it, if the user want it" | 1378 "Searches for the old signature and deletes it, if the user want it" |
1314 (save-excursion | 1379 (save-excursion |
1315 (goto-char (point-min)) | 1380 (goto-char (point-min)) |
1316 (let ((case-fold-search t)) | 1381 (if (search-forward (concat "<address> " |
1317 (if (re-search-forward (concat "<address>[ \t\n]*" | 1382 "<a name=" |
1318 "<a[ \t\n]+name=[ \t\n]*\"?" | 1383 hm--html-signature-reference-name |
1319 hm--html-signature-reference-name | 1384 " href=\"") |
1320 "\"?[ \t\n]+href=[ \t\n]*\"") | 1385 nil |
1321 nil | 1386 t) |
1322 t) | 1387 (let ((signature-start (match-beginning 0)) |
1323 (let ((signature-start (match-beginning 0)) | 1388 (signature-end (progn |
1324 (signature-end (progn | 1389 (search-forward "</address>" nil t) |
1325 (re-search-forward "</address>[ \t]*[\n]?" | 1390 (point)))) |
1326 nil | 1391 (if (yes-or-no-p "Delete the old signature (yes or no) ?") |
1327 t) | 1392 (delete-region signature-start signature-end)))))) |
1328 (point)))) | |
1329 (when (yes-or-no-p "Delete the old signature (yes or no) ?") | |
1330 (delete-region signature-start signature-end) | |
1331 (hm--html-indent-line))))))) | |
1332 | 1393 |
1333 | 1394 |
1334 (defun hm--html-set-point-for-signature () | 1395 (defun hm--html-set-point-for-signature () |
1335 "Searches and sets the point for inserting the signature. | 1396 "Searches and sets the point for inserting the signature. |
1336 It searches from the end to the beginning of the file. At first it | 1397 It searches from the end to the beginning of the file. At first it |
1337 tries to use the point before the </body> tag then the point before | 1398 tries to use the point before the </body> tag then the point before |
1338 the </html> tag and the the end of the file." | 1399 the </html> tag and the the end of the file." |
1339 (goto-char (point-max)) | 1400 (goto-char (point-max)) |
1340 (let ((case-fold-search t)) | 1401 (cond ((search-backward "</body>" nil t) |
1341 (cond ((search-backward "</body>" nil t) | 1402 (end-of-line 0) |
1342 (end-of-line 0) | 1403 (if (> (current-column) 0) |
1343 (if (> (current-column) 0) | 1404 (newline 2))) |
1344 (newline 1))) | 1405 ((search-backward "</html>" nil t) |
1345 ((search-backward "</html>" nil t) | 1406 (end-of-line 0) |
1346 (end-of-line 0) | 1407 (if (> (current-column) 0) |
1347 (if (> (current-column) 0) | 1408 (newline 2))) |
1348 (newline 2))) | 1409 ((> (current-column) 0) |
1349 ((> (current-column) 0) | 1410 (newline 2)) |
1350 (newline 2)) | 1411 (t))) |
1351 (t)))) | |
1352 | 1412 |
1353 | 1413 |
1354 (defun hm--html-add-signature () | 1414 (defun hm--html-add-signature () |
1355 "Adds the owner's signature at the end of the buffer." | 1415 "Adds the owner's signature at the end of the buffer." |
1356 (interactive) | 1416 (interactive) |
1359 (if (not hm--html-username) | 1419 (if (not hm--html-username) |
1360 (setq hm--html-username (user-full-name))) | 1420 (setq hm--html-username (user-full-name))) |
1361 (save-excursion | 1421 (save-excursion |
1362 (hm--html-delete-old-signature) | 1422 (hm--html-delete-old-signature) |
1363 (hm--html-set-point-for-signature) | 1423 (hm--html-set-point-for-signature) |
1364 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1424 (hm--html-add-tags 'hm--html-insert-start-tag |
1365 "<ADDRESS>" | 1425 "<ADDRESS> " |
1366 'hm--html-insert-end-tag | 1426 'hm--html-insert-end-tag |
1367 "</A>\n</ADDRESS>" | 1427 "</A></ADDRESS>" |
1368 'hm--html-insert-start-tag | 1428 'hm--html-insert-start-tag |
1369 (hm--html-make-signature-link-string | 1429 (hm--html-make-signature-link-string |
1370 hm--html-signature-file) | 1430 hm--html-signature-file) |
1371 ) | 1431 ) |
1372 (insert hm--html-username))) | 1432 (insert hm--html-username))) |
1405 position after the tag. If not, the function next searches for the | 1465 position after the tag. If not, the function next searches for the |
1406 tag <HEAD> and sets the point after the tag, if it exists, or searches for | 1466 tag <HEAD> and sets the point after the tag, if it exists, or searches for |
1407 the tag <HTML>. If this tag exists, the point is set to the position after | 1467 the tag <HTML>. If this tag exists, the point is set to the position after |
1408 this tag or the beginning of the file otherwise." | 1468 this tag or the beginning of the file otherwise." |
1409 (goto-char (point-min)) | 1469 (goto-char (point-min)) |
1410 (let ((case-fold-search t)) | 1470 (cond ((search-forward-regexp "<isindex>" nil t) (newline)) |
1411 (cond ((search-forward-regexp "<isindex[^>]*>" nil t) (newline)) | 1471 ((search-forward-regexp "<head>" nil t) (newline)) |
1412 ((search-forward-regexp "<head[^>]*>" nil t) (newline)) | 1472 ((search-forward-regexp "<html>" nil t) (newline)) |
1413 ((search-forward-regexp "<html[^>]*>" nil t) (newline)) | 1473 (t))) |
1414 (t)))) | |
1415 | 1474 |
1416 | 1475 |
1417 (defun hm--html-add-title (title) | 1476 (defun hm--html-add-title (title) |
1418 "Adds the HTML tags for a title at the beginning of the buffer." | 1477 "Adds the HTML tags for a title at the beginning of the buffer." |
1419 (interactive "sTitle: ") | 1478 (interactive "sTitle: ") |
1420 (save-excursion | 1479 (save-excursion |
1421 (goto-char (point-min)) | 1480 (goto-char (point-min)) |
1422 (let ((case-fold-search t)) | 1481 (if (search-forward "<title>" nil t) |
1423 (if (search-forward "<title>" nil t) | 1482 (let ((point-after-start-tag (point))) |
1424 (let ((point-after-start-tag (point))) | 1483 (if (not (search-forward "</title>" nil t)) |
1425 (if (not (search-forward "</title>" nil t)) | 1484 nil |
1426 nil | 1485 (goto-char (- (point) 8)) |
1427 (goto-char (- (point) 8)) | 1486 (delete-backward-char (- (point) point-after-start-tag)) |
1428 (delete-backward-char (- (point) point-after-start-tag)) | 1487 (let ((start (point))) |
1429 (let ((start (point))) | 1488 (insert title " (" (hm--date) ")") |
1430 (insert title " (" (hm--date) ")") | 1489 (goto-char start)))) |
1431 (goto-char start)))) | 1490 ;; Noch kein <TITLE> im Buffer vorhanden |
1432 ;; Noch kein <TITLE> im Buffer vorhanden | 1491 (hm--html-set-point-for-title) |
1433 (hm--html-set-point-for-title) | 1492 (hm--html-add-tags 'hm--html-insert-start-tag |
1434 (hm--html-add-tags 'hm--html-insert-start-tag | 1493 "<TITLE>" |
1435 "<TITLE>" | 1494 'hm--html-insert-end-tag |
1436 'hm--html-insert-end-tag | 1495 "</TITLE>" |
1437 "</TITLE>" | 1496 'insert |
1438 'insert | 1497 (concat title " (" (hm--date) ")")) |
1439 (concat title " (" (hm--date) ")")) | 1498 (forward-char 8) |
1440 (forward-char 8) | 1499 (newline 1) |
1441 (newline 1) | 1500 ))) |
1442 )))) | |
1443 | 1501 |
1444 | 1502 |
1445 (defun hm--html-add-title-to-region () | 1503 (defun hm--html-add-title-to-region () |
1446 "Adds the HTML tags for a title to the region." | 1504 "Adds the HTML tags for a title to the region." |
1447 (interactive) | 1505 (interactive) |
1448 (let ((title (buffer-substring (region-beginning) (region-end))) | 1506 (let ((title (buffer-substring (region-beginning) (region-end)))) |
1449 (case-fold-search t)) | |
1450 (save-excursion | 1507 (save-excursion |
1451 (goto-char (point-min)) | 1508 (goto-char (point-min)) |
1452 (if (search-forward "<title>" nil t) | 1509 (if (search-forward "<title>" nil t) |
1453 (let ((point-after-start-tag (point))) | 1510 (let ((point-after-start-tag (point))) |
1454 (if (not (search-forward "</title>" nil t)) | 1511 (if (not (search-forward "</title>" nil t)) |
1469 )))) | 1526 )))) |
1470 | 1527 |
1471 | 1528 |
1472 (defun hm--html-add-html () | 1529 (defun hm--html-add-html () |
1473 "Adds the HTML tags <HTML> and </HTML> in the buffer. | 1530 "Adds the HTML tags <HTML> and </HTML> in the buffer. |
1474 The tag <HTML> will be inserted at the beginning (after the | 1531 The tag <HTML> will be inserted at the beginning and </HTML> at the |
1475 <!DOCTYPE ...>, if it is already there.) and </HTML> at the | |
1476 end of the file." | 1532 end of the file." |
1477 (interactive) | 1533 (interactive) |
1478 (let ((new-cursor-position nil) | 1534 (let ((new-cursor-position nil)) |
1479 (case-fold-search t)) | |
1480 (save-excursion | 1535 (save-excursion |
1481 (goto-char (point-min)) | 1536 (goto-char (point-min)) |
1482 (if (search-forward "<html>" nil t) | 1537 (if (search-forward "<html>" nil t) |
1483 (error "There is an old tag <HTML> in the current buffer !") | 1538 (error "There is an old tag <HTML> in the current buffer !") |
1484 (re-search-forward "<!DOCTYPE[^>]*>[ \t\n]*" nil t) | |
1485 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline "<HTML>") | 1539 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline "<HTML>") |
1486 ; (newline 1) | 1540 ; (newline 1) |
1487 ) | 1541 ) |
1488 (setq new-cursor-position (point)) | 1542 (setq new-cursor-position (point)) |
1489 (goto-char (point-max)) | 1543 (goto-char (point-max)) |
1494 (goto-char new-cursor-position))) | 1548 (goto-char new-cursor-position))) |
1495 | 1549 |
1496 | 1550 |
1497 (defun hm--html-add-head () | 1551 (defun hm--html-add-head () |
1498 "Adds the HTML tags <HEAD> and </HEAD> in the buffer. | 1552 "Adds the HTML tags <HEAD> and </HEAD> in the buffer. |
1499 The tags will be inserted after <HTML> or at the beginning | 1553 The tags will be inserted after <HTML> or at the beginning of the file. |
1500 of the file after <DOCTYPE...> (if it is already there). | |
1501 The function also looks for the tags <BODY> and </TITLE>." | 1554 The function also looks for the tags <BODY> and </TITLE>." |
1502 (interactive) | 1555 (interactive) |
1503 (let ((case-fold-search t)) | |
1504 (goto-char (point-min)) | 1556 (goto-char (point-min)) |
1505 (re-search-forward "<!DOCTYPE[^>]*>[ \t\n]*" nil t) | |
1506 (if (search-forward "<html>" nil t) | 1557 (if (search-forward "<html>" nil t) |
1507 (if (search-forward "<head>" nil t) | 1558 (if (search-forward "<head>" nil t) |
1508 (error "There is an old tag <HEAD> in the current buffer !") | 1559 (error "There is an old tag <HEAD> in the current buffer !") |
1509 (if (search-forward "</head>" nil t) | 1560 (if (search-forward "</head>" nil t) |
1510 (error "There is an old tag </HEAD> in the current buffer !") | 1561 (error "There is an old tag </HEAD> in the current buffer !") |
1533 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1584 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1534 "<HEAD>")) | 1585 "<HEAD>")) |
1535 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1586 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1536 "<HEAD>" | 1587 "<HEAD>" |
1537 'hm--html-insert-end-tag-with-newline | 1588 'hm--html-insert-end-tag-with-newline |
1538 "</HEAD>")))))) | 1589 "</HEAD>"))))) |
1539 | 1590 |
1540 | 1591 |
1541 (defun hm--html-add-head-to-region () | 1592 (defun hm--html-add-head-to-region () |
1542 "Adds the HTML tags <HEAD> and </HEAD> to the region." | 1593 "Adds the HTML tags <HEAD> and </HEAD> to the region." |
1543 (interactive) | 1594 (interactive) |
1549 | 1600 |
1550 (defun hm--html-add-body () | 1601 (defun hm--html-add-body () |
1551 "Adds the HTML tags <BODY> and </BODY> in the buffer. | 1602 "Adds the HTML tags <BODY> and </BODY> in the buffer. |
1552 The tags will be inserted before </HTML> or at the end of the file." | 1603 The tags will be inserted before </HTML> or at the end of the file." |
1553 (interactive) | 1604 (interactive) |
1554 (let ((case-fold-search t)) | |
1555 (goto-char (point-max)) | 1605 (goto-char (point-max)) |
1556 (if (search-backward "</html>" nil t) | 1606 (if (search-backward "</html>" nil t) |
1557 (progn | 1607 (progn |
1558 (if (search-backward "</body>" nil t) | 1608 (if (search-backward "</body>" nil t) |
1559 (error "There is an old tag </BODY> in the current buffer !") | 1609 (error "There is an old tag </BODY> in the current buffer !") |
1560 (if (search-backward "<body>" nil t) | 1610 (if (search-backward "<body>" nil t) |
1561 (error "There is an old tag <BODY> in the current buffer !"))) | 1611 (error "There is an old tag <BODY> in the current buffer !"))) |
1562 (forward-char -1))) | 1612 (forward-char -1))) |
1563 (let ((end-tag-position (set-marker (make-marker) (point)))) | 1613 (let ((end-tag-position (point))) |
1564 (if (search-backward "</head>" nil t) | 1614 (if (search-backward "</head>" nil t) |
1565 (progn | 1615 (progn |
1566 (forward-char 7) | 1616 (forward-char 7) |
1567 (newline 1) | 1617 (newline 1) |
1568 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline | 1618 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline |
1569 "<BODY>") | 1619 "<BODY>") |
1570 (let ((cursor-position (point))) | 1620 (let ((cursor-position (point))) |
1571 (goto-char end-tag-position) | 1621 (goto-char (+ end-tag-position 8)) |
1572 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline | 1622 (hm--html-add-tags 'hm--html-insert-end-tag-with-newline |
1573 "</BODY>") | 1623 "</BODY>") |
1574 (goto-char cursor-position) | 1624 (goto-char cursor-position) |
1575 )) | 1625 )) |
1576 (if (not (= (current-column) 0)) | 1626 (if (not (= (current-column) 0)) |
1577 (newline)) | 1627 (newline)) |
1578 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline "<BODY>" | 1628 (hm--html-add-tags 'hm--html-insert-start-tag-with-newline "<BODY>" |
1579 'hm--html-insert-end-tag-with-newline "</BODY>"))))) | 1629 'hm--html-insert-end-tag-with-newline "</BODY>")))) |
1580 | 1630 |
1581 | 1631 |
1582 (defun hm--html-add-body-to-region () | 1632 (defun hm--html-add-body-to-region () |
1583 "Adds the HTML tags <BODY> and </BODY> to the region." | 1633 "Adds the HTML tags <BODY> and </BODY> to the region." |
1584 (interactive) | 1634 (interactive) |
1588 "</BODY>")) | 1638 "</BODY>")) |
1589 | 1639 |
1590 | 1640 |
1591 (defun hm--html-add-title-and-header (title) | 1641 (defun hm--html-add-title-and-header (title) |
1592 "Adds the HTML tags for a title and a header in the current buffer." | 1642 "Adds the HTML tags for a title and a header in the current buffer." |
1643 ; (interactive "sTitle and Header String: \nnHeader Size (1 .. 6): ") | |
1644 ; (if (> size 6) | |
1645 ; (message "The size must be a number from 1 to 6 !") | |
1593 (interactive "sTitle and Header String: ") | 1646 (interactive "sTitle and Header String: ") |
1594 (let ((case-fold-search t)) | 1647 (hm--html-add-title title) |
1595 (hm--html-add-title title) | 1648 (save-excursion |
1596 (save-excursion | 1649 (goto-char (point-min)) |
1597 (goto-char (point-min)) | 1650 (search-forward "</title>" nil t) |
1598 (search-forward "</title>" nil t) | 1651 (if (search-forward "</head>" nil t) |
1599 (if (search-forward "</head>" nil t) | 1652 (progn |
1600 (progn | 1653 (search-forward "<body>" nil t) |
1601 (search-forward "<body>" nil t) | 1654 (newline 1)) |
1602 (newline 1)) | 1655 (if (search-forward "<body>" nil t) |
1603 (if (search-forward "<body>" nil t) | 1656 (newline 1) |
1604 (newline 1) | 1657 (if (string= (what-line) "Line 1") |
1605 (if (string= (what-line) "Line 1") | 1658 (progn |
1606 (progn | 1659 (end-of-line) |
1607 (end-of-line) | 1660 (newline 1))))) |
1608 (newline 1))))) | 1661 (hm--html-add-header 1 title))) |
1609 (hm--html-add-header 1 title)))) | |
1610 | 1662 |
1611 | 1663 |
1612 (defun hm--html-add-title-and-header-to-region () | 1664 (defun hm--html-add-title-and-header-to-region () |
1613 "Adds the HTML tags for a title and a header to the region." | 1665 "Adds the HTML tags for a title and a header to the region." |
1666 ;The parameter 'size' spezifies the size of the header.";" | |
1667 ; (interactive "nSize (1 .. 6): ") | |
1668 ; (if (> size 6) | |
1669 ; (message "The size must be a number from 1 to 6 !") | |
1614 (interactive) | 1670 (interactive) |
1615 (let ((title (buffer-substring (region-beginning) (region-end)))) | 1671 (let ((title (buffer-substring (region-beginning) (region-end)))) |
1616 (hm--html-add-header-to-region 1) | 1672 (hm--html-add-header-to-region 1) |
1617 (hm--html-add-title title))) | 1673 (hm--html-add-title title))) |
1618 | 1674 |
1621 "Adds a full HTML frame to the current buffer. | 1677 "Adds a full HTML frame to the current buffer. |
1622 The frame consists of the elements html, head, body, title, | 1678 The frame consists of the elements html, head, body, title, |
1623 header and the signature. The parameter TITLE specifies the | 1679 header and the signature. The parameter TITLE specifies the |
1624 title and the header of the document." | 1680 title and the header of the document." |
1625 (interactive "sTitle and Header String: ") | 1681 (interactive "sTitle and Header String: ") |
1626 (let ((case-fold-search t)) | 1682 (hm--html-add-html) |
1627 (hm--html-add-doctype) | 1683 (hm--html-add-head) |
1628 (hm--html-add-html) | 1684 (hm--html-add-body) |
1629 (hm--html-add-head) | 1685 (hm--html-add-title-and-header title) |
1630 (hm--html-add-body) | 1686 (if hm--html-signature-file |
1631 (hm--html-add-title-and-header title) | 1687 (hm--html-add-signature)) |
1632 (if hm--html-signature-file | 1688 (goto-char (point-min)) |
1633 (hm--html-add-signature)) | 1689 (search-forward "</h1>" nil t) |
1634 (goto-char (point-min)) | 1690 (forward-line 1) |
1635 (search-forward "</h1>" nil t) | 1691 (if hm--html-automatic-created-comment |
1636 (forward-line 1) | 1692 (hm--html-insert-created-comment))) |
1637 (if hm--html-automatic-created-comment | |
1638 (hm--html-insert-created-comment)))) | |
1639 | 1693 |
1640 | 1694 |
1641 (defun hm--html-add-full-html-frame-with-region () | 1695 (defun hm--html-add-full-html-frame-with-region () |
1642 "Adds a full HTML frame to the current buffer with the use of a region. | 1696 "Adds a full HTML frame to the current buffer with the use of a region. |
1643 The frame consists of the elements html, head, body, title, | 1697 The frame consists of the elements html, head, body, title, |
1644 header and the signature. The function uses the region as | 1698 header and the signature. The function uses the region as |
1645 the string for the title and the header of the document." | 1699 the string for the title and the header of the document." |
1646 (interactive) | 1700 (interactive) |
1647 (hm--html-add-title-and-header-to-region) | 1701 (hm--html-add-title-and-header-to-region) |
1648 (hm--html-add-doctype) | |
1649 (hm--html-add-html) | 1702 (hm--html-add-html) |
1650 (hm--html-add-head) | 1703 (hm--html-add-head) |
1651 (hm--html-add-body) | 1704 (hm--html-add-body) |
1652 (hm--html-add-signature) | 1705 (hm--html-add-signature) |
1653 (if hm--html-automatic-created-comment | 1706 (if hm--html-automatic-created-comment |
1662 'hm--html-insert-end-tag | 1715 'hm--html-insert-end-tag |
1663 "</A>")) | 1716 "</A>")) |
1664 | 1717 |
1665 (defun hm--html-add-link-target (name) | 1718 (defun hm--html-add-link-target (name) |
1666 "Adds the HTML tags for a link target at point in the current buffer." | 1719 "Adds the HTML tags for a link target at point in the current buffer." |
1720 ; (interactive "sName (or RET for numeric): ") | |
1667 (interactive "sName: ") | 1721 (interactive "sName: ") |
1722 ; (and (string= name "") | |
1723 ; (progn | |
1724 ; (setq html-link-counter (1+ html-link-counter)) | |
1725 ; (setq name (format "%d" html-link-counter)))) | |
1668 (hm--html-add-tags 'hm--html-insert-start-tag | 1726 (hm--html-add-tags 'hm--html-insert-start-tag |
1669 (concat "<A NAME=\"" name "\">") | 1727 (concat "<A NAME=\"" name "\">") |
1670 'hm--html-insert-end-tag | 1728 'hm--html-insert-end-tag |
1671 "</A>")) | 1729 "</A>")) |
1672 | 1730 |
1674 ;;; Functions which add links | 1732 ;;; Functions which add links |
1675 | 1733 |
1676 (defun hm--html-mark-example (parameter-list) | 1734 (defun hm--html-mark-example (parameter-list) |
1677 "Marks the example of the parameterlist in the current buffer. | 1735 "Marks the example of the parameterlist in the current buffer. |
1678 It returns the example extent." | 1736 It returns the example extent." |
1679 (let ((case-fold-search t)) | 1737 (if (hm--html-get-example-from-parameter-list parameter-list) |
1680 (if (hm--html-get-example-from-parameter-list parameter-list) | 1738 (progn |
1681 (progn | 1739 (search-forward (hm--html-get-example-from-parameter-list |
1682 (search-forward (hm--html-get-example-from-parameter-list | 1740 parameter-list)) |
1683 parameter-list)) | 1741 (let ((extent (make-extent (match-beginning 0) |
1684 (let ((extent (make-extent (match-beginning 0) | 1742 (match-end 0)))) |
1685 (match-end 0)))) | 1743 (set-extent-face extent 'hm--html-help-face) |
1686 (set-extent-face extent 'hm--html-help-face) | 1744 extent)))) |
1687 extent))))) | |
1688 | 1745 |
1689 | 1746 |
1690 (defun hm--html-unmark-example (extent) | 1747 (defun hm--html-unmark-example (extent) |
1691 "Unmarks the example for the current question." | 1748 "Unmarks the example for the current question." |
1692 (if extent | 1749 (if extent |
1693 (delete-extent extent))) | 1750 (delete-extent extent))) |
1751 | |
1752 ; ) | |
1753 ; ;; For the Emacs 19 | |
1754 ; (defun hm--html-mark-example (parameter-list) | |
1755 ; "Marks the example of the parameterlist in the current buffer. | |
1756 ;It returns the example extent." | |
1757 ; (if (hm--html-get-example-from-parameter-list parameter-list) | |
1758 ; (progn | |
1759 ; (search-forward (hm--html-get-example-from-parameter-list | |
1760 ; parameter-list)) | |
1761 ; (put-text-property (match-beginning 0) | |
1762 ; (match-end 0) | |
1763 ; 'face | |
1764 ; 'hm--html-help-face)))) | |
1765 ; | |
1766 ; | |
1767 ; (defun hm--html-unmark-example (extent) | |
1768 ; "Unmarks the example for the current question." | |
1769 ; t)) | |
1694 | 1770 |
1695 | 1771 |
1696 (defun hm--html-write-alist-in-buffer (alist) | 1772 (defun hm--html-write-alist-in-buffer (alist) |
1697 "The function writes the contents of the ALIST in the currentbuffer." | 1773 "The function writes the contents of the ALIST in the currentbuffer." |
1698 (cond ((car alist) | 1774 (cond ((car alist) |
1794 "" | 1870 "" |
1795 require-match | 1871 require-match |
1796 nil))) | 1872 nil))) |
1797 (hm--html-unmark-example marked-object) | 1873 (hm--html-unmark-example marked-object) |
1798 (hm--html-delete-wrong-path-prefix filename)) | 1874 (hm--html-delete-wrong-path-prefix filename)) |
1875 ; (if (not hm--html-delete-wrong-path-prefix) | |
1876 ; filename | |
1877 ; (if (string-match hm--html-delete-wrong-path-prefix filename) | |
1878 ; (substring filename (match-end 0)) | |
1879 ; filename))) | |
1799 "")) | 1880 "")) |
1800 | 1881 |
1801 | 1882 |
1802 (defun hm--html-completing-read (parameter-list) | 1883 (defun hm--html-completing-read (parameter-list) |
1803 "Reads a string with completing-read, if alist is non nil. | 1884 "Reads a string with completing-read, if alist is non nil. |
1827 | 1908 |
1828 | 1909 |
1829 (defun hm--html-generate-help-buffer-faces () | 1910 (defun hm--html-generate-help-buffer-faces () |
1830 "Generates faces for the add-link-help-buffer." | 1911 "Generates faces for the add-link-help-buffer." |
1831 (if (not (facep 'hm--html-help-face)) | 1912 (if (not (facep 'hm--html-help-face)) |
1913 ; (if (not hm--html-faces-exist) | |
1832 (progn | 1914 (progn |
1833 (setq hm--html-faces-exist t) | 1915 (setq hm--html-faces-exist t) |
1834 (make-face 'hm--html-help-face) | 1916 (make-face 'hm--html-help-face) |
1835 (if hm--html-help-foreground | 1917 (if hm--html-help-foreground |
1836 (set-face-foreground 'hm--html-help-face hm--html-help-foreground)) | 1918 (set-face-foreground 'hm--html-help-face hm--html-help-foreground)) |
1943 SERVERNAME:PORT-PARAMETER-LIST, PATH+FILE-PARAMETER-LIST and | 2025 SERVERNAME:PORT-PARAMETER-LIST, PATH+FILE-PARAMETER-LIST and |
1944 ANCHOR-PARAMETER-LIST are lists with a prompt string, an alist, a default | 2026 ANCHOR-PARAMETER-LIST are lists with a prompt string, an alist, a default |
1945 value and an example string. The ANCHOR-PARAMETER-LIST has as an additional | 2027 value and an example string. The ANCHOR-PARAMETER-LIST has as an additional |
1946 element an anchor seperator string. All these elements are used to read and | 2028 element an anchor seperator string. All these elements are used to read and |
1947 construct the link." | 2029 construct the link." |
1948 ; (let ((point nil)) | 2030 (let ((point nil)) |
1949 (save-window-excursion | 2031 (save-window-excursion |
1950 (let ((html-buffer (current-buffer)) | 2032 (let ((html-buffer (current-buffer)) |
1951 (html-help-buffer (hm--html-generate-add-link-help-buffer | 2033 (html-help-buffer (hm--html-generate-add-link-help-buffer |
1952 scheme-parameter-list | 2034 scheme-parameter-list |
1953 host-name:port-parameter-list | 2035 host-name:port-parameter-list |
1954 servername:port-parameter-list | 2036 servername:port-parameter-list |
1955 path+file-parameter-list | 2037 path+file-parameter-list |
1956 anchor-parameter-list)) | 2038 anchor-parameter-list)) |
1957 (scheme (hm--html-completing-read scheme-parameter-list)) | 2039 (scheme (hm--html-completing-read scheme-parameter-list)) |
1958 (hostname:port (hm--html-completing-read | 2040 (hostname:port (hm--html-completing-read |
1959 host-name:port-parameter-list)) | 2041 host-name:port-parameter-list)) |
1960 (servername:port (hm--html-completing-read | 2042 (servername:port (hm--html-completing-read |
1961 servername:port-parameter-list)) | 2043 servername:port-parameter-list)) |
1962 (path+file (hm--html-read-filename path+file-parameter-list)) | 2044 (path+file (hm--html-read-filename path+file-parameter-list)) |
1963 (anchor (hm--html-completing-read anchor-parameter-list)) | 2045 (anchor (hm--html-completing-read anchor-parameter-list)) |
1964 ; (hrefname (setq html-link-counter (1+ html-link-counter))) | 2046 ; (hrefname (setq html-link-counter (1+ html-link-counter))) |
1965 (anchor-seperator | 2047 (anchor-seperator |
1966 (hm--html-get-anchor-seperator-from-parameter-list | 2048 (hm--html-get-anchor-seperator-from-parameter-list |
1967 anchor-parameter-list))) | 2049 anchor-parameter-list))) |
1968 (if (not (string= scheme "")) | 2050 (if (not (string= scheme "")) |
1969 (if (string= hostname:port "") | 2051 (if (string= hostname:port "") |
1970 (setq scheme (concat scheme ":")) | 2052 (setq scheme (concat scheme ":")) |
1971 (setq scheme (concat scheme "://")))) | 2053 (setq scheme (concat scheme "://")))) |
1972 (if (and (not (string= hostname:port "")) | 2054 (if (and (not (string= hostname:port "")) |
1973 (not (string= servername:port "")) | 2055 (not (string= servername:port "")) |
1974 (not (string= (substring servername:port 0 1) "/"))) | 2056 (not (string= (substring servername:port 0 1) "/"))) |
1975 (setq servername:port (concat "/" servername:port))) | 2057 (setq servername:port (concat "/" servername:port))) |
1976 (if (and (not (string= path+file "")) | 2058 (if (and (not (string= path+file "")) |
1977 (not (string= "/" (substring path+file 0 1)))) | 2059 (not (string= "/" (substring path+file 0 1)))) |
1978 (setq path+file (concat "/" path+file))) | 2060 (setq path+file (concat "/" path+file))) |
1979 (if (not (string= anchor "")) | 2061 (if (not (string= anchor "")) |
1980 (setq anchor (concat anchor-seperator anchor))) | 2062 (setq anchor (concat anchor-seperator anchor))) |
1981 (kill-buffer html-help-buffer) | 2063 (kill-buffer html-help-buffer) |
1982 (pop-to-buffer html-buffer) | 2064 (pop-to-buffer html-buffer) |
1983 (eval (list function-add-tags | 2065 (eval (list function-add-tags |
1984 ''hm--html-insert-start-tag | 2066 ''hm--html-insert-start-tag |
1985 (concat "<A" | 2067 (concat "<A" |
1986 ; "<A Name=" | 2068 ; "<A Name=" |
1987 ; hrefname | 2069 ; hrefname |
1988 " HREF=\"" | 2070 " HREF=\"" |
1989 scheme | 2071 scheme |
1990 hostname:port | 2072 hostname:port |
1991 servername:port | 2073 servername:port |
1992 path+file | 2074 path+file |
1993 anchor | 2075 anchor |
1994 "\">") | 2076 "\">") |
1995 ''hm--html-insert-end-tag | 2077 ''hm--html-insert-end-tag |
1996 "</A>"))) | 2078 "</A>"))) |
1997 ; (setq point (point)))) | 2079 (setq point (point)))) |
1998 ; (goto-char (point))) | 2080 (goto-char (point))) |
1999 )) | 2081 |
2000 | 2082 |
2001 (defun hm--html-add-info-link-1 (function-add-tags) | 2083 (defun hm--html-add-info-link-1 (function-add-tags) |
2002 "Internal function. Adds the HTML tags for a link on a GNU Info file." | 2084 "Internal function. Adds the HTML tags for a link on a GNU Info file." |
2003 (hm--html-add-link function-add-tags | 2085 (hm--html-add-link function-add-tags |
2004 (list ; scheme | 2086 (list ; scheme |
2336 "Makes a proggate-alist from the PROGGATE-ALLOWED-FILE." | 2418 "Makes a proggate-alist from the PROGGATE-ALLOWED-FILE." |
2337 (if (and (stringp proggate-allowed-file) | 2419 (if (and (stringp proggate-allowed-file) |
2338 (file-exists-p proggate-allowed-file)) | 2420 (file-exists-p proggate-allowed-file)) |
2339 (save-window-excursion | 2421 (save-window-excursion |
2340 (let ((alist nil) | 2422 (let ((alist nil) |
2341 (buffername (find-file-noselect proggate-allowed-file)) | 2423 (buffername (find-file-noselect proggate-allowed-file))) |
2342 (case-fold-search t)) | |
2343 (set-buffer buffername) | 2424 (set-buffer buffername) |
2344 (toggle-read-only) | 2425 (toggle-read-only) |
2345 (goto-char (point-min)) | 2426 (goto-char (point-min)) |
2346 (while (search-forward-regexp "[^ \t\n]+" nil t) | 2427 (while (search-forward-regexp "[^ \t\n]+" nil t) |
2347 (setq alist (append (list (list (buffer-substring | 2428 (setq alist (append (list (list (buffer-substring |
2471 | 2552 |
2472 | 2553 |
2473 (defun hm--html-make-newsgroup-alist () | 2554 (defun hm--html-make-newsgroup-alist () |
2474 "Makes a hm--html-make-newsgroup-alist from a .newsrc.el file. | 2555 "Makes a hm--html-make-newsgroup-alist from a .newsrc.el file. |
2475 The function looks at the environment variable NNTPSERVER. | 2556 The function looks at the environment variable NNTPSERVER. |
2476 If this variable exists, it tries to open the file with the Name | 2557 If this variable exists, it trys to open the file with the Name |
2477 ~/$NNTPSERVER.el. If this file exists, the alist of the file is | 2558 ~/$NNTPSERVER.el. If this file exists, the alist of the file is |
2478 returned as the newsgroup-alist. If the file doesn't exist, it | 2559 returned as the newsgroup-alist. If the file doesn't exist, it |
2479 tries to use the file ~/$NNTPSERVER to make the alist. The function | 2560 tries to use the file ~/$NNTPSERVER to make the alist. The function |
2480 returns '((\"\"))" | 2561 returns '((\"\"))" |
2481 (if hm--html-newsgroup-alist | 2562 (if hm--html-newsgroup-alist |
2492 (setq hm--html-newsgroup-alist gnus-newsrc-assoc)) | 2573 (setq hm--html-newsgroup-alist gnus-newsrc-assoc)) |
2493 (if (not (file-exists-p newsrc-file)) | 2574 (if (not (file-exists-p newsrc-file)) |
2494 '(("")) | 2575 '(("")) |
2495 (save-window-excursion | 2576 (save-window-excursion |
2496 (let ((alist nil) | 2577 (let ((alist nil) |
2497 (buffername (find-file-noselect newsrc-file)) | 2578 (buffername (find-file-noselect newsrc-file))) |
2498 (case-fold-search t)) | |
2499 (set-buffer buffername) | 2579 (set-buffer buffername) |
2500 (toggle-read-only) | 2580 (toggle-read-only) |
2501 (goto-char (point-min)) | 2581 (goto-char (point-min)) |
2502 (while (search-forward-regexp "[^:!]+" nil t) | 2582 (while (search-forward-regexp "[^:!]+" nil t) |
2503 (setq alist (append (list (list (buffer-substring | 2583 (setq alist (append (list (list (buffer-substring |
2591 | 2671 |
2592 | 2672 |
2593 (defun hm--html-add-mail-box-link () | 2673 (defun hm--html-add-mail-box-link () |
2594 "Adds the HTML tags for a link to a mail box." | 2674 "Adds the HTML tags for a link to a mail box." |
2595 (interactive) | 2675 (interactive) |
2596 (hm--html-add-mail-box-link-1 'hm--html-add-tags)) | 2676 (hm--html-add-mail-link-1 'hm--html-add-tags)) |
2597 | 2677 |
2598 | 2678 |
2599 (defun hm--html-add-mail-box-link-to-region () | 2679 (defun hm--html-add-mail-box-link-to-region () |
2600 "Adds the HTML tags for a link to a mail box to the region." | 2680 "Adds the HTML tags for a link to a mail box to the region." |
2601 (interactive) | 2681 (interactive) |
2602 (hm--html-add-mail-box-link-1 'hm--html-add-tags-to-region)) | 2682 (hm--html-add-mail-link-1 'hm--html-add-tags-to-region)) |
2603 | 2683 |
2604 | 2684 |
2605 (defun hm--html-add-mailto-link-1 (function-add-tags) | 2685 (defun hm--html-add-mailto-link-1 (function-add-tags) |
2606 "Internal function. Adds the HTML tags for a mailto link." | 2686 "Internal function. Adds the HTML tags for a mailto link." |
2607 (let ((mailto-alist (if (and (boundp 'user-mail-address) | 2687 (let ((mailto-alist (if (and (boundp 'user-mail-address) |
2648 (interactive) | 2728 (interactive) |
2649 (hm--html-add-mailto-link-1 'hm--html-add-tags-to-region)) | 2729 (hm--html-add-mailto-link-1 'hm--html-add-tags-to-region)) |
2650 | 2730 |
2651 (defun hm--html-add-relative-link (relative-file-path) | 2731 (defun hm--html-add-relative-link (relative-file-path) |
2652 "Adds the HTML tags for a relative link at the current point." | 2732 "Adds the HTML tags for a relative link at the current point." |
2653 (interactive (list (file-relative-name | 2733 (interactive (list (read-file-name "Relative Filename: " |
2654 (read-file-name "Relative Filename: " | 2734 nil |
2655 nil | 2735 nil |
2656 nil | 2736 nil |
2657 nil | 2737 ""))) |
2658 "") | |
2659 default-directory) | |
2660 )) | |
2661 (hm--html-add-tags 'hm--html-insert-start-tag | 2738 (hm--html-add-tags 'hm--html-insert-start-tag |
2662 (concat "<A HREF=\"" | 2739 (concat "<A HREF=\"" |
2663 relative-file-path | 2740 relative-file-path |
2664 "\">") | 2741 "\">") |
2665 'hm--html-insert-end-tag | 2742 'hm--html-insert-end-tag |
2666 "</A>")) | 2743 "</A>")) |
2667 | 2744 |
2668 (defun hm--html-add-relative-link-to-region (relative-file-path) | 2745 (defun hm--html-add-relative-link-to-region (relative-file-path) |
2669 "Adds the HTML tags for a relative link to the region." | 2746 "Adds the HTML tags for a relative link to the region." |
2670 (interactive (list (file-relative-name | 2747 (interactive (list (read-file-name "Relative Filename: " |
2671 (read-file-name "Relative Filename: " | 2748 nil |
2672 nil | 2749 nil |
2673 nil | 2750 nil |
2674 nil | 2751 ""))) |
2675 "")))) | |
2676 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | 2752 (hm--html-add-tags-to-region 'hm--html-insert-start-tag |
2677 (concat "<A HREF=\"" | 2753 (concat "<A HREF=\"" |
2678 relative-file-path | 2754 relative-file-path |
2679 "\">") | 2755 "\">") |
2680 'hm--html-insert-end-tag | 2756 'hm--html-insert-end-tag |
2697 Single argument LINK-OBJECT is value of HREF in the new anchor. | 2773 Single argument LINK-OBJECT is value of HREF in the new anchor. |
2698 Mark is set after anchor." | 2774 Mark is set after anchor." |
2699 (interactive "sNode Link to: ") | 2775 (interactive "sNode Link to: ") |
2700 (hm--html-add-tags-to-region 'hm--html-insert-start-tag | 2776 (hm--html-add-tags-to-region 'hm--html-insert-start-tag |
2701 (concat "<A HREF=\"" | 2777 (concat "<A HREF=\"" |
2778 ; (read-string "Link to: ") | |
2702 link-object | 2779 link-object |
2703 "\">") | 2780 "\">") |
2704 'hm--html-insert-end-tag | 2781 'hm--html-insert-end-tag |
2705 "</A>")) | 2782 "</A>")) |
2706 | 2783 |
2739 (point-max))))) | 2816 (point-max))))) |
2740 (goto-char (point-min)) | 2817 (goto-char (point-min)) |
2741 (if (re-search-forward | 2818 (if (re-search-forward |
2742 (concat | 2819 (concat |
2743 "\\((\\)" | 2820 "\\((\\)" |
2744 "\\([ \t]*[0-3]?[0-9]-[A-Z][a-z][a-z]-[0-9][0-9][0-9][0-9]" | 2821 "\\([ \t]*[0-3]?[0-9]-[A-Z][a-z][a-z]-[0-9][0-9][0-9][0-9][ \t]*\\)" |
2745 "[ \t]*\\)" | |
2746 "\\()[ \t\n]*</title>\\)") | 2822 "\\()[ \t\n]*</title>\\)") |
2747 end-of-head | 2823 end-of-head |
2748 t) | 2824 t) |
2749 (progn | 2825 (progn |
2750 (delete-region (match-beginning 2) (match-end 2)) | 2826 (delete-region (match-beginning 2) (match-end 2)) |
2769 (point-max))))) | 2845 (point-max))))) |
2770 (goto-char (point-min)) | 2846 (goto-char (point-min)) |
2771 (if (not (search-forward "</title>" end-of-head t)) | 2847 (if (not (search-forward "</title>" end-of-head t)) |
2772 (if (not noerror) | 2848 (if (not noerror) |
2773 (error "ERROR: Please insert a title in the document !")) | 2849 (error "ERROR: Please insert a title in the document !")) |
2774 ; (let ((end-of-title-position (point))) | 2850 (let ((end-of-title-position (point))) |
2775 (if (search-forward "<!-- Created by: " end-of-head t) | 2851 (if (search-forward "<!-- Created by: " end-of-head t) |
2776 (if (yes-or-no-p | 2852 (if (yes-or-no-p |
2777 "Replace the old comment \"<!-- Created by: \" ") | 2853 "Replace the old comment \"<!-- Created by: \" ") |
2778 (progn | 2854 (progn |
2779 (goto-char (match-beginning 0)) | 2855 (goto-char (match-beginning 0)) |
2780 (kill-line) | 2856 (kill-line) |
2781 (hm--html-add-comment) | 2857 (hm--html-add-comment) |
2782 (insert "Created by: " | 2858 (insert "Created by: " |
2783 (or hm--html-username (user-full-name)) | 2859 (or hm--html-username (user-full-name)) |
2784 ", " | 2860 ", " |
2785 (hm--date)))) | 2861 (hm--date)))) |
2786 (newline) | 2862 (newline) |
2787 (hm--html-add-comment) | 2863 (hm--html-add-comment) |
2788 (insert "Created by: " | 2864 (insert "Created by: " |
2789 (or hm--html-username (user-full-name)) | 2865 (or hm--html-username (user-full-name)) |
2790 ", " | 2866 ", " |
2791 (hm--date) | 2867 (hm--date) |
2792 )))))) | 2868 ))))))) |
2793 | 2869 |
2794 | 2870 |
2795 (defun hm--html-insert-changed-comment-1 (newline username) | 2871 (defun hm--html-insert-changed-comment-1 (newline username) |
2796 "Internal function of 'hm--html-insert-changed-comment'. | 2872 "Internal function of 'hm--html-insert-changed-comment'. |
2797 Inserts a newline if NEWLINE is t, before the comment is inserted. | 2873 Inserts a newline if NEWLINE is t, before the comment is inserted. |
2798 USERNAME is the name to be inserted in the comment." | 2874 USERNAME is the name to be inserted in the comment." |
2799 (if newline | 2875 (if newline |
2800 (progn | 2876 (progn |
2877 ; (end-of-line) | |
2801 (newline))) | 2878 (newline))) |
2802 (hm--html-add-comment) | 2879 (hm--html-add-comment) |
2803 (insert "Changed by: " username ", " (hm--date))) | 2880 (insert "Changed by: " username ", " (hm--date))) |
2804 | 2881 |
2805 (defun hm--html-insert-changed-comment (&optional noerror) | 2882 (defun hm--html-insert-changed-comment (&optional noerror) |
2861 | 2938 |
2862 | 2939 |
2863 ;;; Functions to insert templates | 2940 ;;; Functions to insert templates |
2864 | 2941 |
2865 (defvar hm--html-template-file-history nil | 2942 (defvar hm--html-template-file-history nil |
2866 "Historyvariable for the template files in the `hm--html-mode'.") | 2943 "Historvariable for the template files.") |
2867 | 2944 |
2868 (defun hm--html-insert-template (filename) | 2945 (defun hm--html-insert-template (filename) |
2869 "Inserts a templatefile. | 2946 "Inserts a templatefile." |
2870 It uses `tmpl-insert-template-file' to insert | 2947 (interactive (list |
2871 the templates. The variables `tmpl-template-dir-list', | 2948 (let ((file-name-history hm--html-template-file-history)) |
2872 `tmpl-automatic-expand' and `tmpl-history-variable-name' are | 2949 (read-file-name "Templatefile: " |
2873 overwritten by `hm--html-template-dir', | 2950 hm--html-template-dir |
2874 `hm--html-automatic-expand-templates' and `hm--html-template-file-history'." | 2951 nil |
2875 (interactive (list nil)) | 2952 t |
2876 (let ((tmpl-template-dir-list (if (listp hm--html-template-dir) | 2953 nil)))) |
2877 hm--html-template-dir | 2954 ; 'hm--html-template-file-history))) |
2878 (list hm--html-template-dir))) | 2955 (insert-file (expand-file-name filename)) |
2879 (tmpl-automatic-expand hm--html-automatic-expand-templates) | 2956 (if hm--html-automatic-expand-templates |
2880 (tmpl-history-variable-name 'hm--html-template-file-history)) | 2957 (tmpl-expand-templates-in-buffer)) |
2881 (if filename | 2958 (if hm--html-automatic-created-comment |
2882 (tmpl-insert-template-file filename) | 2959 (hm--html-insert-created-comment t))) |
2883 (call-interactively 'tmpl-insert-template-file)) | 2960 |
2884 )) | 2961 |
2885 | 2962 |
2886 (defun hm--html-insert-template-from-fixed-dirs (filename) | 2963 ;;; Functions for highlighting |
2887 "Inserts a templatefile. | 2964 |
2888 It uses `tmpl-insert-template-file-from-fixed-dirs' to insert | 2965 ;(defun hm--html-toggle-use-highlighting () |
2889 the templates. The variables `tmpl-template-dir-list', | 2966 ; "Toggles the variable html-use-highlighting." |
2890 `tmpl-automatic-expand', `tmpl-filter-regexp' and | 2967 ; (interactive) |
2891 `tmpl-history-variable-name' are overwritten by | 2968 ; (if html-use-highlighting |
2892 `hm--html-template-dir', `hm--html-automatic-expand-templates', | 2969 ; (setq html-use-highlighting nil) |
2893 `hm--html-template-filter-regexp' and `hm--html-template-file-history'." | 2970 ; (setq html-use-highlighting t))) |
2894 (interactive (list nil)) | |
2895 (let ((tmpl-template-dir-list (if (listp hm--html-template-dir) | |
2896 hm--html-template-dir | |
2897 (list hm--html-template-dir))) | |
2898 (tmpl-automatic-expand hm--html-automatic-expand-templates) | |
2899 (tmpl-filter-regexp hm--html-template-filter-regexp) | |
2900 (tmpl-history-variable-name 'hm--html-template-file-history)) | |
2901 (if filename | |
2902 (tmpl-insert-template-file-from-fixed-dirs filename) | |
2903 (call-interactively 'tmpl-insert-template-file-from-fixed-dirs)) | |
2904 )) | |
2905 | 2971 |
2906 | 2972 |
2907 ;;; Functions for font lock mode | 2973 ;;; Functions for font lock mode |
2908 | 2974 |
2909 (if (adapt-emacs19p) | 2975 (if (adapt-emacs19p) |
2918 (or (face-differs-from-default-p 'font-lock-string-face) | 2984 (or (face-differs-from-default-p 'font-lock-string-face) |
2919 (progn | 2985 (progn |
2920 (copy-face 'font-lock-doc-string-face 'font-lock-string-face) | 2986 (copy-face 'font-lock-doc-string-face 'font-lock-string-face) |
2921 (set-face-underline-p 'font-lock-string-face t))) | 2987 (set-face-underline-p 'font-lock-string-face t))) |
2922 (setq font-lock-comment-face 'font-lock-comment-face) | 2988 (setq font-lock-comment-face 'font-lock-comment-face) |
2989 ;; (setq font-lock-doc-string-face 'font-lock-doc-string-face) | |
2923 (setq font-lock-string-face 'font-lock-string-face))) | 2990 (setq font-lock-string-face 'font-lock-string-face))) |
2991 | |
2992 | |
2993 ;(defun hm--html-set-font-lock-color () | |
2994 ; "Sets the color for the font lock mode in HTML mode. | |
2995 ;This color is used to highlight HTML expressions." | |
2996 ; (interactive) | |
2997 ; (setq hm--html-font-lock-color | |
2998 ; (completing-read "Color: " | |
2999 ; '(("grey80") | |
3000 ; ("black") | |
3001 ; ("red") | |
3002 ; ("yellow") | |
3003 ; ("blue")) | |
3004 ; nil | |
3005 ; nil | |
3006 ; "black")) | |
3007 ; (set-face-foreground 'font-lock-comment-face hm--html-font-lock-color) | |
3008 ; (set-face-foreground 'font-lock-string-face hm--html-font-lock-color)) | |
3009 | |
3010 | |
3011 ;;; Functions which determine if an active region exists | |
3012 | |
3013 ;(defvar hm--region-active nil | |
3014 ; "t : Region is active. | |
3015 ;nil: Region is inactive.") | |
3016 ; | |
3017 ; | |
3018 ;(defun hm--set-hm--region-active () | |
3019 ; (setq hm--region-active t)) | |
3020 ; | |
3021 ; | |
3022 ;(defun hm--unset-hm--region-active () | |
3023 ; (setq hm--region-active nil)) | |
3024 | |
2924 | 3025 |
2925 | 3026 |
2926 ;;; Functions to insert forms | 3027 ;;; Functions to insert forms |
2927 | 3028 |
2928 (defun hm--html-form-read-method () | 3029 (defun hm--html-form-read-method () |
3374 (interactive "NNo of cells in a row: ") | 3475 (interactive "NNo of cells in a row: ") |
3375 (if (< no-of-cells 1) | 3476 (if (< no-of-cells 1) |
3376 (error "ERROR: There must be at least one cell in a row!")) | 3477 (error "ERROR: There must be at least one cell in a row!")) |
3377 (hm--html-add-tags | 3478 (hm--html-add-tags |
3378 'hm--html-insert-end-tag-with-newline | 3479 'hm--html-insert-end-tag-with-newline |
3379 (concat "<TR>" | 3480 (concat |
3380 (mapconcat '(lambda (entry) | 3481 (mapconcat '(lambda (entry) |
3381 (concat "<TH" entry)) | 3482 (concat "<TH" entry)) |
3382 (hm--html-table-read-cell-entries-and-alignments | 3483 (hm--html-table-read-cell-entries-and-alignments 1 no-of-cells) |
3383 1 | 3484 " ") |
3384 no-of-cells) | 3485 " <TR>"))) |
3385 " </TH>") | |
3386 " </TH></TR>"))) | |
3387 | 3486 |
3388 | 3487 |
3389 (defun hm--html-add-first-table-row (no-of-cells) | 3488 (defun hm--html-add-first-table-row (no-of-cells) |
3390 "Adds the HTML tags for a table row. | 3489 "Adds the HTML tags for a table row. |
3391 It asks for the number of cells and the allignment of the cells. | 3490 It asks for the number of cells and the allignment of the cells. |
3393 (interactive "NNo of cells in a row: ") | 3492 (interactive "NNo of cells in a row: ") |
3394 (if (< no-of-cells 1) | 3493 (if (< no-of-cells 1) |
3395 (error "ERROR: There must be at least one cell in a row!")) | 3494 (error "ERROR: There must be at least one cell in a row!")) |
3396 (hm--html-add-tags | 3495 (hm--html-add-tags |
3397 'hm--html-insert-end-tag-with-newline | 3496 'hm--html-insert-end-tag-with-newline |
3398 (concat "<TR><TD" | 3497 (concat "<TD" (car (hm--html-table-read-cell-entries-and-alignments 1 1)) |
3399 (car (hm--html-table-read-cell-entries-and-alignments 1 1)) | 3498 " " |
3400 " </TD>" | |
3401 (if (<= no-of-cells 1) | 3499 (if (<= no-of-cells 1) |
3402 "</TR>" | 3500 "<TR>" |
3403 (concat | 3501 (concat |
3404 (mapconcat '(lambda (entry) | 3502 (mapconcat '(lambda (entry) |
3405 (concat "<TD" entry)) | 3503 (concat "<TD" entry)) |
3406 (hm--html-table-read-cell-entries-and-alignments | 3504 (hm--html-table-read-cell-entries-and-alignments |
3407 2 no-of-cells) | 3505 2 no-of-cells) |
3408 " </TD>") | 3506 " ") |
3409 " </TD></TR>"))))) | 3507 " <TR>"))))) |
3410 | 3508 |
3411 | 3509 |
3412 (defun hm--html-table-get-previous-alignments () | 3510 (defun hm--html-table-get-previous-alignments () |
3413 "Returns a list with the alignments of the previous table row. | 3511 "Returns a list with the alignments of the previous table row. |
3414 The row must be a data row and not a header row! | 3512 The row must be a data row and not a header row! |
3415 An example for the return list: '(\"left\" \"default\" \"center\" \"right\")" | 3513 An example for the return list: '(\"left\" \"default\" \"center\" \"right\")" |
3416 (save-excursion | 3514 (save-excursion |
3417 (let* ((point-of-view (point)) | 3515 (let* ((point-of-view (point)) |
3418 (case-fold-search t) | 3516 (end-of-last-row (search-backward "<tr>" nil t)) |
3419 (end-of-last-row (search-backward "</tr>" (point-min) t)) | 3517 (begin-of-last-row (progn (search-backward "<tr" nil t) |
3420 (begin-of-last-row (progn (search-backward "<tr" (point-min) t) | 3518 (search-forward "<td" nil t) |
3421 (re-search-forward "<t[dh]" | |
3422 point-of-view t) | |
3423 (match-beginning 0))) | 3519 (match-beginning 0))) |
3424 (alignment-list nil)) | 3520 (alignment-list nil)) |
3425 (goto-char begin-of-last-row) | 3521 (if (not (search-forward "<td" end-of-last-row t)) |
3426 (if (not (re-search-forward "<t[dh]" end-of-last-row t)) | |
3427 (error "Error: No previous data row found!") | 3522 (error "Error: No previous data row found!") |
3428 (goto-char end-of-last-row) | 3523 (goto-char end-of-last-row) |
3429 (while (> (point) begin-of-last-row) | 3524 (while (> (point) begin-of-last-row) |
3430 (let ((cell-start | 3525 (let ((cell-start |
3431 (search-backward-regexp "\\(<td[^>]*>\\)\\|\\(<th[^>]*>\\)" | 3526 (search-backward-regexp "\\(<td[^>]*>\\)\\|\\(<th[^>]*>\\)" |
3453 (interactive) | 3548 (interactive) |
3454 (let* ((old-alignment-list (hm--html-table-get-previous-alignments)) | 3549 (let* ((old-alignment-list (hm--html-table-get-previous-alignments)) |
3455 (no-of-cells (length old-alignment-list))) | 3550 (no-of-cells (length old-alignment-list))) |
3456 (hm--html-add-tags | 3551 (hm--html-add-tags |
3457 'hm--html-insert-end-tag-with-newline | 3552 'hm--html-insert-end-tag-with-newline |
3458 (concat "<TR><TD" (car (hm--html-table-read-cell-entries-and-alignments | 3553 (concat "<TD" (car (hm--html-table-read-cell-entries-and-alignments |
3459 1 | 3554 1 |
3460 1 | 3555 1 |
3461 old-alignment-list)) | 3556 old-alignment-list)) |
3462 " </TD>" | 3557 " " |
3463 (if (<= no-of-cells 1) | 3558 (if (<= no-of-cells 1) |
3464 "</TR>" | 3559 "<TR>" |
3465 (concat | 3560 (concat |
3466 (mapconcat '(lambda (entry) | 3561 (mapconcat '(lambda (entry) |
3467 (concat "<TD" entry)) | 3562 (concat "<TD" entry)) |
3468 (hm--html-table-read-cell-entries-and-alignments | 3563 (hm--html-table-read-cell-entries-and-alignments |
3469 2 | 3564 2 |
3470 no-of-cells | 3565 no-of-cells |
3471 (cdr old-alignment-list)) | 3566 (cdr old-alignment-list)) |
3472 " </TD>") | 3567 " ") |
3473 " </TD></TR>")))))) | 3568 " <TR>")))))) |
3474 | 3569 |
3475 | 3570 |
3476 (defun hm--html-add-row-entry (alignment) | 3571 (defun hm--html-add-row-entry (alignment) |
3477 "Adds the HTML tag for a table row entry at the current point." | 3572 "Adds the HTML tag for a table row entry at the current point." |
3478 (interactive (list (completing-read "Alignment of the cell: " | 3573 (interactive (list (completing-read "Alignment of the cell: " |
3535 | 3630 |
3536 (defun hm--html-table-add-colspan-attribute (columns) | 3631 (defun hm--html-table-add-colspan-attribute (columns) |
3537 "Adds a colspawn attribute to a table cell. | 3632 "Adds a colspawn attribute to a table cell. |
3538 A prefix arg is used as no of COLUMNS." | 3633 A prefix arg is used as no of COLUMNS." |
3539 (interactive "NNo of columns, spaned by this cell: ") | 3634 (interactive "NNo of columns, spaned by this cell: ") |
3540 (let ((case-fold-search t)) | 3635 (save-excursion |
3541 (save-excursion | 3636 (if (and (search-backward "<" nil t) |
3542 (if (and (search-backward "<" nil t) | 3637 (search-forward-regexp "<[ \t\n]*\\(th\\)\\|\\(td\\)" nil t)) |
3543 (search-forward-regexp "<[ \t\n]*\\(th\\)\\|\\(td\\)" nil t)) | 3638 (if (search-forward-regexp "\\([ \t\n]+colspan=\\)\\([^ \t\n>]*\\)" |
3544 (if (search-forward-regexp "\\([ \t\n]+colspan=\\)\\([^ \t\n>]*\\)" | 3639 nil |
3545 nil | 3640 t) |
3546 t) | 3641 (progn |
3547 (progn | 3642 (delete-region (match-beginning 2) (match-end 2)) |
3548 (delete-region (match-beginning 2) (match-end 2)) | 3643 (insert (format "\"%d\"" columns))) |
3549 (insert (format "\"%d\"" columns))) | 3644 (insert (format " colspan=\"%d\"" columns))) |
3550 (insert (format " colspan=\"%d\"" columns))) | 3645 (error "ERROR: Point not in a table cell!")))) |
3551 (error "ERROR: Point not in a table cell!"))))) | |
3552 | 3646 |
3553 | 3647 |
3554 (defun hm--html-table-add-rowspan-attribute (rows) | 3648 (defun hm--html-table-add-rowspan-attribute (rows) |
3555 "Adds a rowspan attribute to a table cell. | 3649 "Adds a rowspan attribute to a table cell. |
3556 A prefix arg is used as no of ROWS." | 3650 A prefix arg is used as no of ROWS." |
3557 (interactive "NNo of rows, spaned by this cell: ") | 3651 (interactive "NNo of rows, spaned by this cell: ") |
3558 (let ((case-fold-search t)) | 3652 (save-excursion |
3559 (save-excursion | 3653 (if (and (search-backward "<" nil t) |
3560 (if (and (search-backward "<" nil t) | 3654 (search-forward-regexp "<[ \t\n]*\\(th\\)\\|\\(td\\)" nil t)) |
3561 (search-forward-regexp "<[ \t\n]*\\(th\\)\\|\\(td\\)" nil t)) | 3655 (if (search-forward-regexp "\\([ \t\n]+rowspan=\\)\\([^ \t\n>]*\\)" |
3562 (if (search-forward-regexp "\\([ \t\n]+rowspan=\\)\\([^ \t\n>]*\\)" | 3656 nil |
3563 nil | 3657 t) |
3564 t) | 3658 (progn |
3565 (progn | 3659 (delete-region (match-beginning 2) (match-end 2)) |
3566 (delete-region (match-beginning 2) (match-end 2)) | 3660 (insert (format "\"%d\"" rows))) |
3567 (insert (format "\"%d\"" rows))) | 3661 (insert (format " rowspan=\"%d\"" rows))) |
3568 (insert (format " rowspan=\"%d\"" rows))) | 3662 (error "ERROR: Point not in a table cell!")))) |
3569 (error "ERROR: Point not in a table cell!"))))) | |
3570 | 3663 |
3571 | 3664 |
3572 ;;; ISO-Characters for Emacs HTML-mode (Berthold Crysmann) | 3665 ;;; ISO-Characters for Emacs HTML-mode (Berthold Crysmann) |
3573 ;(setq buffer-invisibility-spec '(hm--html-iso-entity-invisible-flag)) | 3666 ;(setq buffer-invisibility-spec '(hm--html-iso-entity-invisible-flag)) |
3574 | 3667 |
4022 | 4115 |
4023 ;;This should be extended in the future to use also other viewers. | 4116 ;;This should be extended in the future to use also other viewers. |
4024 (defun hm--html-view-www-package-docu () | 4117 (defun hm--html-view-www-package-docu () |
4025 "View the WWW documentation of the package." | 4118 "View the WWW documentation of the package." |
4026 (interactive) | 4119 (interactive) |
4027 (w3-fetch (concat "http://www.tnt.uni-hannover.de" | 4120 (w3-fetch "http://www.tnt.uni-hannover.de:80/data/info/www/tnt/soft/info/www/html-editors/hm--html-menus/overview.html")) |
4028 "/~muenkel/software/own/hm--html-menus/overview.html"))) | |
4029 | |
4030 | 4121 |
4031 ;;; | 4122 ;;; |
4032 ; Bug reporting | 4123 ; Bug reporting |
4033 ; | 4124 ; |
4034 | 4125 |
4078 'hm--html-server-side-include-command-with-parameter-alist | 4169 'hm--html-server-side-include-command-with-parameter-alist |
4079 'hm--html-signature-file | 4170 'hm--html-signature-file |
4080 'hm--html-template-dir | 4171 'hm--html-template-dir |
4081 'hm--html-url-alist | 4172 'hm--html-url-alist |
4082 'hm--html-user-config-file | 4173 'hm--html-user-config-file |
4083 'hm--html-site-config-file | |
4084 'hm--html-username | 4174 'hm--html-username |
4085 'hm--html-wais-hostname:port-alist | 4175 'hm--html-wais-hostname:port-alist |
4086 'hm--html-wais-hostname:port-default | 4176 'hm--html-wais-hostname:port-default |
4087 'hm--html-wais-path-alist | 4177 'hm--html-wais-path-alist |
4088 'hm--html-wais-servername:port-alist | 4178 'hm--html-wais-servername:port-alist |
4089 'hm--html-wais-servername:port-default | 4179 'hm--html-wais-servername:port-default |
4180 ; 'html-deemphasize-color | |
4090 'html-document-previewer | 4181 'html-document-previewer |
4182 ; 'html-document-previewer-args | |
4183 ; 'html-emphasize-color | |
4184 ; 'html-quotify-hrefs-on-find | |
4091 'hm--html-region-mode | 4185 'hm--html-region-mode |
4092 'html-sigusr1-signal-value | 4186 'html-sigusr1-signal-value |
4187 ; 'html-use-font-lock | |
4188 ; 'html-use-highlighting | |
4093 ) | 4189 ) |
4094 nil | 4190 nil |
4095 nil | 4191 nil |
4096 "Decribe your Bug: " | 4192 "Decribe your Bug: " |
4097 ))) | 4193 ))) |
4104 (if (adapt-xemacsp) | 4200 (if (adapt-xemacsp) |
4105 (progn | 4201 (progn |
4106 | 4202 |
4107 (add-hook 'zmacs-activate-region-hook | 4203 (add-hook 'zmacs-activate-region-hook |
4108 'hm--html-switch-region-modes-on) | 4204 'hm--html-switch-region-modes-on) |
4205 ; (function (lambda () (hm--html-region-mode 1)))) | |
4109 | 4206 |
4110 (add-hook 'zmacs-deactivate-region-hook | 4207 (add-hook 'zmacs-deactivate-region-hook |
4111 'hm--html-switch-region-modes-off) | 4208 'hm--html-switch-region-modes-off) |
4209 ; (function (lambda () (hm--html-region-mode -1)))) | |
4112 | 4210 |
4113 ) | 4211 ) |
4114 | 4212 |
4115 (transient-mark-mode t) | 4213 (transient-mark-mode t) |
4116 | 4214 |
4117 (add-hook 'activate-mark-hook | 4215 (add-hook 'activate-mark-hook |
4118 'hm--html-switch-region-modes-on) | 4216 'hm--html-switch-region-modes-on) |
4217 ; (function (lambda () (hm--html-region-mode t)))) | |
4119 | 4218 |
4120 (add-hook 'deactivate-mark-hook | 4219 (add-hook 'deactivate-mark-hook |
4121 'hm--html-switch-region-modes-off) | 4220 'hm--html-switch-region-modes-off) |
4221 ; (function (lambda () (hm--html-region-mode nil)))) | |
4122 | 4222 |
4123 ) | 4223 ) |
4224 | |
4225 | |
4226 ;(add-hook 'hm--html-mode-hook | |
4227 ; (function | |
4228 ; (lambda () | |
4229 ; (make-variable-buffer-local 'write-file-hooks) | |
4230 ; (add-hook 'write-file-hooks | |
4231 ; 'hm--html-maybe-new-date-and-changed-comment)))) | |
4232 | |
4233 ;(add-hook 'zmacs-activate-region-hook 'hm--set-hm--region-active) | |
4234 ; | |
4235 ;(add-hook 'zmacs-deactivate-region-hook 'hm--unset-hm--region-active) | |
4236 | |
4124 | 4237 |
4125 | 4238 |
4126 ;;; | 4239 ;;; |
4127 ; Environment loading | 4240 ; Environment loading |
4128 ; | 4241 ; |
4129 | 4242 |
4130 (defun hm--html-load-config-files () | 4243 (defun hm--html-load-config-files () |
4131 "Load the html configuration files. | 4244 "Load the html configuration files. |
4132 First, the system config file (detemined by the environment variable | 4245 First, the system config file (detemined by the environment variable |
4133 HTML_CONFIG_FILE; normaly hm--html-configuration.el(c)) is loaded. | 4246 HTML_CONFIG_FILE; normaly hm--html-configuration.el(c)) is loaded and |
4134 At second a site config file is loaded, if the environment variable | 4247 after that the user config file (determined by the environment variable |
4135 HTML_SITE_CONFIG_FILE or the lisp variable `hm--html-site-config-file' | |
4136 is set to such a file. | |
4137 At least the user config file (determined by the environment variable | |
4138 HTML_USER_CONFIG_FILE; normaly the file ~/.hm--html-configuration.el(c)). | 4248 HTML_USER_CONFIG_FILE; normaly the file ~/.hm--html-configuration.el(c)). |
4139 If no HTML_CONFIG_FILE exists, then the file hm--html-configuration.el(c) | 4249 If no HTML_CONFIG_FILE exists, then the file hm--html-configuration.el(c) |
4140 is searched in one of the lisp load path directories. | 4250 is searched in one of the lisp load path directories. |
4141 If no HTML_USER_CONFIG_FILE exists, then the variable | 4251 If no HTML_USER_CONFIG_FILE exists, then the variable |
4142 `hm--html-user-config-file' is checked. If this variable is nil or the file | 4252 `hm--html-user-config-file' is checked. If this variable is nil or the file |
4147 (file-exists-p | 4257 (file-exists-p |
4148 (expand-file-name | 4258 (expand-file-name |
4149 (getenv "HTML_CONFIG_FILE")))) | 4259 (getenv "HTML_CONFIG_FILE")))) |
4150 (load-library (expand-file-name (getenv "HTML_CONFIG_FILE"))) | 4260 (load-library (expand-file-name (getenv "HTML_CONFIG_FILE"))) |
4151 (load-library "hm--html-configuration")) | 4261 (load-library "hm--html-configuration")) |
4152 | |
4153 ;; at second the site config file | |
4154 (if (and (stringp (getenv "HTML_SITE_CONFIG_FILE")) | |
4155 (file-exists-p | |
4156 (expand-file-name | |
4157 (getenv "HTML_SITE_CONFIG_FILE")))) | |
4158 (load-file (expand-file-name (getenv "HTML_SITE_CONFIG_FILE"))) | |
4159 (when (and (boundp 'hm--html-site-config-file) | |
4160 (stringp hm--html-site-config-file) | |
4161 (file-exists-p (expand-file-name hm--html-site-config-file))) | |
4162 (load-file (expand-file-name hm--html-site-config-file)))) | |
4163 | 4262 |
4164 ;; and now the user config file | 4263 ;; and now the user config file |
4165 (cond ((and (stringp (getenv "HTML_USER_CONFIG_FILE")) | 4264 (cond ((and (stringp (getenv "HTML_USER_CONFIG_FILE")) |
4166 (file-exists-p | 4265 (file-exists-p |
4167 (expand-file-name | 4266 (expand-file-name |
4180 "Look at hm--html-load-config-files !"))) | 4279 "Look at hm--html-load-config-files !"))) |
4181 ) | 4280 ) |
4182 ) | 4281 ) |
4183 | 4282 |
4184 | 4283 |
4284 | |
4285 ;(hm--html-load-config-files) | |
4286 | |
4287 ;;; Definition of the minor mode html-region-mode | |
4288 | |
4289 ;(defvar html-region-mode nil | |
4290 ; "*t, if the minor mode html-region-mode is on and nil otherwise.") | |
4291 | |
4292 ;(make-variable-buffer-local 'html-region-mode) | |
4293 | |
4294 ;(defvar html-region-mode-map nil "") | |
4295 | |
4296 ;(hm--html-load-config-files) | |
4297 | |
4298 ;(if hm--html-use-old-keymap | |
4299 ; (progn | |
4300 | |
4301 ;;(setq minor-mode-alist (cons '(html-region-mode " Region") minor-mode-alist)) | |
4302 ;(or (assq 'html-region-mode minor-mode-alist) | |
4303 ; (setq minor-mode-alist | |
4304 ; (purecopy | |
4305 ; (append minor-mode-alist | |
4306 ; '((html-region-mode " Region")))))) | |
4307 | |
4308 ;(defun html-region-mode (on) | |
4309 ; "Turns the minor mode html-region-mode on or off. | |
4310 ;The function turns the html-region-mode on, if ON is t and off otherwise." | |
4311 ; (if (string= mode-name "HTML") | |
4312 ; (if on | |
4313 ; ;; html-region-mode on | |
4314 ; (progn | |
4315 ; (setq html-region-mode t) | |
4316 ; (use-local-map html-region-mode-map)) | |
4317 ; ;; html-region-mode off | |
4318 ; (setq html-region-mode nil) | |
4319 ; (use-local-map html-mode-map)))) | |
4320 | |
4321 ;)) | |
4322 | |
4323 | |
4324 | |
4325 | |
4326 | |
4327 ;;; | |
4328 ; Set font lock color | |
4329 ; (hm--html-font-lock-color should be defined in hm--html-configuration.el | |
4330 ; oder .hm--html-configuration.el) | |
4331 ; | |
4332 ;(require 'font-lock) | |
4333 ;(load-library "font-lock") | |
4334 ;(set-face-foreground 'font-lock-comment-face hm--html-font-lock-color) | |
4335 | |
4336 | |
4337 ;(hm--html-generate-help-buffer-faces) | |
4338 | |
4339 | |
4340 | |
4341 | |
4342 ;;;;;;;; | |
4343 ;(setq hm--html-hostname-search-string | |
4344 ; "[-a-zA-Z0-9]*\\.[-a-zA-Z0-9]*\\.[-a-zA-Z0-9.]*") | |
4345 ; | |
4346 ;(defun hm--html-get-next-hostname () | |
4347 ; (interactive) | |
4348 ; (search-forward-regexp hm--html-hostname-search-string) | |
4349 ; (buffer-substring (match-beginning 0) (match-end 0))) | |
4350 ; | |
4351 | |
4352 ;;; Announce the feature hm--html-configuration | |
4353 | |
4185 ;;; quotify href | 4354 ;;; quotify href |
4186 | 4355 |
4187 (defvar hm--html-quotify-href-regexp | 4356 (defvar hm--html-quotify-href-regexp |
4188 "<[aA][ \t\n]+\\([nN][aA][mM][eE]=[a-zA-Z0-9]+[ \t\n]+\\)?[hH][rR][eE][fF]=" | 4357 "<[aA][ \t\n]+\\([nN][aA][mM][eE]=[a-zA-Z0-9]+[ \t\n]+\\)?[hH][rR][eE][fF]=" |
4189 "Regular expression used for searching hrefs.") | 4358 "Regular expression used for searching hrefs.") |