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