yatex

diff yahtml.el @ 57:18f4939986e6

(j)LaTeX2e supported yatex19.el fixed a lot
author yuuji
date Sat, 02 Dec 1995 18:35:28 +0000
parents 2d45e43fb35f
children 3a7c0c2bf16d
line diff
     1.1 --- a/yahtml.el	Mon Apr 24 14:42:53 1995 +0000
     1.2 +++ b/yahtml.el	Sat Dec 02 18:35:28 1995 +0000
     1.3 @@ -1,6 +1,6 @@
     1.4  ;;; -*- Emacs-Lisp -*-
     1.5  ;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp, pcs39334@ascii-net.or.jp]
     1.6 -;;; Last modified Mon Apr 24 22:52:17 1995 on pajero
     1.7 +;;; Last modified Mon Nov 20 11:26:38 1995 on inspire
     1.8  ;;; This is PURELY tentative.
     1.9  ;;; $Id$
    1.10  
    1.11 @@ -10,11 +10,16 @@
    1.12  ;;; completing featureas are available: ([prefix] means `C-c' by default)
    1.13  ;;;
    1.14  ;;;  * [prefix] b X	Complete environments such as `H1' which
    1.15 -;;;			normally requires newline.
    1.16 +;;;			normally requires closing tag `</H1>
    1.17 +;;;			<a href=foo> ... </a> is also classified into
    1.18 +;;;			this group
    1.19  ;;;  * [prefix] s	Complete declarative notations such as
    1.20 -;;;			`<a href="foo.html"> .... </a>'
    1.21 +;;;			`<img src="foo.gif">'
    1.22 +;;;			`<input name="var" ...>'
    1.23  ;;;  * [prefix] l	Complete typeface-changing commands such as
    1.24  ;;;			`<i> ... </i>' or `<samp> ... </samp>'
    1.25 +;;;  * [prefix] m	Complete single commands such as
    1.26 +;;;			`<br>' or `<hr>'
    1.27  ;;;  * menu-bar yahtml	Complete all by selecting a menu item (Though I
    1.28  ;;;			hate menu, this is most useful)
    1.29  ;;;
    1.30 @@ -23,16 +28,87 @@
    1.31  
    1.32  
    1.33  (require 'yatex)
    1.34 -(defvar yahtml-prefix-map (copy-keymap YaTeX-prefix-map))
    1.35 -(defvar yahtml-mode-map nil
    1.36 -  "Keymap used in yahtml-mode.")
    1.37 +(defvar yahtml-prefix-map nil)
    1.38 +(defvar yahtml-mode-map nil "Keymap used in yahtml-mode.")
    1.39 +
    1.40 +(defun yahtml-define-begend-key-normal (key env &optional map)
    1.41 +  "Define short cut yahtml-insert-begin-end key."
    1.42 +  (YaTeX-define-key
    1.43 +   key
    1.44 +   (list 'lambda '(arg) '(interactive "P")
    1.45 +	 (list 'yahtml-insert-begin-end env 'arg))
    1.46 +   map))
    1.47 +
    1.48 +(defun yahtml-define-begend-region-key (key env &optional map)
    1.49 +  "Define short cut yahtml-insert-begin-end-region key."
    1.50 +  (YaTeX-define-key key (list 'lambda nil '(interactive)
    1.51 +			      (list 'yahtml-insert-begin-end env t)) map))
    1.52 +
    1.53 +(defun yahtml-define-begend-key (key env &optional map)
    1.54 +  "Define short cut key for begin type completion both for
    1.55 +normal and region mode.  To customize yahtml, user should use this function."
    1.56 +  (yahtml-define-begend-key-normal key env map)
    1.57 +  (if YaTeX-inhibit-prefix-letter nil
    1.58 +    (yahtml-define-begend-region-key
    1.59 +     (concat (upcase (substring key 0 1)) (substring key 1)) env)))
    1.60 +
    1.61 +
    1.62  (if yahtml-mode-map nil
    1.63 -  (setq yahtml-mode-map (make-sparse-keymap))
    1.64 +  (setq yahtml-mode-map (make-sparse-keymap)
    1.65 +	yahtml-prefix-map (make-sparse-keymap))
    1.66    (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map)
    1.67    (define-key yahtml-mode-map "\M-\C-@" 'YaTeX-mark-environment)
    1.68    (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment)
    1.69 -  (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment))
    1.70 +  (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment)
    1.71 +  (define-key yahtml-mode-map "\C-i" 'YaTeX-indent-line)
    1.72 +  (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map)
    1.73 +  (let ((map yahtml-prefix-map))
    1.74 +    (YaTeX-define-key "^" 'yahtml-visit-main map)
    1.75 +    (YaTeX-define-key "4^" 'yahtml-visit-main-other-window map)
    1.76 +    (YaTeX-define-key "4g" 'yahtml-goto-corresponding-*-other-window map)
    1.77 +    (YaTeX-define-key "44" 'YaTeX-switch-to-window map)
    1.78 +    (and YaTeX-emacs-19 window-system
    1.79 +	 (progn
    1.80 +	   (YaTeX-define-key "5^" 'yahtml-visit-main-other-frame map)
    1.81 +	   (YaTeX-define-key "5g" 'yahtml-goto-corresponding-*-other-frame map)
    1.82 +	   (YaTeX-define-key "55" 'YaTeX-switch-to-window map)))
    1.83 +    (YaTeX-define-key "v" 'YaTeX-version map)
    1.84 +    (YaTeX-define-key "}" 'YaTeX-insert-braces-region map)
    1.85 +    (YaTeX-define-key "]" 'YaTeX-insert-brackets-region map)
    1.86 +    (YaTeX-define-key ")" 'YaTeX-insert-parens-region map)
    1.87 +    (YaTeX-define-key "s" 'yahtml-insert-form map)
    1.88 +    (YaTeX-define-key "l" 'yahtml-insert-tag map)
    1.89 +    (YaTeX-define-key "m" 'yahtml-insert-single map)
    1.90 +    (YaTeX-define-key "n" '(lambda () (interactive) (insert "<br>\n")) map)
    1.91 +    (if YaTeX-no-begend-shortcut
    1.92 +	(progn
    1.93 +	  (YaTeX-define-key "B" 'yahtml-insert-begend-region map)
    1.94 +	  (YaTeX-define-key "b" 'yahtml-insert-begend map))
    1.95 +      (yahtml-define-begend-key "bh" "HTML" map)
    1.96 +      (yahtml-define-begend-key "bH" "HEAD" map)
    1.97 +      (yahtml-define-begend-key "bt" "TITLE" map)
    1.98 +      (yahtml-define-begend-key "bb" "BODY" map)
    1.99 +      (yahtml-define-begend-key "bd" "DL" map)
   1.100 +      (yahtml-define-begend-key "b1" "H1" map)
   1.101 +      (yahtml-define-begend-key "b2" "H2" map)
   1.102 +      (yahtml-define-begend-key "b3" "H3" map)
   1.103 +      (yahtml-define-begend-key "ba" "a" map)
   1.104 +      (yahtml-define-begend-key "bf" "form" map)
   1.105 +      (yahtml-define-begend-key "bs" "select" map)
   1.106 +      (YaTeX-define-key "b " 'yahtml-insert-begend map)
   1.107 +      (YaTeX-define-key "B " 'yahtml-insert-begend map)
   1.108 +      )
   1.109 +    (YaTeX-define-key "e" 'yahtml-end-environment map)
   1.110 +    (YaTeX-define-key ">" 'yahtml-comment-region map)
   1.111 +    (YaTeX-define-key "<" 'yahtml-uncomment-region map)
   1.112 +    (YaTeX-define-key "g" 'yahtml-goto-corresponding-* map)
   1.113 +    )
   1.114 +)
   1.115  
   1.116 +(defvar yahtml-paragraph-separate
   1.117 +  (concat
   1.118 +   "^$\\|<br>\\|<p>\\|^[ \t]*</?\\(h[1-6]\\|p\\|dl\\|dd\\|dt\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\)>")
   1.119 +  "*Regexp of html paragraph separater")
   1.120  (defvar yahtml-syntax-table nil
   1.121    "*Syntax table for typesetting buffer")
   1.122  
   1.123 @@ -44,24 +120,37 @@
   1.124  )
   1.125  (defvar yahtml-command-regexp "[A-Za-z0-9]+"
   1.126    "Regexp of constituent of html commands.")
   1.127 +(defvar yahtml-kanji-code 2
   1.128 +  "Kanji coding system of html file; 1=sjis, 2=jis, 3=euc")
   1.129  
   1.130  ;;; Completion tables for `form'
   1.131 -(defvar yahtml-form-table '(("a") ("form")))
   1.132 +(defvar yahtml-form-table
   1.133 +  '(("img") ("input")))
   1.134  (defvar yahtml-user-form-table nil)
   1.135  (defvar yahtml-tmp-form-table nil)
   1.136  
   1.137  (defvar yahtml-env-table
   1.138 -  '(("html") ("head") ("title") ("body") ("dl")
   1.139 -    ("h1") ("h2") ("h3") ("h4") ("h5") ("h6")))
   1.140 +  '(("html") ("head") ("title") ("body") ("dl") ("a") ("form") ("select")
   1.141 +    ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") ("ul")))
   1.142 +
   1.143 +(defvar yahtml-user-env-table nil)
   1.144 +(defvar yahtml-tmp-env-table nil)
   1.145  
   1.146  ;;; Completion tables for typeface designator
   1.147  (defvar yahtml-typeface-table
   1.148    '(("defn") ("em") ("cite") ("code") ("kbd") ("samp")
   1.149 -    ("strong") ("var") ("b") ("i") ("tt") ("u"))
   1.150 +    ("strong") ("var") ("b") ("i") ("tt") ("u") ("address"))
   1.151    "Default completion table of typeface designator")
   1.152  (defvar yahtml-user-typeface-table nil)
   1.153  (defvar yahtml-tmp-typeface-table nil)
   1.154  
   1.155 +(defvar yahtml-single-cmd-table
   1.156 +  '(("hr") ("br") ("option") ("p"))
   1.157 +  "Default completion table of HTML single command.")
   1.158 +(defvar yahtml-user-single-cmd-table nil)
   1.159 +(defvar yahtml-tmp-single-cmd-table nil)
   1.160 +(defvar yahtml-last-single-cmd nil)
   1.161 +
   1.162  (defvar yahtml-prefer-upcases nil)
   1.163  (cond
   1.164   (yahtml-prefer-upcases
   1.165 @@ -75,38 +164,42 @@
   1.166  	(mapcar (function (lambda (list) (list (upcase (car list)))))
   1.167  		yahtml-typeface-table))))
   1.168  
   1.169 +(defvar yahtml-struct-name-regexp
   1.170 +  "\\<\\(h[1-6]\\|[uod]l\\|body\\|title\\|head\\)")
   1.171 +
   1.172 +
   1.173  (defun yahtml-mode ()
   1.174    (interactive)
   1.175    (yatex-mode)
   1.176 +  (cond
   1.177 +   ((boundp 'MULE)
   1.178 +    (set-file-coding-system
   1.179 +     (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist))))
   1.180 +   ((boundp 'NEMACS)
   1.181 +    (make-local-variable 'kanji-fileio-code)
   1.182 +    (setq kanji-fileio-code yahtml-kanji-code)))
   1.183    (setq major-mode 'yahtml-mode
   1.184  	mode-name "yahtml")
   1.185    (make-local-variable 'YaTeX-ec) (setq YaTeX-ec "")
   1.186 -  (make-local-variable 'YaTeX-struct-begin) (setq YaTeX-struct-begin "<%1>")
   1.187 +  (make-local-variable 'YaTeX-struct-begin) (setq YaTeX-struct-begin "<%1%2>")
   1.188    (make-local-variable 'YaTeX-struct-end) (setq YaTeX-struct-end "</%1>")
   1.189 -  (mapcar 'make-local-variable
   1.190 -	  '(env-table user-env-table tmp-env-table))
   1.191 -  (setq env-table yahtml-env-table)
   1.192 -  (mapcar 'make-local-variable
   1.193 -	  '(singlecmd-table user-singlecmd-table tmp-singlecmd-table))
   1.194    (make-local-variable 'YaTeX-struct-name-regexp)
   1.195 -  (setq YaTeX-struct-name-regexp "[^/]+")
   1.196 +  (setq YaTeX-struct-name-regexp yahtml-struct-name-regexp)
   1.197    (make-local-variable 'YaTeX-prefix-map)
   1.198    (make-local-variable 'YaTeX-command-token-regexp)
   1.199    (setq YaTeX-command-token-regexp yahtml-command-regexp)
   1.200 -  (setq YaTeX-prefix-map yahtml-prefix-map)
   1.201 +  (make-local-variable 'YaTeX-environment-indent)
   1.202 +  (setq YaTeX-environment-indent 0)
   1.203 +  (make-local-variable 'fill-prefix)
   1.204 +  (setq fill-prefix nil)
   1.205 +  (make-local-variable 'paragraph-separate)
   1.206 +  (setq paragraph-separate yahtml-paragraph-separate
   1.207 +	paragraph-start  yahtml-paragraph-separate)
   1.208 +  (make-local-variable 'comment-start)
   1.209 +  (make-local-variable 'comment-end)
   1.210 +  (setq comment-start "<!-- " comment-end " -->")
   1.211    (set-syntax-table yahtml-syntax-table)
   1.212    (use-local-map yahtml-mode-map)
   1.213 -  (YaTeX-define-key "s" 'yahtml-insert-form)
   1.214 -  (YaTeX-define-key "l" 'yahtml-insert-tag)
   1.215 -  (if YaTeX-no-begend-shortcut nil
   1.216 -    (YaTeX-define-begend-key "bh" "HTML")
   1.217 -    (YaTeX-define-begend-key "bH" "HEAD")
   1.218 -    (YaTeX-define-begend-key "bt" "TITLE")
   1.219 -    (YaTeX-define-begend-key "bb" "BODY")
   1.220 -    (YaTeX-define-begend-key "bd" "DL")
   1.221 -    (YaTeX-define-begend-key "b1" "H1")
   1.222 -    (YaTeX-define-begend-key "b2" "H2")
   1.223 -    (YaTeX-define-begend-key "b3" "H3"))
   1.224    (run-hooks 'yahtml-mode-hook))
   1.225  
   1.226  (defun yahtml-define-menu (keymap bindlist)
   1.227 @@ -186,6 +279,17 @@
   1.228        (dl	"Description" .
   1.229  		(lambda () (interactive) (yahtml-insert-begin-end "DL" nil)))
   1.230        )))
   1.231 +  (setq yahtml-menu-map-item (make-sparse-keymap "item"))
   1.232 +  (yahtml-define-menu
   1.233 +   yahtml-menu-map-item
   1.234 +   (nreverse
   1.235 +    '((li	"Simple item" .
   1.236 +		(lambda () (interactive) (yahtml-insert-single "li")))
   1.237 +      (dt	"Define term" .
   1.238 +		(lambda () (interactive) (yahtml-insert-single "dt")))
   1.239 +      (dd	"Description of term" .
   1.240 +		(lambda () (interactive) (yahtml-insert-single "dd")))
   1.241 +      )))
   1.242    (define-key yahtml-mode-map [menu-bar yahtml]
   1.243      (cons "yahtml" yahtml-menu-map))
   1.244    (yahtml-define-menu
   1.245 @@ -196,6 +300,8 @@
   1.246  	   (cons "sectioning" yahtml-menu-map-sectioning))
   1.247       (cons (list 'list "Listing")
   1.248  	   (cons "Listing" yahtml-menu-map-listing))
   1.249 +     (cons (list 'item "Item")
   1.250 +	   (cons "Itemizing" yahtml-menu-map-item));;; 
   1.251       (cons (list 'logi "Logical tags")
   1.252  	   (cons "logical" yahtml-menu-map-logical))
   1.253       (cons (list 'type "Typeface tags")
   1.254 @@ -221,8 +327,39 @@
   1.255  		  yahtml-urls)))
   1.256      (message "Collecting global history...Done")))
   1.257  
   1.258 +;;; ----------- Completion ----------
   1.259 +(defvar yahtml-last-begend "html")
   1.260 +(defun yahtml-insert-begend (&optional region)
   1.261 +  "Insert <cmd> ... </cmd>."
   1.262 +  (interactive "P")
   1.263 +  (let ((cmd (YaTeX-cplread-with-learning
   1.264 +	      (format "Environment(default %s): " yahtml-last-begend)
   1.265 +	      'yahtml-env-table 'yahtml-user-env-table 'yahtml-tmp-env-table))
   1.266 +	(bolp (bolp)))
   1.267 +    (if (string< "" cmd) (setq yahtml-last-begend cmd))
   1.268 +    (setq cmd yahtml-last-begend)
   1.269 +    (if region
   1.270 +	(let ((beg (region-beginning))
   1.271 +	      (end (region-end))
   1.272 +	      (addin (yahtml-addin cmd)))
   1.273 +	  (goto-char end)
   1.274 +	  (insert (format "</%s>%s" cmd (if bolp "\n" "")))
   1.275 +	  (goto-char beg)
   1.276 +	  (insert (format "<%s%s>%s" cmd addin (if bolp "\n" ""))))
   1.277 +      (insert (format "<%s%s" cmd (yahtml-addin cmd)))
   1.278 +      (if bolp (progn (insert (format ">\n</%s>\n" cmd cmd))
   1.279 +			(forward-line -1))
   1.280 +	(insert ">")
   1.281 +	(save-excursion (insert (format "</%s>" cmd)))))))
   1.282 +
   1.283 +(defun yahtml-insert-begend-region ()
   1.284 +  "Call yahtml-insert-begend in the region mode."
   1.285 +  (interactive)
   1.286 +  (yahtml-insert-begend t))
   1.287 +
   1.288 +
   1.289  (defun yahtml-insert-form (&optional form)
   1.290 -  "Insert <FORM option=\"argument\">  </FORM>."
   1.291 +  "Insert <FORM option=\"argument\">."
   1.292     (interactive)
   1.293     (or form
   1.294         (setq form
   1.295 @@ -230,25 +367,71 @@
   1.296  	      "Form: "
   1.297  	       'yahtml-form-table 'yahtml-user-form-table
   1.298  	       'yahtml-tmp-form-table)))
   1.299 -   (let ((p (point)))
   1.300 -     (insert (format "<%s%s>\n" form (yahtml-addin (downcase form))))
   1.301 -     (indent-relative-maybe)
   1.302 -     (save-excursion (insert (format "</%s>" form)))
   1.303 +   (let ((p (point)) q)
   1.304 +     (insert (format "<%s%s>" form (yahtml-addin (downcase form))))
   1.305 +     ;;(indent-relative-maybe)
   1.306 +     (if (cdr (assoc form yahtml-form-table))
   1.307 +	 (save-excursion (insert (format "</%s>" form))))
   1.308       (if (search-backward "\"\"" p t) (forward-char 1))))
   1.309  
   1.310  (defun yahtml-addin (form)
   1.311    "Check add-in function's existence and call it if exists."
   1.312 -   (let ((addin (concat "yahtml::" form)))
   1.313 +   (let ((addin (concat "yahtml:" form)))
   1.314       (if (and (intern-soft addin) (fboundp (intern-soft addin)))
   1.315  	 (concat " " (funcall (intern addin)))
   1.316         "")))
   1.317  
   1.318 -(defun yahtml::a ()
   1.319 +(defun yahtml:a ()
   1.320    "Add-in function for <a>"
   1.321 +;  (or yahtml-urls (yahtml-collect-url-history))
   1.322 +;  (concat "href=\""
   1.323 +;	  (completing-read "href: " yahtml-urls)
   1.324 +;	  "\"")
   1.325 +  (concat "href=\"" (read-file-name "href: " "" nil nil "") "\"")
   1.326 +)
   1.327 +
   1.328 +(defun yahtml:img ()
   1.329 +  "Add-in function for <img>"
   1.330    (or yahtml-urls (yahtml-collect-url-history))
   1.331 -  (concat "href=\""
   1.332 -	  (completing-read "href: " yahtml-urls)
   1.333 -	  "\""))
   1.334 +  (let ((src (read-file-name "src: " "" nil t ""))
   1.335 +	(alg (completing-read "align: " '(("top") ("middle") ("bottom")))))
   1.336 +    (concat "src=\"" src "\""
   1.337 +	    (if (string< "" alg) (concat " align=\"" alg "\"")))))
   1.338 +
   1.339 +(defun yahtml:form ()
   1.340 +  "Add-in function `form' input format"
   1.341 +  (concat
   1.342 +   " method=" (completing-read "Method: " '(("POST") ("GET")) nil t)
   1.343 +   " action=\"" (read-string "Action: ") "\""
   1.344 +   ))
   1.345 +
   1.346 +(defun yahtml:select ()
   1.347 +  "Add-in function for `select' input format"
   1.348 +  (setq yahtml-last-single-cmd "option")
   1.349 +  (concat " name=\"" (read-string "name: ") "\""))
   1.350 +
   1.351 +(defvar yahtml-input-types
   1.352 +  '(("text") ("password") ("checkbox") ("radio") ("submit")
   1.353 +    ("reset") ("image") ("hidden")))
   1.354 +
   1.355 +(defun yahtml:input ()
   1.356 +  "Add-in function for `input' form"
   1.357 +  (let (name type value checked (size "") (maxlength ""))
   1.358 +    (setq name (read-string "name: ")
   1.359 +	  type (completing-read "type (default=text): "
   1.360 +				yahtml-input-types nil t)
   1.361 +	  value (read-string "value: "))
   1.362 +    (if (string-match "text\\|password\\|^$" type)
   1.363 +	(setq size (read-string "size: ")
   1.364 +	      maxlength (read-string "maxlength: ")))
   1.365 +    (concat
   1.366 +     "name=\"" name "\""
   1.367 +     (if (string< "" type) (concat " type=\"" type "\""))
   1.368 +     (if (string< "" value) (concat " value=\"" value "\""))
   1.369 +     (if (string< "" size) (concat " size=\"" size "\""))
   1.370 +     (if (string< "" maxlength) (concat " maxlength=\"" maxlength "\""))
   1.371 +    )))
   1.372 +	
   1.373  
   1.374  (defun yahtml-insert-begin-end (env &optional region-mode)
   1.375    "Insert <ENV> \\n </ENV> by calling YaTeX-insert-begin-end."
   1.376 @@ -256,19 +439,159 @@
   1.377    (setq env (funcall (if yahtml-prefer-upcases 'upcase 'downcase) env))
   1.378    (YaTeX-insert-begin-end env region-mode))
   1.379  
   1.380 -(defun yahtml-insert-tag (&optional tag)
   1.381 +(defun yahtml-insert-tag (tag)
   1.382    "Insert <TAG> </TAG> and put cursor inside of them."
   1.383 -  (interactive)
   1.384 -  (or tag
   1.385 -      (setq tag
   1.386 -	    (YaTeX-cplread-with-learning
   1.387 -	     "Tag: "
   1.388 -	     'yahtml-typeface-table 'yahtml-user-typeface-table
   1.389 -	     'yahtml-tmp-typeface-table)))
   1.390 +  (interactive
   1.391 +   (list
   1.392 +    (YaTeX-cplread-with-learning
   1.393 +     "Tag: "
   1.394 +     'yahtml-typeface-table 'yahtml-user-typeface-table
   1.395 +     'yahtml-tmp-typeface-table)))
   1.396    (setq tag (funcall (if yahtml-prefer-upcases 'upcase 'downcase) tag))
   1.397    (insert (format "<%s> " tag))
   1.398    (save-excursion (insert (format "</%s>" tag))))
   1.399  
   1.400 +(defun yahtml-insert-single (cmd)
   1.401 +  "Insert <CMD>."
   1.402 +  (interactive
   1.403 +   (list (YaTeX-cplread-with-learning
   1.404 +	  (format "Command%s: "
   1.405 +		  (if yahtml-last-single-cmd
   1.406 +		      (concat "(default " yahtml-last-single-cmd ")") ""))
   1.407 +	  'yahtml-single-cmd-table 'yahtml-user-single-cmd-table
   1.408 +	  'yahtml-tmp-single-cmd-table)))
   1.409 +  (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) cmd))
   1.410 +  (if (string< "" cmd) (setq yahtml-last-single-cmd cmd))
   1.411 +  (insert (format "<%s>" yahtml-last-single-cmd)))
   1.412 +
   1.413 +;;; ---------- Jump ----------
   1.414 +(defun yahtml-on-href-p ()
   1.415 +  "Check if point is on href clause."
   1.416 +  (let ((p (point)) cmd)
   1.417 +    (save-excursion
   1.418 +      (or (bobp) (skip-chars-backward "^ \t"))
   1.419 +      (and (looking-at "href\\s *=\\s *\"?\\([^\"]+\\)\"?")
   1.420 +	   (< p (match-end 0))
   1.421 +	   (YaTeX-match-string 1)))))
   1.422 +
   1.423 +(defun yahtml-goto-corresponding-href (&optional other)
   1.424 +  "Go to corresponding name."
   1.425 +  (let ((href (yahtml-on-href-p)) file name)
   1.426 +    (if href
   1.427 +	(cond
   1.428 +	 ((string-match "^http:" href)
   1.429 +	  (message "Sorry, jump across http is not supported."))
   1.430 +	 (t (setq file (substring href 0 (string-match "#" href)))
   1.431 +	    (if (string-match "#" href)
   1.432 +		(setq name (substring href (1+ (string-match "#" href)))))
   1.433 +	    (if (string< "" file)
   1.434 +		(progn
   1.435 +		  (if (string-match "/$" file)
   1.436 +		      (setq file (concat file "index.html")))
   1.437 +		  (if other (YaTeX-switch-to-buffer-other-window file)
   1.438 +		    (YaTeX-switch-to-buffer file))))
   1.439 +	    (if name
   1.440 +		(progn (set-mark-command nil) (yahtml-jump-to-name name)))
   1.441 +	    t)))))
   1.442 +
   1.443 +(defun yahtml-jump-to-name (name)
   1.444 +  "Jump to html's named tag."
   1.445 +  (setq name (format "name\\s *=\\s *\"?%s\"?" name))
   1.446 +  (or (and (re-search-forward name nil t) (goto-char (match-beginning 0)))
   1.447 +      (and (re-search-backward name nil t) (goto-char (match-beginning 0)))
   1.448 +      (message "Named tag `%s' not found" (substring href 1))))
   1.449 +
   1.450 +(defun yahtml-on-begend-p (&optional p)
   1.451 +  "Check if point is on begend clause."
   1.452 +  (let ((p (point)) cmd)
   1.453 +    (save-excursion
   1.454 +      (if p (goto-char p))
   1.455 +      (if (= (char-after (point)) ?<) (forward-char 1))
   1.456 +      (if (and (re-search-backward "<" nil t)
   1.457 +	       (looking-at
   1.458 +		(concat "<\\(/?" yahtml-command-regexp "\\)\\b"))
   1.459 +	       (condition-case nil
   1.460 +		   (forward-list 1))
   1.461 +	       (< p (point)))
   1.462 +	  (YaTeX-match-string 1)))))
   1.463 +
   1.464 +(defun yahtml-goto-corresponding-begend ()
   1.465 +  (let ((cmd (yahtml-on-begend-p)))
   1.466 +  (if cmd
   1.467 +      (progn
   1.468 +	(if (= (aref cmd 0) ?/)		;on </cmd> line
   1.469 +	    (re-search-backward (format "<%s" (substring cmd 1)))
   1.470 +	  (re-search-forward (format "</%s" cmd)))
   1.471 +	(if (match-beginning 0) (goto-char (match-beginning 0)))))))
   1.472 +
   1.473 +(defun yahtml-goto-corresponding-* (&optional other)
   1.474 +  "Go to corresponding object."
   1.475 +  (interactive)
   1.476 +  (cond
   1.477 +   ((yahtml-goto-corresponding-href other))
   1.478 +   ((yahtml-goto-corresponding-begend other))
   1.479 +   ))
   1.480 +
   1.481 +(defun yahtml-goto-corresponding-*-other-window ()
   1.482 +  "Go to corresponding object."
   1.483 +  (interactive)
   1.484 +  (yahtml-goto-corresponding-* t))
   1.485 +
   1.486 +;;; ---------- commenting ----------
   1.487 +(defun yahtml-comment-region (beg end)
   1.488 +  (interactive "r")
   1.489 +  (comment-region beg end nil))
   1.490 +
   1.491 +(defun yahtml-uncomment-region (beg end)
   1.492 +  (interactive "r")
   1.493 +  (comment-region beg end '(4)))
   1.494 +
   1.495 +
   1.496 +
   1.497 +;;; ---------- ----------
   1.498 +;;; ---------- ----------
   1.499 +;;; ---------- ----------
   1.500 +
   1.501 +;;;
   1.502 +;;hilit19
   1.503 +;;;
   1.504 +(defvar yahtml-default-face-table
   1.505 +  '(
   1.506 +    (form	black/ivory	white/hex-442233	italic)
   1.507 +    ))
   1.508 +(defvar yahtml-hilit-patterns-alist
   1.509 +  '(
   1.510 +    ;; comments
   1.511 +    ("<!--\\s " "-->" comment)
   1.512 +    ;; include&exec
   1.513 +    ("<!--#\\(include\\|exec\\)" "-->" include)
   1.514 +    ;; string
   1.515 +    (hilit-string-find 39 string)
   1.516 +    (yahtml-hilit-region-tag "\\(em\\|strong\\)" bold)
   1.517 +    ("</?[uod]l>" 0 decl)
   1.518 +    ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label)
   1.519 +    ("<a\\s +href" "</a>" crossref)
   1.520 +    ("</?\\sw+>" 0 decl)
   1.521 +    ("<form" "</form" form)
   1.522 +    ))
   1.523 +
   1.524 +(defun yahtml-hilit-region-tag (tag)
   1.525 +  "Return list of start/end point of <TAG> form."
   1.526 +  (if (re-search-forward (concat "<" tag ">") nil t)
   1.527 +      (let ((m0 (match-beginning 0)))
   1.528 +	(skip-chars-forward " \t\n")
   1.529 +	(cons (point)
   1.530 +	      (progn (re-search-forward (concat "</" tag ">") nil t)
   1.531 +		     (1- (match-beginning 0)))))))
   1.532 +
   1.533 +;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist))
   1.534 +(cond
   1.535 + ((and (featurep 'hilit19) (featurep 'yatex19))
   1.536 +  (or (assq 'yahtml-mode hilit-patterns-alist)
   1.537 +      (setq hilit-patterns-alist
   1.538 +	    (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist)
   1.539 +		  hilit-patterns-alist)))))
   1.540 +
   1.541  (provide 'yahtml)
   1.542  
   1.543  ; Local variables: