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