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