Mercurial > hgrepos > hgweb.cgi > yatex
annotate yahtml.el @ 330:9cef5d10a0f1 dev
First Drag-n-Drop support
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 16 Dec 2014 11:12:38 +0900 |
parents | 1bbc6cff5b6c |
children | 2a72779d9c50 |
rev | line source |
---|---|
286 | 1 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- |
294 | 2 ;;; (c) 1994-2013 by HIROSE Yuuji [yuuji(@)yatex.org] |
330 | 3 ;;; Last modified Tue Dec 16 11:11:25 2014 on firestorm |
121 | 4 ;;; $Id$ |
54 | 5 |
330 | 6 (defconst yahtml-revision-number "1.77" |
72 | 7 "Revision number of running yahtml.el") |
8 | |
286 | 9 ;;; Commentary: |
10 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
11 ;;;[Installation] |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
12 ;;; |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
13 ;;; First, you have to install YaTeX and make sure it works fine. Then |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
14 ;;; put these expressions into your ~/.emacs |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
15 ;;; |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
16 ;;; (setq auto-mode-alist |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
17 ;;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
18 ;;; (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) |
115
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
19 ;;; (setq yahtml-www-browser "firefox") |
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
20 ;;; ;Write your favorite browser. But firefox is advantageous. |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
21 ;;; (setq yahtml-path-url-alist |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
22 ;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
23 ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
24 ;;; ;Write correspondence alist from ABSOLUTE unix path name to URL path. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
25 ;;; |
64 | 26 ;;;[インストール方法] |
27 ;;; | |
28 ;;; yahtml.el, yatexlib.el, yatexprc.el を load-path の通ったディレクト | |
29 ;;; リにインストールしてください。その後、以下を参考に ~/.emacs に設定を | |
30 ;;; 追加して下さい。 | |
31 ;;; | |
32 ;;; (setq auto-mode-alist | |
33 ;;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) | |
34 ;;; (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) | |
115
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
35 ;;; (setq yahtml-www-browser "firefox") |
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
36 ;;; ;お気に入りのブラウザを書いて下さい。firefoxが便利です。 |
64 | 37 ;;; (setq yahtml-path-url-alist |
38 ;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") | |
39 ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) | |
40 ;;; ;UNIXの絶対パスと対応するURLのリストを書いて下さい。 | |
41 ;;; | |
77 | 42 ;;; HTMLファイル漢字コードが正しく判別されるようにホームディレクトリに |
43 ;;; .htaccess ファイルを作り以下のどれか1行を選んで書いて下さい。 | |
44 ;;; | |
45 ;;; AddType "text/html; charset=Shift_JIS" .html (SJISの場合) | |
46 ;;; AddType "text/html; charset=iso2022-jp" .html (JISの場合) | |
47 ;;; AddType "text/html; charset=EUC-JP" .html (EUCの場合) | |
102 | 48 ;;; AddType "text/html; charset=utf-8" .html (UTF-8の場合) |
77 | 49 ;;; |
50 ;;; .htaccess が作れない場合は | |
51 ;;; (setq yahtml-kanji-code 2) | |
102 | 52 ;;; ;HTMLファイルの漢字コードを変更する場合は |
53 ;;; ;1=SJIS、2=JIS、3=EUC 4=UTF-8 | |
77 | 54 ;;; ;で設定して下さい。デフォルトは 2 です。 |
55 ;;; | |
56 ;;; を適切に書き換えて ~/.emacs に足して下さい。 | |
57 ;;; | |
54 | 58 ;;;[Commentary] |
59 ;;; | |
60 ;;; It is assumed you are already familiar with YaTeX. The following | |
61 ;;; completing featureas are available: ([prefix] means `C-c' by default) | |
13 | 62 ;;; |
54 | 63 ;;; * [prefix] b X Complete environments such as `H1' which |
57 | 64 ;;; normally requires closing tag `</H1> |
65 ;;; <a href=foo> ... </a> is also classified into | |
66 ;;; this group | |
59 | 67 ;;; When input `href=...', you can complete file |
68 ;;; name or label(href="#foo") by typing TAB. | |
54 | 69 ;;; * [prefix] l Complete typeface-changing commands such as |
70 ;;; `<i> ... </i>' or `<samp> ... </samp>' | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
71 ;;; This completion can be used to make in-line |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
72 ;;; tags which is normally completed with [prefix] b. |
64 | 73 ;;; * [prefix] s Complete declarative notations such as |
74 ;;; `<img src="foo.gif">' | |
75 ;;; `<input name="var" ...>' | |
57 | 76 ;;; * [prefix] m Complete single commands such as |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
77 ;;; `<br>' or `<hr> or <li>...' |
64 | 78 ;;; * [prefix] p Insert <p></p> on the point |
59 | 79 ;;; * M-RET Intelligent newline; if current TAG is one of |
80 ;;; ul, ol, or dl. insert newline and <li> or | |
81 ;;; <dt> or <dd> suitable for current condition. | |
54 | 82 ;;; * menu-bar yahtml Complete all by selecting a menu item (Though I |
83 ;;; hate menu, this is most useful) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
84 ;;; * [prefix] g Goto corresponding Tag or HREF such as |
59 | 85 ;;; <dl> <-> </dl> or href="xxx". |
86 ;;; Or invoke image viewer if point is on <img src=...>. | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
87 ;;; * [prefix] k Kill html tags on the point. If you provide |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
88 ;;; universal-argument, kill surrounded contents too. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
89 ;;; * [prefix] c Change html tags on the point. |
59 | 90 ;;; When typeing [prefix] c on `href="xxx"', you can |
91 ;;; change the reference link with completion. | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
92 ;;; * [prefix] t j Call weblint on current file. |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
93 ;;; * [prefix] t p View current html with WWW browser |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
94 ;;; (To activate this, never fail to set the lisp |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
95 ;;; variable yahtml-www-browser. Recommended value |
115
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
96 ;;; is "firefox") |
59 | 97 ;;; * [prefix] a YaTeX's accent mark's equivalent of yahtml. |
98 ;;; This function can input $lt, $gt or so. | |
69 | 99 ;;; * [prefix] ; Translate chars of `>', `<', `&', and `"' to |
100 ;;; `>', `<', `&', `"' respectively | |
101 ;;; in the region. | |
102 ;;; * [prefix] : Do translation opposite to above, in the region. | |
103 ;;; * [prefix] # Translate unsafe-chars and unreserved-chars to | |
104 ;;; URLencoded string in the region. | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
105 ;;; |
64 | 106 ;;;[キーの説明] |
107 ;;; | |
108 ;;; 以下の説明において、特にカスタマイズをしていない限り、[prefix] は | |
109 ;;; C-c キーを意味します。 | |
110 ;;; | |
111 ;;; * [prefix] b X `</H1>' といった終了タグが必要となる`H1'のよう | |
112 ;;; な環境を補完入力します。<a href=foo> ... </a> | |
113 ;;; もこのグループです。 | |
114 ;;; `href=...' と入力した後、TABキーを押すことで、 | |
115 ;;; ファイル名や (href="#foo") のようなラベルも補完 | |
116 ;;; できます。 | |
117 ;;; * [prefix] s 以下のような宣言の補完を行います。 | |
118 ;;; `<img src="foo.gif">' | |
119 ;;; `<input name="var" ...>' | |
120 ;;; * [prefix] l `<i> ... </i>' や `<samp> ... </samp>' のよう | |
121 ;;; なテキストスタイル指定のタグを補完します。 | |
122 ;;; この補完機能は通常 [prefix] b で補完できるものを | |
123 ;;; 一行内で書きたいときにも用いることが出来ます。 | |
124 ;;; * [prefix] m `<br>' や `<hr> '、`<li>' 等の単体タグの補完 | |
125 ;;; を行います。 | |
126 ;;; * [prefix] p カーソル位置に<p></p>を挿入します。 | |
127 ;;; * M-RET おまかせ改行; もしul、ol、dl等のタグ(リスト)を | |
128 ;;; 使っている場合に、環境に合わせて改行と <li>、 | |
129 ;;; <dt>、<dd>を入力します。 | |
130 ;;; * menu-bar yahtml 選択したアイテムをメニューより補完できます。 | |
131 ;;; (私はメニューが嫌いなんですが、htmlに関してはメ | |
132 ;;; ニューは一番ありがたいかも) | |
133 ;;; * [prefix] g 対応するタグ、<dl> <-> </dl> や href="xxx" の | |
134 ;;; ような TAG にジャンプします。 | |
135 ;;; <img src=...> の場合はイメージビューワを呼び出 | |
136 ;;; します。href=hoge.html の場合はhoge.htmlに飛びま | |
137 ;;; す。 | |
138 ;;; * [prefix] k ポイント上の HTML タグを消去します。 | |
139 ;;; もし universal-argument を付けた場合(C-uを先に押 | |
140 ;;; す)HTMLタグで囲まれた内容も同時に消去します。 | |
141 ;;; * [prefix] c ポイント上のタグを変更します。 | |
142 ;;; `href="xxx"'の上で [prefix] c を利用した場合は、 | |
143 ;;; 参照しているリンクを補完機能を使いながら変更で | |
144 ;;; きます。 | |
145 ;;; * [prefix] t j カレントファイルに対して jweblint を呼び出しま | |
160 | 146 ;;; す。ファイル先頭付近に |
147 ;;; <!-- #lint コマンド --> | |
148 ;;; と書いておくとそのコマンドを呼びます。 | |
64 | 149 ;;; * [prefix] t p WWW ブラウザでカレントファイルを表示します。 |
150 ;;; (lisp変数 yahtml-www-browser の設定をお忘れな | |
115
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
151 ;;; く。お推めは "firefox" です) |
64 | 152 ;;; * [prefix] a YaTeX のアクセント記号補完と同じです。 |
153 ;;; < > 等が入力できます。 | |
69 | 154 ;;; * [prefix] ; 指定したリジョン中の > < & " をそれぞれ |
155 ;;; > < & " に変換します。 | |
156 ;;; * [prefix] : 指定したリジョン中で上と逆の変換をします。 | |
157 ;;; * [prefix] # 指定したリジョン中で%エンコードの必要な文字が | |
158 ;;; あればそれらをエンコードします。 | |
160 | 159 ;;; * [prefix] } リジョン内の特定文字区切りのレコードを <td> 並びに |
160 ;;; 変換します。C-u (universal-argument) 付きで起動 | |
161 ;;; するとtd以外の任意要素で括ります。thdを指定する | |
162 ;;; と最初の1つだけth,残りすべてをtdで括ります。 | |
163 ;;; * [prefix] ] リジョン内のすべての行をフィールドごとにtdで括り, | |
164 ;;; さらに各行をtrで括ります。universal-argument を | |
165 ;;; 付けるとフィールド括りをtd以外に指定できます。 | |
72 | 166 ;;; * [prefix] ESC yahtml-mode を抜け yahtml-mode に入る前に動作し |
167 ;;; ていたメジャーモードに戻ります。 | |
64 | 168 ;;; |
169 ;;; [謝辞] | |
170 ;;; | |
171 ;;; fj野鳥の会の皆さんには貴重な助言を頂きました。また、下に示す方々には | |
172 ;;; 特に大きな協力を頂きました。あわせてここに感謝申し上げます。 | |
173 ;;; | |
174 ;;; * 横田和也さん(マツダ) | |
175 ;;; マニュアルの和訳をして頂きました。 | |
176 ;;; * 吉田尚志さん(NTT Data) | |
177 ;;; Mule for Win32 での動作のさせ方を教えて頂きました。 | |
178 ;;; (というかほとんどやってもらった ^^;) | |
179 ;;; | |
54 | 180 |
286 | 181 ;;; Code: |
13 | 182 |
64 | 183 (require 'yatexlib) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
184 ;;; --- customizable variable starts here --- |
64 | 185 (defvar yahtml-prefix "\C-c" |
186 "*Prefix key stroke of yahtml functions.") | |
80 | 187 (defvar yahtml-image-viewer "display" "*Image viewer program") |
188 (defvar yahtml-www-browser "firefox" "*WWW Browser command") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
189 (defvar yahtml-kanji-code 2 |
88 | 190 "*Kanji coding system number of html file; 1=sjis, 2=jis, 3=euc, 4=UTF-8") |
69 | 191 ;;(defvar yahtml-coding-system |
192 ;; (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist)) | |
193 ;; "Kanji coding system") | |
194 (and (featurep 'mule) | |
195 (integerp yahtml-kanji-code) | |
196 (setq yahtml-kanji-code | |
197 (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist)))) | |
198 | |
64 | 199 (defvar yahtml-fill-column 72 "*fill culumn used for yahtml-mode") |
200 (defvar yahtml-fill-prefix nil "*fill prefix for yahtml-mode") | |
201 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
202 ;;(defvar yahtml-www-server "www" "*Host name of your domain's WWW server") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
203 (defvar yahtml-path-url-alist nil |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
204 "*Alist of unix path name vs. URL name of WWW server. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
205 Ex. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
206 '((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") |
70 | 207 (\"/home/yuuji/http\" . \"http://www.gentei.org/~yuuji\"))") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
208 (defvar yahtml-directory-index "index.html" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
209 "*Directory index file name; |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
210 Consult your site's WWW administrator.") |
57 | 211 |
64 | 212 (defvar yahtml-environment-indent 1 |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
213 "*Indentation depth of HTML's listing environment") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
214 |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
215 ;; YaTeX-japan is defined in yatexlib.el |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
216 (defvar yahtml-lint-program (if YaTeX-japan "jweblint" "weblint") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
217 "*Program name to lint HTML file") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
218 (defvar yahtml-hate-too-deep-indentation nil |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
219 "*Non-nil for this variable suppress deep indentation in listing environments.") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
220 |
80 | 221 (defvar yahtml-always-/p t |
64 | 222 "*Those who always use <p> with </p> set this to t.") |
80 | 223 (defvar yahtml-always-/li nil |
224 "*Those who always use <li> with </li> set this to t.") | |
225 (defvar yahtml-always-/dt nil | |
226 "*Those who always use <dt> with </dt> set this to t.") | |
227 (defvar yahtml-always-/dd nil | |
228 "*Those who always use <dd> with </dd> set this to t.") | |
64 | 229 |
70 | 230 (defvar yahtml-p-prefered-env-regexp "^\\(body\\|dl\\|blockquote\\)" |
64 | 231 "*Regexp of envs where paragraphed sentences are prefered.") |
232 | |
80 | 233 (defvar yahtml-template-file "~/public_html/template.html" |
64 | 234 "*Template HTML file. It'll be inserted to empty file.") |
235 | |
69 | 236 (defvar yahtml-prefer-upcases nil |
237 "*Non-nil for preferring upcase TAGs") | |
238 | |
239 (defvar yahtml-prefer-upcase-attributes nil | |
240 "*Non-nil for preferring upcase attributes") | |
241 | |
80 | 242 (defvar yahtml-server-type 'apache "*WWW server program type") |
69 | 243 |
244 (defvar yahtml-apache-access-file ".htaccess" | |
245 "*Server access file name for apache") | |
246 | |
247 (defvar yahtml-use-css t "*Use stylesheet or not") | |
248 | |
161 | 249 (defvar yahtml-image-inspection-bytes 500000 |
70 | 250 "*Number of bytes to inspect the image for geometry information") |
251 (defvar yahtml:img-default-alt-format "%xx%y(%sbytes)" | |
252 "*Default format of img entity's ALT attributes. | |
253 %x: width, %y: height, %s: size in bytes, %c: first comment string, | |
254 %f: filename") | |
255 | |
203
ee74177831b4
Oops, yahtml-faithful-to-htmllint is not negative of yahtml-always/li. Fixed.
yuuji@gentei.org
parents:
200
diff
changeset
|
256 (defvar yahtml-faithful-to-htmllint yahtml-always-/li |
190
3db120d6b7d1
Calculation of indentation depth revised. (included again after merge conflict)
yuuji@gentei.org
parents:
189
diff
changeset
|
257 "*Non-nil doesn't put space after opening tags.") |
3db120d6b7d1
Calculation of indentation depth revised. (included again after merge conflict)
yuuji@gentei.org
parents:
189
diff
changeset
|
258 |
72 | 259 (defvar yahtml-error-line-regexp |
260 "^\\(.*\\)(\\([0-9]+\\)):\\|^line \\([0-9]+\\)" | |
261 "*Regexp of error position which is produced by lint program.") | |
262 | |
263 (defvar yahtml-translate-hyphens-when-comment-region t | |
264 "*Non-nil for translate hyphens to - when comment-region") | |
265 (defvar yahtml-escape-chars 'ask | |
266 "*Escape reserved characters to URL-encoding or not. | |
267 Nil for never, t for everytime, and 'ask for inquiring | |
268 at each reserved chars.") | |
269 | |
270 (defvar yahtml-use-font-lock (and (featurep 'font-lock) | |
271 (fboundp 'font-lock-fontify-region)) | |
272 "*Non-nil means to use font-lock to fontify buffer.") | |
273 | |
274 (defvar yahtml-use-hilit19 (and (featurep 'hilit19) | |
275 (not yahtml-use-font-lock)) | |
276 "*Non-nil means to Use hilit19 to highlight buffer") | |
70 | 277 |
73 | 278 (defvar yahtml-mode-abbrev-table nil |
279 "*Abbrev table in use in yahtml-mode buffers.") | |
280 (define-abbrev-table 'yahtml-mode-abbrev-table ()) | |
281 | |
282 (defvar yahtml-indentation-boundary "^\\s *<h[1-3]>" | |
283 "*Boundary regexp for indentation calculation.") | |
284 | |
80 | 285 (defvar yahtml-html4-strict t |
286 "*Non-nil means editing HTML 4.01 Strict. | |
287 Completing read for obsoleted attributes disabled.") | |
288 | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
289 ;;; --- customizable variable ends here --- |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
290 (defvar yahtml-prefix-map nil) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
291 (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
292 (defvar yahtml-lint-buffer-map nil "Keymap used in lint buffer.") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
293 (defvar yahtml-shell-command-option |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
294 (or (and (boundp 'shell-command-option) shell-command-option) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
295 (if (eq system-type 'ms-dos) "/c" "-c"))) |
72 | 296 (defvar yahtml-use-highlighting (or yahtml-use-font-lock yahtml-use-hilit19)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
297 |
57 | 298 (defun yahtml-define-begend-key-normal (key env &optional map) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
299 "Define short cut yahtml-insert-begend key." |
57 | 300 (YaTeX-define-key |
301 key | |
302 (list 'lambda '(arg) '(interactive "P") | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
303 (list 'yahtml-insert-begend 'arg env)) |
57 | 304 map)) |
305 | |
306 (defun yahtml-define-begend-region-key (key env &optional map) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
307 "Define short cut yahtml-insert-begend-region key." |
57 | 308 (YaTeX-define-key key (list 'lambda nil '(interactive) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
309 (list 'yahtml-insert-begend t env)) map)) |
57 | 310 |
311 (defun yahtml-define-begend-key (key env &optional map) | |
312 "Define short cut key for begin type completion both for | |
313 normal and region mode. To customize yahtml, user should use this function." | |
314 (yahtml-define-begend-key-normal key env map) | |
315 (if YaTeX-inhibit-prefix-letter nil | |
316 (yahtml-define-begend-region-key | |
61 | 317 (concat (upcase (substring key 0 1)) (substring key 1)) env map))) |
57 | 318 |
13 | 319 (if yahtml-mode-map nil |
57 | 320 (setq yahtml-mode-map (make-sparse-keymap) |
321 yahtml-prefix-map (make-sparse-keymap)) | |
64 | 322 (define-key yahtml-mode-map yahtml-prefix yahtml-prefix-map) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
323 (define-key yahtml-mode-map "\M-\C-@" 'yahtml-mark-begend) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
324 (if (and (boundp 'window-system) (eq window-system 'x) YaTeX-emacs-19) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
325 (define-key yahtml-mode-map [?\M-\C- ] 'yahtml-mark-begend)) |
54 | 326 (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) |
57 | 327 (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
328 (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline) |
80 | 329 (define-key yahtml-mode-map "\M-\C-j" 'yahtml-intelligent-newline) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
330 (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line) |
70 | 331 (define-key yahtml-mode-map "&" 'yahtml-insert-amps) |
57 | 332 (let ((map yahtml-prefix-map)) |
333 (YaTeX-define-key "^" 'yahtml-visit-main map) | |
334 (YaTeX-define-key "4^" 'yahtml-visit-main-other-window map) | |
335 (YaTeX-define-key "4g" 'yahtml-goto-corresponding-*-other-window map) | |
336 (YaTeX-define-key "44" 'YaTeX-switch-to-window map) | |
337 (and YaTeX-emacs-19 window-system | |
338 (progn | |
339 (YaTeX-define-key "5^" 'yahtml-visit-main-other-frame map) | |
340 (YaTeX-define-key "5g" 'yahtml-goto-corresponding-*-other-frame map) | |
341 (YaTeX-define-key "55" 'YaTeX-switch-to-window map))) | |
72 | 342 (YaTeX-define-key "v" 'yahtml-version map) |
57 | 343 (YaTeX-define-key "s" 'yahtml-insert-form map) |
344 (YaTeX-define-key "l" 'yahtml-insert-tag map) | |
61 | 345 (YaTeX-define-key "L" 'yahtml-insert-tag-region map) |
57 | 346 (YaTeX-define-key "m" 'yahtml-insert-single map) |
61 | 347 (YaTeX-define-key "n" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<BR>" "<br>"))) map) |
348 (YaTeX-define-key "-" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<HR>" "<hr>") "\n")) map) | |
64 | 349 (YaTeX-define-key "p" 'yahtml-insert-p map) |
57 | 350 (if YaTeX-no-begend-shortcut |
351 (progn | |
352 (YaTeX-define-key "B" 'yahtml-insert-begend-region map) | |
353 (YaTeX-define-key "b" 'yahtml-insert-begend map)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
354 (yahtml-define-begend-key "bh" "html" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
355 (yahtml-define-begend-key "bH" "head" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
356 (yahtml-define-begend-key "bt" "title" map) |
59 | 357 (yahtml-define-begend-key "bT" "table" map) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
358 (yahtml-define-begend-key "bb" "body" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
359 (yahtml-define-begend-key "bc" "center" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
360 (yahtml-define-begend-key "bd" "dl" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
361 (yahtml-define-begend-key "bu" "ul" map) |
80 | 362 (yahtml-define-begend-key "bo" "ol" map) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
363 (yahtml-define-begend-key "b1" "h1" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
364 (yahtml-define-begend-key "b2" "h2" map) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
365 (yahtml-define-begend-key "b3" "h3" map) |
57 | 366 (yahtml-define-begend-key "ba" "a" map) |
367 (yahtml-define-begend-key "bf" "form" map) | |
368 (yahtml-define-begend-key "bs" "select" map) | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
369 (yahtml-define-begend-key "bv" "div" map) |
80 | 370 (yahtml-define-begend-key "bS" "span" map) |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
371 (yahtml-define-begend-key "bp" "pre" map) |
57 | 372 (YaTeX-define-key "b " 'yahtml-insert-begend map) |
102 | 373 (YaTeX-define-key "B " 'yahtml-insert-begend-region map)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
374 (YaTeX-define-key "e" 'YaTeX-end-environment map) |
57 | 375 (YaTeX-define-key ">" 'yahtml-comment-region map) |
376 (YaTeX-define-key "<" 'yahtml-uncomment-region map) | |
377 (YaTeX-define-key "g" 'yahtml-goto-corresponding-* map) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
378 (YaTeX-define-key "k" 'yahtml-kill-* map) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
379 (YaTeX-define-key "c" 'yahtml-change-* map) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
380 (YaTeX-define-key "t" 'yahtml-browse-menu map) |
59 | 381 (YaTeX-define-key "a" 'yahtml-complete-mark map) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
382 (YaTeX-define-key "'" 'yahtml-prev-error map) |
69 | 383 (YaTeX-define-key ";" 'yahtml-translate-region map) |
384 (YaTeX-define-key ":" 'yahtml-translate-reverse-region map) | |
385 (YaTeX-define-key "#" 'yahtml-escape-chars-region map) | |
154 | 386 (YaTeX-define-key "}" 'yahtml-td-region map) |
387 (YaTeX-define-key "]" 'yahtml-tr-region map) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
388 ;;;;;(YaTeX-define-key "i" 'yahtml-fill-item map) |
102 | 389 (YaTeX-define-key "\e" 'yahtml-quit map)) |
72 | 390 (substitute-all-key-definition |
391 'fill-paragraph 'yahtml-fill-paragraph yahtml-mode-map) | |
392 (substitute-all-key-definition | |
393 'kill-buffer 'YaTeX-kill-buffer yahtml-mode-map)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
394 |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
395 (if yahtml-lint-buffer-map nil |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
396 (setq yahtml-lint-buffer-map (make-keymap)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
397 (define-key yahtml-lint-buffer-map " " 'yahtml-jump-to-error-line)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
398 |
54 | 399 |
59 | 400 (defvar yahtml-paragraph-start |
401 (concat | |
61 | 402 "^$\\|<!--\\|^[ \t]*</?\\(h[1-6]\\|p\\|d[ldt]\\|[bhtd][rdh]\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\|table\\|center\\|blockquote\\)\\b") |
59 | 403 "*Regexp of html paragraph separater") |
57 | 404 (defvar yahtml-paragraph-separate |
405 (concat | |
61 | 406 "^$\\|<!--\\|^[ \t]*</?\\(h[1-6]\\|p\\|[bhtd][ldt]\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\|table\\|center\\|blockquote\\|!--\\)\\b") |
57 | 407 "*Regexp of html paragraph separater") |
54 | 408 (defvar yahtml-syntax-table nil |
64 | 409 "*Syntax table for yahtml-mode") |
54 | 410 |
411 (if yahtml-syntax-table nil | |
412 (setq yahtml-syntax-table | |
413 (make-syntax-table (standard-syntax-table))) | |
61 | 414 (modify-syntax-entry ?\< "(>" yahtml-syntax-table) |
415 (modify-syntax-entry ?\> ")<" yahtml-syntax-table) | |
102 | 416 (modify-syntax-entry ?\n " " yahtml-syntax-table)) |
417 | |
54 | 418 (defvar yahtml-command-regexp "[A-Za-z0-9]+" |
419 "Regexp of constituent of html commands.") | |
420 | |
421 ;;; Completion tables for `form' | |
57 | 422 (defvar yahtml-form-table |
69 | 423 '(("img") ("input") ("link") ("meta"))) |
54 | 424 (defvar yahtml-user-form-table nil) |
425 (defvar yahtml-tmp-form-table nil) | |
64 | 426 (defvar yahtml-last-form "img") |
54 | 427 |
428 (defvar yahtml-env-table | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
429 '(("html") ("head") ("title") ("body") ("dl") ("ul") ("ol") ("pre") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
430 ("a") ("form") ("select") ("center") ("textarea") ("blockquote") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
431 ("OrderedList" . "ol") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
432 ("UnorderedList" . "ul") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
433 ("DefinitionList" . "dl") |
59 | 434 ("Preformatted" . "pre") |
80 | 435 ("table") ("thead") ("tbody") ("tfoot") ("tr") ("th") ("td") |
136 | 436 ("address") ("button") |
61 | 437 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") |
64 | 438 ;; ("p") ;This makes indentation screwed up! |
80 | 439 ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del") |
315 | 440 ("option") |
64 | 441 )) |
57 | 442 |
80 | 443 (if yahtml-html4-strict |
444 (setq yahtml-env-table | |
445 (delete (assoc "center" yahtml-env-table) yahtml-env-table))) | |
446 | |
69 | 447 ;(defvar yahtml-itemizing-regexp |
448 ; "\\(ul\\|ol\\|dl\\)" | |
449 ; "Regexp of itemizing forms") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
450 |
57 | 451 (defvar yahtml-user-env-table nil) |
452 (defvar yahtml-tmp-env-table nil) | |
54 | 453 |
454 ;;; Completion tables for typeface designator | |
64 | 455 (and yahtml-always-/p |
456 (or (assoc "p" yahtml-env-table) | |
457 (setq yahtml-env-table (cons '("p") yahtml-env-table)))) | |
80 | 458 (and yahtml-always-/li |
459 (or (assoc "li" yahtml-env-table) | |
460 (setq yahtml-env-table (cons '("li") yahtml-env-table)))) | |
461 (and yahtml-always-/dt | |
462 (or (assoc "dt" yahtml-env-table) | |
463 (setq yahtml-env-table (cons '("dt") yahtml-env-table)))) | |
464 (and yahtml-always-/dd | |
465 (or (assoc "dd" yahtml-env-table) | |
466 (setq yahtml-env-table (cons '("dd") yahtml-env-table)))) | |
64 | 467 |
54 | 468 (defvar yahtml-typeface-table |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
469 (append |
80 | 470 '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") ("caption") |
471 ("strong") ("var") ("b") ("i") ("tt") ("big") ("small") | |
472 ("sup") ("sub") ("span") ("abbr")) | |
473 (if (not yahtml-html4-strict) | |
474 '(("strike") ("s") ("u") ("font"))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
475 yahtml-env-table) |
54 | 476 "Default completion table of typeface designator") |
477 (defvar yahtml-user-typeface-table nil) | |
478 (defvar yahtml-tmp-typeface-table nil) | |
64 | 479 (defvar yahtml-last-typeface-cmd "a") |
54 | 480 |
57 | 481 (defvar yahtml-single-cmd-table |
80 | 482 '(("hr") ("br") ("option") |
483 ("HorizontalRule" . "hr") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
484 ("BreakLine" . "br") |
80 | 485 ("exec" . "!--#exec") |
486 ("!--#exec") | |
487 ("include" . "!--#include") | |
488 ("!--#include") | |
489 ;; ("Item" . "li") | |
490 ;; ("DefineTerm" . "dt") | |
491 ;; ("Description" . "dd") | |
492 ;; ("dd") ("dt") ("li") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
493 ) |
57 | 494 "Default completion table of HTML single command.") |
495 (defvar yahtml-user-single-cmd-table nil) | |
496 (defvar yahtml-tmp-single-cmd-table nil) | |
497 (defvar yahtml-last-single-cmd nil) | |
498 | |
70 | 499 (defvar yahtml-current-completion-type nil |
500 "Has current completion type. This may be used in yahtml addin functions.") | |
501 | |
57 | 502 (defvar yahtml-struct-name-regexp |
61 | 503 (concat |
504 "\\<\\(" | |
70 | 505 ;(mapconcat 'car yahtml-typeface-table "\\|") |
506 (mapconcat 'car yahtml-env-table "\\|") | |
61 | 507 "\\)\\b") |
508 "Regexp of structure beginning.") | |
70 | 509 |
510 (defvar yahtml-closable-regexp | |
511 (concat | |
512 "\\<\\(" | |
513 (mapconcat 'car yahtml-typeface-table "\\|") | |
514 (mapconcat 'car yahtml-env-table "\\|") | |
515 "\\)\\b") | |
516 "Regexp of any closable elemnts.") | |
73 | 517 |
518 (defvar yahtml-indent-listing-constant t | |
519 "*Nil means indentation for listing obeys the column of `>'. | |
520 T for static indentation depth") | |
70 | 521 |
64 | 522 (or (assoc "p" yahtml-env-table) |
523 (setq yahtml-env-table (cons '("p") yahtml-env-table))) | |
57 | 524 |
70 | 525 |
526 (defun yahtml-get-user-httpconf-entry (regexp) | |
69 | 527 (cond |
528 ((and (eq yahtml-server-type 'apache) ;;check .htaccess | |
529 buffer-file-name) | |
530 (let ((dir default-directory) | |
531 charset af ext (ldir "") | |
70 | 532 line |
69 | 533 (case-fold-search t) |
534 (uid (car (cdr (cdr (file-attributes ".")))))) | |
535 (if (string-match "^[A-Z]:" dir) | |
536 (setq dir (substring dir 2))) ;remove drive letter | |
537 (while (and dir | |
538 (not (string= dir ldir)) | |
539 (equal uid (car (cdr (cdr (file-attributes dir)))))) | |
540 (setq af (expand-file-name yahtml-apache-access-file dir)) | |
541 (if (file-exists-p af) | |
542 (save-excursion | |
543 (set-buffer (find-file-noselect af)) | |
544 (save-excursion | |
545 (goto-char (point-min)) | |
70 | 546 (if (re-search-forward regexp nil t) |
547 (setq line (buffer-substring | |
548 (point-beginning-of-line) | |
549 (point-end-of-line)) | |
550 dir nil))) | |
69 | 551 (kill-buffer (current-buffer)))) |
70 | 552 (if dir |
553 (setq ldir dir | |
554 dir (substring dir 0 (string-match "/$" dir)) | |
555 dir (file-name-directory dir)))) | |
102 | 556 line)) |
557 (t nil))) | |
69 | 558 |
70 | 559 (defun yahtml-dir-default-charset () |
560 (let*((fn (file-name-nondirectory (or buffer-file-name ""))) | |
561 (ext (substring fn (or (string-match "\\.[a-z0-9]+$" fn) 0))) | |
562 (ptn (format "^\\s *AddType.*charset=\\(.*\\)\\%s$" ext)) | |
77 | 563 (case-fold-search t) |
70 | 564 line |
565 charset) | |
566 (if (setq line (yahtml-get-user-httpconf-entry ptn)) | |
567 (progn | |
568 (string-match ptn line) | |
569 (setq charset | |
570 (substring line (match-beginning 1) (match-end 1))) | |
571 (cond | |
572 ((string-match "iso-2022-jp" charset) | |
573 (setq charset 2)) | |
574 ((string-match "euc-jp" charset) | |
575 (setq charset 3)) | |
576 ((string-match "shift_jis" charset) | |
577 (setq charset 1)) | |
80 | 578 ((string-match "utf-8" charset) |
579 (setq charset 4)) | |
70 | 580 (t (setq charset nil))) |
581 (setq dir ""))) | |
582 (if (featurep 'mule) | |
583 (setq charset (cdr (assq charset YaTeX-kanji-code-alist)))) | |
584 charset)) | |
585 | |
586 (defun yahtml-get-directory-index () | |
587 (let ((line (yahtml-get-user-httpconf-entry "^\\s *DirectoryIndex")) | |
588 x index-list) | |
589 ;;s/\\s *$//; | |
590 (if line | |
591 (progn | |
592 (if (string-match "DirectoryIndex\\s +\\(.*\\)\\s *$" line) | |
593 (setq line (substring line (match-beginning 1) (match-end 1)))) | |
594 (while (string< "" line) | |
595 (if (setq x (string-match "\\(\\s +\\)" line)) | |
596 (setq index-list (cons (substring line 0 x) index-list) | |
597 line (substring line (match-end 1))) | |
598 (setq index-list (cons line index-list) | |
102 | 599 line ""))) |
70 | 600 (or (nreverse index-list) |
601 (if (listp yahtml-directory-index) | |
602 yahtml-directory-index | |
603 (list yahtml-directory-index))))))) | |
604 | |
72 | 605 (defvar yahtml-mode-old-mode nil) |
13 | 606 (defun yahtml-mode () |
607 (interactive) | |
73 | 608 (let ((old-mm major-mode)) ;Emacs21.0.95 resets major-mode |
609 (kill-all-local-variables) ;with kill-all-local-variables | |
610 (if (not (eq 'yahtml-mode old-mm)) | |
611 (set (make-local-variable 'yahtml-mode-old-mode) old-mm))) | |
69 | 612 (let ((coding (or (yahtml-dir-default-charset) yahtml-kanji-code))) |
613 (cond | |
79
0734be649cb8
Do not care file-coding-system when YaTeX-kanji-code is nil.
yuuji
parents:
77
diff
changeset
|
614 ((null coding) nil) |
69 | 615 ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system)) |
72 | 616 (setq buffer-file-coding-system |
617 (or (and (fboundp 'set-auto-coding) buffer-file-name | |
80 | 618 (save-excursion |
619 (goto-char (point-min)) | |
620 (set-auto-coding buffer-file-name (buffer-size)))) | |
72 | 621 coding))) |
69 | 622 ((featurep 'mule) |
623 (set-file-coding-system coding)) | |
624 ((boundp 'NEMACS) | |
625 (make-local-variable 'kanji-fileio-code) | |
626 (setq kanji-fileio-code coding)))) | |
13 | 627 (setq major-mode 'yahtml-mode |
72 | 628 mode-name "yahtml" |
73 | 629 YaTeX-current-file-name (file-name-nondirectory |
630 (or (buffer-file-name) "")) | |
631 local-abbrev-table yahtml-mode-abbrev-table) | |
64 | 632 (mapcar |
633 (function (lambda (x) | |
634 (make-local-variable (car x)) | |
635 (set (car x) (if (and (symbolp (cdr x)) | |
636 (boundp (cdr x))) | |
637 (symbol-value (cdr x)) | |
638 (cdr x))))) | |
639 '((YaTeX-ec . "") | |
640 (YaTeX-struct-begin . "<%1%2") | |
641 (YaTeX-struct-end . "</%1>") | |
70 | 642 (YaTeX-struct-name-regexp . yahtml-closable-regexp) |
80 | 643 (YaTeX-comment-prefix . "<!--[^#]") |
69 | 644 (YaTeX-coding-system . yahtml-kanji-code) ;necessary? |
64 | 645 (YaTeX-typesetting-mode-map . yahtml-lint-buffer-map) |
646 (fill-prefix . yahtml-fill-prefix) (fill-column . yahtml-fill-column) | |
647 (paragraph-start . yahtml-paragraph-start) | |
648 (paragraph-separate . yahtml-paragraph-separate) | |
649 (comment-start . "<!-- ") (comment-end . " -->") | |
650 (comment-start-skip . comment-start) | |
651 (indent-line-function . yahtml-indent-line))) | |
652 | |
72 | 653 (if yahtml-use-font-lock |
654 (progn | |
655 (yahtml-font-lock-set-default-keywords) | |
656 (or (featurep 'xemacs) | |
657 (progn | |
658 (set (make-local-variable 'font-lock-defaults) | |
659 '(yahtml-font-lock-keywords nil t)) | |
660 ;;(font-lock-mode -1) | |
661 (font-lock-mode 1) ;;Why should I fontify again??? | |
662 ;; in yatex-mode, there's no need to refontify... | |
102 | 663 (font-lock-fontify-buffer))))) |
330 | 664 ;; +dnd for X11 w/ emacs23+ |
665 (and window-system (featurep 'dnd) | |
666 (set (make-local-variable 'dnd-protocol-alist) | |
667 (cons (cons "^\\(file\\|https?\\):" 'yahtml-dnd-handler) | |
668 dnd-protocol-alist))) | |
669 | |
54 | 670 (set-syntax-table yahtml-syntax-table) |
13 | 671 (use-local-map yahtml-mode-map) |
64 | 672 (YaTeX-read-user-completion-table) |
69 | 673 (yahtml-css-scan-styles) |
64 | 674 (turn-on-auto-fill) ;Sorry, this is prerequisite |
675 (and (= 0 (buffer-size)) (file-exists-p yahtml-template-file) | |
676 (y-or-n-p (format "Insert %s?" yahtml-template-file)) | |
677 (insert-file-contents (expand-file-name yahtml-template-file))) | |
72 | 678 (run-hooks 'text-mode-hook 'yahtml-mode-hook) |
679 | |
680 ;; This warning should be removed after a while(2000/12/2) | |
681 (let ((fld (or (and (local-variable-p 'font-lock-defaults (current-buffer)) | |
682 font-lock-defaults) | |
683 (get 'yahtml-mode 'font-lock-defaults)))) | |
684 (and fld (not (memq 'yahtml-font-lock-keywords fld)) | |
685 (YaTeX-warning-font-lock "yahtml")))) | |
686 | |
687 (defun yahtml-version () | |
688 "Return string of the version of running yahtml." | |
689 (interactive) | |
690 (message | |
691 (concat "Yet Another HTML-mode " | |
692 (if YaTeX-japan "「HTML屋」" "`yahtml'") | |
693 " Revision " | |
694 yahtml-revision-number))) | |
695 | |
696 (defun yahtml-quit () | |
697 (interactive) | |
698 (and yahtml-mode-old-mode | |
699 (fboundp yahtml-mode-old-mode) | |
700 (funcall yahtml-mode-old-mode))) | |
54 | 701 |
702 (defun yahtml-define-menu (keymap bindlist) | |
64 | 703 (cond |
704 ((featurep 'xemacs) | |
705 (let ((name (keymap-name (symbol-value keymap)))) | |
706 (set keymap nil) | |
707 (mapcar | |
708 (function | |
709 (lambda (bind) | |
710 (setq bind (cdr bind)) | |
711 (if (eq (car (cdr bind)) 'lambda) | |
712 (setcar (cdr bind) 'progn)) | |
713 (if (stringp (car (cdr bind))) | |
714 (set keymap (cons (cdr bind) (symbol-value keymap))) | |
715 (set keymap (cons (vector (car bind) (cdr bind) t) | |
716 (symbol-value keymap)))))) | |
717 bindlist) | |
718 (set keymap (cons name (symbol-value keymap))))) | |
719 (t | |
720 (mapcar | |
721 (function | |
722 (lambda (bind) | |
723 (define-key (symbol-value keymap) (vector (car bind)) (cdr bind)))) | |
724 bindlist)))) | |
54 | 725 |
726 (defvar yahtml-menu-map nil "Menu map of yahtml") | |
727 (defvar yahtml-menu-map-sectioning nil "Menu map of yahtml(sectioning)") | |
728 (defvar yahtml-menu-map-listing nil "Menu map of yahtml(listing)") | |
729 (defvar yahtml-menu-map-logical nil "Menu map of yahtml(logical tags)") | |
730 (defvar yahtml-menu-map-typeface nil "Menu map of yahtml(typeface tags)") | |
731 | |
732 ;;; Variables for mosaic url history | |
733 (defvar yahtml-urls nil "Alist of global history") | |
64 | 734 (defvar yahtml-urls-private nil) |
735 (defvar yahtml-urls-local nil) | |
54 | 736 |
737 (cond | |
738 ((and YaTeX-emacs-19 (null yahtml-menu-map)) | |
64 | 739 (setq yahtml-menu-map (make-sparse-keymap "yahtml")) |
54 | 740 (setq yahtml-menu-map-sectioning (make-sparse-keymap "sectioning menu")) |
64 | 741 (YaTeX-define-menu |
742 'yahtml-menu-map-sectioning | |
54 | 743 (nreverse |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
744 '((1 "H1" . (lambda () (interactive) (yahtml-insert-begend nil "H1"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
745 (2 "H2" . (lambda () (interactive) (yahtml-insert-begend nil "H2"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
746 (3 "H3" . (lambda () (interactive) (yahtml-insert-begend nil "H3"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
747 (4 "H4" . (lambda () (interactive) (yahtml-insert-begend nil "H4"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
748 (5 "H5" . (lambda () (interactive) (yahtml-insert-begend nil "H5"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
749 (6 "H6" . (lambda () (interactive) (yahtml-insert-begend nil "H6"))) |
54 | 750 ))) |
751 (setq yahtml-menu-map-logical (make-sparse-keymap "logical tags")) | |
64 | 752 (YaTeX-define-menu |
753 'yahtml-menu-map-logical | |
54 | 754 (nreverse |
755 '((em "Embolden" . | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
756 (lambda () (interactive) (yahtml-insert-tag nil "EM"))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
757 (dfn "Define a word" . |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
758 (lambda () (interactive) (yahtml-insert-tag nil "DFN"))) |
54 | 759 (cite "Citation" . |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
760 (lambda () (interactive) (yahtml-insert-tag nil "CITE"))) |
54 | 761 (code "Code" . |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
762 (lambda () (interactive) (yahtml-insert-tag nil "CODE"))) |
54 | 763 (kbd "Keyboard" . |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
764 (lambda () (interactive) (yahtml-insert-tag nil "KBD"))) |
54 | 765 (samp "Sample display" . |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
766 (lambda () (interactive) (yahtml-insert-tag nil "SAMP"))) |
54 | 767 (strong "Strong" . |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
768 (lambda () (interactive) (yahtml-insert-tag nil "STRONG"))) |
54 | 769 (VAR "Variable notation" . |
180 | 770 (lambda () (interactive) (yahtml-insert-tag nil "var")))))) |
54 | 771 (setq yahtml-menu-map-typeface (make-sparse-keymap "typeface tags")) |
64 | 772 (YaTeX-define-menu |
773 'yahtml-menu-map-typeface | |
54 | 774 (nreverse |
775 '((b "Bold" . | |
180 | 776 (lambda () (interactive) (yahtml-insert-tag nil "b"))) |
54 | 777 (i "Italic" . |
180 | 778 (lambda () (interactive) (yahtml-insert-tag nil "i"))) |
54 | 779 (tt "Typewriter" . |
180 | 780 (lambda () (interactive) (yahtml-insert-tag nil "tt"))) |
54 | 781 (u "Underlined" . |
180 | 782 (lambda () (interactive) (yahtml-insert-tag nil "u")))))) |
54 | 783 (setq yahtml-menu-map-listing (make-sparse-keymap "listing")) |
64 | 784 (YaTeX-define-menu |
785 'yahtml-menu-map-listing | |
54 | 786 (nreverse |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
787 '((ul "Unordered" . |
180 | 788 (lambda () (interactive) (yahtml-insert-begend nil "ul"))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
789 (ol "Ordered" . |
180 | 790 (lambda () (interactive) (yahtml-insert-begend nil "ol"))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
791 (dl "Definition" . |
180 | 792 (lambda () (interactive) (yahtml-insert-begend nil "dl")))))) |
57 | 793 (setq yahtml-menu-map-item (make-sparse-keymap "item")) |
64 | 794 (YaTeX-define-menu |
795 'yahtml-menu-map-item | |
57 | 796 (nreverse |
797 '((li "Simple item" . | |
798 (lambda () (interactive) (yahtml-insert-single "li"))) | |
799 (dt "Define term" . | |
800 (lambda () (interactive) (yahtml-insert-single "dt"))) | |
801 (dd "Description of term" . | |
102 | 802 (lambda () (interactive) (yahtml-insert-single "dd")))))) |
54 | 803 (define-key yahtml-mode-map [menu-bar yahtml] |
804 (cons "yahtml" yahtml-menu-map)) | |
64 | 805 (YaTeX-define-menu |
806 'yahtml-menu-map | |
54 | 807 (nreverse |
808 (list | |
809 (cons (list 'sect "Sectioning") | |
810 (cons "sectioning" yahtml-menu-map-sectioning)) | |
811 (cons (list 'list "Listing") | |
812 (cons "Listing" yahtml-menu-map-listing)) | |
57 | 813 (cons (list 'item "Item") |
814 (cons "Itemizing" yahtml-menu-map-item));;; | |
54 | 815 (cons (list 'logi "Logical tags") |
816 (cons "logical" yahtml-menu-map-logical)) | |
817 (cons (list 'type "Typeface tags") | |
102 | 818 (cons "typeface" yahtml-menu-map-typeface))))) |
64 | 819 (if (featurep 'xemacs) |
820 (add-hook 'yahtml-mode-hook | |
821 '(lambda () | |
822 (or (assoc "yahtml" current-menubar) | |
823 (progn | |
824 (set-buffer-menubar (copy-sequence current-menubar)) | |
102 | 825 (add-submenu nil yahtml-menu-map)))))))) |
54 | 826 |
57 | 827 ;;; ----------- Completion ---------- |
828 (defvar yahtml-last-begend "html") | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
829 (defun yahtml-insert-begend (&optional region env) |
57 | 830 "Insert <cmd> ... </cmd>." |
831 (interactive "P") | |
70 | 832 (setq yahtml-current-completion-type 'multiline) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
833 (let*((completion-ignore-case t) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
834 (cmd |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
835 (or env |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
836 (YaTeX-cplread-with-learning |
57 | 837 (format "Environment(default %s): " yahtml-last-begend) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
838 'yahtml-env-table 'yahtml-user-env-table 'yahtml-tmp-env-table))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
839 (bolp (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
840 (skip-chars-backward " \t" (point-beginning-of-line)) (bolp))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
841 (cc (current-column))) |
57 | 842 (if (string< "" cmd) (setq yahtml-last-begend cmd)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
843 (setq yahtml-last-begend |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
844 (or (cdr (assoc yahtml-last-begend yahtml-env-table)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
845 yahtml-last-begend)) |
57 | 846 (setq cmd yahtml-last-begend) |
180 | 847 (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) cmd)) |
57 | 848 (if region |
69 | 849 ;; We want to keep region effective for new tagged environment |
850 ;; to enable continuous regioning by another environment | |
57 | 851 (let ((beg (region-beginning)) |
852 (end (region-end)) | |
853 (addin (yahtml-addin cmd))) | |
69 | 854 (save-excursion |
855 (goto-char end) | |
856 (insert-before-markers (format "</%s>%s" cmd (if bolp "\n" ""))) | |
857 (goto-char beg) | |
858 (insert (format "<%s%s>%s" cmd addin (if bolp "\n" ""))))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
859 (insert (format "<%s%s>" cmd (yahtml-addin cmd))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
860 (save-excursion |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
861 (insert "\n") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
862 (indent-to-column cc) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
863 (insert (format "</%s>" cmd))) |
64 | 864 (if (string-match "^a\\|p$" cmd) ;aとp決め打ちってのが美しくない… |
865 (newline) | |
866 (yahtml-intelligent-newline nil)) | |
867 (yahtml-indent-line)))) | |
57 | 868 |
869 (defun yahtml-insert-begend-region () | |
870 "Call yahtml-insert-begend in the region mode." | |
871 (interactive) | |
872 (yahtml-insert-begend t)) | |
873 | |
874 | |
54 | 875 (defun yahtml-insert-form (&optional form) |
57 | 876 "Insert <FORM option=\"argument\">." |
54 | 877 (interactive) |
70 | 878 (setq yahtml-current-completion-type 'single) |
54 | 879 (or form |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
880 (let ((completion-ignore-case t)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
881 (setq form |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
882 (YaTeX-cplread-with-learning |
64 | 883 (format "Form(default %s): " yahtml-last-form) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
884 'yahtml-form-table 'yahtml-user-form-table |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
885 'yahtml-tmp-form-table)))) |
57 | 886 (let ((p (point)) q) |
64 | 887 (if (string= form "") (setq form yahtml-last-form)) |
888 (setq yahtml-last-form form) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
889 (if yahtml-prefer-upcases (setq form (upcase form))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
890 (insert (format "<%s%s>" form (yahtml-addin form))) |
57 | 891 ;;(indent-relative-maybe) |
892 (if (cdr (assoc form yahtml-form-table)) | |
893 (save-excursion (insert (format "</%s>" form)))) | |
54 | 894 (if (search-backward "\"\"" p t) (forward-char 1)))) |
895 | |
80 | 896 (defun yahtml-read-css (alist) |
897 (let ((completion-ignore-case t) (delim " ") | |
898 (minibuffer-completion-table alist)) | |
899 (read-from-minibuffer | |
900 (substitute-command-keys | |
901 (if YaTeX-japan | |
902 "クラス(複数指定は\\[quoted-insert] SPCで区切る): " | |
903 "class(or class list delimited by \\[quoted-insert] SPC): ")) | |
904 nil YaTeX-minibuffer-completion-map nil))) | |
905 | |
138 | 906 (defvar yahtml-newpage-command "newpage.rb" |
907 "*Command name to create new HTML file referring to index.html. | |
908 This command should create new HTML file named argument 1 and | |
909 output string like `<a href=\"newfile.html\">anchor tag</a>'. | |
910 This program should take -o option to overwrite existing HTML file.") | |
911 (defun yahtml-newpage (file ov) | |
912 "Create newpage via newpage script" | |
913 (interactive | |
914 (list | |
915 (let (insert-default-directory) | |
916 (read-file-name "New webpage file name: " "")) | |
917 current-prefix-arg)) | |
918 (if (and (file-exists-p file) (not ov)) | |
919 (error "%s already exists. Call this with universal argument to force overwrite." file)) | |
920 (insert (substring | |
921 (YaTeX-command-to-string | |
922 (concat yahtml-newpage-command " " (if ov "-o ") file)) | |
923 0 -1))) | |
924 | |
59 | 925 ;;; ---------- Add-in ---------- |
54 | 926 (defun yahtml-addin (form) |
927 "Check add-in function's existence and call it if exists." | |
69 | 928 (let ((addin (concat "yahtml:" (downcase form))) s a) |
929 (concat | |
70 | 930 (and (setq a (yahtml-css-get-element-completion-alist form)) |
290
1a4332ecc58b
For emacs-24.3+ and NEmacs(last-command-{char,event} handling)
HIROSE Yuuji <yuuji@gentei.org>
parents:
286
diff
changeset
|
931 (not (equal (YaTeX-last-key) ?\C-j)) |
70 | 932 (memq yahtml-current-completion-type '(multiline inline)) |
147 | 933 (not (string-match "#" form)) |
70 | 934 (yahtml-make-optional-argument ;should be made generic? |
80 | 935 "class" (yahtml-read-css a))) |
69 | 936 (if (and (intern-soft addin) (fboundp (intern-soft addin)) |
937 (stringp (setq s (funcall (intern addin)))) | |
938 (string< "" s)) | |
939 (if (eq (aref s 0) ? ) s (concat " " s)) | |
940 "")))) | |
54 | 941 |
59 | 942 (defvar yahtml-completing-buffer nil) |
943 (defun yahtml-collect-labels (&optional file) | |
68 | 944 "Collect current buffers label (<?? name=...>). |
59 | 945 If optional argument FILE is specified collect labels in FILE." |
69 | 946 (let (list end) |
59 | 947 (save-excursion |
948 (set-buffer yahtml-completing-buffer) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
949 (if file (let (hilit-auto-highlight) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
950 (set-buffer (find-file-noselect file)))) |
59 | 951 (save-excursion |
952 (goto-char (point-min)) | |
69 | 953 (while ;(re-search-forward "<\\w+\\b" nil t) |
954 (re-search-forward "\\(name\\|id\\)\\s *=" nil t) | |
955 ;(setq bound (match-end 0)) | |
956 ;(search-forward ">" nil t) | |
957 (setq end (match-end 0)) | |
958 (if (and ;(re-search-backward "\\(name\\|id\\)\\s *=" bound t) | |
959 (yahtml-on-assignment-p) | |
960 (progn | |
961 (goto-char end) | |
962 (skip-chars-forward " \t\n") | |
963 (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) | |
59 | 964 (setq list (cons |
965 (list (concat "#" (YaTeX-match-string 1))) | |
966 list)))) | |
102 | 967 list)))) |
59 | 968 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
969 (defvar yahtml-url-completion-map nil "Key map used in URL completion buffer") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
970 (if yahtml-url-completion-map nil |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
971 (setq yahtml-url-completion-map |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
972 (copy-keymap minibuffer-local-completion-map)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
973 (define-key yahtml-url-completion-map "\t" 'yahtml-complete-url) |
102 | 974 (define-key yahtml-url-completion-map " " 'yahtml-complete-url)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
975 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
976 (defun yahtml-complete-url () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
977 "Complete external URL from history or local file name." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
978 (interactive) |
72 | 979 (let ((p (point)) initial i2 cmpl path dir file listfunc beg labels |
73 | 980 (lim (YaTeX-minibuffer-begin)) |
981 (min (if (fboundp 'field-beginning) (field-beginning) (point-min)))) | |
72 | 982 (setq initial (YaTeX-minibuffer-string)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
983 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
984 ((string-match "^http:" initial) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
985 (setq cmpl (try-completion initial yahtml-urls) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
986 listfunc (list 'lambda nil |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
987 (list 'all-completions initial 'yahtml-urls)) |
73 | 988 beg min)) |
59 | 989 ((setq beg (string-match "#" initial)) |
990 (or (equal beg 0) ;begin with # | |
991 (progn | |
992 (setq path (substring initial 0 beg)) | |
993 (if (string-match "^/" path) | |
994 (setq path (yahtml-url-to-path path))))) | |
995 (setq initial (substring initial beg)) | |
996 (setq labels (yahtml-collect-labels path) | |
997 cmpl (try-completion initial labels) | |
998 listfunc (list 'lambda () | |
999 (list 'all-completions | |
1000 initial (list 'quote labels))) | |
73 | 1001 beg (+ min beg))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1002 (t |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1003 (setq path (if (string-match "^/" initial) |
64 | 1004 (or (yahtml-url-to-path initial) initial) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1005 initial)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1006 (setq dir (or (file-name-directory path) ".") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1007 file (file-name-nondirectory path) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1008 initial file |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1009 cmpl (file-name-completion file dir) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1010 listfunc (list 'lambda nil |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1011 (list 'file-name-all-completions |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1012 file dir)) |
72 | 1013 beg (save-excursion (skip-chars-backward "^/" lim) (point))))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1014 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1015 ((stringp cmpl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1016 (if (string= initial cmpl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1017 (with-output-to-temp-buffer "*Completions*" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1018 (princ "Possible completinos are:\n") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1019 (princ |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1020 (mapconcat '(lambda (x) x) (funcall listfunc) "\n"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1021 (delete-region (point) beg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1022 (insert cmpl))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1023 ((null cmpl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1024 (ding)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1025 ((eq t cmpl) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1026 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1027 (unwind-protect |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1028 (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1029 (goto-char p) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1030 (insert " [Sole completion]")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1031 (delete-region p (point-max)))))))) |
69 | 1032 |
1033 ; | |
1034 ; Subject: [yatex:02849] Re: [yahtml] tilda in href tag | |
193 | 1035 ; From: Masayasu Ishikawa <mimasa<at>sfc.keio.ac.jp> |
1036 ; To: yatex<at>arcadia.jaist.ac.jp | |
69 | 1037 ; Date: Mon, 31 May 1999 21:09:31 +0900 |
1038 ; RFC 2396 の "2.4.3. Excluded US-ASCII Characters" によると、以下の文字 | |
1039 ; は必ずエスケープしないといけません。 | |
1040 ; | |
1041 ; control = <US-ASCII coded characters 00-1F and 7F hexadecimal> | |
1042 ; space = <US-ASCII coded character 20 hexadecimal> | |
1043 ; delims = "<" | ">" | "#" | "%" | <"> | |
1044 ; unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`" | |
1045 (defvar yahtml-unsafe-chars-regexp | |
1046 "[][\x0- \x7f <>%\"{}|\\^`]" ;#は除去する | |
1047 "Characters regexp which must be escaped in URI.") | |
1048 ; | |
1049 ; また、以下の文字は予約された用法以外に用いる場合にはエスケープしないと | |
1050 ; いけないことになっています。 | |
1051 ; | |
1052 ; reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | | |
1053 ; "$" | "," | |
1054 (defvar yahtml-unreserved-chars-regexp | |
1055 "[;/?:@&=+$,]" | |
1056 "Characters regexp which should be escaped in URI on certain conditions. | |
1057 Not used yet.") | |
1058 | |
1059 (defun yahtml-escape-chars-string (str) | |
1060 "Translate reserved chars to URL encoded string." | |
1061 (let ((p 0) (target "") | |
1062 (ask (eq yahtml-escape-chars 'ask))) | |
1063 (cond | |
1064 ((null yahtml-escape-chars) str) | |
1065 (t | |
1066 (while (and (string< "" str) | |
1067 (setq p (string-match yahtml-unsafe-chars-regexp str))) | |
1068 (if (and ask (y-or-n-p (format "Escape char [%c] of `%s'" | |
1069 (aref str p) (substring str 0 (1+ p))))) | |
1070 (setq target (concat target | |
1071 (substring str 0 p) | |
1072 (format "%%%x" (aref str p)))) | |
1073 (setq target (concat target (substring str 0 (1+ p))))) | |
1074 (setq str (substring str (1+ p)))) | |
1075 (concat target str))))) | |
1076 | |
153
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1077 (defun yahtml-unescape-string (str) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1078 "Untranslate reserved URL-encoded string." |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1079 (let ((p 0) c (target "") (md (match-data)) (case-fold-search nil)) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1080 (unwind-protect |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1081 (progn |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1082 (while (string-match "%\\([0-9a-f][0-9a-f]\\)" str p) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1083 (setq target (concat target |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1084 (substring str p (1- (match-beginning 1)))) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1085 p (match-end 0) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1086 c (YaTeX-hex (substring |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1087 str (match-beginning 1) (match-end 1))) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1088 target (concat target (format "%c" c)))) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1089 (concat target (substring str p))) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1090 (store-match-data md)))) |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1091 |
69 | 1092 (defun yahtml-escape-chars-region (beg end) |
1093 "Translate reserved chars to encoded string in the region." | |
1094 (interactive "r") | |
1095 (save-excursion | |
1096 (let ((e (set-marker (make-marker) end)) c m yes) | |
1097 (goto-char beg) | |
1098 (while (and (< (point) e) | |
1099 (re-search-forward | |
1100 (concat yahtml-unsafe-chars-regexp "\\|" | |
1101 yahtml-unreserved-chars-regexp) e t)) | |
1102 (sit-for 0) | |
1103 ; (setq m (buffer-modified-p) | |
1104 ; c (char-after (1- (point)))) | |
1105 ; (save-excursion (backward-char 1) (insert " ==>")) | |
1106 ; (unwind-protect | |
1107 ; (setq yes (y-or-n-p (format "Replace: [%c]" c))) | |
1108 ; (save-excursion | |
1109 ; (backward-char 1) | |
1110 ; (delete-backward-char 4)) | |
1111 ; (set-buffer-modified-p m)) | |
1112 (message "Replace: [%c] (y or n):" (setq c (char-after (1- (point))))) | |
1113 (if (memq (read-char) '(?y ?Y)) | |
1114 (progn | |
1115 (delete-region (match-beginning 0) (match-end 0)) | |
1116 (insert (format "%%%x" c))))) | |
1117 (set-marker e nil)))) | |
1118 ;; ab%defgls/.| | |
1119 | |
57 | 1120 (defun yahtml:a () |
54 | 1121 "Add-in function for <a>" |
64 | 1122 (let ((href "")) |
1123 (setq yahtml-completing-buffer (current-buffer) | |
69 | 1124 yahtml-urls (append yahtml-urls-private yahtml-urls-local) |
1125 href (yahtml-escape-chars-string | |
1126 (read-from-minibuffer "href: " "" yahtml-url-completion-map))) | |
64 | 1127 (prog1 |
1128 (concat (yahtml-make-optional-argument | |
1129 "href" href) | |
1130 (yahtml-make-optional-argument | |
1131 "name" (read-string "name: "))) | |
1132 (if (and (string-match "^http://" href) | |
69 | 1133 (null (assoc href yahtml-urls-private)) |
1134 (null (assoc href yahtml-urls-local))) | |
64 | 1135 (YaTeX-update-table |
1136 (list href) | |
102 | 1137 'yahtml-urls-private 'yahtml-urls-private 'yahtml-urls-local))))) |
57 | 1138 |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1139 (defvar yahtml-parameters-completion-alist |
61 | 1140 '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center")) |
70 | 1141 ("clear" ("left") ("right") ("center") ("all") ("none")) |
80 | 1142 ("lang" ("ja") ("en") ("kr") ("ch") ("fr")) |
1143 ("src" . file) ("file" . file) | |
70 | 1144 ("background" . file) |
1145 ("class file name" . file) ("data" . file) | |
69 | 1146 ("method" ("POST") ("GET")) |
1147 ("rev" . yahtml-link-types-alist) | |
1148 ("rel" . yahtml-link-types-alist) | |
70 | 1149 ("type" . yahtml-content-types-alist) |
73 | 1150 ("codetype" . yahtml-content-types-alist) |
1151 ("http-equiv" ("Refresh")))) | |
69 | 1152 |
1153 (defvar yahtml-link-types-alist | |
1154 '(("alternate") ("stylesheet") ("start") ("next") ("prev") | |
1155 ("contents") ("index") ("glossary") ("chapter") ("section") | |
1156 ("subsection") ("appendix") ("help") ("bookmark"))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1157 |
69 | 1158 (defvar yahtml-content-types-alist |
1159 '(("text/css") ("text/html") ("text/plain") ("text/richtext") | |
1160 ("text/sgml") ("text/xml") | |
80 | 1161 ("text/javascript") ("text/tcl") ("text/vbscript") |
69 | 1162 ("application/octet-stream") ("application/postscript") ("application/pdf") |
70 | 1163 ("application/java") |
1164 ("image/jpeg") ("image/gif") ("image/tiff") ("image/png") ("video/mpeg")) | |
69 | 1165 "Alist of content-types") |
1166 | |
1167 (defun yahtml-read-parameter (par &optional default alist) | |
1168 (let* ((alist | |
1169 (cdr-safe (assoc (downcase par) | |
1170 (or alist yahtml-parameters-completion-alist)))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1171 (prompt (concat par ": ")) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1172 v) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1173 (cond |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1174 ((eq alist 'file) |
80 | 1175 (let ((insert-default-directory)) |
1176 (read-file-name prompt "" default nil ""))) | |
147 | 1177 ((eq alist 'command) |
1178 (if (fboundp 'read-shell-command) | |
1179 (read-shell-command prompt) | |
1180 (read-string prompt))) | |
70 | 1181 ((and alist (symbolp alist)) |
69 | 1182 (completing-read prompt (symbol-value alist) nil nil default)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1183 (alist |
69 | 1184 (completing-read prompt alist nil nil default)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1185 (t |
69 | 1186 (read-string prompt default))))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1187 |
64 | 1188 (defun yahtml-make-optional-argument (opt arg) |
1189 "Make optional argument string." | |
80 | 1190 (if (or (null arg) (string= "" arg)) |
64 | 1191 "" |
69 | 1192 (concat " " |
1193 (if yahtml-prefer-upcase-attributes (upcase opt) (downcase opt)) | |
64 | 1194 "=\"" arg "\""))) |
1195 | |
80 | 1196 (defun yahtml:html () |
1197 "Add-in for <html>" | |
1198 (setq yahtml-last-begend "head" yahtml-last-typeface-cmd "head") | |
1199 (yahtml-make-optional-argument | |
1200 "lang" (yahtml-read-parameter "lang" (if YaTeX-japan "ja")))) | |
1201 | |
1202 (defun yahtml:head () | |
1203 "Add-in for <head>" | |
1204 (setq yahtml-last-begend "title" yahtml-last-typeface-cmd "title") | |
1205 "") | |
1206 | |
64 | 1207 (defun yahtml:body () |
1208 "Add-in function for <body>" | |
80 | 1209 (cond |
1210 (yahtml-html4-strict nil) | |
1211 (t | |
1212 (let ((b (read-string "bgcolor=")) | |
1213 (bg (yahtml-read-parameter "background" "")) | |
1214 (x (read-string "text color=")) | |
1215 (l (read-string "link color=")) | |
1216 (v (read-string "vlink color="))) | |
1217 (concat | |
1218 (yahtml-make-optional-argument "bgcolor" b) | |
1219 (yahtml-make-optional-argument "background" bg) | |
1220 (yahtml-make-optional-argument "text" x) | |
1221 (yahtml-make-optional-argument "link" l) | |
1222 (yahtml-make-optional-argument "vlink" v)))))) | |
1223 | |
1224 (defun yahtml-make-style-parameter (proplist) | |
1225 "Make CSS property definitions in style attribute." | |
1226 (mapconcat | |
1227 '(lambda (x) (if (and (cdr x) (string< "" (cdr x))) | |
1228 (format "%s: %s;" (car x) (cdr x)))) | |
1229 (delq nil proplist) | |
1230 " ")) | |
64 | 1231 |
57 | 1232 (defun yahtml:img () |
1233 "Add-in function for <img>" | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1234 (let ((src (yahtml-read-parameter "src")) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1235 (alg (yahtml-read-parameter "align")) |
70 | 1236 alt |
64 | 1237 (brd (read-string "border=")) |
70 | 1238 (l yahtml-prefer-upcase-attributes) |
1239 info width height bytes comments) | |
1240 (and (stringp src) (string< "" src) (file-exists-p src) | |
1241 (setq info (yahtml-get-image-info src)) | |
1242 (car info) | |
1243 (setq width (int-to-string (car info)) | |
1244 height (int-to-string (car (cdr info))) | |
1245 bytes (car (cdr (cdr info))) | |
1246 comments (nth 4 info))) | |
1247 (if info | |
1248 (setq alt | |
1249 (YaTeX-replace-formats | |
1250 yahtml:img-default-alt-format | |
1251 (list (cons "x" width) | |
1252 (cons "y" height) | |
1253 (cons "s" (int-to-string bytes)) | |
1254 (cons "f" (file-name-nondirectory src)) | |
1255 (cons "c" (car comments)))))) | |
1256 | |
1257 (setq alt (yahtml-read-parameter "alt" alt)) | |
1258 (setq width (yahtml-read-parameter "width" width) | |
1259 height (yahtml-read-parameter "height" height)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1260 (concat (if l "SRC" "src") "=\"" src "\"" |
64 | 1261 (yahtml-make-optional-argument "alt" alt) |
70 | 1262 (yahtml-make-optional-argument "width" width) |
1263 (yahtml-make-optional-argument "height" height) | |
80 | 1264 (if yahtml-html4-strict |
1265 (yahtml-make-optional-argument | |
1266 "style" | |
1267 (if (or brd alg) | |
1268 (yahtml-make-style-parameter | |
1269 (list | |
1270 (if (string< "" alg) | |
1271 (cons "align" alg)) | |
1272 (if (string< "" brd) | |
1273 (cons "border" | |
1274 (format "%dpx" (string-to-int brd)))))))) | |
1275 (concat | |
1276 (yahtml-make-optional-argument "border" brd) | |
1277 (yahtml-make-optional-argument "align" alg)))))) | |
57 | 1278 |
70 | 1279 (defun yahtml-file-truename (file) |
1280 (cond | |
1281 ((fboundp 'file-truename) (file-truename (expand-file-name file))) | |
1282 (t (let ((new file)) | |
1283 (while (and (stringp (setq new (nth 0 (file-attributes file)))) | |
1284 (not (equal new file))) | |
1285 (setq file new)) | |
1286 file)))) | |
1287 | |
1288 (defun yahtml-hex-value (point length &optional little-endian) | |
1289 "Return the hex value the POINT positions LENGTH byte stream represents. | |
1290 Optional third argument LITTLE-ENDIAN is self extplanatory." | |
1291 (setq point (1+ point)) ;translate file offset to Emacs's point value | |
1292 (let ((mlt 1) | |
1293 (pos (if little-endian point (+ point length -1))) | |
1294 (direc (if little-endian 1 -1)) | |
1295 (value 0)) | |
1296 (while (> length 0) | |
1297 (setq value (+ value (* mlt (char-after pos))) | |
1298 pos (+ pos direc) | |
1299 mlt (* mlt 256) | |
1300 length (1- length))) | |
1301 value)) | |
1302 | |
1303 (defun yahtml-get-image-info (file) | |
1304 "Return the information on the image file FILE. | |
1305 Returns list of '(WIDTH HEIGHT BYTES DEPTH COMMENTLIST)." | |
1306 (save-excursion | |
1307 (let*((tmpbuf (get-buffer-create " *imgheader*")) | |
1308 width height bytes depth comment | |
1309 (file-coding-system-alist (list (cons "." 'no-conversion))) ;20 | |
1310 (file-coding-system-for-read (and (boundp '*noconv*) *noconv*)) ;19 | |
72 | 1311 (coding-system-for-read 'no-conversion) |
70 | 1312 (seekpoint 1) |
1313 c1 c2 c3 c4 beg end | |
1314 (case-fold-search nil)) | |
1315 (setq bytes (nth 7 (file-attributes (yahtml-file-truename file)))) | |
1316 (set-buffer tmpbuf) | |
1317 (if (boundp 'mc-flag) (set (make-local-variable 'mc-flag) nil)) | |
1318 (erase-buffer) | |
1319 (if (fboundp 'set-buffer-multibyte) (set-buffer-multibyte nil)) | |
1320 (unwind-protect | |
1321 (progn | |
1322 (message "Inspecting image information of %s..." file) | |
1323 ;; Read 4bytes-more than inspection-bytes in case that | |
1324 ;; JPEG marker delimiter (4bytes) is on the alignment. | |
1325 (YaTeX-insert-file-contents | |
1326 file nil 0 (+ yahtml-image-inspection-bytes 4)) | |
1327 (goto-char (point-min)) ;assertion | |
1328 (setq c1 (char-after 1) ;cache first 4 bytes | |
1329 c2 (char-after 2) | |
1330 c3 (char-after 3) | |
1331 c4 (char-after 4)) | |
1332 (cond | |
73 | 1333 ((and (eq c1 ?\377) (eq c2 ?\330)) ; 0xff 0xd8 |
70 | 1334 ;;JPEG images need JPEG markers inspection |
1335 ;;JPEG markers consist of [ 0xff ID(B) LEN(S) CONTENTS... ] | |
1336 ;; Warning: here seekpoint is measured by Emacs's point value | |
1337 ;; while yahtml-hex-vale requires file offset | |
1338 (setq seekpoint 3) ;where the first JPEG marker exists | |
1339 (catch 'exit | |
1340 (while (< seekpoint (- (buffer-size) 4)) | |
1341 (cond | |
73 | 1342 ((not (eq (char-after seekpoint) ?\377)) |
70 | 1343 ;maybe corrupted, exit from loop |
1344 (throw 'exit t)) | |
73 | 1345 ((memq |
1346 (char-after (1+ seekpoint)) | |
1347 '(?\300 ?\301 ?\302 ?\303 | |
1348 ?\305 ?\306 ?\307 ?\311 ?\312 ?\313 ?\315 ?\316 ?\317)) | |
1349 ;;'(192 193 194 195 197 198 199 201 202 203 205 206 207 | |
70 | 1350 ;;found! |
1351 (setq height (yahtml-hex-value (+ seekpoint 4) 2) | |
1352 width (yahtml-hex-value (+ seekpoint 6) 2) | |
1353 depth (yahtml-hex-value (+ seekpoint 3) 1))) | |
73 | 1354 ((eq (char-after (1+ seekpoint)) ?\376) ;0xFE = comment |
70 | 1355 ;; JPEG comment area |
1356 (setq beg (+ seekpoint 2 2) | |
1357 end (+ seekpoint | |
1358 (yahtml-hex-value (1+ seekpoint) 2) 2)) | |
1359 (setq comment (cons (buffer-substring beg end) comment))) | |
1360 (t ;other markers | |
1361 nil)) ;just skip it | |
1362 (setq seekpoint (+ seekpoint 2) | |
1363 seekpoint (+ seekpoint | |
1364 (yahtml-hex-value (1- seekpoint) 2)))))) | |
73 | 1365 ((and (eq c1 ?\211) ;0x89 |
70 | 1366 (eq c2 ?P) (eq c3 ?N) (eq c4 ?G)) |
1367 ;;PNG Image data X=@0x10(L), Y=@0x14(L), D=@0x18(B) | |
1368 (setq width (yahtml-hex-value 16 4) | |
1369 height (yahtml-hex-value 20 4) | |
1370 depth (yahtml-hex-value 24 1))) | |
1371 ((looking-at "GIF8") | |
1372 ;;GIF Image data X=@0x6(leshort), Y=@0x8(leshort) | |
1373 (setq width (yahtml-hex-value 6 2 t) | |
1374 height (yahtml-hex-value 8 2 t))) | |
1375 ((looking-at "BM") | |
1376 ;;# OS/2, Windoze BMP files | |
1377 ;;@0x0e = 12 -> OS/2 1.x - X=@0x12(leshort), Y=@0x14(leshort) | |
1378 ;;@0x0e = 64 -> OS/2 2.x - X=@0x12(leshort), Y=@0x14(leshort) | |
1379 ;;@0x0e = 40 -> Windows 3.x - X=@0x12(lelong), Y=@0x16(lelong) | |
1380 (cond | |
1381 ((eq (yahtml-hex-value 14 2 t) 40) | |
1382 (setq width (yahtml-hex-value 18 4 t) | |
1383 height (yahtml-hex-value 22 4 t))) | |
1384 (t | |
1385 (setq width (yahtml-hex-value 18 2 t) | |
102 | 1386 height (yahtml-hex-value 20 2 t))))))) |
70 | 1387 (message "") |
1388 (kill-buffer tmpbuf)) | |
1389 (list width height bytes depth (nreverse comment))))) | |
1390 | |
57 | 1391 (defun yahtml:form () |
1392 "Add-in function `form' input format" | |
1393 (concat | |
162
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1394 " " (if yahtml-prefer-upcase-attributes "METHOD" "method") "=\"" |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1395 (completing-read "Method: " '(("POST") ("GET")) nil t) |
162
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1396 "\"" |
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1397 (yahtml-make-optional-argument |
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1398 (if yahtml-prefer-upcase-attributes "ENCTYPE" "enctype") |
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1399 (completing-read |
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1400 "Enctype: " |
af550c574ae1
Add `enctype' attribute completion to 'yahtml:form.
yuuji@gentei.org
parents:
161
diff
changeset
|
1401 '(("application/x-www-form-urlencoded") ("multipart/form-data")))) |
69 | 1402 " " (if yahtml-prefer-upcase-attributes "ACTION" "action") "=\"" |
102 | 1403 (read-string "Action: ") "\"")) |
57 | 1404 |
1405 (defun yahtml:select () | |
1406 "Add-in function for `select' input format" | |
1407 (setq yahtml-last-single-cmd "option") | |
69 | 1408 (concat " " (if yahtml-prefer-upcase-attributes "NAME" "name") "=\"" |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1409 (read-string "name: ") "\"")) |
57 | 1410 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1411 (defun yahtml:ol () |
73 | 1412 "Add-in function for <ol>" |
1413 (setq yahtml-last-single-cmd "li") | |
243 | 1414 (let ((start (YaTeX-read-string-or-skip "start=")) |
1415 (type (YaTeX-completing-read-or-skip | |
73 | 1416 "type=" '(("1") ("a") ("A") ("i") ("I")) nil t))) |
1417 (concat | |
1418 (yahtml-make-optional-argument "start" start) | |
1419 (yahtml-make-optional-argument "type" type)))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1420 (defun yahtml:ul () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1421 (setq yahtml-last-single-cmd "li") "") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1422 (defun yahtml:dl () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1423 (setq yahtml-last-single-cmd "dt") "") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1424 (defun yahtml:dt () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1425 (setq yahtml-last-single-cmd "dd") "") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1426 |
61 | 1427 (defun yahtml:p () |
80 | 1428 (if yahtml-html4-strict nil |
1429 (let ((alg (yahtml-read-parameter "align"))) | |
1430 (yahtml-make-optional-argument "align" alg)))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1431 |
57 | 1432 (defvar yahtml-input-types |
1433 '(("text") ("password") ("checkbox") ("radio") ("submit") | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1434 ("reset") ("image") ("hidden") ("file"))) |
57 | 1435 |
1436 (defun yahtml:input () | |
1437 "Add-in function for `input' form" | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1438 (let ((size "") name type value checked (maxlength "") |
69 | 1439 (l yahtml-prefer-upcase-attributes)) |
57 | 1440 (setq name (read-string "name: ") |
243 | 1441 type (YaTeX-completing-read-or-skip "type (default=text): " |
57 | 1442 yahtml-input-types nil t) |
243 | 1443 value (YaTeX-read-string-or-skip "value: ")) |
57 | 1444 (if (string-match "text\\|password\\|^$" type) |
243 | 1445 (setq size (YaTeX-read-string-or-skip "size: ") |
1446 maxlength (YaTeX-read-string-or-skip "maxlength: "))) | |
57 | 1447 (concat |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1448 (if l "NAME" "name") "=\"" name "\"" |
64 | 1449 (yahtml-make-optional-argument "type" type) |
1450 (yahtml-make-optional-argument "value" value) | |
1451 (yahtml-make-optional-argument "size" size) | |
102 | 1452 (yahtml-make-optional-argument "maxlength" maxlength)))) |
59 | 1453 |
1454 (defun yahtml:textarea () | |
1455 "Add-in function for `textarea'" | |
1456 (interactive) | |
1457 (let (name rows cols) | |
1458 (setq name (read-string "Name: ") | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1459 cols (read-string "Columns: ") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1460 rows (read-string "Rows: ")) |
59 | 1461 (concat |
69 | 1462 (concat (if yahtml-prefer-upcase-attributes "NAME=" "name=") |
59 | 1463 "\"" name "\"") |
64 | 1464 (yahtml-make-optional-argument "cols" cols) |
1465 (yahtml-make-optional-argument "rows" rows)))) | |
59 | 1466 |
64 | 1467 (defun yahtml:table () |
1468 "Add-in function for `table'" | |
69 | 1469 (let ((b (read-string "border=")) |
80 | 1470 (a (yahtml-read-parameter |
1471 "align" nil '(("align" ("right")("center")))))) | |
1472 (if yahtml-html4-strict | |
1473 (yahtml-make-optional-argument | |
1474 "style" | |
1475 (if (or (string< "" b) (string< "" a)) | |
1476 (yahtml-make-style-parameter | |
1477 (append | |
1478 (if (string< "" b) | |
1479 (list | |
1480 (cons "border" (format "%dpx solid" (string-to-int b))) | |
1481 (cons "border-collapse" "collapse"))) | |
1482 (if (string< "" a) | |
1483 (cond | |
1484 ((string-match "right" a) | |
1485 (list (cons "margin-left" "auto") | |
1486 (cons "margin-right" "0"))) | |
1487 ((string-match "center" a) | |
1488 (list (cons "margin-left" "auto") | |
1489 (cons "margin-right" "auto"))))))))) | |
1490 (concat | |
1491 (yahtml-make-optional-argument "border" b) | |
1492 (yahtml-make-optional-argument "align" a))))) | |
1493 | |
69 | 1494 ;(fset 'yahtml:caption 'yahtml:p) |
1495 (defun yahtml:caption () | |
1496 "Add-in function for `caption' in table tag" | |
80 | 1497 (let ((par (yahtml-read-parameter "align"))) |
1498 (if yahtml-html4-strict | |
1499 (yahtml-make-optional-argument | |
1500 "style" (if par (yahtml-make-style-parameter | |
1501 (list (cons "caption-side" par))))) | |
1502 (yahtml-make-optional-argument "align" par)))) | |
64 | 1503 |
1504 (defun yahtml:font () | |
1505 "Add-in function for `font'" | |
68 | 1506 (concat |
1507 (yahtml-make-optional-argument "color" (read-string "color=")) | |
1508 (yahtml-make-optional-argument "size" (read-string "size=")))) | |
59 | 1509 |
69 | 1510 (defun yahtml:style () |
1511 "Add-in function for `style'" | |
1512 (yahtml-make-optional-argument | |
1513 "type" (read-string "type=" "text/css"))) | |
1514 | |
80 | 1515 (defun yahtml:script () |
1516 "Add-in function for `script'" | |
1517 (concat | |
1518 (yahtml-make-optional-argument | |
1519 "type" (yahtml-read-parameter "type" "text/javascript")) | |
1520 (yahtml-make-optional-argument | |
1521 "src" (yahtml-read-parameter "src" "")))) | |
1522 | |
69 | 1523 (defun yahtml:tr () |
1524 "Add-in function for `tr'" | |
1525 (setq ;yahtml-last-begend "td" ;; which do you prefer? | |
1526 yahtml-last-typeface-cmd "td") | |
1527 "") | |
1528 | |
1529 (defun yahtml:link () | |
1530 "Add-in function for `link' (まだちょっと良く分かってない)" | |
1531 (let (rel rev type href) | |
1532 (setq rel (yahtml-read-parameter "rel")) | |
1533 (cond | |
1534 ((equal rel "") | |
1535 (concat (yahtml-make-optional-argument | |
1536 "rev" (yahtml-read-parameter "rev")) | |
1537 (yahtml-make-optional-argument | |
1538 "href" (yahtml-read-parameter "href") | |
1539 ;;他に良く使うのって何? | |
1540 ))) | |
1541 ((string-match "stylesheet" rel) | |
1542 (concat | |
1543 (yahtml-make-optional-argument "rel" rel) | |
1544 (yahtml-make-optional-argument | |
1545 "type" (yahtml-read-parameter "type" "text/css")) | |
1546 (progn | |
1547 (setq href | |
1548 (read-from-minibuffer "href: " "" yahtml-url-completion-map)) | |
1549 (if (string< "" href) | |
1550 (progn | |
1551 (if (and (file-exists-p (yahtml-url-to-path href)) | |
1552 (y-or-n-p "Load css symbols now? ")) | |
1553 (setq yahtml-css-class-alist | |
1554 (yahtml-css-collect-classes-file | |
1555 (yahtml-url-to-path href) yahtml-css-class-alist))) | |
1556 (message "") | |
1557 (yahtml-make-optional-argument "href" href)))))) | |
80 | 1558 (t |
1559 (concat | |
1560 (yahtml-make-optional-argument "rel" rel) | |
1561 (yahtml-make-optional-argument | |
1562 "type" (yahtml-read-parameter "type" "text/css")) | |
1563 (yahtml-make-optional-argument | |
102 | 1564 "href" |
1565 (read-from-minibuffer "href: " "" yahtml-url-completion-map))))))) | |
69 | 1566 |
73 | 1567 (defvar yahtml:meta-names |
1568 '(("name" ("keywords")("author")("copyright")("date")("GENERATOR")))) | |
1569 | |
1570 (defun yahtml:meta () | |
1571 (let ((name (yahtml-make-optional-argument | |
1572 "name" | |
1573 (yahtml-read-parameter "name" nil yahtml:meta-names))) | |
1574 http-equiv content) | |
1575 (if (string= "" name) | |
1576 (if (string-match | |
1577 "Content-type" | |
1578 (setq http-equiv (yahtml-make-optional-argument | |
1579 "http-equiv" | |
1580 (yahtml-read-parameter "http-equiv" nil)))) | |
1581 (error "It's very bad idea to set Content-type in META. %s" | |
1582 "See docs/qanda") | |
1583 (concat http-equiv | |
1584 (yahtml-make-optional-argument | |
1585 "content" (yahtml-read-parameter "content")))) | |
1586 (concat | |
1587 name | |
1588 (yahtml-make-optional-argument | |
1589 "content" | |
1590 (cond | |
1591 ((string-match "date" name) | |
1592 (read-string "Date: " (current-time-string))) | |
1593 ((string-match "author" name) | |
1594 (read-string "Author: " | |
1595 (if (and (user-full-name) (string< "" (user-full-name))) | |
1596 (user-full-name) | |
1597 (user-login-name)))) | |
1598 ((string-match "GENERATOR" name) | |
1599 (setq content (read-string "Generator: " "User-agent: ")) | |
1600 (if (string-match "yahtml" content) | |
1601 (message "Thank you!")) | |
1602 content) | |
1603 (t (read-string (concat name ": "))))))))) | |
1604 | |
70 | 1605 (defun yahtml:br () |
1606 (yahtml-make-optional-argument "clear" (yahtml-read-parameter "clear"))) | |
1607 | |
1608 (defun yahtml:object () | |
1609 (let ((codetype (yahtml-read-parameter "codetype" "application/java")) | |
1610 data classid) | |
1611 (cond | |
1612 ((string-match "java" codetype) | |
1613 (let ((completion-ignored-extensions | |
1614 ;;any extensions except ".class" | |
1615 '(".java" ".html" ".htm" ".gif" ".jpg" ".jpeg" ".png"))) | |
1616 (setq classid (concat "java:" | |
1617 (yahtml-read-parameter "class file name")))) | |
1618 (concat | |
1619 (yahtml-make-optional-argument "codetype" codetype) | |
1620 (yahtml-make-optional-argument "classid" classid) | |
1621 (yahtml-make-optional-argument | |
1622 "width" (yahtml-read-parameter "width")) | |
1623 (yahtml-make-optional-argument | |
1624 "height" (yahtml-read-parameter "height")) | |
1625 (yahtml-make-optional-argument | |
102 | 1626 "align" (yahtml-read-parameter "align")))) |
70 | 1627 (t |
102 | 1628 "")))) |
70 | 1629 |
80 | 1630 (defun yahtml:abbr () |
1631 "Add-in function for abbr." | |
1632 (yahtml-make-optional-argument "title" (yahtml-read-parameter "title"))) | |
1633 | |
136 | 1634 (defun yahtml:button () |
1635 (concat | |
1636 (yahtml-make-optional-argument | |
1637 "name" (yahtml-read-parameter "name")) | |
1638 (yahtml-make-optional-argument | |
1639 "type" (yahtml-read-parameter | |
137 | 1640 "type" "button" '(("submit")("reset")("button")))) |
1641 (yahtml-make-optional-argument | |
1642 "value" (yahtml-read-parameter "value")))) | |
136 | 1643 |
59 | 1644 ;;; ---------- Simple tag ---------- |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1645 (defun yahtml-insert-tag (region-mode &optional tag) |
54 | 1646 "Insert <TAG> </TAG> and put cursor inside of them." |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1647 (interactive "P") |
70 | 1648 (setq yahtml-current-completion-type 'inline) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1649 (or tag |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1650 (let ((completion-ignore-case t)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1651 (setq tag |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1652 (YaTeX-cplread-with-learning |
64 | 1653 (format "Tag %s(default %s): " |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1654 (if region-mode "region: " "") yahtml-last-typeface-cmd) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1655 'yahtml-typeface-table 'yahtml-user-typeface-table |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1656 'yahtml-tmp-typeface-table)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1657 (if (string= "" tag) (setq tag yahtml-last-typeface-cmd)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1658 (setq tag (or (cdr (assoc tag yahtml-typeface-table)) tag)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1659 (setq yahtml-last-typeface-cmd tag |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1660 tag (funcall (if yahtml-prefer-upcases 'upcase 'downcase) tag)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1661 (if region-mode |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1662 (if (if (string< "19" emacs-version) (mark t) (mark)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1663 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1664 (if (> (point) (mark)) (exchange-point-and-mark)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1665 (insert (format "<%s%s>" tag (yahtml-addin tag))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1666 (exchange-point-and-mark) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1667 (insert "</" tag ">")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1668 (message "No mark set now")) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1669 (insert (format "<%s%s>" tag (yahtml-addin tag))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1670 (save-excursion (insert (format "</%s>" tag))))) |
54 | 1671 |
61 | 1672 (defun yahtml-insert-tag-region (&optional tag) |
1673 "Call yahtml-insert-tag with region mode." | |
1674 (interactive) | |
1675 (yahtml-insert-tag t tag)) | |
1676 | |
80 | 1677 (defvar yahtml-need-single-closer nil) ;for test |
57 | 1678 (defun yahtml-insert-single (cmd) |
1679 "Insert <CMD>." | |
1680 (interactive | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1681 (list |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1682 (let ((completion-ignore-case t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1683 (YaTeX-cplread-with-learning |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1684 (format "Command%s: " |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1685 (if yahtml-last-single-cmd |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1686 (concat "(default " yahtml-last-single-cmd ")") "")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1687 'yahtml-single-cmd-table 'yahtml-user-single-cmd-table |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1688 'yahtml-tmp-single-cmd-table)))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1689 (if (string= "" cmd) (setq cmd yahtml-last-single-cmd)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1690 (setq yahtml-last-single-cmd |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1691 (or (cdr (assoc cmd yahtml-single-cmd-table)) cmd)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1692 (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1693 yahtml-last-single-cmd)) |
80 | 1694 (insert (format "<%s%s%s>" |
1695 cmd | |
1696 (yahtml-addin cmd) | |
1697 (if (and yahtml-need-single-closer | |
1698 (assoc cmd '(("br")("hr")))) | |
1699 " /" ""))) | |
1700 (if (assoc cmd yahtml-env-table) | |
1701 (save-excursion (insert (format "</%s>" cmd))))) | |
57 | 1702 |
64 | 1703 (defun yahtml-insert-p (&optional arg) |
1704 "Convenient function to insert <p></p>" | |
1705 (interactive "P") | |
80 | 1706 (if (or yahtml-always-/p arg) (yahtml-insert-tag arg "p") |
68 | 1707 (yahtml-insert-single "p"))) |
64 | 1708 |
70 | 1709 (defun yahtml-insert-amps (arg) |
1710 "Insert char-entity references via ampersand" | |
1711 ;; Thanks; http://www.tsc.co.jp/~asada/html/wdg40_f/entities/ | |
1712 (interactive "P") | |
1713 (let*((mess "") c | |
1714 (list (append yahtml-entity-reference-chars-alist-default | |
1715 yahtml-entity-reference-chars-alist)) | |
1716 (l list)) | |
1717 (while l | |
1718 (setq mess (format "%s %c" mess (car (car l)) (cdr (car l))) | |
1719 l (cdr l))) | |
319
afe97f605d96
yahtml-insert-amps: `& BackSpace' translate preceding char to entity reference.
HIROSE Yuuji <yuuji@gentei.org>
parents:
315
diff
changeset
|
1720 (message "Char-entity reference: %s SPC=& RET=&; BS=%s Other=&#..;" |
afe97f605d96
yahtml-insert-amps: `& BackSpace' translate preceding char to entity reference.
HIROSE Yuuji <yuuji@gentei.org>
parents:
315
diff
changeset
|
1721 mess (if YaTeX-japan "直前の文字" "Preceding-Char")) |
70 | 1722 (setq c (read-char)) |
1723 (cond | |
1724 ((equal c (car-safe (assoc c list))) | |
1725 (insert (format "&%s;" (cdr (assoc c list))))) | |
1726 ((or (equal c ?\n) (equal c ?\r)) | |
1727 (insert "&;") | |
1728 (forward-char -1)) | |
1729 ((equal c ? ) | |
1730 (insert ?&)) | |
319
afe97f605d96
yahtml-insert-amps: `& BackSpace' translate preceding char to entity reference.
HIROSE Yuuji <yuuji@gentei.org>
parents:
315
diff
changeset
|
1731 ((and (memq c '(127 8)) |
afe97f605d96
yahtml-insert-amps: `& BackSpace' translate preceding char to entity reference.
HIROSE Yuuji <yuuji@gentei.org>
parents:
315
diff
changeset
|
1732 (setq c (preceding-char)) |
afe97f605d96
yahtml-insert-amps: `& BackSpace' translate preceding char to entity reference.
HIROSE Yuuji <yuuji@gentei.org>
parents:
315
diff
changeset
|
1733 (delete-backward-char 1) |
afe97f605d96
yahtml-insert-amps: `& BackSpace' translate preceding char to entity reference.
HIROSE Yuuji <yuuji@gentei.org>
parents:
315
diff
changeset
|
1734 nil)) ;Fall through to the next 't block |
320 | 1735 (t (insert (format "&#x%x;" c)))))) |
70 | 1736 |
80 | 1737 (defun yahtml:!--\#include () |
1738 (let ((file (yahtml-read-parameter "file" ""))) | |
1739 (format "%s=\"%s\"--" (if (string-match "/" file) "virtual" "file") file))) | |
1740 | |
1741 (defun yahtml:!--\#exec () | |
147 | 1742 (format "cmd=\"%s\"--" |
1743 (yahtml-read-parameter "cmd" "" '(("cmd" . command))))) | |
80 | 1744 |
57 | 1745 ;;; ---------- Jump ---------- |
1746 (defun yahtml-on-href-p () | |
1747 "Check if point is on href clause." | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1748 (let ((p (point)) e cmd (case-fold-search t)) |
57 | 1749 (save-excursion |
69 | 1750 (and ;;(string= (YaTeX-inner-environment t) "a") ;aでなくても許可にした |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1751 (save-excursion |
69 | 1752 ;;(search-forward "</a>" nil t) ;aでなくても許可にした |
1753 (search-forward "[\" \t\n]" nil t) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1754 (setq e (point))) |
69 | 1755 ;(goto-char (get 'YaTeX-inner-environment 'point)) |
1756 (re-search-backward "<\\(a\\|link\\)\\>" nil t) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1757 (search-forward "href" e t) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1758 (search-forward "=" e t) |
64 | 1759 (progn |
1760 (skip-chars-forward " \t\n") | |
1761 (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) | |
57 | 1762 (< p (match-end 0)) |
153
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1763 (yahtml-unescape-string (YaTeX-match-string 1)))))) |
57 | 1764 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1765 (defun yahtml-netscape-sentinel (proc mes) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1766 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1767 ((null (buffer-name (process-buffer proc))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1768 (set-process-buffer proc nil)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1769 ((eq (process-status proc) 'exit) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1770 (let ((cb (current-buffer))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1771 (set-buffer (process-buffer proc)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1772 (goto-char (point-min)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1773 (if (search-forward "not running" nil t) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1774 (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1775 (message "Starting netscape...") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1776 (start-process |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1777 "browser" (process-buffer proc) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1778 shell-file-name yahtml-shell-command-option |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1779 (format "%s \"%s\"" yahtml-www-browser |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1780 (get 'yahtml-netscape-sentinel 'url))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1781 (message "Starting netscape...Done"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1782 (set-buffer cb))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1783 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1784 (defvar yahtml-browser-process nil) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1785 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1786 (defun yahtml-browse-html (href) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1787 "Call WWW Browser to see HREF." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1788 (let ((pb "* WWW Browser *") (cb (current-buffer))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1789 (cond |
64 | 1790 ((string-match "^start\\>" yahtml-www-browser) |
1791 (if (get-buffer pb) | |
1792 (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) | |
1793 (put 'yahtml-netscape-sentinel 'url href) | |
1794 (set-process-sentinel | |
1795 (setq yahtml-browser-process | |
1796 (start-process | |
1797 "browser" pb shell-file-name yahtml-shell-command-option | |
1798 (format "%s \"%s\"" yahtml-www-browser href))) | |
1799 'yahtml-netscape-sentinel)) | |
86 | 1800 ((and (string-match |
1801 "[Nn]etscape\\|[Ff]irefox\\|[Mm]ozilla" yahtml-www-browser) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1802 (not (eq system-type 'windows-nt))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1803 (if (get-buffer pb) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1804 (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1805 (put 'yahtml-netscape-sentinel 'url href) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1806 (set-process-sentinel |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1807 (setq yahtml-browser-process |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1808 (start-process |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1809 "browser" pb shell-file-name yahtml-shell-command-option ;"-c" |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1810 (format "%s -remote \"openURL(%s)\"" yahtml-www-browser href))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1811 'yahtml-netscape-sentinel)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1812 ((and (string= "w3" yahtml-www-browser) (fboundp 'w3-fetch)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1813 (w3-fetch href)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1814 ((stringp yahtml-www-browser) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1815 (if (and yahtml-browser-process |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1816 (eq (process-status yahtml-browser-process) 'run)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1817 (message "%s is already running" yahtml-www-browser) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1818 (setq yahtml-browser-process |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1819 (start-process |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1820 "browser" "* WWW Browser *" |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1821 shell-file-name yahtml-shell-command-option |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1822 (format "%s \"%s\"" yahtml-www-browser href))))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1823 (t |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1824 (message "Sorry, jump across http is not supported."))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1825 |
57 | 1826 (defun yahtml-goto-corresponding-href (&optional other) |
1827 "Go to corresponding name." | |
64 | 1828 (let ((href (yahtml-on-href-p)) file name (parent buffer-file-name)) |
57 | 1829 (if href |
1830 (cond | |
80 | 1831 ((string-match "^\\(ht\\|f\\)tps?:" href) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1832 (yahtml-browse-html href)) |
57 | 1833 (t (setq file (substring href 0 (string-match "#" href))) |
1834 (if (string-match "#" href) | |
1835 (setq name (substring href (1+ (string-match "#" href))))) | |
1836 (if (string< "" file) | |
1837 (progn | |
1838 (if (string-match "/$" file) | |
70 | 1839 (or (catch 'dirindex |
1840 (mapcar | |
72 | 1841 (function |
1842 (lambda (f) | |
1843 (if (file-exists-p (concat file f)) | |
1844 (throw 'dirindex | |
1845 (setq file (concat file f)))))) | |
73 | 1846 (yahtml-get-directory-index)) |
1847 nil) | |
70 | 1848 (setq file (concat file yahtml-directory-index)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1849 (if (string-match "^/" file) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1850 (setq file (yahtml-url-to-path file))) |
57 | 1851 (if other (YaTeX-switch-to-buffer-other-window file) |
64 | 1852 (YaTeX-switch-to-buffer file)) |
1853 (or YaTeX-parent-file (setq YaTeX-parent-file parent)))) | |
57 | 1854 (if name |
1855 (progn (set-mark-command nil) (yahtml-jump-to-name name))) | |
1856 t))))) | |
1857 | |
1858 (defun yahtml-jump-to-name (name) | |
1859 "Jump to html's named tag." | |
69 | 1860 (setq name (format "\\(name\\|id\\)\\s *=\\s *\"?%s\\>\"?" name)) |
57 | 1861 (or (and (re-search-forward name nil t) (goto-char (match-beginning 0))) |
1862 (and (re-search-backward name nil t) (goto-char (match-beginning 0))) | |
1863 (message "Named tag `%s' not found" (substring href 1)))) | |
1864 | |
1865 (defun yahtml-on-begend-p (&optional p) | |
1866 "Check if point is on begend clause." | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1867 (let ((p (or p (point))) cmd (case-fold-search t)) |
57 | 1868 (save-excursion |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
1869 (goto-char p) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1870 (if (equal (char-after (point)) ?<) (forward-char 1)) |
57 | 1871 (if (and (re-search-backward "<" nil t) |
1872 (looking-at | |
70 | 1873 ;(concat "<\\(/?" yahtml-struct-name-regexp "\\)\\b") |
102 | 1874 "<\\(/?[A-Z][A-Z0-9]*\\)\\b") |
57 | 1875 (condition-case nil |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1876 (forward-list 1) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1877 (error nil)) |
57 | 1878 (< p (point))) |
1879 (YaTeX-match-string 1))))) | |
1880 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1881 (defun yahtml-goto-corresponding-begend (&optional noerr) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1882 "Go to corresponding opening/closing tag. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1883 Optional argument NOERR causes no error for unballanced tag." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1884 (let ((cmd (yahtml-on-begend-p)) m0 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1885 (p (point)) (case-fold-search t) func str (nest 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1886 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1887 (cmd |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1888 (setq m0 (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1889 (if (= (aref cmd 0) ?/) ;on </cmd> line |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1890 (setq cmd (substring cmd 1) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1891 str (format "\\(<%s\\)\\|\\(</%s\\)" cmd cmd) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1892 func 're-search-backward) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1893 (setq str (format "\\(</%s\\)\\|\\(<%s\\)" cmd cmd) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1894 func 're-search-forward)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1895 (while (and (>= nest 0) (funcall func str nil t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1896 (if (equal m0 (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1897 nil |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1898 (setq nest (+ nest (if (match-beginning 1) -1 1))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1899 (if (< nest 0) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1900 (goto-char (match-beginning 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1901 (funcall |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1902 (if noerr 'message 'error) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1903 "Corresponding tag of `%s' not found." cmd) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1904 (goto-char p) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1905 nil)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1906 (t nil)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1907 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1908 (defun yahtml-current-tag () |
80 | 1909 "Return the current tag name including #exec and #include." |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1910 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1911 (let ((p (point)) b tag) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1912 (or (bobp) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1913 (looking-at "<") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1914 (progn (skip-chars-backward "^<") (forward-char -1))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1915 (setq b (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1916 (skip-chars-forward "<") |
80 | 1917 (setq tag (YaTeX-buffer-substring |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1918 (point) (progn (skip-chars-forward "^ \t\n") (point)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1919 (goto-char b) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1920 (forward-list 1) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1921 (and (< p (point)) tag)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
1922 |
68 | 1923 (defun yahtml-get-attrvalue (attr) |
1924 "Extract current tag's attribute value from buffer." | |
1925 (let (e (case-fold-search t)) | |
1926 (save-excursion | |
1927 (or (looking-at "<") | |
1928 (progn (skip-chars-backward "^<") (backward-char 1))) | |
1929 (setq e (save-excursion (forward-list 1) (point))) | |
1930 (if (and | |
1931 (re-search-forward (concat "\\b" attr "\\b") e t) | |
1932 (progn (skip-chars-forward " \t\n=") | |
1933 (looking-at "\"?\\([^\"> \t\n]+\\)\"?"))) | |
1934 (YaTeX-match-string 1))))) | |
1935 | |
80 | 1936 (defun yahtml-goto-corresponding-img () |
1937 "View image on point" | |
1938 (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t)) | |
1939 (if (and tag | |
1940 (string-match "img" tag) | |
153
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1941 (setq image |
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1942 (yahtml-unescape-string (yahtml-get-attrvalue "src")))) |
80 | 1943 (progn |
1944 (message "Invoking %s %s..." yahtml-image-viewer image) | |
1945 (start-process | |
1946 "Viewer" " * Image Viewer *" | |
1947 shell-file-name yahtml-shell-command-option ;"-c" | |
1948 (concat yahtml-image-viewer " " image)) | |
1949 (message "Invoking %s %s...Done" yahtml-image-viewer image))))) | |
1950 | |
68 | 1951 (defun yahtml-goto-corresponding-source (&optional other) |
80 | 1952 "Goto applet's or script's source." |
68 | 1953 (let ((env (yahtml-current-tag)) s (p (point))) |
1954 (cond | |
1955 ((string-match "applet" env) | |
153
207f0b4af9df
Unescape URL strings from buffer(yahtml-unescape-string).
yuuji@gentei.org
parents:
147
diff
changeset
|
1956 (if (setq s (yahtml-unescape-string (yahtml-get-attrvalue "code"))) |
68 | 1957 (progn |
1958 (setq s (YaTeX-match-string 1) | |
1959 s (concat | |
1960 (substring s 0 (string-match "\\.[A-Za-z]+$" s)) | |
1961 ".java")) | |
1962 (if other (YaTeX-switch-to-buffer-other-window s) | |
1963 (YaTeX-switch-to-buffer s)) | |
1964 s) ;return source file name | |
1965 (message "No applet source specified") | |
1966 (sit-for 1) | |
1967 nil)) | |
80 | 1968 ((string-match "script" env) |
1969 (if (setq s (yahtml-get-attrvalue "src")) | |
1970 (progn | |
1971 (funcall (if other 'YaTeX-switch-to-buffer-other-window | |
1972 'YaTeX-switch-to-buffer) | |
1973 (yahtml-url-to-path s)) | |
1974 s))) | |
68 | 1975 ((string-match "!--#include" env) |
1976 (cond | |
1977 ((setq s (yahtml-get-attrvalue "file")) ;<!--#include file="foo"--> | |
1978 (if other (YaTeX-switch-to-buffer-other-window s) | |
1979 (YaTeX-switch-to-buffer s)) | |
1980 s) | |
1981 ((setq s (yahtml-get-attrvalue "virtual"));<!--#include virtual="foo"--> | |
1982 (setq s (yahtml-url-to-path s)) | |
1983 (if other (YaTeX-switch-to-buffer-other-window s) | |
1984 (YaTeX-switch-to-buffer s)) | |
1985 s))) | |
1986 ((and (string-match "!--#exec" env) | |
1987 (setq s (yahtml-get-attrvalue "cmd"))) | |
1988 (setq s (substring s 0 (string-match " \t\\?" s))) ;get argv0 | |
1989 (let ((b " *yahtmltmp*")) ;peek a little | |
1990 (unwind-protect | |
1991 (progn | |
1992 (set-buffer (get-buffer-create b)) | |
70 | 1993 (YaTeX-insert-file-contents s nil 0 100) |
68 | 1994 (if (looking-at "#!") |
1995 (if other (YaTeX-switch-to-buffer-other-window s) | |
1996 (YaTeX-switch-to-buffer s)))) | |
1997 (kill-buffer (get-buffer b))) | |
1998 (get-file-buffer s)))))) | |
1999 | |
57 | 2000 (defun yahtml-goto-corresponding-* (&optional other) |
2001 "Go to corresponding object." | |
80 | 2002 (interactive "P") |
57 | 2003 (cond |
2004 ((yahtml-goto-corresponding-href other)) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2005 ((yahtml-goto-corresponding-img)) |
80 | 2006 ((yahtml-goto-corresponding-source other)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2007 ((yahtml-goto-corresponding-begend)) |
102 | 2008 (t (message "I don't know where to go.")))) |
57 | 2009 |
2010 (defun yahtml-goto-corresponding-*-other-window () | |
2011 "Go to corresponding object." | |
2012 (interactive) | |
2013 (yahtml-goto-corresponding-* t)) | |
2014 | |
64 | 2015 (defun yahtml-visit-main () |
2016 "Go to parent file from where you visit current file." | |
2017 (interactive) | |
2018 (if YaTeX-parent-file (YaTeX-switch-to-buffer YaTeX-parent-file))) | |
2019 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2020 ;;; ---------- killing ---------- |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2021 (defun yahtml-kill-begend (&optional whole) |
68 | 2022 (let ((tag (yahtml-on-begend-p)) p q r bbolp) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2023 (if tag |
64 | 2024 (save-excursion |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2025 (or (looking-at "<") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2026 (progn (skip-chars-backward "^<") (forward-char -1))) |
64 | 2027 (setq p (point)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2028 (yahtml-goto-corresponding-begend) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2029 (or (looking-at "<") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2030 (progn (skip-chars-backward "^<") (forward-char -1))) |
64 | 2031 (if (< (point) p) ;if on the opening tag |
2032 (progn (setq q p p (point)) | |
2033 (goto-char q)) | |
2034 (setq q (point))) ;now q has end-line's (point) | |
2035 (if (not whole) | |
2036 (kill-region | |
68 | 2037 (progn (skip-chars-backward " \t") |
2038 (if (setq bbolp (bolp)) (point) q)) | |
64 | 2039 (progn (forward-list 1) |
2040 (setq r (point)) | |
2041 (skip-chars-forward " \t") | |
68 | 2042 (if (and bbolp (eolp) (not (eobp))) (1+ (point)) r)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2043 (goto-char p) |
64 | 2044 (skip-chars-backward " \t") |
2045 (if (not whole) | |
2046 (progn | |
2047 (kill-append | |
2048 (buffer-substring | |
68 | 2049 (setq p (if (setq bbolp (bolp)) (point) p)) |
64 | 2050 (setq q (progn |
2051 (forward-list 1) | |
2052 (setq r (point)) | |
2053 (skip-chars-forward " \t") | |
68 | 2054 (if (and bbolp (eolp) (not (eobp))) |
2055 (1+ (point)) | |
2056 r)))) | |
64 | 2057 t) |
2058 (delete-region p q)) | |
2059 (kill-region | |
2060 (if (bolp) (point) p) | |
2061 (progn (goto-char q) | |
2062 (forward-list 1) | |
2063 (setq r (point)) | |
2064 (skip-chars-forward " \t") | |
2065 (if (and (eolp) (not (eobp))) (1+ (point)) r)))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2066 tag)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2067 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2068 (defun yahtml-kill-* (whole) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2069 "Kill current position's HTML tag (set)." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2070 (interactive "P") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2071 (cond |
102 | 2072 ((yahtml-kill-begend whole)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2073 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2074 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2075 ;;; ---------- changing ---------- |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2076 (defun yahtml-on-assignment-p () |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2077 "Return if current point is on parameter assignment. |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2078 If so, return parameter name, otherwise nil. |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2079 This function should be able to treat white spaces in value, but not yet." |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2080 (let ((p (point))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2081 (save-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2082 (put 'yahtml-on-assignment-p 'region nil) |
70 | 2083 (skip-chars-backward "^ \t\n") |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2084 (and (looking-at "\\([A-Za-z0-9]+\\)\\s *=\\s *\"?\\([^ \t\"]+\\)\"?") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2085 (< p (match-end 0)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2086 (>= p (1- (match-beginning 2))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2087 (put 'yahtml-on-assignment-p 'region |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2088 (cons (match-beginning 2) (match-end 2))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2089 (YaTeX-match-string 1))))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2090 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2091 (defun yahtml-change-begend () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2092 (let ((tag (yahtml-on-begend-p)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2093 (completion-ignore-case t) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2094 (case-fold-search t) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2095 (p (point)) (q (make-marker)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2096 (default (append yahtml-env-table yahtml-typeface-table)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2097 (user (append yahtml-user-env-table yahtml-user-typeface-table)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2098 (tmp (append yahtml-tmp-env-table yahtml-tmp-typeface-table)) |
69 | 2099 href b1 e1 attr new css) |
59 | 2100 (cond |
2101 (tag | |
2102 (cond | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2103 ((and (string-match "^a$" tag) |
59 | 2104 (save-excursion |
2105 (and | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2106 (re-search-backward "<a\\b" nil t) |
64 | 2107 (progn |
2108 (goto-char (match-end 0)) | |
2109 (skip-chars-forward " \t\n") | |
2110 (setq b1 (point)) | |
2111 (search-forward ">" nil t)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2112 (setq e1 (match-beginning 0)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2113 (goto-char b1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2114 (re-search-forward "href\\s *=" e1 t) |
59 | 2115 (>= p (point)) |
64 | 2116 (progn |
2117 (goto-char (match-end 0)) | |
2118 (skip-chars-forward " \t\n") | |
2119 (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) | |
59 | 2120 (< p (match-end 0))))) |
2121 (setq b1 (match-beginning 1) e1 (match-end 1) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2122 yahtml-completing-buffer (current-buffer) |
64 | 2123 ;; yahtml-urls-local is buffer-local, so we must put |
2124 ;; that into yahtml-urls here | |
2125 yahtml-urls (append yahtml-urls-private yahtml-urls-local) | |
59 | 2126 href (read-from-minibuffer |
2127 "Change href to: " "" yahtml-url-completion-map)) | |
2128 (if (string< "" href) | |
2129 (progn | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2130 ;;(setq href ;?? |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2131 ;; (if yahtml-prefer-upcases (upcase href) (downcase href))) |
59 | 2132 (delete-region b1 e1) |
2133 (goto-char b1) | |
2134 (insert href)))) | |
69 | 2135 ((setq attr (yahtml-on-assignment-p)) ;if on the assignment to attr |
2136 (if (and (equal attr "class") ;treat "class" attribute specially | |
70 | 2137 (setq css (yahtml-css-get-element-completion-alist tag))) |
80 | 2138 |
2139 (setq new (yahtml-read-css css)) | |
69 | 2140 ;;other than "class", read parameter normally |
2141 (setq new (yahtml-read-parameter attr))) | |
2142 (goto-char (car (get 'yahtml-on-assignment-p 'region))) | |
2143 (delete-region (point) (cdr (get 'yahtml-on-assignment-p 'region))) | |
2144 (insert new)) | |
59 | 2145 (t |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2146 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2147 (if (= (aref tag 0) ?/) (setq tag (substring tag 1))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2148 (or (= (char-after (point)) ?<) (skip-chars-backward "^<")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2149 (skip-chars-forward "^A-Za-z") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2150 (set-marker q (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2151 (setq p (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2152 (yahtml-goto-corresponding-begend) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2153 (or (= (char-after (point)) ?<) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2154 (skip-chars-backward "^<")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2155 (skip-chars-forward "^A-Za-z") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2156 (if (= (char-after (1- (point))) ?/) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2157 (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2158 (set-marker q (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2159 (goto-char p))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2160 (setq tag (let ((completion-ignore-case t)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2161 (YaTeX-cplread-with-learning |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2162 (format "Change `%s' to(default %s): " |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2163 tag yahtml-last-begend) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2164 'default 'user 'tmp))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2165 (delete-region (point) (progn (skip-chars-forward "^>") (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2166 (if (string= "" tag) (setq tag yahtml-last-begend)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2167 (setq yahtml-last-begend |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2168 (or (cdr (assoc tag yahtml-env-table)) tag) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2169 tag yahtml-last-begend) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2170 (setq tag (if yahtml-prefer-upcases (upcase tag) (downcase tag))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2171 (insert (format "%s%s" tag (yahtml-addin tag))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2172 (goto-char q) |
68 | 2173 (set-marker q nil) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2174 (delete-region (point) (progn (skip-chars-forward "^>") (point))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2175 (insert tag)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2176 t)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2177 |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2178 (defun yahtml-change-command () |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2179 (let ((p (point)) (case-fold-search t) cmd par new |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2180 (beg (make-marker)) (end (make-marker))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2181 (skip-chars-backward "^<") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2182 (if (and |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2183 (looking-at yahtml-command-regexp) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2184 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2185 (set-marker beg (match-beginning 0)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2186 (set-marker end (match-end 0)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2187 t) ;for further work |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2188 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2189 (forward-char -1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2190 (condition-case nil |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2191 (forward-list 1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2192 (error nil)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2193 (< p (point)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2194 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2195 (goto-char p) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2196 (if (setq par (yahtml-on-assignment-p)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2197 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2198 (setq new (yahtml-read-parameter par)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2199 (set-marker beg (car (get 'yahtml-on-assignment-p 'region))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2200 (set-marker end (cdr (get 'yahtml-on-assignment-p 'region)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2201 (setq new |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2202 (YaTeX-cplread-with-learning |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2203 "Change form to: " |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2204 'yahtml-form-table 'yahtml-user-form-table |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2205 'yahtml-tmp-form-table))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2206 (delete-region beg end) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2207 (goto-char beg) |
68 | 2208 (set-marker beg nil) |
2209 (set-marker end nil) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2210 (insert new) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2211 t) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2212 (goto-char p) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2213 nil))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2214 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2215 (defun yahtml-change-* () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2216 "Change current position's HTML tag (set)." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2217 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2218 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2219 ((yahtml-change-begend)) |
102 | 2220 ((yahtml-change-command)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2221 |
57 | 2222 ;;; ---------- commenting ---------- |
69 | 2223 |
64 | 2224 (defun yahtml-comment-region (&optional uncom) |
2225 "Comment out region or environment." | |
2226 (interactive) | |
72 | 2227 (let ((e (make-marker)) be beg p) |
64 | 2228 (cond |
72 | 2229 (;(marker-position (set-marker e (yahtml-on-begend-p))) |
2230 (setq be (yahtml-on-begend-p)) | |
64 | 2231 (save-excursion |
2232 (setq p (point)) | |
72 | 2233 (if (string-match "^/" be) |
64 | 2234 (setq beg (progn (forward-line 1) (point))) |
2235 (setq beg (progn (beginning-of-line) (point)))) | |
2236 (goto-char p) | |
2237 (yahtml-goto-corresponding-begend) | |
72 | 2238 (if (string-match "^/" be) |
64 | 2239 (beginning-of-line) |
2240 (forward-line 1)) | |
69 | 2241 (set-marker e (point)) |
102 | 2242 ;(comment-region beg (point) (if uncom (list 4))))) |
103 | 2243 )) |
69 | 2244 (t ;(comment-region (region-beginning) (region-end) (if uncom (list 4))) |
2245 (setq beg (region-beginning)) | |
2246 (set-marker e (region-end)))) | |
2247 (if yahtml-translate-hyphens-when-comment-region | |
2248 (let ((yahtml-entity-reference-chars-alist-default nil) | |
2249 (yahtml-entity-reference-chars-alist '((?- . "#45"))) | |
2250 yahtml-entity-reference-chars-regexp | |
2251 yahtml-entity-reference-chars-reverse-regexp) | |
2252 (yahtml-entity-reference-chars-setup) | |
2253 (funcall | |
2254 (if uncom 'yahtml-translate-reverse-region | |
2255 'yahtml-translate-region) | |
2256 beg e))) | |
2257 (comment-region beg e (if uncom (list 4))) | |
2258 (set-marker e nil))) | |
57 | 2259 |
64 | 2260 (defun yahtml-uncomment-region () |
2261 (interactive) | |
2262 (yahtml-comment-region t)) | |
57 | 2263 |
69 | 2264 ;;; ---------- translate to entity references ---------- |
2265 (defvar yahtml-entity-reference-chars-alist-default | |
2266 ;'((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot") (?' . "apos")) | |
2267 '((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot")) | |
2268 "Default translation table from character to entity reference") | |
2269 (defvar yahtml-entity-reference-chars-alist nil | |
2270 "*Translation table from character to entity reference") | |
2271 (defvar yahtml-entity-reference-chars-regexp nil) | |
2272 (defvar yahtml-entity-reference-chars-reverse-regexp nil) | |
57 | 2273 |
69 | 2274 (defun yahtml-entity-reference-chars-setup () |
2275 (let ((list (append yahtml-entity-reference-chars-alist-default | |
2276 yahtml-entity-reference-chars-alist))) | |
2277 (setq yahtml-entity-reference-chars-regexp "[" | |
2278 yahtml-entity-reference-chars-reverse-regexp "&\\(") | |
2279 (while list | |
2280 (setq yahtml-entity-reference-chars-regexp | |
2281 (concat yahtml-entity-reference-chars-regexp | |
2282 (char-to-string (car (car list)))) | |
2283 yahtml-entity-reference-chars-reverse-regexp | |
2284 (concat yahtml-entity-reference-chars-reverse-regexp | |
2285 (cdr (car list)) | |
2286 (if (cdr list) "\\|"))) | |
2287 (setq list (cdr list))) | |
2288 (setq yahtml-entity-reference-chars-regexp | |
2289 (concat yahtml-entity-reference-chars-regexp "]") | |
2290 yahtml-entity-reference-chars-reverse-regexp | |
2291 (concat yahtml-entity-reference-chars-reverse-regexp "\\);")))) | |
2292 | |
2293 (yahtml-entity-reference-chars-setup) | |
2294 | |
2295 (defun yahtml-translate-region (beg end) | |
2296 "Translate inhibited literals." | |
2297 (interactive "r") | |
2298 (save-excursion | |
2299 (save-restriction | |
2300 (narrow-to-region beg end) | |
2301 (let ((ct (append yahtml-entity-reference-chars-alist | |
2302 yahtml-entity-reference-chars-alist-default))) | |
2303 (goto-char beg) | |
2304 (while (re-search-forward yahtml-entity-reference-chars-regexp nil t) | |
2305 ;(setq c (preceding-char)) | |
2306 (replace-match | |
2307 (concat "&" (cdr (assoc (preceding-char) ct)) ";"))))))) | |
2308 | |
2309 (defun yahtml-translate-reverse-region (beg end) | |
2310 "Translate entity references to literals." | |
2311 (interactive "r") | |
2312 (save-excursion | |
2313 (save-restriction | |
2314 (narrow-to-region beg end) | |
2315 (let ((ct (append yahtml-entity-reference-chars-alist | |
2316 yahtml-entity-reference-chars-alist-default)) | |
2317 ec) | |
2318 (goto-char beg) | |
2319 (while (re-search-forward | |
2320 yahtml-entity-reference-chars-reverse-regexp nil t) | |
2321 ;(setq c (preceding-char)) | |
2322 (setq ec (YaTeX-match-string 1)) | |
2323 (delete-region (match-end 0) (match-beginning 0)) | |
2324 (insert (car (YaTeX-rassoc ec ct)))))))) | |
57 | 2325 |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2326 (defun yahtml-inner-environment-but (exclude &optional quick) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2327 "Return the inner environment but matches with EXCLUDE tag." |
64 | 2328 (let (e (case-fold-search t)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2329 (save-excursion |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2330 (while (and (setq e (YaTeX-inner-environment quick)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2331 (string-match exclude e)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2332 (goto-char (get 'YaTeX-inner-environment 'point)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2333 e)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2334 |
145
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2335 (defun yahtml-untranslate-string (str) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2336 "Untranslate entity reference." |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2337 (let ((md (match-data)) (left "") (right str) b0 ch |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2338 (ct (append yahtml-entity-reference-chars-alist |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2339 yahtml-entity-reference-chars-alist-default)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2340 (revrex yahtml-entity-reference-chars-reverse-regexp)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2341 (unwind-protect |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2342 (progn |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2343 (while (string< "" right) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2344 (cond |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2345 ((string-match revrex right) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2346 (setq ch (YaTeX-rassoc |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2347 (substring right (match-beginning 1) (match-end 1))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2348 b0 (substring right 0 (match-beginning 0)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2349 right (substring right (match-end 0)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2350 left (concat left |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2351 (substring right 0 (match-beginning 0)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2352 (char-to-string ch)))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2353 ((string-match "\\&#\\(x\\)?\\([0-9a-f]+\\);" right) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2354 (setq ch (substring right (match-beginning 2) (match-end 2)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2355 b0 (substring right 0 (match-beginning 0)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2356 right (substring right (match-end 0)) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2357 left (concat left |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2358 b0 |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2359 (char-to-string |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2360 (if (match-beginning 1) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2361 (YaTeX-hex ch) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2362 (string-to-number ch)))))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2363 (t (setq left (concat left right) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2364 right "")))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2365 left) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2366 (store-match-data md)))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2367 |
154 | 2368 ;;; ---------- table-ize region ---------- |
2369 (defun yahtml-td-region (e delim beg end) | |
2370 "Enclose each item in a region with <td>..</td>. | |
2371 Interactive prefix argument consults enclosing element other than td." | |
2372 (interactive "P\nsDelimiter(s): \nr") | |
156 | 2373 (let ((e (cond |
2374 ((null e) "td") | |
2375 ((stringp e) e) | |
157
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2376 (t (read-string "Enclose with(`thd' means th td td..): " "th")))) |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2377 (ws "[ \t]") |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2378 elm p i) |
154 | 2379 (if (string= delim "") (setq delim " \t\n")) |
157
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2380 (setq delim (concat "[" delim "]+") |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2381 elm (if (string= "thd" e) |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2382 (cons "th" "td") |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2383 (cons e e))) |
154 | 2384 (save-excursion |
2385 (save-restriction | |
2386 (narrow-to-region beg end) | |
2387 (goto-char (setq p (point-min))) | |
157
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2388 (setq i 0 e (car elm)) |
154 | 2389 (while (re-search-forward delim nil t) |
157
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2390 (setq e (if (= (setq i (1+ i)) 1) (car elm) (cdr elm))) |
154 | 2391 (goto-char (match-beginning 0)) |
2392 (insert "</" e ">") | |
2393 (save-excursion | |
2394 (goto-char p) | |
2395 (insert "<" e ">")) | |
2396 (setq p (point)) | |
155
4fd09665b2be
yahtml-tr-region(): Allow null field (eg. ,,) in CSV.
yuuji@gentei.org
parents:
154
diff
changeset
|
2397 (while (and (not (eobp)) (looking-at ws)) |
4fd09665b2be
yahtml-tr-region(): Allow null field (eg. ,,) in CSV.
yuuji@gentei.org
parents:
154
diff
changeset
|
2398 (delete-char 1)) |
4fd09665b2be
yahtml-tr-region(): Allow null field (eg. ,,) in CSV.
yuuji@gentei.org
parents:
154
diff
changeset
|
2399 (if (looking-at delim) (delete-char 1))) |
154 | 2400 (insert "<" e ">") |
2401 (goto-char (point-max)) | |
2402 (insert "</" e ">"))))) | |
2403 | |
2404 (defun yahtml-tr-region (e delim beg end) | |
2405 "Enclose lines in a form tab-sv/csv with <tr><td>..</td></tr>." | |
2406 (interactive "P\nsDelimiter(s): \nr") | |
157
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2407 (setq e (if (and e (listp e)) |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2408 (read-string "Enclose with(td or th, `thd' -> th td td td...: " |
e3d7307f71e0
yahtml-td-region(): `thd' means <th> for 1st column <td> for the rest.
yuuji@gentei.org
parents:
156
diff
changeset
|
2409 "th"))) |
156 | 2410 (save-excursion |
2411 (save-restriction | |
2412 (narrow-to-region (point) (mark)) | |
2413 (goto-char (point-min)) | |
2414 (while (not (eobp)) | |
2415 (insert "<tr>") | |
2416 (yahtml-td-region e delim (point) (point-end-of-line)) | |
2417 (end-of-line) | |
2418 (insert "</tr>") | |
2419 (forward-line 1))))) | |
154 | 2420 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2421 ;;; ---------- filling ---------- |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2422 (defvar yahtml-saved-move-to-column (symbol-function 'move-to-column)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2423 (defun yahtml-move-to-column (col &optional force) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2424 (beginning-of-line) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2425 (let ((ccol 0)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2426 (while (and (> col ccol) (not (eolp))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2427 (if (eq (following-char) ?\<) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2428 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2429 (while (and (not (eq (following-char) ?\>)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2430 (not (eolp))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2431 (forward-char)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2432 (or (eolp) (forward-char))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2433 (or (eolp) (forward-char)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2434 (if (eq (preceding-char) ?\t) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2435 (let ((wd (- 8 (% (+ ccol 8) 8)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2436 (if (and force (< col (+ ccol wd))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2437 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2438 (backward-char 1) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2439 (insert-char ?\ (- col ccol)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2440 (setq ccol col)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2441 (setq ccol (+ ccol wd)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2442 (setq ccol (1+ ccol))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2443 (if (and YaTeX-japan |
69 | 2444 (or |
2445 (and (fboundp 'char-category) | |
2446 (string-match "[chj]" (char-category (preceding-char)))) | |
2447 (and (fboundp 'char-charset) | |
2448 (not (eq (char-charset (preceding-char)) 'ascii))))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2449 (setq ccol (1+ ccol))))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2450 (if (and force (> col ccol)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2451 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2452 (insert-char ?\ (- col ccol)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2453 col) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2454 ccol))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2455 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2456 (defun yahtml-fill-paragraph (arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2457 (interactive "P") |
68 | 2458 (let*((case-fold-search t) (p (point)) fill-prefix |
61 | 2459 (e (or (yahtml-inner-environment-but "^\\(a\\|p\\)\\b" t) "html")) |
68 | 2460 indent |
2461 (startp (get 'YaTeX-inner-environment 'point)) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2462 (prep (string-match "^pre$" e)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2463 (ps1 (if prep (default-value 'paragraph-start) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2464 paragraph-start)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2465 (ps2 (if prep (concat (default-value 'paragraph-start) |
69 | 2466 "$\\|^\\s *</?pre>") |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2467 paragraph-start))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2468 (save-excursion |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2469 (unwind-protect |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2470 (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2471 (if prep |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2472 (fset 'move-to-column 'yahtml-move-to-column)) |
68 | 2473 (save-excursion |
2474 (beginning-of-line) | |
2475 (indent-to-column (yahtml-this-indent)) | |
2476 (setq fill-prefix | |
2477 (buffer-substring (point) (point-beginning-of-line))) | |
2478 (delete-region (point) (point-beginning-of-line))) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2479 (fill-region-as-paragraph |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2480 (progn (re-search-backward paragraph-start nil t) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2481 (or (save-excursion |
64 | 2482 (goto-char (match-beginning 0)) |
2483 (if (looking-at "<") | |
2484 (forward-list) | |
2485 (goto-char (match-end 0)) | |
2486 (skip-chars-forward " \t>")) | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2487 (if (looking-at "[ \t]*$") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2488 (progn (forward-line 1) (point)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2489 (point))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2490 (progn (goto-char p) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2491 (re-search-forward ps2 nil t) |
69 | 2492 (match-beginning 0)))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2493 (fset 'move-to-column yahtml-saved-move-to-column))))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2494 |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2495 ;(defun yahtml-indent-new-commnet-line () |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2496 ; (unwind-protect |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2497 ; (progn |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2498 ; (fset 'move-to-column 'yahtml-move-to-column) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2499 ; (apply 'YaTeX-saved-indent-new-comment-line (if soft (list soft)))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2500 ; (fset 'move-to-column yahtml-saved-move-to-column))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2501 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2502 ;;; |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2503 ;;; ---------- indentation ---------- |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2504 ;;; |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2505 (defun yahtml-indent-line () |
64 | 2506 "Indent a line (faster wrapper)" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2507 (interactive) |
64 | 2508 (let (indent) |
2509 (if (and (save-excursion | |
2510 (beginning-of-line) (skip-chars-forward "\t ") | |
2511 (not (looking-at "<"))) | |
2512 (save-excursion | |
2513 (forward-line -1) | |
2514 (while (and (not (bobp)) (looking-at "^\\s *$")) | |
2515 (forward-line -1)) | |
2516 (skip-chars-forward "\t ") | |
2517 (setq indent (current-column)) | |
2518 (not (looking-at "<")))) | |
2519 (progn | |
2520 (save-excursion | |
2521 (beginning-of-line) | |
2522 (skip-chars-forward " \t") | |
2523 (or (= (current-column) indent) | |
2524 (YaTeX-reindent indent))) | |
2525 (and (bolp) (skip-chars-forward " \t"))) | |
2526 (yahtml-indent-line-real)))) | |
2527 | |
68 | 2528 (defun yahtml-this-indent () |
190
3db120d6b7d1
Calculation of indentation depth revised. (included again after merge conflict)
yuuji@gentei.org
parents:
189
diff
changeset
|
2529 (let ((envs "[uod]l\\|table\\|[ht][rhd0-6]\\|select\\|blockquote\\|center\\|menu\\|dir\\|d[td]\\|li") |
3db120d6b7d1
Calculation of indentation depth revised. (included again after merge conflict)
yuuji@gentei.org
parents:
189
diff
changeset
|
2530 (itemizing-envs "^\\([uod]l\\|menu\\|dir\\|li\\|d[td]\\)$") |
61 | 2531 (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\|option\\)\\b") |
70 | 2532 (excludes |
190
3db120d6b7d1
Calculation of indentation depth revised. (included again after merge conflict)
yuuji@gentei.org
parents:
189
diff
changeset
|
2533 "\\b\\(a\\|p\\|span\\|code\\|tt\\|em\\|u\\|i\\|big\\|small\\|font\\)\\b") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2534 inenv p col peol (case-fold-search t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2535 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2536 (beginning-of-line) |
70 | 2537 (setq inenv (or (yahtml-inner-environment-but excludes t) |
61 | 2538 "html") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2539 col (get 'YaTeX-inner-environment 'indent) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2540 p (get 'YaTeX-inner-environment 'point) |
64 | 2541 op nil)) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2542 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2543 (cond |
70 | 2544 ((string-match (concat "^\\(" envs "\\)") inenv) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2545 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2546 (beginning-of-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2547 (skip-chars-forward " \t") |
64 | 2548 (cond ;lookup current line's tag |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2549 ((looking-at (concat "</\\(" envs "\\)>")) |
68 | 2550 col) |
64 | 2551 ((looking-at itms) |
68 | 2552 (+ col yahtml-environment-indent)) |
64 | 2553 ((and yahtml-hate-too-deep-indentation |
2554 (looking-at (concat "<\\(" envs "\\)"))) | |
68 | 2555 (+ col (* 2 yahtml-environment-indent))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2556 ((and (< p (point)) |
64 | 2557 (string-match itemizing-envs inenv) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2558 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2559 (and |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2560 (setq op (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2561 (goto-char p) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2562 (re-search-forward itms op t) |
64 | 2563 (progn |
73 | 2564 (if yahtml-indent-listing-constant |
2565 (setq col (+ (current-column) | |
2566 (if yahtml-faithful-to-htmllint 1 2))) | |
2567 (skip-chars-forward "^>") | |
2568 (skip-chars-forward ">") | |
2569 (skip-chars-forward " \t") | |
2570 (setq col (if (looking-at "$") | |
2571 (+ col yahtml-environment-indent) | |
2572 (current-column)))))))) | |
68 | 2573 col) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2574 (t |
68 | 2575 (+ col yahtml-environment-indent))))) |
2576 (t col))))) | |
2577 | |
2578 (defun yahtml-indent-line-real () | |
2579 "Indent current line." | |
2580 (interactive) | |
2581 (YaTeX-reindent (yahtml-this-indent)) | |
2582 (if (bolp) (skip-chars-forward " \t")) | |
70 | 2583 (let (peol col inenv) |
68 | 2584 (if (and (setq inenv (yahtml-on-begend-p)) |
2585 (string-match | |
2586 (concat "^\\<\\(" yahtml-struct-name-regexp "\\)") inenv)) | |
2587 (save-excursion | |
2588 (setq peol (point-end-of-line)) | |
2589 (or (= (char-after (point)) ?<) | |
2590 (progn (skip-chars-backward "^<") (forward-char -1))) | |
2591 (setq col (current-column)) | |
2592 (if (and (yahtml-goto-corresponding-begend t) | |
2593 (> (point) peol)) ;if on the different line | |
2594 (YaTeX-reindent col)))))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2595 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2596 ;(defun yahtml-fill-item () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2597 ; "Fill item HTML version" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2598 ; (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2599 ; (let (inenv p fill-prefix peol (case-fold-search t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2600 ; (setq inenv (or (YaTeX-inner-environment) "html") |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2601 ; p (get 'YaTeX-inner-environment 'point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2602 ; (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2603 ; ((string-match "^[uod]l" inenv) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2604 ; (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2605 ; (if (re-search-backward "<\\(d[td]\\|li\\)>[ \t\n]*" p t) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2606 ; (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2607 ; (goto-char (match-end 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2608 ; (setq col (current-column))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2609 ; (error "No <li>, <dt>, <dd>"))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2610 ; (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2611 ; (end-of-line) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2612 ; (setq peol (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2613 ; (newline) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2614 ; (indent-to-column col) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2615 ; (setq fill-prefix (buffer-substring (point) (1+ peol))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2616 ; (delete-region (point) peol) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2617 ; (fill-region-as-paragraph |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2618 ; (progn (re-search-backward paragraph-start nil t) (point)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2619 ; (progn (re-search-forward paragraph-start nil t 2) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2620 ; (match-beginning 0))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2621 ; (t nil)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2622 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2623 ;;; |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2624 ;;; ---------- Lint and Browsing ---------- |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2625 ;;; |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2626 (defun yahtml-browse-menu () |
138 | 2627 "Browsing or other external process invokation menu." |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2628 (interactive) |
138 | 2629 (message "J)weblint p)Browse R)eload N)ewpage...") |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2630 (let ((c (char-to-string (read-char)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2631 (cond |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2632 ((string-match "j" c) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2633 (yahtml-lint-buffer (current-buffer))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2634 ((string-match "[bp]" c) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2635 (yahtml-browse-current-file)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2636 ((string-match "r" c) |
138 | 2637 (yahtml-browse-reload)) |
2638 ((string-match "n" c) | |
2639 (call-interactively 'yahtml-newpage))))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2640 |
72 | 2641 (if (fboundp 'wrap-function-to-control-ime) |
2642 (wrap-function-to-control-ime 'yahtml-browse-menu t nil)) | |
2643 | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2644 (defvar yahtml-lint-buffer "*weblint*") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2645 |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2646 (defun yahtml-lint-buffer (buf) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2647 "Call lint on buffer BUF." |
64 | 2648 (require 'yatexprc) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2649 (interactive "bCall lint on buffer: ") |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2650 (setq buf (get-buffer buf)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2651 (YaTeX-save-buffers) |
145
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2652 (let ((bcmd (YaTeX-get-builtin "lint"))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2653 (and bcmd (setq bcmd (yahtml-untranslate-string bcmd))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2654 (YaTeX-typeset |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2655 (concat (or bcmd yahtml-lint-program) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2656 " " (file-name-nondirectory (buffer-file-name buf))) |
efc3819f749b
Recognize <!-- #lint CommandLine --> as yahtml-lint-program.
yuuji@gentei.org
parents:
138
diff
changeset
|
2657 yahtml-lint-buffer "lint" "lint"))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2658 |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2659 (defun yahtml-file-to-url (file) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2660 "Convert local unix file name to URL. |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2661 If no matches found in yahtml-path-url-alist, return raw file name." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2662 (let ((list yahtml-path-url-alist) p url) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2663 (if (file-directory-p file) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2664 (setq file (expand-file-name yahtml-directory-index file)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2665 (setq file (expand-file-name file))) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2666 (if (string-match "^[A-Za-z]:/" file) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2667 (progn |
64 | 2668 ;; (aset file 1 ?|) ;これは要らないらしい… |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2669 (setq file (concat "///" file)))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2670 (while list |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2671 (if (string-match (concat "^" (regexp-quote (car (car list)))) file) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2672 (setq url (cdr (car list)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2673 file (substring file (match-end 0)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2674 url (concat url file) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2675 list nil)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2676 (setq list (cdr list))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2677 (or url (concat "file:" file)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2678 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2679 (defun yahtml-url-to-path (file &optional basedir) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2680 "Convert local URL name to unix file name." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2681 (let ((list yahtml-path-url-alist) url realpath docroot |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2682 (dirsufp (string-match "/$" file))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2683 (setq basedir (or basedir |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2684 (file-name-directory |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2685 (expand-file-name default-directory)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2686 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2687 ((string-match "^/" file) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2688 (while list |
59 | 2689 (if (file-directory-p (car (car list))) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2690 (progn |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2691 (setq url (cdr (car list))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2692 (if (string-match "\\(http://[^/]*\\)/" url) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2693 (setq docroot (substring url (match-end 1))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2694 (setq docroot url)) |
64 | 2695 (cond |
2696 ((string-match (concat "^" (regexp-quote docroot)) file) | |
2697 (setq realpath | |
2698 (expand-file-name | |
2699 (substring | |
2700 file | |
2701 (if (= (aref file (1- (match-end 0))) ?/) | |
2702 (match-end 0) ; "/foo" | |
2703 (min (1+ (match-end 0)) (length file)))) ; "/~foo" | |
2704 (car (car list)))))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2705 (if realpath |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2706 (progn (setq list nil) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2707 (if (and dirsufp (not (string-match "/$" realpath))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2708 (setq realpath (concat realpath "/"))))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2709 (setq list (cdr list))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2710 realpath) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2711 (t file)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2712 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2713 (defun yahtml-browse-current-file () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2714 "Call WWW browser on current file." |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2715 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2716 (basic-save-buffer) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2717 (yahtml-browse-html (yahtml-file-to-url (buffer-file-name)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2718 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2719 (defun yahtml-browse-reload () |
115
d461ecc865d4
Default browser changed from Netscape to Firefox.
yuuji@gentei.org
parents:
103
diff
changeset
|
2720 "Send `reload' event to netscape." |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2721 (let ((pb "* WWW Browser *") (cb (current-buffer))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2722 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2723 ((string-match "[Nn]etscape" yahtml-www-browser) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2724 (if (get-buffer pb) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2725 (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2726 ;;(or (get 'yahtml-netscape-sentinel 'url) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2727 ;; (error "Reload should be called after Browsing.")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2728 (put 'yahtml-netscape-sentinel 'url |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2729 (yahtml-file-to-url (buffer-file-name))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2730 (basic-save-buffer) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2731 (set-process-sentinel |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2732 (setq yahtml-browser-process |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2733 (start-process |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2734 "browser" pb shell-file-name yahtml-shell-command-option ;"-c" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2735 (format "%s -remote 'reload'" yahtml-www-browser))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2736 'yahtml-netscape-sentinel)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2737 (t |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2738 (message "Sorry, RELOAD is supported only for Netscape."))))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2739 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2740 ;;; ---------- Intelligent newline ---------- |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2741 (defun yahtml-intelligent-newline (arg) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2742 "Intelligent newline for HTML" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2743 (interactive "P") |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2744 (let (env func) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2745 (end-of-line) |
64 | 2746 (setq env (downcase (or (yahtml-inner-environment-but "^\\(a\\|p\\)\\b" t) |
2747 "html"))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2748 (setq func (intern-soft (concat "yahtml-intelligent-newline-" env))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2749 (newline) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2750 (if (and env func (fboundp func)) |
64 | 2751 ;; if intelligent line function is defined, call that |
2752 (funcall func) | |
2753 ;; else do the default action | |
2754 (if (string-match yahtml-p-prefered-env-regexp env) | |
2755 (yahtml-insert-p))))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2756 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2757 (defun yahtml-intelligent-newline-ul () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2758 (interactive) |
64 | 2759 (yahtml-insert-single "li") |
80 | 2760 (or yahtml-always-/li yahtml-faithful-to-htmllint (insert " ")) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2761 (yahtml-indent-line)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2762 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2763 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2764 |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2765 (defun yahtml-intelligent-newline-dl () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2766 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2767 (let ((case-fold-search t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2768 (if (save-excursion |
73 | 2769 (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)[ \t>]" |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2770 (get 'YaTeX-inner-environment 'point) t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2771 (cond |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2772 ((match-beginning 2) |
64 | 2773 (yahtml-insert-single "dd") |
80 | 2774 (or yahtml-always-/dd yahtml-faithful-to-htmllint (insert " ")) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2775 (setq yahtml-last-single-cmd "dt")) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2776 ((match-beginning 3) |
64 | 2777 (yahtml-insert-single "dt") |
80 | 2778 (or yahtml-always-/dt yahtml-faithful-to-htmllint (insert " ")) |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2779 (setq yahtml-last-single-cmd "dd"))) |
121 | 2780 (yahtml-insert-single "dt") |
2781 (or yahtml-always-/li yahtml-faithful-to-htmllint (insert " ")) | |
64 | 2782 (setq yahtml-last-single-cmd "dd")) |
2783 (yahtml-indent-line) | |
2784 (and (string-match yahtml-p-prefered-env-regexp "dl") | |
2785 (string-equal yahtml-last-single-cmd "dt") | |
2786 (yahtml-insert-p nil)))) | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2787 |
59 | 2788 (defun yahtml-intelligent-newline-select () |
2789 (interactive) | |
315 | 2790 (yahtml-insert-single (if yahtml-prefer-upcases "OPTION" "option")) |
59 | 2791 (yahtml-indent-line)) |
2792 | |
70 | 2793 (defun yahtml-intelligent-newline-style () |
2794 (interactive) | |
2795 (if (save-excursion | |
2796 (and | |
2797 (re-search-backward "<style\\|<!-- " nil t) | |
2798 (looking-at "<style"))) | |
2799 (let (c) | |
2800 (yahtml-indent-line) | |
2801 (setq c (current-column)) | |
2802 (insert "<!--\n") | |
2803 (YaTeX-reindent c) | |
2804 (insert "-->") | |
2805 (beginning-of-line) | |
2806 (open-line 1) | |
2807 (YaTeX-reindent c)))) | |
2808 | |
80 | 2809 (defun yahtml-intelligent-newline-head () |
2810 (let ((title (read-string "Document title: ")) | |
2811 (b "<title>") (e "</title>") p) | |
2812 (yahtml-indent-line) | |
2813 (insert (format "%s" (if yahtml-prefer-upcases (upcase b) b))) | |
2814 (setq p (point)) | |
2815 (insert (format "%s%s" title (if yahtml-prefer-upcases (upcase e) e))) | |
2816 (if (string= "" title) (goto-char p)) | |
2817 (setq yahtml-last-begend "body"))) | |
2818 | |
2819 (defun yahtml-intelligent-newline-script () | |
2820 (let ((p (point)) b) | |
2821 (if (save-excursion | |
2822 (and | |
2823 (setq b (re-search-backward "<script\\>" nil t)) | |
2824 (re-search-forward | |
2825 "\\(javascript\\)\\|\\(tcl\\)\\|\\(vbscript\\)" p t))) | |
2826 (let ((js (match-end 1)) (tcl (match-end 2)) (vb (match-end 3)) | |
2827 c (srcp (re-search-backward "src=" b t))) | |
2828 (goto-char p) | |
2829 (yahtml-indent-line) | |
2830 (setq c (current-column)) | |
2831 (if srcp | |
2832 nil | |
2833 (insert "<!--\n" (cond (js "//") (tcl "#") (vb "'")) " -->") | |
2834 (beginning-of-line) | |
2835 (open-line 1) | |
2836 (YaTeX-reindent c)))))) | |
2837 | |
86 | 2838 (defun yahtml-intelligent-newline-table () |
2839 (let ((cp (point)) (p (point)) tb rb (cols 0) th line (i 0) fmt | |
2840 (ptn "\\(<t[dh]\\>\\)\\|<t\\(r\\|head\\|body\\)\\>")) | |
2841 (cond | |
2842 ((save-excursion (setq tb (YaTeX-beginning-of-environment "table"))) | |
2843 (while (and (setq rb (re-search-backward ptn tb t)) | |
2844 (match-beginning 1)) | |
2845 (setq th (looking-at "<th")) ;Remember if first-child is tr or not | |
2846 (goto-char (match-end 0)) | |
2847 (skip-chars-forward " \t\n") | |
2848 (if (and (search-forward "colspan\\s *=" p t) | |
2849 (progn | |
2850 (skip-chars-forward "\"' \t\n") | |
2851 (looking-at "[0-9]+"))) | |
2852 (setq cols (+ (string-to-int (YaTeX-match-string 0)) cols)) | |
2853 (setq cols (1+ cols))) | |
2854 (goto-char rb) | |
2855 (setq p (point))) | |
2856 (if (> cols 0) | |
2857 (message "%s columns found. %s" | |
2858 cols (if YaTeX-japan "新しいtr(N)? 前のtrの複写?(D)?: " | |
2859 "New tr?(N) or Duplicate"))) | |
2860 (cond | |
2861 ((and (> cols 0) | |
2862 (memq (read-char) '(?d ?D))) ;Duplication mode | |
135
5c61fe39f1c4
Suppress insertion of superfluous newline at duplication of previous <tr>.
yuuji@gentei.org
parents:
121
diff
changeset
|
2863 (setq line (YaTeX-buffer-substring (point) (1- cp)))) |
86 | 2864 (t ;empty cells |
2865 (setq line "<tr>" i 0) | |
2866 (if (> cols 0) | |
2867 (while (> cols i) | |
2868 (setq line (concat line (if (and (= i 0) th) "<th></th>" | |
2869 "<td></td>")) | |
2870 th nil i (1+ i))) | |
2871 (setq fmt (read-string "`th' or `td' format: " "th td td")) | |
2872 (while (string-match "t\\(h\\)\\|td" fmt i) | |
2873 (setq line (concat line (if (match-beginning 1) "<th></th>" | |
2874 "<td></td>")) | |
2875 i (match-end 0)))) | |
2876 (setq line (concat line "</tr>")))) | |
2877 (goto-char cp) | |
2878 (if th | |
2879 (message | |
2880 "Type `%s' to change td from/to th." | |
2881 (key-description (car (where-is-internal 'yahtml-change-*))))) | |
2882 (if (string< "" line) | |
2883 (progn | |
2884 (insert line) | |
2885 (goto-char (+ 8 cp)) | |
2886 (yahtml-indent-line))))))) | |
2887 | |
58
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2888 ;;; ---------- Marking ---------- |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2889 (defun yahtml-mark-begend () |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2890 "Mark current tag" |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2891 (interactive) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2892 (YaTeX-beginning-of-environment) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2893 (let ((p (point))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2894 (save-excursion |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2895 (skip-chars-backward " \t" (point-beginning-of-line)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2896 (if (bolp) (setq p (point)))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2897 (push-mark p t)) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2898 (yahtml-goto-corresponding-begend) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2899 (forward-list 1) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2900 (if (eolp) (forward-char 1))) |
3a7c0c2bf16d
Official support for AMS-LaTeX, HTML, xdvi -remote, Netscape
yuuji
parents:
57
diff
changeset
|
2901 |
59 | 2902 ;;; ---------- complete marks ---------- |
2903 (defun yahtml-complete-mark () | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2904 "Complete >, <, &ersand, and "e." |
59 | 2905 (interactive) |
69 | 2906 (message "1:< 2:> 3:& 4:\" 5:' 6:nbsp") |
59 | 2907 (let ((c (read-char))) |
69 | 2908 (setq c (if (or (< c ?0) (> c ?7)) |
59 | 2909 (string-match (regexp-quote (char-to-string c)) "<>&\"") |
2910 (- c ?1))) | |
69 | 2911 (if (or (< c 0) (> c 6)) |
59 | 2912 nil |
69 | 2913 (insert (format "&%s;" |
2914 (nth c '("lt" "gt" "amp" "quot" "apos" "nbsp"))))))) | |
59 | 2915 |
2916 | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2917 ;;; ---------- jump to error line ---------- |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2918 (defun yahtml-prev-error () |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2919 "Jump to previous error seeing lint buffer." |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2920 (interactive) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2921 (or (get-buffer yahtml-lint-buffer) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2922 (error "No lint program ran.")) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2923 (YaTeX-showup-buffer yahtml-lint-buffer nil t) |
64 | 2924 (yahtml-jump-to-error-line t)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2925 |
64 | 2926 (defun yahtml-jump-to-error-line (&optional sit) |
2927 (interactive "P") | |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2928 (let ((p (point)) (e (point-end-of-line))) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2929 (end-of-line) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2930 (if (re-search-backward yahtml-error-line-regexp nil t) |
72 | 2931 (let ((f (if (string= "" (YaTeX-match-string 1)) |
2932 YaTeX-current-file-name | |
2933 (YaTeX-match-string 1))) | |
2934 (l (string-to-int (or (YaTeX-match-string 2) | |
2935 (YaTeX-match-string 3))))) | |
64 | 2936 (if sit (sit-for 1)) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2937 (forward-line -1) |
64 | 2938 (YaTeX-showup-buffer (YaTeX-switch-to-buffer f t) nil t) |
60
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2939 (goto-line l)) |
9e08ed569d80
yahtml: change keystroke of calling browser to [prefix] t p
yuuji
parents:
59
diff
changeset
|
2940 (message "No line number usage")))) |
69 | 2941 |
2942 ;;; ---------- Style Sheet Support ---------- | |
2943 (defvar yahtml-css-class-alist nil | |
2944 "Alist of elements vs. their classes") | |
2945 | |
2946 (defun yahtml-css-collect-classes-region (beg end &optional initial) | |
70 | 2947 (save-excursion |
2948 (save-restriction | |
69 | 2949 (narrow-to-region beg end) |
2950 (goto-char (point-min)) | |
70 | 2951 (let ((alist initial) b e element class a) |
69 | 2952 (setq b (point)) |
80 | 2953 (while (re-search-forward "\\({\\)\\|\\(@import\\)" nil t) |
2954 (if (match-beginning 2) | |
2955 (let ((f (YaTeX-buffer-substring | |
2956 (progn (skip-chars-forward "^\"")(1+ (point))) | |
2957 (progn (forward-char 1) | |
2958 (skip-chars-forward "^\"")(point))))) | |
2959 (if (file-exists-p f) | |
2960 (setq alist | |
286 | 2961 (append alist (yahtml-css-collect-classes-file |
2962 f initial))))) | |
80 | 2963 (setq e (point)) |
2964 (goto-char b) | |
2965 (while (re-search-forward ;ちょといい加減なREGEXP | |
86 | 2966 "\\([a-z*][-a-z0-9]*\\)?\\.\\([-a-z0-9][-a-z0-9]*\\)\\>" |
80 | 2967 e t) |
2968 (setq element (YaTeX-match-string 1) | |
2969 class (YaTeX-match-string 2)) | |
2970 ;;if starts with period (match-string 1 is nil), | |
2971 ;;this is global class | |
86 | 2972 (setq element (downcase (or element "*"))) |
80 | 2973 (if (setq a (assoc element alist)) |
2974 (or (assoc class (cdr a)) | |
2975 (setcdr a (cons (list class) (cdr a)))) | |
2976 (setq alist (cons (list element (list class)) alist)))) | |
2977 (goto-char (1- e)) | |
199 | 2978 (search-forward "}" nil 1) ;1=move to limit when not found. |
80 | 2979 (setq b (point)))) |
70 | 2980 alist)))) |
69 | 2981 |
2982 (defun yahtml-css-collect-classes-buffer (&optional initial) | |
2983 (interactive) | |
2984 (yahtml-css-collect-classes-region (point-min) (point-max) initial)) | |
2985 | |
2986 (defun yahtml-css-collect-classes-file (file &optional initial) | |
70 | 2987 (let*((hilit-auto-highlight nil) |
86 | 2988 (buf (get-buffer-create |
2989 (format " *css-collection*%s" (file-name-nondirectory file)))) | |
2990 (cb (current-buffer))) | |
2991 (unwind-protect | |
2992 (progn | |
2993 (set-buffer buf) | |
2994 (insert-file-contents file) | |
2995 (cd (or (file-name-directory file) ".")) | |
2996 (yahtml-css-collect-classes-buffer initial)) | |
2997 (if (eq buf cb) | |
2998 nil | |
2999 (kill-buffer buf) | |
3000 (set-buffer cb))))) | |
69 | 3001 |
3002 (defun yahtml-css-scan-styles () | |
3003 (save-excursion | |
3004 (goto-char (point-min)) | |
3005 (set (make-local-variable 'yahtml-css-class-alist) nil) | |
72 | 3006 (let (b tag type e href alist) |
3007 (while (re-search-forward "<\\(style\\|link\\)" nil t) | |
3008 (setq b (match-beginning 0) | |
3009 tag (YaTeX-match-string 1)) | |
69 | 3010 (cond |
3011 ((string-match "style" tag) | |
3012 (goto-char b) | |
3013 (save-excursion (forward-list 1) (setq e (point))) | |
3014 (cond | |
3015 ((search-forward "text/css" e 1) ;css definition starts | |
3016 (setq alist | |
3017 (yahtml-css-collect-classes-region | |
3018 (point) (progn (search-forward "</style>") (point)) | |
3019 alist))))) | |
3020 ((and (string-match "link" tag) | |
72 | 3021 (stringp (setq type (yahtml-get-attrvalue "type"))) |
3022 (string-match "text/css" type) | |
69 | 3023 (setq href (yahtml-get-attrvalue "href")) |
3024 (file-exists-p (yahtml-url-to-path href))) | |
3025 (setq alist | |
3026 (yahtml-css-collect-classes-file | |
3027 (yahtml-url-to-path href) alist)))) | |
3028 (setq yahtml-css-class-alist alist))))) | |
3029 | |
70 | 3030 (defun yahtml-css-get-element-completion-alist (element) |
73 | 3031 (let ((alist (cdr-safe (assoc (downcase element) yahtml-css-class-alist))) |
86 | 3032 (global (cdr-safe (assoc "*" yahtml-css-class-alist)))) |
70 | 3033 (and (or alist global) |
3034 (append alist global)))) | |
3035 | |
57 | 3036 ;;; ---------- ---------- |
3037 | |
3038 ;;; | |
3039 ;;hilit19 | |
3040 ;;; | |
3041 (defvar yahtml-default-face-table | |
3042 '( | |
3043 (form black/ivory white/hex-442233 italic) | |
3044 )) | |
3045 (defvar yahtml-hilit-patterns-alist | |
3046 '( | |
70 | 3047 'case-fold |
57 | 3048 ;; comments |
3049 ("<!--\\s " "-->" comment) | |
3050 ;; include&exec | |
69 | 3051 ("<!--#\\(include\\|exec\\|config\\|fsize\\|flastmod\\)" "-->" include) |
57 | 3052 ;; string |
68 | 3053 (hilit-string-find ?\\ string) |
80 | 3054 (yahtml-hilit-region-tag "<\\(strong\\|b\\)\\>" bold) |
57 | 3055 ("</?[uod]l>" 0 decl) |
3056 ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label) | |
80 | 3057 (yahtml-hilit-region-tag "<\\(em\\|i\\>\\)" italic) |
72 | 3058 ;("<a\\s +href" "</a>" crossref) ;good for hilit19, but odd for font-lock.. |
3059 (yahtml-hilit-region-tag "<\\(a\\)\\s +href" crossref) | |
64 | 3060 (yahtml-hilit-region-tag-itself "</?\\sw+\\>" decl) |
57 | 3061 )) |
3062 | |
3063 (defun yahtml-hilit-region-tag (tag) | |
3064 "Return list of start/end point of <TAG> form." | |
72 | 3065 (if (re-search-forward tag nil t) |
3066 (let ((m0 (match-beginning 0)) (e0 (match-end 0)) | |
3067 (elm (YaTeX-match-string 1))) | |
3068 (skip-chars-forward "^>") | |
3069 (prog1 | |
3070 (cons (1+ (point)) | |
3071 (progn (re-search-forward (concat "</" elm ">") nil t) | |
3072 (match-beginning 0))) | |
3073 (goto-char e0))))) | |
57 | 3074 |
64 | 3075 (defun yahtml-hilit-region-tag-itself (ptn) |
3076 "Return list of start/end point of <tag options...> itself." | |
3077 (if (re-search-forward ptn nil t) | |
73 | 3078 (let ((m0 (match-beginning 0)) (e0 (match-end 0))) |
3079 (skip-chars-forward "^<>") | |
3080 (if (eq (char-after (point)) ?<) nil | |
3081 (prog1 | |
3082 (cons m0 (min (point-max) (1+ (point)))) | |
3083 (goto-char e0)))))) | |
64 | 3084 |
57 | 3085 ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist)) |
70 | 3086 (and yahtml-use-hilit19 |
64 | 3087 (or (assq 'yahtml-mode hilit-patterns-alist) |
3088 (setq hilit-patterns-alist | |
3089 (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist) | |
3090 hilit-patterns-alist)))) | |
72 | 3091 ;;; |
3092 ;; for font-lock | |
3093 ;;; | |
3094 | |
3095 ; <<STATIC KEYWORDS BELOW NOT USED>> | |
3096 ;(defvar yahtml-font-lock-keywords | |
3097 ; '( | |
3098 ; ;; comments | |
3099 ; ("<!--\\s .* -->" . font-lock-comment-face) | |
3100 ; ;; include&exec | |
3101 ; ("<!--#\\(include\\|exec\\|config\\|fsize\\|flastmod\\).*-->" | |
3102 ; 0 font-lock-include-face keep) | |
3103 ; ;; string | |
3104 ; ;(hilit-string-find ?\\ string) | |
3105 ; ;(yahtml-hilit-region-tag "\\(em\\|strong\\)" bold) | |
3106 ; ("</?[uod]l>" 0 font-lock-keyword-face) | |
3107 ; ("<\\(di\\|dt\\|li\\|dd\\)>" 0 font-lock-label-face) | |
3108 ; ("<a\\s +href=.*</a>" (0 font-lock-crossref-face keep)) | |
3109 ; ;(yahtml-hilit-region-tag-itself "</?\\sw+\\>" decl) | |
3110 ; ("</?\\sw+\\>" (yahtml-fontify-to-tagend nil nil)) | |
3111 ; ) | |
3112 ; "*Defualt font-lock-keywords for yahtml-mode.") | |
3113 (defvar yahtml-font-lock-keywords | |
3114 (YaTeX-convert-pattern-hilit2fontlock yahtml-hilit-patterns-alist) | |
3115 "Default fontifying patterns for yahtml-mode") | |
3116 | |
3117 (defun yahtml-font-lock-set-default-keywords () | |
3118 (put 'yahtml-mode 'font-lock-defaults | |
3119 '(yahtml-font-lock-keywords nil t))) | |
3120 | |
3121 (if yahtml-use-font-lock | |
3122 (progn | |
3123 (if (and (boundp 'hilit-mode-enable-list) hilit-mode-enable-list) | |
3124 ;;for those who use both hilit19 and font-lock | |
3125 (if (eq (car hilit-mode-enable-list) 'not) | |
3126 (or (member 'yahtml-mode hilit-mode-enable-list) | |
3127 (nconc hilit-mode-enable-list (list 'yahtml-mode))) | |
3128 (setq hilit-mode-enable-list | |
3129 (delq 'yahtml-mode hilit-mode-enable-list)))) | |
3130 (yahtml-font-lock-set-default-keywords))) | |
3131 | |
73 | 3132 (defun yahtml-font-lock-recenter (&optional arg) |
3133 (interactive "P") | |
3134 (font-lock-mode -1) ;is stupid, but sure. | |
3135 (font-lock-mode 1)) | |
3136 | |
330 | 3137 ;;; |
3138 ;; Drag-n-Drop | |
3139 ;;; | |
3140 (defun yahtml-dnd-handler (uri action) | |
3141 "DnD handler for yahtml mode | |
3142 Convert image URI to img-src and others to a-href." | |
3143 (let*((file (dnd-get-local-file-name uri)) | |
3144 (path (if file (file-relative-name file) uri)) | |
3145 (case-fold-search t) | |
3146 (geom "")) | |
3147 (cond | |
3148 ((memq action '(copy link move private)) | |
3149 (cond | |
3150 ((string-match "\\.\\(jpe?g\\|png\\|gif\\|bmp\\|tiff?\\)$" path) | |
3151 (if file | |
3152 (setq geom (yahtml-get-image-info path) | |
3153 geom (if (car geom) | |
3154 (apply 'format " width=\"%s\" height=\"%s\"" geom) | |
3155 ""))) | |
3156 (insert (format "<img src=\"%s\" alt=\"%s\"%s>" | |
3157 path (file-name-nondirectory path) geom))) | |
3158 | |
3159 (t (insert (format "<a href=\"%s\"></a>" path)) | |
3160 (forward-char -4)))) | |
3161 (t (message "No handler for action `%s'" action)))) | |
3162 action) | |
3163 | |
68 | 3164 (run-hooks 'yahtml-load-hook) |
54 | 3165 (provide 'yahtml) |
3166 | |
3167 ; Local variables: | |
3168 ; fill-prefix: ";;; " | |
3169 ; paragraph-start: "^$\\|\\|;;;$" | |
3170 ; paragraph-separate: "^$\\|\\|;;;$" | |
80 | 3171 ; coding: sjis |
54 | 3172 ; End: |