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