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