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