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