yatex

view yahtml.el @ 58:3a7c0c2bf16d

Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
author yuuji
date Thu, 01 Feb 1996 18:55:47 +0000
parents 18f4939986e6
children 48ac97a6b6ce
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp, pcs39334@asciinet.or.jp]
3 ;;; Last modified Fri Feb 2 02:37:23 1996 on supra
4 ;;; This package is no longer tentative.
5 ;;; $Id$
7 ;;;[Installation]
8 ;;;
9 ;;; First, you have to install YaTeX and make sure it works fine. Then
10 ;;; put these expressions into your ~/.emacs
11 ;;;
12 ;;; (setq auto-mode-alist
13 ;;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist))
14 ;;; (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t)
15 ;;; (setq yahtml-www-browser "netscape")
16 ;;; ;Write your favorite browser. But netscape is advantageous.
17 ;;; (setq yahtml-path-url-alist
18 ;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji")
19 ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji")))
20 ;;; ;Write correspondence alist from ABSOLUTE unix path name to URL path.
21 ;;;
22 ;;;[Commentary]
23 ;;;
24 ;;; It is assumed you are already familiar with YaTeX. The following
25 ;;; completing featureas are available: ([prefix] means `C-c' by default)
26 ;;;
27 ;;; * [prefix] b X Complete environments such as `H1' which
28 ;;; normally requires closing tag `</H1>
29 ;;; <a href=foo> ... </a> is also classified into
30 ;;; this group
31 ;;; * [prefix] s Complete declarative notations such as
32 ;;; `<img src="foo.gif">'
33 ;;; `<input name="var" ...>'
34 ;;; * [prefix] l Complete typeface-changing commands such as
35 ;;; `<i> ... </i>' or `<samp> ... </samp>'
36 ;;; * [prefix] m Complete single commands such as
37 ;;; `<br>' or `<hr> or <li>...'
38 ;;; * menu-bar yahtml Complete all by selecting a menu item (Though I
39 ;;; hate menu, this is most useful)
40 ;;; * [prefix] g Goto corresponding Tag or HREF such as
41 ;;; <dl> <-> </dl> or href="xxx"
42 ;;; * [prefix] k Kill html tags on the point. If you provide
43 ;;; universal-argument, kill surrounded contents too.
44 ;;; * [prefix] c Change html tags on the point.
45 ;;; * [prefix] t b View current html with WWW browser
46 ;;; (To activate this, never fail to set the lisp
47 ;;; variable yahtml-www-browser. Recommended value
48 ;;; is "netscape")
49 ;;;
50 ;;; NOTE! This program is truly tentative. If you find some bright
51 ;;; future with this, please send me a mail to drive me to maintain this :)
54 (require 'yatex)
55 (defvar yahtml-prefix-map nil)
56 (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.")
57 (defvar yahtml-image-viewer "xv" "*Image viewer program")
58 (defvar yahtml-www-browser "netscape"
59 "*WWW Browser command")
60 (defvar yahtml-kanji-code 2
61 "Kanji coding system of html file; 1=sjis, 2=jis, 3=euc")
62 ;;(defvar yahtml-www-server "www" "*Host name of your domain's WWW server")
63 (defvar yahtml-path-url-alist nil
64 "*Alist of unix path name vs. URL name of WWW server.
65 Ex.
66 '((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\")
67 (\"/usr/home/yuuji/darts/http\" . \"http://inspire.comp.ae.keio.ac.jp/~darts\"))")
68 (defvar yahtml-directory-index "index.html"
69 "*Directory index file name;
70 Consult your site's WWW administrator.")
72 (defun yahtml-define-begend-key-normal (key env &optional map)
73 "Define short cut yahtml-insert-begin-end key."
74 (YaTeX-define-key
75 key
76 (list 'lambda '(arg) '(interactive "P")
77 (list 'yahtml-insert-begin-end env 'arg))
78 map))
80 (defun yahtml-define-begend-region-key (key env &optional map)
81 "Define short cut yahtml-insert-begin-end-region key."
82 (YaTeX-define-key key (list 'lambda nil '(interactive)
83 (list 'yahtml-insert-begin-end env t)) map))
85 (defun yahtml-define-begend-key (key env &optional map)
86 "Define short cut key for begin type completion both for
87 normal and region mode. To customize yahtml, user should use this function."
88 (yahtml-define-begend-key-normal key env map)
89 (if YaTeX-inhibit-prefix-letter nil
90 (yahtml-define-begend-region-key
91 (concat (upcase (substring key 0 1)) (substring key 1)) env)))
94 (if yahtml-mode-map nil
95 (setq yahtml-mode-map (make-sparse-keymap)
96 yahtml-prefix-map (make-sparse-keymap))
97 (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map)
98 (define-key yahtml-mode-map "\M-\C-@" 'yahtml-mark-begend)
99 (if (and (boundp 'window-system) (eq window-system 'x) YaTeX-emacs-19)
100 (define-key yahtml-mode-map [?\M-\C- ] 'yahtml-mark-begend))
101 (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment)
102 (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment)
103 (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline)
104 (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line)
105 (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map)
106 (let ((map yahtml-prefix-map))
107 (YaTeX-define-key "^" 'yahtml-visit-main map)
108 (YaTeX-define-key "4^" 'yahtml-visit-main-other-window map)
109 (YaTeX-define-key "4g" 'yahtml-goto-corresponding-*-other-window map)
110 (YaTeX-define-key "44" 'YaTeX-switch-to-window map)
111 (and YaTeX-emacs-19 window-system
112 (progn
113 (YaTeX-define-key "5^" 'yahtml-visit-main-other-frame map)
114 (YaTeX-define-key "5g" 'yahtml-goto-corresponding-*-other-frame map)
115 (YaTeX-define-key "55" 'YaTeX-switch-to-window map)))
116 (YaTeX-define-key "v" 'YaTeX-version map)
117 (YaTeX-define-key "}" 'YaTeX-insert-braces-region map)
118 (YaTeX-define-key "]" 'YaTeX-insert-brackets-region map)
119 (YaTeX-define-key ")" 'YaTeX-insert-parens-region map)
120 (YaTeX-define-key "s" 'yahtml-insert-form map)
121 (YaTeX-define-key "l" 'yahtml-insert-tag map)
122 (YaTeX-define-key "m" 'yahtml-insert-single map)
123 (YaTeX-define-key "n" '(lambda () (interactive) (insert "<br>\n")) map)
124 (if YaTeX-no-begend-shortcut
125 (progn
126 (YaTeX-define-key "B" 'yahtml-insert-begend-region map)
127 (YaTeX-define-key "b" 'yahtml-insert-begend map))
128 (yahtml-define-begend-key "bh" "HTML" map)
129 (yahtml-define-begend-key "bH" "HEAD" map)
130 (yahtml-define-begend-key "bt" "TITLE" map)
131 (yahtml-define-begend-key "bb" "BODY" map)
132 (yahtml-define-begend-key "bd" "DL" map)
133 (yahtml-define-begend-key "b1" "H1" map)
134 (yahtml-define-begend-key "b2" "H2" map)
135 (yahtml-define-begend-key "b3" "H3" map)
136 (yahtml-define-begend-key "ba" "a" map)
137 (yahtml-define-begend-key "bf" "form" map)
138 (yahtml-define-begend-key "bs" "select" map)
139 (YaTeX-define-key "b " 'yahtml-insert-begend map)
140 (YaTeX-define-key "B " 'yahtml-insert-begend-region map)
141 )
142 (YaTeX-define-key "e" 'YaTeX-end-environment map)
143 (YaTeX-define-key ">" 'yahtml-comment-region map)
144 (YaTeX-define-key "<" 'yahtml-uncomment-region map)
145 (YaTeX-define-key "g" 'yahtml-goto-corresponding-* map)
146 (YaTeX-define-key "k" 'yahtml-kill-* map)
147 (YaTeX-define-key "c" 'yahtml-change-* map)
148 (YaTeX-define-key "t" 'yahtml-browse-menu map)
149 ;;;;;(YaTeX-define-key "i" 'yahtml-fill-item map)
150 )
151 )
153 (defvar yahtml-paragraph-separate
154 (concat
155 "^$\\|<[bh]r>\\|<p>\\|^[ \t]*</?\\(h[1-6]\\|p\\|dl\\|dd\\|dt\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\)>")
156 "*Regexp of html paragraph separater")
157 (defvar yahtml-syntax-table nil
158 "*Syntax table for typesetting buffer")
160 (if yahtml-syntax-table nil
161 (setq yahtml-syntax-table
162 (make-syntax-table (standard-syntax-table)))
163 (modify-syntax-entry ?\< "(" yahtml-syntax-table)
164 (modify-syntax-entry ?\> ")" yahtml-syntax-table)
165 )
166 (defvar yahtml-command-regexp "[A-Za-z0-9]+"
167 "Regexp of constituent of html commands.")
169 ;;; Completion tables for `form'
170 (defvar yahtml-form-table
171 '(("img") ("input")))
172 (defvar yahtml-user-form-table nil)
173 (defvar yahtml-tmp-form-table nil)
175 (defvar yahtml-env-table
176 '(("html") ("head") ("title") ("body") ("dl") ("a") ("form") ("select")
177 ("OrderedList" . "ol")
178 ("UnorderedList" . "ul")
179 ("DefinitionList" . "dl")
180 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") ("ul")))
182 (defvar yahtml-itemizing-regexp
183 "\\(ul\\|ul\\|dl\\)"
184 "Regexp of itemizing forms")
186 (defvar yahtml-user-env-table nil)
187 (defvar yahtml-tmp-env-table nil)
189 ;;; Completion tables for typeface designator
190 (defvar yahtml-typeface-table
191 '(("defn") ("em") ("cite") ("code") ("kbd") ("samp")
192 ("strong") ("var") ("b") ("i") ("tt") ("u") ("address"))
193 "Default completion table of typeface designator")
194 (defvar yahtml-user-typeface-table nil)
195 (defvar yahtml-tmp-typeface-table nil)
196 (defvar yahtml-last-typeface-cmd "address")
198 (defvar yahtml-single-cmd-table
199 '(("hr") ("br") ("option") ("p")
200 ("HorizontalLine" . "hr")
201 ("BreakLine" . "br")
202 ("Paragraph" . "p")
203 ("Item" . "li")
204 ("DefineTerm" . "dt")
205 ("Description" . "dd")
206 ("dd") ("dt") ("li")
207 )
208 "Default completion table of HTML single command.")
209 (defvar yahtml-user-single-cmd-table nil)
210 (defvar yahtml-tmp-single-cmd-table nil)
211 (defvar yahtml-last-single-cmd nil)
213 (defvar yahtml-prefer-upcases nil)
214 (cond
215 (yahtml-prefer-upcases
216 (setq yahtml-form-table
217 (mapcar (function (lambda (list) (list (upcase (car list)))))
218 yahtml-form-table))
219 (setq yahtml-env-table
220 (mapcar (function (lambda (list) (list (upcase (car list)))))
221 yahtml-env-table))
222 (setq yahtml-typeface-table
223 (mapcar (function (lambda (list) (list (upcase (car list)))))
224 yahtml-typeface-table))))
226 (defvar yahtml-struct-name-regexp
227 "\\<\\(h[1-6]\\|[uod]l\\|body\\|title\\|head\\|table\\|t[rhd]\\)")
230 (defun yahtml-mode ()
231 (interactive)
232 (yatex-mode)
233 (cond
234 ((boundp 'MULE)
235 (set-file-coding-system
236 (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist))))
237 ((boundp 'NEMACS)
238 (make-local-variable 'kanji-fileio-code)
239 (setq kanji-fileio-code yahtml-kanji-code)))
240 (setq major-mode 'yahtml-mode
241 mode-name "yahtml")
242 (make-local-variable 'YaTeX-ec) (setq YaTeX-ec "")
243 (make-local-variable 'YaTeX-struct-begin) (setq YaTeX-struct-begin "<%1%2>")
244 (make-local-variable 'YaTeX-struct-end) (setq YaTeX-struct-end "</%1>")
245 (make-local-variable 'YaTeX-struct-name-regexp)
246 (setq YaTeX-struct-name-regexp yahtml-struct-name-regexp)
247 (make-local-variable 'YaTeX-prefix-map)
248 (make-local-variable 'YaTeX-command-token-regexp)
249 (setq YaTeX-command-token-regexp yahtml-command-regexp)
250 ;;(make-local-variable 'YaTeX-environment-indent)
251 ;;(setq YaTeX-environment-indent 0)
252 (make-local-variable 'fill-prefix)
253 (setq fill-prefix nil)
254 (make-local-variable 'paragraph-separate)
255 (setq paragraph-separate yahtml-paragraph-separate
256 paragraph-start yahtml-paragraph-separate)
257 (make-local-variable 'comment-start)
258 (make-local-variable 'comment-end)
259 (setq comment-start "<!-- " comment-end " -->")
260 (make-local-variable 'indent-line-function)
261 (setq indent-line-function 'yahtml-indent-line)
262 (make-local-variable 'YaTeX-item-regexp)
263 (setq YaTeX-item-regexp "<\\(li\\|d[td]\\)>")
264 (set-syntax-table yahtml-syntax-table)
265 (use-local-map yahtml-mode-map)
266 (run-hooks 'yahtml-mode-hook))
268 (defun yahtml-define-menu (keymap bindlist)
269 (mapcar
270 (function
271 (lambda (bind)
272 (define-key keymap (vector (car bind)) (cdr bind))))
273 bindlist))
275 (defvar yahtml-menu-map nil "Menu map of yahtml")
276 (defvar yahtml-menu-map-sectioning nil "Menu map of yahtml(sectioning)")
277 (defvar yahtml-menu-map-listing nil "Menu map of yahtml(listing)")
278 (defvar yahtml-menu-map-logical nil "Menu map of yahtml(logical tags)")
279 (defvar yahtml-menu-map-typeface nil "Menu map of yahtml(typeface tags)")
281 ;;; Variables for mosaic url history
282 (defvar yahtml-urls nil "Alist of global history")
283 (defvar yahtml-url-history-file "~/.mosaic-global-history"
284 "File name of url history")
286 (cond
287 ((and YaTeX-emacs-19 (null yahtml-menu-map))
288 (setq yahtml-menu-map (make-sparse-keymap "yahtml menu"))
289 (setq yahtml-menu-map-sectioning (make-sparse-keymap "sectioning menu"))
290 (yahtml-define-menu
291 yahtml-menu-map-sectioning
292 (nreverse
293 '((1 "H1" . (lambda () (interactive) (yahtml-insert-begend nil "H1")))
294 (2 "H2" . (lambda () (interactive) (yahtml-insert-begend nil "H2")))
295 (3 "H3" . (lambda () (interactive) (yahtml-insert-begend nil "H3")))
296 (4 "H4" . (lambda () (interactive) (yahtml-insert-begend nil "H4")))
297 (5 "H5" . (lambda () (interactive) (yahtml-insert-begend nil "H5")))
298 (6 "H6" . (lambda () (interactive) (yahtml-insert-begend nil "H6")))
299 )))
300 (setq yahtml-menu-map-logical (make-sparse-keymap "logical tags"))
301 (yahtml-define-menu
302 yahtml-menu-map-logical
303 (nreverse
304 '((em "Embolden" .
305 (lambda () (interactive) (yahtml-insert-tag nil "EM")))
306 (defn "Define a word" .
307 (lambda () (interactive) (yahtml-insert-tag nil "DEFN")))
308 (cite "Citation" .
309 (lambda () (interactive) (yahtml-insert-tag nil "CITE")))
310 (code "Code" .
311 (lambda () (interactive) (yahtml-insert-tag nil "CODE")))
312 (kbd "Keyboard" .
313 (lambda () (interactive) (yahtml-insert-tag nil "KBD")))
314 (samp "Sample display" .
315 (lambda () (interactive) (yahtml-insert-tag nil "SAMP")))
316 (strong "Strong" .
317 (lambda () (interactive) (yahtml-insert-tag nil "STRONG")))
318 (VAR "Variable notation" .
319 (lambda () (interactive) (yahtml-insert-tag nil "VAR")))
320 )))
321 (setq yahtml-menu-map-typeface (make-sparse-keymap "typeface tags"))
322 (yahtml-define-menu
323 yahtml-menu-map-typeface
324 (nreverse
325 '((b "Bold" .
326 (lambda () (interactive) (yahtml-insert-tag nil "B")))
327 (i "Italic" .
328 (lambda () (interactive) (yahtml-insert-tag nil "I")))
329 (tt "Typewriter" .
330 (lambda () (interactive) (yahtml-insert-tag nil "TT")))
331 (u "Underlined" .
332 (lambda () (interactive) (yahtml-insert-tag nil "U")))
333 )))
334 (setq yahtml-menu-map-listing (make-sparse-keymap "listing"))
335 (yahtml-define-menu
336 yahtml-menu-map-listing
337 (nreverse
338 '((ul "Unordered" .
339 (lambda () (interactive) (yahtml-insert-begend nil "UL")))
340 (ol "Ordered" .
341 (lambda () (interactive) (yahtml-insert-begend nil "OL")))
342 (dl "Definition" .
343 (lambda () (interactive) (yahtml-insert-begend nil "DL")))
344 )))
345 (setq yahtml-menu-map-item (make-sparse-keymap "item"))
346 (yahtml-define-menu
347 yahtml-menu-map-item
348 (nreverse
349 '((li "Simple item" .
350 (lambda () (interactive) (yahtml-insert-single "li")))
351 (dt "Define term" .
352 (lambda () (interactive) (yahtml-insert-single "dt")))
353 (dd "Description of term" .
354 (lambda () (interactive) (yahtml-insert-single "dd")))
355 )))
356 (define-key yahtml-mode-map [menu-bar yahtml]
357 (cons "yahtml" yahtml-menu-map))
358 (let ((keys (where-is-internal 'fill-paragraph global-map)))
359 (while keys
360 (define-key yahtml-mode-map (car keys) 'yahtml-fill-paragraph)
361 (setq keys (cdr keys))))
362 (yahtml-define-menu
363 yahtml-menu-map
364 (nreverse
365 (list
366 (cons (list 'sect "Sectioning")
367 (cons "sectioning" yahtml-menu-map-sectioning))
368 (cons (list 'list "Listing")
369 (cons "Listing" yahtml-menu-map-listing))
370 (cons (list 'item "Item")
371 (cons "Itemizing" yahtml-menu-map-item));;;
372 (cons (list 'logi "Logical tags")
373 (cons "logical" yahtml-menu-map-logical))
374 (cons (list 'type "Typeface tags")
375 (cons "typeface" yahtml-menu-map-typeface))
376 )))
377 ))
379 (defun yahtml-collect-url-history ()
380 "Collect urls from global history file."
381 (interactive)
382 (save-excursion
383 (set-buffer
384 (find-file-noselect (expand-file-name yahtml-url-history-file)))
385 (goto-char (point-min))
386 (setq yahtml-urls)
387 (message "Collecting global history...")
388 (while (re-search-forward "^[A-Za-z]+:" nil t)
389 (setq yahtml-urls
390 (cons (list
391 (buffer-substring
392 (progn (beginning-of-line) (point))
393 (progn (skip-chars-forward "^ ") (point))))
394 yahtml-urls)))
395 (message "Collecting global history...Done")))
397 ;;; ----------- Completion ----------
398 (defvar yahtml-last-begend "html")
399 (defun yahtml-insert-begend (&optional region env)
400 "Insert <cmd> ... </cmd>."
401 (interactive "P")
402 (let*((completion-ignore-case t)
403 (cmd
404 (or env
405 (YaTeX-cplread-with-learning
406 (format "Environment(default %s): " yahtml-last-begend)
407 'yahtml-env-table 'yahtml-user-env-table 'yahtml-tmp-env-table)))
408 (bolp (save-excursion
409 (skip-chars-backward " \t" (point-beginning-of-line)) (bolp)))
410 (cc (current-column)))
411 (if (string< "" cmd) (setq yahtml-last-begend cmd))
412 (setq yahtml-last-begend
413 (or (cdr (assoc yahtml-last-begend yahtml-env-table))
414 yahtml-last-begend))
415 (setq cmd yahtml-last-begend)
416 (if region
417 (let ((beg (region-beginning))
418 (end (region-end))
419 (addin (yahtml-addin cmd)))
420 (goto-char end)
421 (insert (format "</%s>%s" cmd (if bolp "\n" "")))
422 (goto-char beg)
423 (insert (format "<%s%s>%s" cmd addin (if bolp "\n" ""))))
424 (insert (format "<%s%s>" cmd (yahtml-addin cmd)))
425 (save-excursion
426 (if bolp (progn
427 (insert "\n")
428 (indent-to-column cc)
429 (insert (format "</%s>" cmd)))
430 (insert (format "</%s>" cmd))))
431 (if bolp (yahtml-intelligent-newline nil)))))
433 (defun yahtml-insert-begend-region ()
434 "Call yahtml-insert-begend in the region mode."
435 (interactive)
436 (yahtml-insert-begend t))
439 (defun yahtml-insert-form (&optional form)
440 "Insert <FORM option=\"argument\">."
441 (interactive)
442 (or form
443 (setq form
444 (YaTeX-cplread-with-learning
445 "Form: "
446 'yahtml-form-table 'yahtml-user-form-table
447 'yahtml-tmp-form-table)))
448 (let ((p (point)) q)
449 (insert (format "<%s%s>" form (yahtml-addin form)))
450 ;;(indent-relative-maybe)
451 (if (cdr (assoc form yahtml-form-table))
452 (save-excursion (insert (format "</%s>" form))))
453 (if (search-backward "\"\"" p t) (forward-char 1))))
455 (defun yahtml-addin (form)
456 "Check add-in function's existence and call it if exists."
457 (let ((addin (concat "yahtml:" (downcase form))) s)
458 (if (and (intern-soft addin) (fboundp (intern-soft addin))
459 (stringp (setq s (funcall (intern addin))))
460 (string< "" s))
461 (concat " " s)
462 "")))
464 (defvar yahtml-url-completion-map nil "Key map used in URL completion buffer")
465 (if yahtml-url-completion-map nil
466 (setq yahtml-url-completion-map
467 (copy-keymap minibuffer-local-completion-map))
468 (define-key yahtml-url-completion-map "\t" 'yahtml-complete-url)
469 (define-key yahtml-url-completion-map " " 'yahtml-complete-url)
470 )
472 (defun yahtml-complete-url ()
473 "Complete external URL from history or local file name."
474 (interactive)
475 (let (initial cmpl path dir file listfunc beg (p (point)))
476 (setq initial (buffer-string))
477 (cond
478 ((string-match "^http:" initial)
479 (setq cmpl (try-completion initial yahtml-urls)
480 listfunc (list 'lambda nil
481 (list 'all-completions initial 'yahtml-urls))
482 beg (point-min)))
483 (t
484 (setq path (if (string-match "^/" initial)
485 (yahtml-url-to-path initial)
486 initial))
487 (setq dir (or (file-name-directory path) ".")
488 file (file-name-nondirectory path)
489 initial file
490 cmpl (file-name-completion file dir)
491 listfunc (list 'lambda nil
492 (list 'file-name-all-completions
493 file dir))
494 beg (save-excursion (skip-chars-backward "^/") (point)))))
495 (cond
496 ((stringp cmpl)
497 (if (string= initial cmpl)
498 (with-output-to-temp-buffer "*Completions*"
499 (princ "Possible completinos are:\n")
500 (princ
501 (mapconcat '(lambda (x) x) (funcall listfunc) "\n")))
502 (delete-region (point) beg)
503 (insert cmpl)))
504 ((null cmpl)
505 (ding))
506 ((eq t cmpl)
507 (save-excursion
508 (unwind-protect
509 (progn
510 (goto-char p)
511 (insert " [Sole completion]"))
512 (delete-region p (point-max))))))))
514 (defun yahtml:a ()
515 "Add-in function for <a>"
516 (or yahtml-urls (yahtml-collect-url-history))
517 ; (concat "href=\""
518 ; (completing-read "href: " yahtml-urls)
519 ; "\"")
520 (message "(H)ref (N)ame?")
521 (cond
522 ((string-match "[hH]" (char-to-string (read-char)))
523 (concat "href=\""
524 (read-from-minibuffer "href: " "" yahtml-url-completion-map)
525 "\""))
526 (t (concat "name=\"" (read-string "name: ") "\""))))
528 (defun yahtml:img ()
529 "Add-in function for <img>"
530 (or yahtml-urls (yahtml-collect-url-history))
531 (let ((src (read-file-name "src: " "" nil nil ""))
532 (alg (completing-read "align: " '(("top") ("middle") ("bottom")))))
533 (concat "src=\"" src "\""
534 (if (string< "" alg) (concat " align=\"" alg "\"")))))
536 (defun yahtml:form ()
537 "Add-in function `form' input format"
538 (concat
539 " method=" (completing-read "Method: " '(("POST") ("GET")) nil t)
540 " action=\"" (read-string "Action: ") "\""
541 ))
543 (defun yahtml:select ()
544 "Add-in function for `select' input format"
545 (setq yahtml-last-single-cmd "option")
546 (concat " name=\"" (read-string "name: ") "\""))
548 (defun yahtml:ol ()
549 (setq yahtml-last-single-cmd "li") "")
550 (defun yahtml:ul ()
551 (setq yahtml-last-single-cmd "li") "")
552 (defun yahtml:dl ()
553 (setq yahtml-last-single-cmd "dt") "")
554 (defun yahtml:dt ()
555 (setq yahtml-last-single-cmd "dd") "")
558 (defvar yahtml-input-types
559 '(("text") ("password") ("checkbox") ("radio") ("submit")
560 ("reset") ("image") ("hidden")))
562 (defun yahtml:input ()
563 "Add-in function for `input' form"
564 (let (name type value checked (size "") (maxlength ""))
565 (setq name (read-string "name: ")
566 type (completing-read "type (default=text): "
567 yahtml-input-types nil t)
568 value (read-string "value: "))
569 (if (string-match "text\\|password\\|^$" type)
570 (setq size (read-string "size: ")
571 maxlength (read-string "maxlength: ")))
572 (concat
573 "name=\"" name "\""
574 (if (string< "" type) (concat " type=\"" type "\""))
575 (if (string< "" value) (concat " value=\"" value "\""))
576 (if (string< "" size) (concat " size=\"" size "\""))
577 (if (string< "" maxlength) (concat " maxlength=\"" maxlength "\""))
578 )))
580 (defun yahtml-insert-tag (region-mode &optional tag)
581 "Insert <TAG> </TAG> and put cursor inside of them."
582 (interactive "P")
583 (or tag
584 (setq tag
585 (YaTeX-cplread-with-learning
586 (format "Tag %s(default %s): "
587 (if region-mode "region: " "") yahtml-last-typeface-cmd)
588 'yahtml-typeface-table 'yahtml-user-typeface-table
589 'yahtml-tmp-typeface-table)))
590 (if (string= "" tag) (setq tag yahtml-last-typeface-cmd))
591 (setq tag (funcall (if yahtml-prefer-upcases 'upcase 'downcase) tag)
592 yahtml-last-typeface-cmd tag)
593 (if region-mode
594 (if (if (string< "19" emacs-version) (mark t) (mark))
595 (save-excursion
596 (if (> (point) (mark)) (exchange-point-and-mark))
597 (insert "<" tag ">")
598 (exchange-point-and-mark)
599 (insert "</" tag ">"))
600 (message "No mark set now"))
601 (insert (format "<%s> " tag))
602 (save-excursion (insert (format "</%s>" tag)))))
604 (defun yahtml-insert-single (cmd)
605 "Insert <CMD>."
606 (interactive
607 (list
608 (let ((completion-ignore-case t))
609 (YaTeX-cplread-with-learning
610 (format "Command%s: "
611 (if yahtml-last-single-cmd
612 (concat "(default " yahtml-last-single-cmd ")") ""))
613 'yahtml-single-cmd-table 'yahtml-user-single-cmd-table
614 'yahtml-tmp-single-cmd-table))))
615 (if (string< "" cmd) (setq yahtml-last-single-cmd cmd))
616 (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) cmd))
617 (setq yahtml-last-single-cmd
618 (or (cdr (assoc yahtml-last-single-cmd yahtml-single-cmd-table))
619 yahtml-last-single-cmd))
620 (insert (format "<%s>" yahtml-last-single-cmd)))
622 ;;; ---------- Jump ----------
623 (defun yahtml-on-href-p ()
624 "Check if point is on href clause."
625 (let ((p (point)) cmd)
626 (save-excursion
627 (or (bobp) (skip-chars-backward "^ \t\n"))
628 (and (looking-at "href\\s *=\\s *\"?\\([^\"> \t\n]+\\)\"?")
629 (< p (match-end 0))
630 (YaTeX-match-string 1)))))
632 (defun yahtml-netscape-sentinel (proc mes)
633 (cond
634 ((null (buffer-name (process-buffer proc)))
635 (set-process-buffer proc nil))
636 ((eq (process-status proc) 'exit)
637 (let ((cb (current-buffer)))
638 (set-buffer (process-buffer proc))
639 (goto-char (point-min))
640 (if (search-forward "not running" nil t)
641 (progn
642 (message "Starting netscape...")
643 (start-process
644 "browser" (process-buffer proc) shell-file-name "-c"
645 (format "%s %s" yahtml-www-browser
646 (get 'yahtml-netscape-sentinel 'url)))
647 (message "Starting netscape...Done")))
648 (set-buffer cb)))))
650 (defvar yahtml-browser-process nil)
652 (defun yahtml-browse-html (href)
653 "Call WWW Browser to see HREF."
654 (let ((pb "* WWW Browser *") (cb (current-buffer)))
655 (cond
656 ((string-match "[Nn]etscape" yahtml-www-browser)
657 (if (get-buffer pb)
658 (progn (set-buffer pb) (erase-buffer) (set-buffer cb)))
659 (put 'yahtml-netscape-sentinel 'url href)
660 (set-process-sentinel
661 (setq yahtml-browser-process
662 (start-process
663 "browser" pb shell-file-name "-c"
664 (format "%s -remote 'openURL(%s)'" yahtml-www-browser href)))
665 'yahtml-netscape-sentinel))
666 ((and (string= "w3" yahtml-www-browser) (fboundp 'w3-fetch))
667 (w3-fetch href))
668 ((stringp yahtml-www-browser)
669 (if (eq (process-status yahtml-browser-process) 'run)
670 (message "%s is already running" yahtml-www-browser)
671 (setq yahtml-browser-process
672 (start-process
673 "browser" "* WWW Browser *" shell-file-name
674 (format "%s %s" yahtml-www-browser href)))))
675 (t
676 (message "Sorry, jump across http is not supported.")))))
678 (defun yahtml-goto-corresponding-href (&optional other)
679 "Go to corresponding name."
680 (let ((href (yahtml-on-href-p)) file name)
681 (if href
682 (cond
683 ((string-match "^http:" href)
684 (yahtml-browse-html href))
685 (t (setq file (substring href 0 (string-match "#" href)))
686 (if (string-match "#" href)
687 (setq name (substring href (1+ (string-match "#" href)))))
688 (if (string< "" file)
689 (progn
690 (if (string-match "/$" file)
691 (setq file (concat file yahtml-directory-index)))
692 (if (string-match "^/" file)
693 (setq file (yahtml-url-to-path file)))
694 (if other (YaTeX-switch-to-buffer-other-window file)
695 (YaTeX-switch-to-buffer file))))
696 (if name
697 (progn (set-mark-command nil) (yahtml-jump-to-name name)))
698 t)))))
700 (defun yahtml-jump-to-name (name)
701 "Jump to html's named tag."
702 (setq name (format "name\\s *=\\s *\"?%s\"?" name))
703 (or (and (re-search-forward name nil t) (goto-char (match-beginning 0)))
704 (and (re-search-backward name nil t) (goto-char (match-beginning 0)))
705 (message "Named tag `%s' not found" (substring href 1))))
707 (defun yahtml-on-begend-p (&optional p)
708 "Check if point is on begend clause."
709 (let ((p (point)) cmd (case-fold-search t))
710 (save-excursion
711 (if p (goto-char p))
712 (if (equal (char-after (point)) ?<) (forward-char 1))
713 (if (and (re-search-backward "<" nil t)
714 (looking-at
715 (concat "<\\(/?" yahtml-command-regexp "\\)\\b"))
716 (condition-case nil
717 (forward-list 1)
718 (error nil))
719 (< p (point)))
720 (YaTeX-match-string 1)))))
722 (defun yahtml-goto-corresponding-begend (&optional noerr)
723 "Go to corresponding opening/closing tag.
724 Optional argument NOERR causes no error for unballanced tag."
725 (let ((cmd (yahtml-on-begend-p)) m0
726 (p (point)) (case-fold-search t) func str (nest 0))
727 (cond
728 (cmd
729 (setq m0 (match-beginning 0))
730 (if (= (aref cmd 0) ?/) ;on </cmd> line
731 (setq cmd (substring cmd 1)
732 str (format "\\(<%s\\)\\|\\(</%s\\)" cmd cmd)
733 func 're-search-backward)
734 (setq str (format "\\(</%s\\)\\|\\(<%s\\)" cmd cmd)
735 func 're-search-forward))
736 (while (and (>= nest 0) (funcall func str nil t))
737 (if (equal m0 (match-beginning 0))
738 nil
739 (setq nest (+ nest (if (match-beginning 1) -1 1)))))
740 (if (< nest 0)
741 (goto-char (match-beginning 0))
742 (funcall
743 (if noerr 'message 'error)
744 "Corresponding tag of `%s' not found." cmd)
745 (goto-char p)
746 nil))
747 (t nil))))
749 (defun yahtml-current-tag ()
750 "Return the current tag name."
751 (save-excursion
752 (let ((p (point)) b tag)
753 (or (bobp)
754 (looking-at "<")
755 (progn (skip-chars-backward "^<") (forward-char -1)))
756 (setq b (point))
757 (skip-chars-forward "<")
758 (setq tag (buffer-substring
759 (point) (progn (skip-chars-forward "^ \t\n") (point))))
760 (goto-char b)
761 (forward-list 1)
762 (and (< p (point)) tag))))
765 (defun yahtml-goto-corresponding-img ()
766 "View image on point"
767 (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t))
768 (if (and tag
769 (string-match "img" tag)
770 (save-excursion
771 (re-search-backward "<\\s *img" nil t)
772 (re-search-forward "src=\"?\\([^\"> ]+\\)\"?>")
773 (match-beginning 1)
774 (setq image
775 (buffer-substring (match-beginning 1) (match-end 1)))))
776 (progn
777 (message "Invoking %s %s..." yahtml-image-viewer image)
778 (start-process
779 "Viewer" " * Image Viewer *" shell-file-name "-c"
780 (concat yahtml-image-viewer " " image))
781 (message "Invoking %s %s...Done" yahtml-image-viewer image)))))
783 (defun yahtml-goto-corresponding-* (&optional other)
784 "Go to corresponding object."
785 (interactive)
786 (cond
787 ((yahtml-goto-corresponding-href other))
788 ((yahtml-goto-corresponding-img))
789 ((yahtml-goto-corresponding-begend))
790 ))
792 (defun yahtml-goto-corresponding-*-other-window ()
793 "Go to corresponding object."
794 (interactive)
795 (yahtml-goto-corresponding-* t))
797 ;;; ---------- killing ----------
798 (defun yahtml-kill-begend (&optional whole)
799 (let ((tag (yahtml-on-begend-p)) (p (make-marker)) (q (make-marker)))
800 (if tag
801 (progn
802 (or (looking-at "<")
803 (progn (skip-chars-backward "^<") (forward-char -1)))
804 (set-marker p (point))
805 (yahtml-goto-corresponding-begend)
806 (or (looking-at "<")
807 (progn (skip-chars-backward "^<") (forward-char -1)))
808 (delete-region (point) (progn (forward-list 1) (point)))
809 (set-marker q (point))
810 (beginning-of-line)
811 (if (looking-at "^\\s *$")
812 (delete-region (point) (progn (forward-line 1) (point))))
813 (goto-char p)
814 (delete-region (point) (progn (forward-list 1) (point)))
815 (if (looking-at "^\\s *$")
816 (delete-region (point) (progn (forward-line 1) (point))))
817 (if whole (delete-region p q))
818 tag))))
820 (defun yahtml-kill-* (whole)
821 "Kill current position's HTML tag (set)."
822 (interactive "P")
823 (cond
824 ((yahtml-kill-begend whole))
825 ))
828 ;;; ---------- changing ----------
829 (defun yahtml-change-begend ()
830 (let ((tag (yahtml-on-begend-p))
831 (completion-ignore-case t)
832 (p (point)) (q (make-marker))
833 (default (append yahtml-env-table yahtml-typeface-table))
834 (user (append yahtml-user-env-table yahtml-user-typeface-table))
835 (tmp (append yahtml-tmp-env-table yahtml-tmp-typeface-table))
836 )
837 (if tag
838 (save-excursion
839 (if (= (aref tag 0) ?/) (setq tag (substring tag 1)))
840 (or (= (char-after (point)) ?<) (skip-chars-backward "^<"))
841 (skip-chars-forward "^A-Za-z")
842 (set-marker q (point))
843 (setq p (point))
844 (yahtml-goto-corresponding-begend)
845 (or (= (char-after (point)) ?<)
846 (skip-chars-backward "^<"))
847 (skip-chars-forward "^A-Za-z")
848 (if (= (char-after (1- (point))) ?/)
849 (progn
850 (set-marker q (point))
851 (goto-char p)))
852 (setq tag (YaTeX-cplread-with-learning
853 (format "Change `%s' to(default %s): "
854 tag yahtml-last-begend)
855 'default 'user 'tmp))
856 (delete-region (point) (progn (skip-chars-forward "^>") (point)))
857 (if (string= "" tag) (setq tag yahtml-last-begend))
858 (setq yahtml-last-begend
859 (or (cdr (assoc tag yahtml-env-table)) tag)
860 tag yahtml-last-begend)
861 (insert (format "%s%s" tag (yahtml-addin tag)))
862 (goto-char q)
863 (delete-region (point) (progn (skip-chars-forward "^>") (point)))
864 (insert tag)))))
866 (defun yahtml-change-* ()
867 "Change current position's HTML tag (set)."
868 (interactive)
869 (cond
870 ((yahtml-change-begend))
871 ))
873 ;;; ---------- commenting ----------
874 (defun yahtml-comment-region (beg end)
875 (interactive "r")
876 (comment-region beg end nil))
878 (defun yahtml-uncomment-region (beg end)
879 (interactive "r")
880 (comment-region beg end '(4)))
884 ;;; ---------- filling ----------
885 (defun yahtml-fill-paragraph (arg)
886 (interactive "P")
887 (let ((case-fold-search t) (p (point)))
888 (save-excursion
889 (fill-region-as-paragraph
890 (progn (re-search-backward paragraph-start nil t)
891 (or (save-excursion
892 (goto-char (match-end 0))
893 (if (looking-at "[ \t]*$")
894 (progn (forward-line 1) (point))))
895 (point)))
896 (progn (goto-char p)
897 (re-search-forward paragraph-start nil t)
898 (match-beginning 0))))))
900 ;;;
901 ;;; ---------- indentation ----------
902 ;;;
903 (defvar yahtml-hate-too-deep-indentation nil)
904 (defun yahtml-indent-line ()
905 (interactive)
906 (let ((envs "[uod]l\\|table\\|t[rhd]")
907 (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\)>")
908 inenv p col peol (case-fold-search t))
909 (save-excursion
910 (beginning-of-line)
911 (setq inenv (or (YaTeX-inner-environment) "html")
912 col (get 'YaTeX-inner-environment 'indent)
913 p (get 'YaTeX-inner-environment 'point)
914 op))
915 (save-excursion
916 (cond
917 ((string-match envs inenv)
918 (save-excursion
919 (beginning-of-line)
920 (skip-chars-forward " \t")
921 (cond
922 ((looking-at (concat "</\\(" envs "\\)>"))
923 (YaTeX-reindent col))
924 ((or (looking-at itms)
925 (and yahtml-hate-too-deep-indentation
926 (looking-at (concat "<" envs))))
927 (YaTeX-reindent (+ col YaTeX-environment-indent)))
928 ((and (< p (point))
929 (save-excursion
930 (and
931 ;;(re-search-backward itms p t)
932 (setq op (point))
933 (goto-char p)
934 (re-search-forward itms op t)
935 (goto-char (match-end 0))
936 (skip-chars-forward " \t")
937 (setq col (current-column)))))
938 (YaTeX-reindent col))
939 (t
940 (YaTeX-reindent (+ col YaTeX-environment-indent)))))))
941 (and (bolp) (skip-chars-forward " \t"))
942 (if (and (setq inenv (yahtml-on-begend-p))
943 (string-match (concat "^\\(" envs "\\)") inenv))
944 (save-excursion
945 (setq peol (point-end-of-line))
946 (or (= (char-after (point)) ?<)
947 (progn (skip-chars-backward "^<") (forward-char -1)))
948 (setq col (current-column))
949 (if (and (yahtml-goto-corresponding-begend t)
950 (> (point) peol)) ;if on the different line
951 (YaTeX-reindent col)))))
952 (and (bolp) (skip-chars-forward " \t"))))
954 ;(defun yahtml-fill-item ()
955 ; "Fill item HTML version"
956 ; (interactive)
957 ; (let (inenv p fill-prefix peol (case-fold-search t))
958 ; (setq inenv (or (YaTeX-inner-environment) "html")
959 ; p (get 'YaTeX-inner-environment 'point))
960 ; (cond
961 ; ((string-match "^[uod]l" inenv)
962 ; (save-excursion
963 ; (if (re-search-backward "<\\(d[td]\\|li\\)>[ \t\n]*" p t)
964 ; (progn
965 ; (goto-char (match-end 0))
966 ; (setq col (current-column)))
967 ; (error "No <li>, <dt>, <dd>")))
968 ; (save-excursion
969 ; (end-of-line)
970 ; (setq peol (point))
971 ; (newline)
972 ; (indent-to-column col)
973 ; (setq fill-prefix (buffer-substring (point) (1+ peol)))
974 ; (delete-region (point) peol)
975 ; (fill-region-as-paragraph
976 ; (progn (re-search-backward paragraph-start nil t) (point))
977 ; (progn (re-search-forward paragraph-start nil t 2)
978 ; (match-beginning 0)))))
979 ; (t nil))))
981 ;;;
982 ;;; ---------- Browsing ----------
983 ;;;
984 (defun yahtml-browse-menu ()
985 "Browsing menu"
986 (interactive)
987 (message "B)rowse R)eload...")
988 (let ((c (char-to-string (read-char))))
989 (cond
990 ((string-match "[bj]" c)
991 (yahtml-browse-current-file))
992 ((string-match "r" c)
993 (yahtml-browse-reload)))))
995 (defun yahtml-file-to-url (file)
996 "Convert local unix file name to URL.
997 If no matches found in yahtml-path-url-alist, return raw file name."
998 (let ((list yahtml-path-url-alist) p url)
999 (if (file-directory-p file)
1000 (setq file (expand-file-name yahtml-directory-index file))
1001 (setq file (expand-file-name file)))
1002 (while list
1003 (if (string-match (concat "^" (regexp-quote (car (car list)))) file)
1004 (setq url (cdr (car list))
1005 file (substring file (match-end 0))
1006 url (concat url file)
1007 list nil))
1008 (setq list (cdr list)))
1009 (or url (concat "file:" file))))
1011 (defun yahtml-url-to-path (file &optional basedir)
1012 "Convert local URL name to unix file name."
1013 (let ((list yahtml-path-url-alist) url realpath docroot
1014 (dirsufp (string-match "/$" file)))
1015 (setq basedir (or basedir
1016 (file-name-directory
1017 (expand-file-name default-directory))))
1018 (cond
1019 ((string-match "^/" file)
1020 (while list
1021 (if (string-match (concat "^" (regexp-quote (car (car list)))) basedir)
1022 (progn
1023 (setq url (cdr (car list)))
1024 (if (string-match "\\(http://[^/]*\\)/" url)
1025 (setq docroot (substring url (match-end 1)))
1026 (setq docroot url))
1027 (if (string-match (regexp-quote docroot) file)
1028 (setq realpath
1029 (expand-file-name
1030 (substring
1031 file (min (1+ (match-end 0)) (length file)))
1032 (car (car list)))))
1033 (if realpath
1034 (progn (setq list nil)
1035 (if (and dirsufp (not (string-match "/$" realpath)))
1036 (setq realpath (concat realpath "/")))))))
1037 (setq list (cdr list)))
1038 realpath)
1039 (t file))))
1041 (defun yahtml-browse-current-file ()
1042 "Call WWW browser on current file."
1043 (interactive)
1044 (basic-save-buffer)
1045 (yahtml-browse-html (yahtml-file-to-url (buffer-file-name))))
1047 (defun yahtml-browse-reload ()
1048 "Send `reload' event to netzscape."
1049 (let ((pb "* WWW Browser *") (cb (current-buffer)))
1050 (cond
1051 ((string-match "[Nn]etscape" yahtml-www-browser)
1052 (if (get-buffer pb)
1053 (progn (set-buffer pb) (erase-buffer) (set-buffer cb)))
1054 ;;(or (get 'yahtml-netscape-sentinel 'url)
1055 ;; (error "Reload should be called after Browsing."))
1056 (put 'yahtml-netscape-sentinel 'url
1057 (yahtml-file-to-url (buffer-file-name)))
1058 (basic-save-buffer)
1059 (set-process-sentinel
1060 (setq yahtml-browser-process
1061 (start-process
1062 "browser" pb shell-file-name "-c"
1063 (format "%s -remote 'reload'" yahtml-www-browser)))
1064 'yahtml-netscape-sentinel))
1065 (t
1066 (message "Sorry, RELOAD is supported only for Netscape.")))))
1068 ;;; ---------- Intelligent newline ----------
1069 (defun yahtml-intelligent-newline (arg)
1070 "Intelligent newline for HTML"
1071 (interactive "P")
1072 (let ((env (downcase (or (YaTeX-inner-environment) "html"))) func)
1073 (setq func (intern-soft (concat "yahtml-intelligent-newline-" env)))
1074 (end-of-line)
1075 (newline)
1076 (if (and env func (fboundp func))
1077 (funcall func))))
1079 (defun yahtml-intelligent-newline-ul ()
1080 (interactive)
1081 (insert (if yahtml-prefer-upcases "<LI> " "<li> "))
1082 (yahtml-indent-line))
1084 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul)
1086 (defun yahtml-intelligent-newline-dl ()
1087 (interactive)
1088 (let ((case-fold-search t))
1089 (if (save-excursion
1090 (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)>"
1091 (get 'YaTeX-inner-environment 'point) t))
1092 (cond
1093 ((match-beginning 2)
1094 (insert (if yahtml-prefer-upcases "<DD> " "<dd> "))
1095 (setq yahtml-last-single-cmd "dt"))
1096 ((match-beginning 3)
1097 (insert (if yahtml-prefer-upcases "<DT> " "<dt> "))
1098 (setq yahtml-last-single-cmd "dd")))
1099 (insert (if yahtml-prefer-upcases "<DT> " "<dt> ")))
1100 (yahtml-indent-line)))
1102 ;;; ---------- Marking ----------
1103 (defun yahtml-mark-begend ()
1104 "Mark current tag"
1105 (interactive)
1106 (YaTeX-beginning-of-environment)
1107 (let ((p (point)))
1108 (save-excursion
1109 (skip-chars-backward " \t" (point-beginning-of-line))
1110 (if (bolp) (setq p (point))))
1111 (push-mark p t))
1112 (yahtml-goto-corresponding-begend)
1113 (forward-list 1)
1114 (if (eolp) (forward-char 1)))
1116 ;;; ---------- ----------
1117 ;;; ---------- ----------
1118 ;;; ---------- ----------
1120 ;;;
1121 ;;hilit19
1122 ;;;
1123 (defvar yahtml-default-face-table
1124 '(
1125 (form black/ivory white/hex-442233 italic)
1126 ))
1127 (defvar yahtml-hilit-patterns-alist
1128 '(
1129 ;; comments
1130 ("<!--\\s " "-->" comment)
1131 ;; include&exec
1132 ("<!--#\\(include\\|exec\\)" "-->" include)
1133 ;; string
1134 (hilit-string-find 39 string)
1135 (yahtml-hilit-region-tag "\\(em\\|strong\\)" bold)
1136 ("</?[uod]l>" 0 decl)
1137 ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label)
1138 ("<a\\s +href" "</a>" crossref)
1139 ("</?\\sw+>" 0 decl)
1140 ("<form" "</form" form)
1141 ))
1143 (defun yahtml-hilit-region-tag (tag)
1144 "Return list of start/end point of <TAG> form."
1145 (if (re-search-forward (concat "<" tag ">") nil t)
1146 (let ((m0 (match-beginning 0)))
1147 (skip-chars-forward " \t\n")
1148 (cons (point)
1149 (progn (re-search-forward (concat "</" tag ">") nil t)
1150 (match-beginning 0))))))
1152 ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist))
1153 (cond
1154 ((and (featurep 'hilit19) (featurep 'yatex19))
1155 (or (assq 'yahtml-mode hilit-patterns-alist)
1156 (setq hilit-patterns-alist
1157 (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist)
1158 hilit-patterns-alist)))))
1160 (provide 'yahtml)
1162 ; Local variables:
1163 ; fill-prefix: ";;; "
1164 ; paragraph-start: "^$\\| \\|;;;$"
1165 ; paragraph-separate: "^$\\| \\|;;;$"
1166 ; End: