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