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