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