Mercurial > hgrepos > hgweb.cgi > yatex
comparison yahtml.el @ 64:36a48185b95a
Changes are listed in yatex.new.
Major one is supporing GNU Emacs20 and XEmacs.
author | yuuji |
---|---|
date | Tue, 16 Dec 1997 13:28:38 +0000 |
parents | b9f753846b6b |
children | 0eb6997bee16 |
comparison
equal
deleted
inserted
replaced
63:6ad4a2399731 | 64:36a48185b95a |
---|---|
1 ;;; -*- Emacs-Lisp -*- | 1 ;;; -*- Emacs-Lisp -*- |
2 ;;; (c ) 1994-1997 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] | 2 ;;; (c ) 1994-1997 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] |
3 ;;; Last modified Mon Apr 7 16:58:32 1997 on crx | 3 ;;; Last modified Tue Dec 16 21:10:05 1997 on crx |
4 ;;; $Id$ | 4 ;;; $Id$ |
5 | 5 |
6 ;;;[Installation] | 6 ;;;[Installation] |
7 ;;; | 7 ;;; |
8 ;;; First, you have to install YaTeX and make sure it works fine. Then | 8 ;;; First, you have to install YaTeX and make sure it works fine. Then |
16 ;;; (setq yahtml-path-url-alist | 16 ;;; (setq yahtml-path-url-alist |
17 ;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") | 17 ;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") |
18 ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) | 18 ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) |
19 ;;; ;Write correspondence alist from ABSOLUTE unix path name to URL path. | 19 ;;; ;Write correspondence alist from ABSOLUTE unix path name to URL path. |
20 ;;; | 20 ;;; |
21 ;;;[インストール方法] | |
22 ;;; | |
23 ;;; yahtml.el, yatexlib.el, yatexprc.el を load-path の通ったディレクト | |
24 ;;; リにインストールしてください。その後、以下を参考に ~/.emacs に設定を | |
25 ;;; 追加して下さい。 | |
26 ;;; | |
27 ;;; (setq auto-mode-alist | |
28 ;;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) | |
29 ;;; (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) | |
30 ;;; (setq yahtml-www-browser "netscape") | |
31 ;;; ;お気に入りのブラウザを書いて下さい。netscapeが便利です。 | |
32 ;;; (setq yahtml-path-url-alist | |
33 ;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") | |
34 ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) | |
35 ;;; ;UNIXの絶対パスと対応するURLのリストを書いて下さい。 | |
36 ;;; | |
21 ;;;[Commentary] | 37 ;;;[Commentary] |
22 ;;; | 38 ;;; |
23 ;;; It is assumed you are already familiar with YaTeX. The following | 39 ;;; It is assumed you are already familiar with YaTeX. The following |
24 ;;; completing featureas are available: ([prefix] means `C-c' by default) | 40 ;;; completing featureas are available: ([prefix] means `C-c' by default) |
25 ;;; | 41 ;;; |
27 ;;; normally requires closing tag `</H1> | 43 ;;; normally requires closing tag `</H1> |
28 ;;; <a href=foo> ... </a> is also classified into | 44 ;;; <a href=foo> ... </a> is also classified into |
29 ;;; this group | 45 ;;; this group |
30 ;;; When input `href=...', you can complete file | 46 ;;; When input `href=...', you can complete file |
31 ;;; name or label(href="#foo") by typing TAB. | 47 ;;; name or label(href="#foo") by typing TAB. |
32 ;;; * [prefix] s Complete declarative notations such as | |
33 ;;; `<img src="foo.gif">' | |
34 ;;; `<input name="var" ...>' | |
35 ;;; * [prefix] l Complete typeface-changing commands such as | 48 ;;; * [prefix] l Complete typeface-changing commands such as |
36 ;;; `<i> ... </i>' or `<samp> ... </samp>' | 49 ;;; `<i> ... </i>' or `<samp> ... </samp>' |
37 ;;; This completion can be used to make in-line | 50 ;;; This completion can be used to make in-line |
38 ;;; tags which is normally completed with [prefix] b. | 51 ;;; tags which is normally completed with [prefix] b. |
52 ;;; * [prefix] s Complete declarative notations such as | |
53 ;;; `<img src="foo.gif">' | |
54 ;;; `<input name="var" ...>' | |
39 ;;; * [prefix] m Complete single commands such as | 55 ;;; * [prefix] m Complete single commands such as |
40 ;;; `<br>' or `<hr> or <li>...' | 56 ;;; `<br>' or `<hr> or <li>...' |
57 ;;; * [prefix] p Insert <p></p> on the point | |
41 ;;; * M-RET Intelligent newline; if current TAG is one of | 58 ;;; * M-RET Intelligent newline; if current TAG is one of |
42 ;;; ul, ol, or dl. insert newline and <li> or | 59 ;;; ul, ol, or dl. insert newline and <li> or |
43 ;;; <dt> or <dd> suitable for current condition. | 60 ;;; <dt> or <dd> suitable for current condition. |
44 ;;; * menu-bar yahtml Complete all by selecting a menu item (Though I | 61 ;;; * menu-bar yahtml Complete all by selecting a menu item (Though I |
45 ;;; hate menu, this is most useful) | 62 ;;; hate menu, this is most useful) |
57 ;;; variable yahtml-www-browser. Recommended value | 74 ;;; variable yahtml-www-browser. Recommended value |
58 ;;; is "netscape") | 75 ;;; is "netscape") |
59 ;;; * [prefix] a YaTeX's accent mark's equivalent of yahtml. | 76 ;;; * [prefix] a YaTeX's accent mark's equivalent of yahtml. |
60 ;;; This function can input $lt, $gt or so. | 77 ;;; This function can input $lt, $gt or so. |
61 ;;; | 78 ;;; |
62 | 79 ;;;[キーの説明] |
63 | 80 ;;; |
64 (require 'yatex) | 81 ;;; 以下の説明において、特にカスタマイズをしていない限り、[prefix] は |
82 ;;; C-c キーを意味します。 | |
83 ;;; | |
84 ;;; * [prefix] b X `</H1>' といった終了タグが必要となる`H1'のよう | |
85 ;;; な環境を補完入力します。<a href=foo> ... </a> | |
86 ;;; もこのグループです。 | |
87 ;;; `href=...' と入力した後、TABキーを押すことで、 | |
88 ;;; ファイル名や (href="#foo") のようなラベルも補完 | |
89 ;;; できます。 | |
90 ;;; * [prefix] s 以下のような宣言の補完を行います。 | |
91 ;;; `<img src="foo.gif">' | |
92 ;;; `<input name="var" ...>' | |
93 ;;; * [prefix] l `<i> ... </i>' や `<samp> ... </samp>' のよう | |
94 ;;; なテキストスタイル指定のタグを補完します。 | |
95 ;;; この補完機能は通常 [prefix] b で補完できるものを | |
96 ;;; 一行内で書きたいときにも用いることが出来ます。 | |
97 ;;; * [prefix] m `<br>' や `<hr> '、`<li>' 等の単体タグの補完 | |
98 ;;; を行います。 | |
99 ;;; * [prefix] p カーソル位置に<p></p>を挿入します。 | |
100 ;;; * M-RET おまかせ改行; もしul、ol、dl等のタグ(リスト)を | |
101 ;;; 使っている場合に、環境に合わせて改行と <li>、 | |
102 ;;; <dt>、<dd>を入力します。 | |
103 ;;; * menu-bar yahtml 選択したアイテムをメニューより補完できます。 | |
104 ;;; (私はメニューが嫌いなんですが、htmlに関してはメ | |
105 ;;; ニューは一番ありがたいかも) | |
106 ;;; * [prefix] g 対応するタグ、<dl> <-> </dl> や href="xxx" の | |
107 ;;; ような TAG にジャンプします。 | |
108 ;;; <img src=...> の場合はイメージビューワを呼び出 | |
109 ;;; します。href=hoge.html の場合はhoge.htmlに飛びま | |
110 ;;; す。 | |
111 ;;; * [prefix] k ポイント上の HTML タグを消去します。 | |
112 ;;; もし universal-argument を付けた場合(C-uを先に押 | |
113 ;;; す)HTMLタグで囲まれた内容も同時に消去します。 | |
114 ;;; * [prefix] c ポイント上のタグを変更します。 | |
115 ;;; `href="xxx"'の上で [prefix] c を利用した場合は、 | |
116 ;;; 参照しているリンクを補完機能を使いながら変更で | |
117 ;;; きます。 | |
118 ;;; * [prefix] t j カレントファイルに対して jweblint を呼び出しま | |
119 ;;; す。 | |
120 ;;; * [prefix] t p WWW ブラウザでカレントファイルを表示します。 | |
121 ;;; (lisp変数 yahtml-www-browser の設定をお忘れな | |
122 ;;; く。お推めは "netscape" で、ねすけの場合既にねす | |
123 ;;; けが起動されていた場合そのねすけに Reload 命令を | |
124 ;;; 送るという芸当が出来ます。ただし今のところX版の | |
125 ;;; ねすけちゃんだけ) | |
126 ;;; * [prefix] a YaTeX のアクセント記号補完と同じです。 | |
127 ;;; < > 等が入力できます。 | |
128 ;;; | |
129 ;;; [謝辞] | |
130 ;;; | |
131 ;;; fj野鳥の会の皆さんには貴重な助言を頂きました。また、下に示す方々には | |
132 ;;; 特に大きな協力を頂きました。あわせてここに感謝申し上げます。 | |
133 ;;; | |
134 ;;; * 横田和也さん(マツダ) | |
135 ;;; マニュアルの和訳をして頂きました。 | |
136 ;;; * 吉田尚志さん(NTT Data) | |
137 ;;; Mule for Win32 での動作のさせ方を教えて頂きました。 | |
138 ;;; (というかほとんどやってもらった ^^;) | |
139 ;;; | |
140 | |
141 | |
142 ;(require 'yatex) | |
143 (require 'yatexlib) | |
65 ;;; --- customizable variable starts here --- | 144 ;;; --- customizable variable starts here --- |
145 (defvar yahtml-prefix "\C-c" | |
146 "*Prefix key stroke of yahtml functions.") | |
66 (defvar yahtml-image-viewer "xv" "*Image viewer program") | 147 (defvar yahtml-image-viewer "xv" "*Image viewer program") |
67 (defvar yahtml-www-browser "netscape" | 148 (defvar yahtml-www-browser "netscape" |
68 "*WWW Browser command") | 149 "*WWW Browser command") |
69 (defvar yahtml-kanji-code 2 | 150 (defvar yahtml-kanji-code 2 |
70 "Kanji coding system of html file; 1=sjis, 2=jis, 3=euc") | 151 "*Kanji coding system number of html file; 1=sjis, 2=jis, 3=euc") |
152 (defvar yahtml-coding-system | |
153 (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist)) | |
154 "Kanji coding system") | |
155 (defvar yahtml-fill-column 72 "*fill culumn used for yahtml-mode") | |
156 (defvar yahtml-fill-prefix nil "*fill prefix for yahtml-mode") | |
157 | |
71 ;;(defvar yahtml-www-server "www" "*Host name of your domain's WWW server") | 158 ;;(defvar yahtml-www-server "www" "*Host name of your domain's WWW server") |
72 (defvar yahtml-path-url-alist nil | 159 (defvar yahtml-path-url-alist nil |
73 "*Alist of unix path name vs. URL name of WWW server. | 160 "*Alist of unix path name vs. URL name of WWW server. |
74 Ex. | 161 Ex. |
75 '((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") | 162 '((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") |
76 (\"/usr/home/yuuji/darts/http\" . \"http://inspire.comp.ae.keio.ac.jp/~darts\"))") | 163 (\"/usr/home/yuuji/darts/http\" . \"http://darts.comp.ae.keio.ac.jp/~darts\"))") |
77 (defvar yahtml-directory-index "index.html" | 164 (defvar yahtml-directory-index "index.html" |
78 "*Directory index file name; | 165 "*Directory index file name; |
79 Consult your site's WWW administrator.") | 166 Consult your site's WWW administrator.") |
80 | 167 |
81 (defvar yahtml-environment-indent YaTeX-environment-indent | 168 (defvar yahtml-environment-indent 1 |
82 "*Indentation depth of HTML's listing environment") | 169 "*Indentation depth of HTML's listing environment") |
170 | |
171 (defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) YaTeX-emacs-20) | |
172 "Whether yatex mode is running on Japanese environment or not.") | |
83 | 173 |
84 (defvar yahtml-lint-program (if YaTeX-japan "jweblint" "weblint") | 174 (defvar yahtml-lint-program (if YaTeX-japan "jweblint" "weblint") |
85 "*Program name to lint HTML file") | 175 "*Program name to lint HTML file") |
86 (defvar yahtml-hate-too-deep-indentation nil | 176 (defvar yahtml-hate-too-deep-indentation nil |
87 "*Non-nil for this variable suppress deep indentation in listing environments.") | 177 "*Non-nil for this variable suppress deep indentation in listing environments.") |
88 | 178 |
179 (defvar yahtml-always-/p nil | |
180 "*Those who always use <p> with </p> set this to t.") | |
181 | |
182 (defvar yahtml-p-prefered-env-regexp "^\\(body\\|dl\\)" | |
183 "*Regexp of envs where paragraphed sentences are prefered.") | |
184 | |
185 (defvar yahtml-template-file "~/http/template.html" | |
186 "*Template HTML file. It'll be inserted to empty file.") | |
187 | |
89 ;;; --- customizable variable ends here --- | 188 ;;; --- customizable variable ends here --- |
90 | |
91 (defvar yahtml-prefix-map nil) | 189 (defvar yahtml-prefix-map nil) |
92 (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.") | 190 (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.") |
93 (defvar yahtml-lint-buffer-map nil "Keymap used in lint buffer.") | 191 (defvar yahtml-lint-buffer-map nil "Keymap used in lint buffer.") |
94 (defvar yahtml-shell-command-option | 192 (defvar yahtml-shell-command-option |
95 (or (and (boundp 'shell-command-option) shell-command-option) | 193 (or (and (boundp 'shell-command-option) shell-command-option) |
119 | 217 |
120 | 218 |
121 (if yahtml-mode-map nil | 219 (if yahtml-mode-map nil |
122 (setq yahtml-mode-map (make-sparse-keymap) | 220 (setq yahtml-mode-map (make-sparse-keymap) |
123 yahtml-prefix-map (make-sparse-keymap)) | 221 yahtml-prefix-map (make-sparse-keymap)) |
124 (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map) | 222 (define-key yahtml-mode-map yahtml-prefix yahtml-prefix-map) |
125 (define-key yahtml-mode-map "\M-\C-@" 'yahtml-mark-begend) | 223 (define-key yahtml-mode-map "\M-\C-@" 'yahtml-mark-begend) |
126 (if (and (boundp 'window-system) (eq window-system 'x) YaTeX-emacs-19) | 224 (if (and (boundp 'window-system) (eq window-system 'x) YaTeX-emacs-19) |
127 (define-key yahtml-mode-map [?\M-\C- ] 'yahtml-mark-begend)) | 225 (define-key yahtml-mode-map [?\M-\C- ] 'yahtml-mark-begend)) |
128 (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) | 226 (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment) |
129 (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment) | 227 (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment) |
130 (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline) | 228 (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline) |
131 (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line) | 229 (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line) |
132 (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map) | |
133 (let ((map yahtml-prefix-map)) | 230 (let ((map yahtml-prefix-map)) |
134 (YaTeX-define-key "^" 'yahtml-visit-main map) | 231 (YaTeX-define-key "^" 'yahtml-visit-main map) |
135 (YaTeX-define-key "4^" 'yahtml-visit-main-other-window map) | 232 (YaTeX-define-key "4^" 'yahtml-visit-main-other-window map) |
136 (YaTeX-define-key "4g" 'yahtml-goto-corresponding-*-other-window map) | 233 (YaTeX-define-key "4g" 'yahtml-goto-corresponding-*-other-window map) |
137 (YaTeX-define-key "44" 'YaTeX-switch-to-window map) | 234 (YaTeX-define-key "44" 'YaTeX-switch-to-window map) |
148 (YaTeX-define-key "l" 'yahtml-insert-tag map) | 245 (YaTeX-define-key "l" 'yahtml-insert-tag map) |
149 (YaTeX-define-key "L" 'yahtml-insert-tag-region map) | 246 (YaTeX-define-key "L" 'yahtml-insert-tag-region map) |
150 (YaTeX-define-key "m" 'yahtml-insert-single map) | 247 (YaTeX-define-key "m" 'yahtml-insert-single map) |
151 (YaTeX-define-key "n" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<BR>" "<br>"))) map) | 248 (YaTeX-define-key "n" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<BR>" "<br>"))) map) |
152 (YaTeX-define-key "-" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<HR>" "<hr>") "\n")) map) | 249 (YaTeX-define-key "-" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<HR>" "<hr>") "\n")) map) |
250 (YaTeX-define-key "p" 'yahtml-insert-p map) | |
153 (if YaTeX-no-begend-shortcut | 251 (if YaTeX-no-begend-shortcut |
154 (progn | 252 (progn |
155 (YaTeX-define-key "B" 'yahtml-insert-begend-region map) | 253 (YaTeX-define-key "B" 'yahtml-insert-begend-region map) |
156 (YaTeX-define-key "b" 'yahtml-insert-begend map)) | 254 (YaTeX-define-key "b" 'yahtml-insert-begend map)) |
157 (yahtml-define-begend-key "bh" "html" map) | 255 (yahtml-define-begend-key "bh" "html" map) |
195 (defvar yahtml-paragraph-separate | 293 (defvar yahtml-paragraph-separate |
196 (concat | 294 (concat |
197 "^$\\|<!--\\|^[ \t]*</?\\(h[1-6]\\|p\\|[bhtd][ldt]\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\|table\\|center\\|blockquote\\|!--\\)\\b") | 295 "^$\\|<!--\\|^[ \t]*</?\\(h[1-6]\\|p\\|[bhtd][ldt]\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\|table\\|center\\|blockquote\\|!--\\)\\b") |
198 "*Regexp of html paragraph separater") | 296 "*Regexp of html paragraph separater") |
199 (defvar yahtml-syntax-table nil | 297 (defvar yahtml-syntax-table nil |
200 "*Syntax table for typesetting buffer") | 298 "*Syntax table for yahtml-mode") |
201 | 299 |
202 (if yahtml-syntax-table nil | 300 (if yahtml-syntax-table nil |
203 (setq yahtml-syntax-table | 301 (setq yahtml-syntax-table |
204 (make-syntax-table (standard-syntax-table))) | 302 (make-syntax-table (standard-syntax-table))) |
205 (modify-syntax-entry ?\< "(>" yahtml-syntax-table) | 303 (modify-syntax-entry ?\< "(>" yahtml-syntax-table) |
212 ;;; Completion tables for `form' | 310 ;;; Completion tables for `form' |
213 (defvar yahtml-form-table | 311 (defvar yahtml-form-table |
214 '(("img") ("input"))) | 312 '(("img") ("input"))) |
215 (defvar yahtml-user-form-table nil) | 313 (defvar yahtml-user-form-table nil) |
216 (defvar yahtml-tmp-form-table nil) | 314 (defvar yahtml-tmp-form-table nil) |
315 (defvar yahtml-last-form "img") | |
217 | 316 |
218 (defvar yahtml-env-table | 317 (defvar yahtml-env-table |
219 '(("html") ("head") ("title") ("body") ("dl") ("ul") ("ol") ("pre") | 318 '(("html") ("head") ("title") ("body") ("dl") ("ul") ("ol") ("pre") |
220 ("a") ("form") ("select") ("center") ("textarea") ("blockquote") | 319 ("a") ("form") ("select") ("center") ("textarea") ("blockquote") |
221 ("OrderedList" . "ol") | 320 ("OrderedList" . "ol") |
222 ("UnorderedList" . "ul") | 321 ("UnorderedList" . "ul") |
223 ("DefinitionList" . "dl") | 322 ("DefinitionList" . "dl") |
224 ("Preformatted" . "pre") | 323 ("Preformatted" . "pre") |
225 ("table") ("tr") ("th") ("td") | 324 ("table") ("tr") ("th") ("td") |
226 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") | 325 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") |
227 ("p"))) | 326 ;; ("p") ;This makes indentation screwed up! |
327 )) | |
228 | 328 |
229 (defvar yahtml-itemizing-regexp | 329 (defvar yahtml-itemizing-regexp |
230 "\\(ul\\|ul\\|dl\\)" | 330 "\\(ul\\|ul\\|dl\\)" |
231 "Regexp of itemizing forms") | 331 "Regexp of itemizing forms") |
232 | 332 |
233 (defvar yahtml-user-env-table nil) | 333 (defvar yahtml-user-env-table nil) |
234 (defvar yahtml-tmp-env-table nil) | 334 (defvar yahtml-tmp-env-table nil) |
235 | 335 |
236 ;;; Completion tables for typeface designator | 336 ;;; Completion tables for typeface designator |
337 (and yahtml-always-/p | |
338 (or (assoc "p" yahtml-env-table) | |
339 (setq yahtml-env-table (cons '("p") yahtml-env-table)))) | |
340 | |
237 (defvar yahtml-typeface-table | 341 (defvar yahtml-typeface-table |
238 (append | 342 (append |
239 '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") | 343 '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") |
240 ("strong") ("var") ("b") ("i") ("tt") ("u") ("address")) | 344 ("strong") ("var") ("b") ("i") ("tt") ("u") ("address") ("font")) |
241 yahtml-env-table) | 345 yahtml-env-table) |
242 "Default completion table of typeface designator") | 346 "Default completion table of typeface designator") |
243 (defvar yahtml-user-typeface-table nil) | 347 (defvar yahtml-user-typeface-table nil) |
244 (defvar yahtml-tmp-typeface-table nil) | 348 (defvar yahtml-tmp-typeface-table nil) |
245 (defvar yahtml-last-typeface-cmd "address") | 349 (defvar yahtml-last-typeface-cmd "a") |
246 | 350 |
247 (defvar yahtml-single-cmd-table | 351 (defvar yahtml-single-cmd-table |
248 '(("hr") ("br") ("option") ("p") | 352 '(("hr") ("br") ("option") ("p") |
249 ("HorizontalLine" . "hr") | 353 ("HorizontalLine" . "hr") |
250 ("BreakLine" . "br") | 354 ("BreakLine" . "br") |
267 (concat | 371 (concat |
268 "\\<\\(" | 372 "\\<\\(" |
269 (mapconcat (function (lambda (x) (car x))) yahtml-typeface-table "\\|") | 373 (mapconcat (function (lambda (x) (car x))) yahtml-typeface-table "\\|") |
270 "\\)\\b") | 374 "\\)\\b") |
271 "Regexp of structure beginning.") | 375 "Regexp of structure beginning.") |
376 (or (assoc "p" yahtml-env-table) | |
377 (setq yahtml-env-table (cons '("p") yahtml-env-table))) | |
272 | 378 |
273 (defun yahtml-mode () | 379 (defun yahtml-mode () |
274 (interactive) | 380 (interactive) |
275 (yatex-mode) | |
276 (cond | 381 (cond |
277 ((boundp 'MULE) | 382 ((and YaTeX-emacs-20 (fboundp 'coding-system-equal)) |
278 (set-file-coding-system | 383 (if t (or (coding-system-equal |
279 (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist)))) | 384 yahtml-coding-system buffer-file-coding-system) |
385 (set-buffer-file-coding-system yahtml-coding-system)) | |
386 ;;^v which is better? | |
387 (let ((bmp (buffer-modified-p))) | |
388 (set-buffer-file-coding-system yahtml-coding-system) | |
389 (set-buffer-modified-p bmp)))) | |
390 ((featurep 'mule) | |
391 (set-file-coding-system yahtml-coding-system)) | |
280 ((boundp 'NEMACS) | 392 ((boundp 'NEMACS) |
281 (make-local-variable 'kanji-fileio-code) | 393 (make-local-variable 'kanji-fileio-code) |
282 (setq kanji-fileio-code yahtml-kanji-code))) | 394 (setq kanji-fileio-code yahtml-kanji-code))) |
283 (setq major-mode 'yahtml-mode | 395 (setq major-mode 'yahtml-mode |
284 mode-name "yahtml") | 396 mode-name "yahtml") |
285 (make-local-variable 'YaTeX-kanji-code) | 397 (mapcar |
286 (make-local-variable 'YaTeX-ec) (setq YaTeX-ec "") | 398 (function (lambda (x) |
287 (make-local-variable 'YaTeX-struct-begin) | 399 (make-local-variable (car x)) |
288 (setq YaTeX-struct-begin "<%1%2") | 400 (set (car x) (if (and (symbolp (cdr x)) |
289 (make-local-variable 'YaTeX-struct-end) (setq YaTeX-struct-end "</%1>") | 401 (boundp (cdr x))) |
290 (make-local-variable 'YaTeX-struct-name-regexp) | 402 (symbol-value (cdr x)) |
291 (setq YaTeX-struct-name-regexp yahtml-struct-name-regexp) | 403 (cdr x))))) |
292 (make-local-variable 'YaTeX-prefix-map) | 404 '((YaTeX-ec . "") |
293 (make-local-variable 'YaTeX-command-token-regexp) | 405 (YaTeX-struct-begin . "<%1%2") |
294 (setq YaTeX-command-token-regexp yahtml-command-regexp) | 406 (YaTeX-struct-end . "</%1>") |
295 (make-local-variable 'YaTeX-comment-prefix) | 407 (YaTeX-struct-name-regexp . yahtml-struct-name-regexp) |
296 (setq YaTeX-comment-prefix "<!--") | 408 (YaTeX-comment-prefix . "<!--") |
297 ;;(make-local-variable 'YaTeX-environment-indent) | 409 (YaTeX-coding-system . yahtml-coding-system) |
298 ;;(setq YaTeX-environment-indent 0) | 410 (YaTeX-typesetting-mode-map . yahtml-lint-buffer-map) |
299 (make-local-variable 'fill-prefix) | 411 (fill-prefix . yahtml-fill-prefix) (fill-column . yahtml-fill-column) |
300 (setq fill-prefix nil) | 412 (paragraph-start . yahtml-paragraph-start) |
301 (make-local-variable 'paragraph-separate) | 413 (paragraph-separate . yahtml-paragraph-separate) |
302 (setq paragraph-start yahtml-paragraph-start | 414 (comment-start . "<!-- ") (comment-end . " -->") |
303 paragraph-separate yahtml-paragraph-separate) | 415 (comment-start-skip . comment-start) |
304 (make-local-variable 'comment-start) | 416 (indent-line-function . yahtml-indent-line))) |
305 (make-local-variable 'comment-end) | 417 |
306 (setq comment-start "<!-- " comment-end " -->") | |
307 (make-local-variable 'indent-line-function) | |
308 (setq indent-line-function 'yahtml-indent-line) | |
309 (make-local-variable 'YaTeX-item-regexp) | |
310 (setq YaTeX-item-regexp "<\\(li\\|d[td]\\)>") | |
311 (make-local-variable 'YaTeX-typesetting-mode-map) | |
312 (setq YaTeX-typesetting-mode-map yahtml-lint-buffer-map) | |
313 (set-syntax-table yahtml-syntax-table) | 418 (set-syntax-table yahtml-syntax-table) |
314 (use-local-map yahtml-mode-map) | 419 (use-local-map yahtml-mode-map) |
315 (run-hooks 'yahtml-mode-hook)) | 420 (YaTeX-read-user-completion-table) |
421 (turn-on-auto-fill) ;Sorry, this is prerequisite | |
422 (and (= 0 (buffer-size)) (file-exists-p yahtml-template-file) | |
423 (y-or-n-p (format "Insert %s?" yahtml-template-file)) | |
424 (insert-file-contents (expand-file-name yahtml-template-file))) | |
425 (run-hooks 'text-mode-hook 'yahtml-mode-hook)) | |
316 | 426 |
317 (defun yahtml-define-menu (keymap bindlist) | 427 (defun yahtml-define-menu (keymap bindlist) |
318 (mapcar | 428 (cond |
319 (function | 429 ((featurep 'xemacs) |
320 (lambda (bind) | 430 (let ((name (keymap-name (symbol-value keymap)))) |
321 (define-key keymap (vector (car bind)) (cdr bind)))) | 431 (set keymap nil) |
322 bindlist)) | 432 (mapcar |
433 (function | |
434 (lambda (bind) | |
435 (setq bind (cdr bind)) | |
436 (if (eq (car (cdr bind)) 'lambda) | |
437 (setcar (cdr bind) 'progn)) | |
438 (if (stringp (car (cdr bind))) | |
439 (set keymap (cons (cdr bind) (symbol-value keymap))) | |
440 (set keymap (cons (vector (car bind) (cdr bind) t) | |
441 (symbol-value keymap)))))) | |
442 bindlist) | |
443 (set keymap (cons name (symbol-value keymap))))) | |
444 (t | |
445 (mapcar | |
446 (function | |
447 (lambda (bind) | |
448 (define-key (symbol-value keymap) (vector (car bind)) (cdr bind)))) | |
449 bindlist)))) | |
323 | 450 |
324 (defvar yahtml-menu-map nil "Menu map of yahtml") | 451 (defvar yahtml-menu-map nil "Menu map of yahtml") |
325 (defvar yahtml-menu-map-sectioning nil "Menu map of yahtml(sectioning)") | 452 (defvar yahtml-menu-map-sectioning nil "Menu map of yahtml(sectioning)") |
326 (defvar yahtml-menu-map-listing nil "Menu map of yahtml(listing)") | 453 (defvar yahtml-menu-map-listing nil "Menu map of yahtml(listing)") |
327 (defvar yahtml-menu-map-logical nil "Menu map of yahtml(logical tags)") | 454 (defvar yahtml-menu-map-logical nil "Menu map of yahtml(logical tags)") |
328 (defvar yahtml-menu-map-typeface nil "Menu map of yahtml(typeface tags)") | 455 (defvar yahtml-menu-map-typeface nil "Menu map of yahtml(typeface tags)") |
329 | 456 |
330 ;;; Variables for mosaic url history | 457 ;;; Variables for mosaic url history |
331 (defvar yahtml-urls nil "Alist of global history") | 458 (defvar yahtml-urls nil "Alist of global history") |
332 (defvar yahtml-url-history-file "~/.mosaic-global-history" | 459 (defvar yahtml-urls-private nil) |
333 "File name of url history") | 460 (defvar yahtml-urls-local nil) |
334 | 461 |
335 (cond | 462 (cond |
336 ((and YaTeX-emacs-19 (null yahtml-menu-map)) | 463 ((and YaTeX-emacs-19 (null yahtml-menu-map)) |
337 (setq yahtml-menu-map (make-sparse-keymap "yahtml menu")) | 464 (setq yahtml-menu-map (make-sparse-keymap "yahtml")) |
338 (setq yahtml-menu-map-sectioning (make-sparse-keymap "sectioning menu")) | 465 (setq yahtml-menu-map-sectioning (make-sparse-keymap "sectioning menu")) |
339 (yahtml-define-menu | 466 (YaTeX-define-menu |
340 yahtml-menu-map-sectioning | 467 'yahtml-menu-map-sectioning |
341 (nreverse | 468 (nreverse |
342 '((1 "H1" . (lambda () (interactive) (yahtml-insert-begend nil "H1"))) | 469 '((1 "H1" . (lambda () (interactive) (yahtml-insert-begend nil "H1"))) |
343 (2 "H2" . (lambda () (interactive) (yahtml-insert-begend nil "H2"))) | 470 (2 "H2" . (lambda () (interactive) (yahtml-insert-begend nil "H2"))) |
344 (3 "H3" . (lambda () (interactive) (yahtml-insert-begend nil "H3"))) | 471 (3 "H3" . (lambda () (interactive) (yahtml-insert-begend nil "H3"))) |
345 (4 "H4" . (lambda () (interactive) (yahtml-insert-begend nil "H4"))) | 472 (4 "H4" . (lambda () (interactive) (yahtml-insert-begend nil "H4"))) |
346 (5 "H5" . (lambda () (interactive) (yahtml-insert-begend nil "H5"))) | 473 (5 "H5" . (lambda () (interactive) (yahtml-insert-begend nil "H5"))) |
347 (6 "H6" . (lambda () (interactive) (yahtml-insert-begend nil "H6"))) | 474 (6 "H6" . (lambda () (interactive) (yahtml-insert-begend nil "H6"))) |
348 ))) | 475 ))) |
349 (setq yahtml-menu-map-logical (make-sparse-keymap "logical tags")) | 476 (setq yahtml-menu-map-logical (make-sparse-keymap "logical tags")) |
350 (yahtml-define-menu | 477 (YaTeX-define-menu |
351 yahtml-menu-map-logical | 478 'yahtml-menu-map-logical |
352 (nreverse | 479 (nreverse |
353 '((em "Embolden" . | 480 '((em "Embolden" . |
354 (lambda () (interactive) (yahtml-insert-tag nil "EM"))) | 481 (lambda () (interactive) (yahtml-insert-tag nil "EM"))) |
355 (dfn "Define a word" . | 482 (dfn "Define a word" . |
356 (lambda () (interactive) (yahtml-insert-tag nil "DFN"))) | 483 (lambda () (interactive) (yahtml-insert-tag nil "DFN"))) |
366 (lambda () (interactive) (yahtml-insert-tag nil "STRONG"))) | 493 (lambda () (interactive) (yahtml-insert-tag nil "STRONG"))) |
367 (VAR "Variable notation" . | 494 (VAR "Variable notation" . |
368 (lambda () (interactive) (yahtml-insert-tag nil "VAR"))) | 495 (lambda () (interactive) (yahtml-insert-tag nil "VAR"))) |
369 ))) | 496 ))) |
370 (setq yahtml-menu-map-typeface (make-sparse-keymap "typeface tags")) | 497 (setq yahtml-menu-map-typeface (make-sparse-keymap "typeface tags")) |
371 (yahtml-define-menu | 498 (YaTeX-define-menu |
372 yahtml-menu-map-typeface | 499 'yahtml-menu-map-typeface |
373 (nreverse | 500 (nreverse |
374 '((b "Bold" . | 501 '((b "Bold" . |
375 (lambda () (interactive) (yahtml-insert-tag nil "B"))) | 502 (lambda () (interactive) (yahtml-insert-tag nil "B"))) |
376 (i "Italic" . | 503 (i "Italic" . |
377 (lambda () (interactive) (yahtml-insert-tag nil "I"))) | 504 (lambda () (interactive) (yahtml-insert-tag nil "I"))) |
379 (lambda () (interactive) (yahtml-insert-tag nil "TT"))) | 506 (lambda () (interactive) (yahtml-insert-tag nil "TT"))) |
380 (u "Underlined" . | 507 (u "Underlined" . |
381 (lambda () (interactive) (yahtml-insert-tag nil "U"))) | 508 (lambda () (interactive) (yahtml-insert-tag nil "U"))) |
382 ))) | 509 ))) |
383 (setq yahtml-menu-map-listing (make-sparse-keymap "listing")) | 510 (setq yahtml-menu-map-listing (make-sparse-keymap "listing")) |
384 (yahtml-define-menu | 511 (YaTeX-define-menu |
385 yahtml-menu-map-listing | 512 'yahtml-menu-map-listing |
386 (nreverse | 513 (nreverse |
387 '((ul "Unordered" . | 514 '((ul "Unordered" . |
388 (lambda () (interactive) (yahtml-insert-begend nil "UL"))) | 515 (lambda () (interactive) (yahtml-insert-begend nil "UL"))) |
389 (ol "Ordered" . | 516 (ol "Ordered" . |
390 (lambda () (interactive) (yahtml-insert-begend nil "OL"))) | 517 (lambda () (interactive) (yahtml-insert-begend nil "OL"))) |
391 (dl "Definition" . | 518 (dl "Definition" . |
392 (lambda () (interactive) (yahtml-insert-begend nil "DL"))) | 519 (lambda () (interactive) (yahtml-insert-begend nil "DL"))) |
393 ))) | 520 ))) |
394 (setq yahtml-menu-map-item (make-sparse-keymap "item")) | 521 (setq yahtml-menu-map-item (make-sparse-keymap "item")) |
395 (yahtml-define-menu | 522 (YaTeX-define-menu |
396 yahtml-menu-map-item | 523 'yahtml-menu-map-item |
397 (nreverse | 524 (nreverse |
398 '((li "Simple item" . | 525 '((li "Simple item" . |
399 (lambda () (interactive) (yahtml-insert-single "li"))) | 526 (lambda () (interactive) (yahtml-insert-single "li"))) |
400 (dt "Define term" . | 527 (dt "Define term" . |
401 (lambda () (interactive) (yahtml-insert-single "dt"))) | 528 (lambda () (interactive) (yahtml-insert-single "dt"))) |
406 (cons "yahtml" yahtml-menu-map)) | 533 (cons "yahtml" yahtml-menu-map)) |
407 (let ((keys (where-is-internal 'fill-paragraph global-map))) | 534 (let ((keys (where-is-internal 'fill-paragraph global-map))) |
408 (while keys | 535 (while keys |
409 (define-key yahtml-mode-map (car keys) 'yahtml-fill-paragraph) | 536 (define-key yahtml-mode-map (car keys) 'yahtml-fill-paragraph) |
410 (setq keys (cdr keys)))) | 537 (setq keys (cdr keys)))) |
411 (yahtml-define-menu | 538 (YaTeX-define-menu |
412 yahtml-menu-map | 539 'yahtml-menu-map |
413 (nreverse | 540 (nreverse |
414 (list | 541 (list |
415 (cons (list 'sect "Sectioning") | 542 (cons (list 'sect "Sectioning") |
416 (cons "sectioning" yahtml-menu-map-sectioning)) | 543 (cons "sectioning" yahtml-menu-map-sectioning)) |
417 (cons (list 'list "Listing") | 544 (cons (list 'list "Listing") |
421 (cons (list 'logi "Logical tags") | 548 (cons (list 'logi "Logical tags") |
422 (cons "logical" yahtml-menu-map-logical)) | 549 (cons "logical" yahtml-menu-map-logical)) |
423 (cons (list 'type "Typeface tags") | 550 (cons (list 'type "Typeface tags") |
424 (cons "typeface" yahtml-menu-map-typeface)) | 551 (cons "typeface" yahtml-menu-map-typeface)) |
425 ))) | 552 ))) |
553 (if (featurep 'xemacs) | |
554 (add-hook 'yahtml-mode-hook | |
555 '(lambda () | |
556 (or (assoc "yahtml" current-menubar) | |
557 (progn | |
558 (set-buffer-menubar (copy-sequence current-menubar)) | |
559 (add-submenu nil yahtml-menu-map)))))) | |
426 )) | 560 )) |
427 | |
428 (defun yahtml-collect-url-history () | |
429 "Collect urls from global history file." | |
430 (interactive) | |
431 (save-excursion | |
432 (set-buffer | |
433 (find-file-noselect (expand-file-name yahtml-url-history-file))) | |
434 (goto-char (point-min)) | |
435 (setq yahtml-urls) | |
436 (message "Collecting global history...") | |
437 (while (re-search-forward "^[A-Za-z]+:" nil t) | |
438 (setq yahtml-urls | |
439 (cons (list | |
440 (buffer-substring | |
441 (progn (beginning-of-line) (point)) | |
442 (progn (skip-chars-forward "^ ") (point)))) | |
443 yahtml-urls))) | |
444 (message "Collecting global history...Done"))) | |
445 | 561 |
446 ;;; ----------- Completion ---------- | 562 ;;; ----------- Completion ---------- |
447 (defvar yahtml-last-begend "html") | 563 (defvar yahtml-last-begend "html") |
448 (defun yahtml-insert-begend (&optional region env) | 564 (defun yahtml-insert-begend (&optional region env) |
449 "Insert <cmd> ... </cmd>." | 565 "Insert <cmd> ... </cmd>." |
474 (insert (format "<%s%s>" cmd (yahtml-addin cmd))) | 590 (insert (format "<%s%s>" cmd (yahtml-addin cmd))) |
475 (save-excursion | 591 (save-excursion |
476 (insert "\n") | 592 (insert "\n") |
477 (indent-to-column cc) | 593 (indent-to-column cc) |
478 (insert (format "</%s>" cmd))) | 594 (insert (format "</%s>" cmd))) |
479 (yahtml-intelligent-newline nil)))) | 595 (if (string-match "^a\\|p$" cmd) ;aとp決め打ちってのが美しくない… |
596 (newline) | |
597 (yahtml-intelligent-newline nil)) | |
598 (yahtml-indent-line)))) | |
480 | 599 |
481 (defun yahtml-insert-begend-region () | 600 (defun yahtml-insert-begend-region () |
482 "Call yahtml-insert-begend in the region mode." | 601 "Call yahtml-insert-begend in the region mode." |
483 (interactive) | 602 (interactive) |
484 (yahtml-insert-begend t)) | 603 (yahtml-insert-begend t)) |
489 (interactive) | 608 (interactive) |
490 (or form | 609 (or form |
491 (let ((completion-ignore-case t)) | 610 (let ((completion-ignore-case t)) |
492 (setq form | 611 (setq form |
493 (YaTeX-cplread-with-learning | 612 (YaTeX-cplread-with-learning |
494 "Form: " | 613 (format "Form(default %s): " yahtml-last-form) |
495 'yahtml-form-table 'yahtml-user-form-table | 614 'yahtml-form-table 'yahtml-user-form-table |
496 'yahtml-tmp-form-table)))) | 615 'yahtml-tmp-form-table)))) |
497 (let ((p (point)) q) | 616 (let ((p (point)) q) |
617 (if (string= form "") (setq form yahtml-last-form)) | |
618 (setq yahtml-last-form form) | |
498 (if yahtml-prefer-upcases (setq form (upcase form))) | 619 (if yahtml-prefer-upcases (setq form (upcase form))) |
499 (insert (format "<%s%s>" form (yahtml-addin form))) | 620 (insert (format "<%s%s>" form (yahtml-addin form))) |
500 ;;(indent-relative-maybe) | 621 ;;(indent-relative-maybe) |
501 (if (cdr (assoc form yahtml-form-table)) | 622 (if (cdr (assoc form yahtml-form-table)) |
502 (save-excursion (insert (format "</%s>" form)))) | 623 (save-excursion (insert (format "</%s>" form)))) |
507 "Check add-in function's existence and call it if exists." | 628 "Check add-in function's existence and call it if exists." |
508 (let ((addin (concat "yahtml:" (downcase form))) s) | 629 (let ((addin (concat "yahtml:" (downcase form))) s) |
509 (if (and (intern-soft addin) (fboundp (intern-soft addin)) | 630 (if (and (intern-soft addin) (fboundp (intern-soft addin)) |
510 (stringp (setq s (funcall (intern addin)))) | 631 (stringp (setq s (funcall (intern addin)))) |
511 (string< "" s)) | 632 (string< "" s)) |
512 (concat " " s) | 633 (if (eq (aref s 0) ? ) s (concat " " s)) |
513 ""))) | 634 ""))) |
514 | 635 |
515 | 636 |
516 (defvar yahtml-completing-buffer nil) | 637 (defvar yahtml-completing-buffer nil) |
517 (defun yahtml-collect-labels (&optional file) | 638 (defun yahtml-collect-labels (&optional file) |
526 (goto-char (point-min)) | 647 (goto-char (point-min)) |
527 (while (re-search-forward "<a\\b" nil t) | 648 (while (re-search-forward "<a\\b" nil t) |
528 (setq bound (match-end 0)) | 649 (setq bound (match-end 0)) |
529 (search-forward ">" nil t) | 650 (search-forward ">" nil t) |
530 (if (and (re-search-backward "\\(name\\|id\\)=" bound t) | 651 (if (and (re-search-backward "\\(name\\|id\\)=" bound t) |
531 (goto-char (match-end 0)) | 652 (progn |
532 (skip-chars-forward " \t\n") | 653 (goto-char (match-end 0)) |
533 (looking-at "\"?#?\\([^\">]+\\)\"?\\b")) | 654 (skip-chars-forward " \t\n") |
655 (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) | |
534 (setq list (cons | 656 (setq list (cons |
535 (list (concat "#" (YaTeX-match-string 1))) | 657 (list (concat "#" (YaTeX-match-string 1))) |
536 list)))) | 658 list)))) |
537 list))) | 659 list))) |
538 ) | 660 ) |
546 ) | 668 ) |
547 | 669 |
548 (defun yahtml-complete-url () | 670 (defun yahtml-complete-url () |
549 "Complete external URL from history or local file name." | 671 "Complete external URL from history or local file name." |
550 (interactive) | 672 (interactive) |
551 (let (initial i2 cmpl path dir file listfunc beg labels (p (point))) | 673 (let ((p (point)) initial i2 cmpl path dir file listfunc beg labels) |
552 (setq initial (buffer-string)) | 674 (setq initial (buffer-string)) |
553 (cond | 675 (cond |
554 ((string-match "^http:" initial) | 676 ((string-match "^http:" initial) |
555 (setq cmpl (try-completion initial yahtml-urls) | 677 (setq cmpl (try-completion initial yahtml-urls) |
556 listfunc (list 'lambda nil | 678 listfunc (list 'lambda nil |
569 (list 'all-completions | 691 (list 'all-completions |
570 initial (list 'quote labels))) | 692 initial (list 'quote labels))) |
571 beg (+ (point-min) beg))) | 693 beg (+ (point-min) beg))) |
572 (t | 694 (t |
573 (setq path (if (string-match "^/" initial) | 695 (setq path (if (string-match "^/" initial) |
574 (yahtml-url-to-path initial) | 696 (or (yahtml-url-to-path initial) initial) |
575 initial)) | 697 initial)) |
576 (setq dir (or (file-name-directory path) ".") | 698 (setq dir (or (file-name-directory path) ".") |
577 file (file-name-nondirectory path) | 699 file (file-name-nondirectory path) |
578 initial file | 700 initial file |
579 cmpl (file-name-completion file dir) | 701 cmpl (file-name-completion file dir) |
600 (insert " [Sole completion]")) | 722 (insert " [Sole completion]")) |
601 (delete-region p (point-max)))))))) | 723 (delete-region p (point-max)))))))) |
602 | 724 |
603 (defun yahtml:a () | 725 (defun yahtml:a () |
604 "Add-in function for <a>" | 726 "Add-in function for <a>" |
605 (let ((l yahtml-prefer-upcases)) | 727 (let ((href "")) |
606 (or yahtml-urls (yahtml-collect-url-history)) | 728 (setq yahtml-completing-buffer (current-buffer) |
607 (setq yahtml-completing-buffer (current-buffer)) | 729 href (read-from-minibuffer "href: " "" yahtml-url-completion-map) |
608 ; (concat "href=\"" | 730 ;; yahtml-urls-local is buffer-local, so we must put |
609 ; (completing-read "href: " yahtml-urls) | 731 ;; that into yahtml-urls here |
610 ; "\"") | 732 yahtml-urls (append yahtml-urls-private yahtml-urls-local)) |
611 (message "(H)ref (N)ame?") | 733 (prog1 |
612 (cond | 734 (concat (yahtml-make-optional-argument |
613 ((string-match "[nN]" (char-to-string (read-char))) | 735 "href" href) |
614 (concat (if l "NAME" "name") "=\"" (read-string "name: ") "\"")) | 736 (yahtml-make-optional-argument |
615 (t | 737 "name" (read-string "name: "))) |
616 (concat (if l "HREF" "href") "=\"" | 738 (if (and (string-match "^http://" href) |
617 (read-from-minibuffer "href: " "" yahtml-url-completion-map) | 739 (null (assoc href yahtml-urls))) |
618 "\""))))) | 740 (YaTeX-update-table |
741 (list href) | |
742 'yahtml-urls-private 'yahtml-urls-private 'yahtml-urls-local)) | |
743 ))) | |
619 | 744 |
620 (defvar yahtml-parameters-completion-alist | 745 (defvar yahtml-parameters-completion-alist |
621 '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center")) | 746 '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center")) |
622 ("src" . file) | 747 ("src" . file) |
623 ("method" ("POST") ("GET")))) | 748 ("method" ("POST") ("GET")))) |
633 (alist | 758 (alist |
634 (completing-read prompt alist)) | 759 (completing-read prompt alist)) |
635 (t | 760 (t |
636 (read-string prompt))))) | 761 (read-string prompt))))) |
637 | 762 |
638 | 763 (defun yahtml-make-optional-argument (opt arg) |
764 "Make optional argument string." | |
765 (if (string= "" arg) | |
766 "" | |
767 (concat " " (if yahtml-prefer-upcases (upcase opt) (downcase opt)) | |
768 "=\"" arg "\""))) | |
769 | |
770 (defun yahtml:body () | |
771 "Add-in function for <body>" | |
772 (let ((b (read-string "bgcolor=")) | |
773 (x (read-string "text color=")) | |
774 (l (read-string "link color=")) | |
775 (v (read-string "vlink color="))) | |
776 (concat | |
777 (yahtml-make-optional-argument "bgcolor" b) | |
778 (yahtml-make-optional-argument "text" x) | |
779 (yahtml-make-optional-argument "link" l) | |
780 (yahtml-make-optional-argument "vlink" v)))) | |
781 | |
782 | |
639 (defun yahtml:img () | 783 (defun yahtml:img () |
640 "Add-in function for <img>" | 784 "Add-in function for <img>" |
641 (or yahtml-urls (yahtml-collect-url-history)) | |
642 (let ((src (yahtml-read-parameter "src")) | 785 (let ((src (yahtml-read-parameter "src")) |
643 (alg (yahtml-read-parameter "align")) | 786 (alg (yahtml-read-parameter "align")) |
644 (alt (yahtml-read-parameter "alt")) | 787 (alt (yahtml-read-parameter "alt")) |
788 (brd (read-string "border=")) | |
645 (l yahtml-prefer-upcases)) | 789 (l yahtml-prefer-upcases)) |
646 (concat (if l "SRC" "src") "=\"" src "\"" | 790 (concat (if l "SRC" "src") "=\"" src "\"" |
647 (if (string< "" alg) | 791 (yahtml-make-optional-argument "align" alg) |
648 (concat " " (if l "ALIGN" "align") "=\"" alg "\"")) | 792 (yahtml-make-optional-argument "alt" alt) |
649 (if (string< "" alt) | 793 (yahtml-make-optional-argument "border" brd)))) |
650 (concat " " (if l "ALT" "alt") "=\"" alt "\""))))) | |
651 | 794 |
652 (defun yahtml:form () | 795 (defun yahtml:form () |
653 "Add-in function `form' input format" | 796 "Add-in function `form' input format" |
654 (concat | 797 (concat |
655 " " (if yahtml-prefer-upcases "METHOD" "method=") | 798 " " (if yahtml-prefer-upcases "METHOD" "method=") |
673 (defun yahtml:dt () | 816 (defun yahtml:dt () |
674 (setq yahtml-last-single-cmd "dd") "") | 817 (setq yahtml-last-single-cmd "dd") "") |
675 | 818 |
676 (defun yahtml:p () | 819 (defun yahtml:p () |
677 (let ((alg (yahtml-read-parameter "align"))) | 820 (let ((alg (yahtml-read-parameter "align"))) |
678 (if (string< "" alg) | 821 (yahtml-make-optional-argument "align" alg) |
679 (setq alg (concat "align=" alg) | 822 )) |
680 alg (if yahtml-prefer-upcases (upcase alg) (downcase alg))) | |
681 ""))) | |
682 | 823 |
683 (defvar yahtml-input-types | 824 (defvar yahtml-input-types |
684 '(("text") ("password") ("checkbox") ("radio") ("submit") | 825 '(("text") ("password") ("checkbox") ("radio") ("submit") |
685 ("reset") ("image") ("hidden") ("file"))) | 826 ("reset") ("image") ("hidden") ("file"))) |
686 | 827 |
695 (if (string-match "text\\|password\\|^$" type) | 836 (if (string-match "text\\|password\\|^$" type) |
696 (setq size (read-string "size: ") | 837 (setq size (read-string "size: ") |
697 maxlength (read-string "maxlength: "))) | 838 maxlength (read-string "maxlength: "))) |
698 (concat | 839 (concat |
699 (if l "NAME" "name") "=\"" name "\"" | 840 (if l "NAME" "name") "=\"" name "\"" |
700 (if (string< "" type) | 841 (yahtml-make-optional-argument "type" type) |
701 (concat " " (if l "TYPE" "type") "=\"" type "\"")) | 842 (yahtml-make-optional-argument "value" value) |
702 (if (string< "" value) | 843 (yahtml-make-optional-argument "size" size) |
703 (concat " " (if l "VALUE" "value") "=\"" value "\"")) | 844 (yahtml-make-optional-argument "maxlength" maxlength) |
704 (if (string< "" size) | |
705 (concat " " (if l "SIZE" "size") "=\"" size "\"")) | |
706 (if (string< "" maxlength) | |
707 (concat " " (if l "MAXLENGTH" "maxlength") "=\"" maxlength "\"")) | |
708 ))) | 845 ))) |
709 | 846 |
710 (defun yahtml:textarea () | 847 (defun yahtml:textarea () |
711 "Add-in function for `textarea'" | 848 "Add-in function for `textarea'" |
712 (interactive) | 849 (interactive) |
715 cols (read-string "Columns: ") | 852 cols (read-string "Columns: ") |
716 rows (read-string "Rows: ")) | 853 rows (read-string "Rows: ")) |
717 (concat | 854 (concat |
718 (concat (if yahtml-prefer-upcases "NAME=" "name=") | 855 (concat (if yahtml-prefer-upcases "NAME=" "name=") |
719 "\"" name "\"") | 856 "\"" name "\"") |
720 (if (string< "" cols) | 857 (yahtml-make-optional-argument "cols" cols) |
721 (concat " " (if yahtml-prefer-upcases "COLS" "cols") "=" cols)) | 858 (yahtml-make-optional-argument "rows" rows)))) |
722 (if (string< "" rows) | 859 |
723 (concat " " (if yahtml-prefer-upcases "ROWS" "rows") "=" rows))))) | 860 (defun yahtml:table () |
724 | 861 "Add-in function for `table'" |
862 (yahtml-make-optional-argument "border" (read-string "border="))) | |
863 | |
864 (defun yahtml:font () | |
865 "Add-in function for `font'" | |
866 (yahtml-make-optional-argument "color" (read-string "color="))) | |
725 | 867 |
726 ;;; ---------- Simple tag ---------- | 868 ;;; ---------- Simple tag ---------- |
727 (defun yahtml-insert-tag (region-mode &optional tag) | 869 (defun yahtml-insert-tag (region-mode &optional tag) |
728 "Insert <TAG> </TAG> and put cursor inside of them." | 870 "Insert <TAG> </TAG> and put cursor inside of them." |
729 (interactive "P") | 871 (interactive "P") |
730 (or tag | 872 (or tag |
731 (let ((completion-ignore-case t)) | 873 (let ((completion-ignore-case t)) |
732 (setq tag | 874 (setq tag |
733 (YaTeX-cplread-with-learning | 875 (YaTeX-cplread-with-learning |
734 (format "Tag %s(default %s): " | 876 (format "Tag %s(default %s): " |
735 (if region-mode "region: " "") yahtml-last-typeface-cmd) | 877 (if region-mode "region: " "") yahtml-last-typeface-cmd) |
736 'yahtml-typeface-table 'yahtml-user-typeface-table | 878 'yahtml-typeface-table 'yahtml-user-typeface-table |
737 'yahtml-tmp-typeface-table)))) | 879 'yahtml-tmp-typeface-table)))) |
738 (if (string= "" tag) (setq tag yahtml-last-typeface-cmd)) | 880 (if (string= "" tag) (setq tag yahtml-last-typeface-cmd)) |
739 (setq tag (or (cdr (assoc tag yahtml-typeface-table)) tag)) | 881 (setq tag (or (cdr (assoc tag yahtml-typeface-table)) tag)) |
753 (defun yahtml-insert-tag-region (&optional tag) | 895 (defun yahtml-insert-tag-region (&optional tag) |
754 "Call yahtml-insert-tag with region mode." | 896 "Call yahtml-insert-tag with region mode." |
755 (interactive) | 897 (interactive) |
756 (yahtml-insert-tag t tag)) | 898 (yahtml-insert-tag t tag)) |
757 | 899 |
900 | |
758 (defun yahtml-insert-single (cmd) | 901 (defun yahtml-insert-single (cmd) |
759 "Insert <CMD>." | 902 "Insert <CMD>." |
760 (interactive | 903 (interactive |
761 (list | 904 (list |
762 (let ((completion-ignore-case t)) | 905 (let ((completion-ignore-case t)) |
771 (or (cdr (assoc cmd yahtml-single-cmd-table)) cmd)) | 914 (or (cdr (assoc cmd yahtml-single-cmd-table)) cmd)) |
772 (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) | 915 (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase) |
773 yahtml-last-single-cmd)) | 916 yahtml-last-single-cmd)) |
774 (insert (format "<%s>" cmd))) | 917 (insert (format "<%s>" cmd))) |
775 | 918 |
919 (defun yahtml-insert-p (&optional arg) | |
920 "Convenient function to insert <p></p>" | |
921 (interactive "P") | |
922 (if arg (yahtml-insert-tag nil "p") | |
923 (insert "<p>") | |
924 (save-excursion | |
925 (insert "</p>")))) | |
926 | |
776 ;;; ---------- Jump ---------- | 927 ;;; ---------- Jump ---------- |
777 (defun yahtml-on-href-p () | 928 (defun yahtml-on-href-p () |
778 "Check if point is on href clause." | 929 "Check if point is on href clause." |
779 (let ((p (point)) e cmd (case-fold-search t)) | 930 (let ((p (point)) e cmd (case-fold-search t)) |
780 (save-excursion | 931 (save-excursion |
783 (search-forward "</a>" nil t) | 934 (search-forward "</a>" nil t) |
784 (setq e (point))) | 935 (setq e (point))) |
785 (goto-char (get 'YaTeX-inner-environment 'point)) | 936 (goto-char (get 'YaTeX-inner-environment 'point)) |
786 (search-forward "href" e t) | 937 (search-forward "href" e t) |
787 (search-forward "=" e t) | 938 (search-forward "=" e t) |
788 (skip-chars-forward " \t\n") | 939 (progn |
789 (looking-at "\"?\\([^\"> \t\n]+\\)\"?") | 940 (skip-chars-forward " \t\n") |
941 (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) | |
790 (< p (match-end 0)) | 942 (< p (match-end 0)) |
791 (YaTeX-match-string 1) | 943 (YaTeX-match-string 1) |
792 )))) | 944 )))) |
793 | 945 |
794 (defun yahtml-netscape-sentinel (proc mes) | 946 (defun yahtml-netscape-sentinel (proc mes) |
814 | 966 |
815 (defun yahtml-browse-html (href) | 967 (defun yahtml-browse-html (href) |
816 "Call WWW Browser to see HREF." | 968 "Call WWW Browser to see HREF." |
817 (let ((pb "* WWW Browser *") (cb (current-buffer))) | 969 (let ((pb "* WWW Browser *") (cb (current-buffer))) |
818 (cond | 970 (cond |
971 ((string-match "^start\\>" yahtml-www-browser) | |
972 (if (get-buffer pb) | |
973 (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) | |
974 (put 'yahtml-netscape-sentinel 'url href) | |
975 (set-process-sentinel | |
976 (setq yahtml-browser-process | |
977 (start-process | |
978 "browser" pb shell-file-name yahtml-shell-command-option | |
979 (format "%s \"%s\"" yahtml-www-browser href))) | |
980 'yahtml-netscape-sentinel)) | |
819 ((and (string-match "[Nn]etscape" yahtml-www-browser) | 981 ((and (string-match "[Nn]etscape" yahtml-www-browser) |
820 (not (eq system-type 'windows-nt))) | 982 (not (eq system-type 'windows-nt))) |
821 (if (get-buffer pb) | 983 (if (get-buffer pb) |
822 (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) | 984 (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) |
823 (put 'yahtml-netscape-sentinel 'url href) | 985 (put 'yahtml-netscape-sentinel 'url href) |
841 (t | 1003 (t |
842 (message "Sorry, jump across http is not supported."))))) | 1004 (message "Sorry, jump across http is not supported."))))) |
843 | 1005 |
844 (defun yahtml-goto-corresponding-href (&optional other) | 1006 (defun yahtml-goto-corresponding-href (&optional other) |
845 "Go to corresponding name." | 1007 "Go to corresponding name." |
846 (let ((href (yahtml-on-href-p)) file name) | 1008 (let ((href (yahtml-on-href-p)) file name (parent buffer-file-name)) |
847 (if href | 1009 (if href |
848 (cond | 1010 (cond |
849 ((string-match "^\\(ht\\|f\\)tp:" href) | 1011 ((string-match "^\\(ht\\|f\\)tp:" href) |
850 (yahtml-browse-html href)) | 1012 (yahtml-browse-html href)) |
851 (t (setq file (substring href 0 (string-match "#" href))) | 1013 (t (setq file (substring href 0 (string-match "#" href))) |
856 (if (string-match "/$" file) | 1018 (if (string-match "/$" file) |
857 (setq file (concat file yahtml-directory-index))) | 1019 (setq file (concat file yahtml-directory-index))) |
858 (if (string-match "^/" file) | 1020 (if (string-match "^/" file) |
859 (setq file (yahtml-url-to-path file))) | 1021 (setq file (yahtml-url-to-path file))) |
860 (if other (YaTeX-switch-to-buffer-other-window file) | 1022 (if other (YaTeX-switch-to-buffer-other-window file) |
861 (YaTeX-switch-to-buffer file)))) | 1023 (YaTeX-switch-to-buffer file)) |
1024 (or YaTeX-parent-file (setq YaTeX-parent-file parent)))) | |
862 (if name | 1025 (if name |
863 (progn (set-mark-command nil) (yahtml-jump-to-name name))) | 1026 (progn (set-mark-command nil) (yahtml-jump-to-name name))) |
864 t))))) | 1027 t))))) |
865 | 1028 |
866 (defun yahtml-jump-to-name (name) | 1029 (defun yahtml-jump-to-name (name) |
952 (interactive) | 1115 (interactive) |
953 (cond | 1116 (cond |
954 ((yahtml-goto-corresponding-href other)) | 1117 ((yahtml-goto-corresponding-href other)) |
955 ((yahtml-goto-corresponding-img)) | 1118 ((yahtml-goto-corresponding-img)) |
956 ((yahtml-goto-corresponding-begend)) | 1119 ((yahtml-goto-corresponding-begend)) |
1120 (t (message "I don't know where to go.")) | |
957 )) | 1121 )) |
958 | 1122 |
959 (defun yahtml-goto-corresponding-*-other-window () | 1123 (defun yahtml-goto-corresponding-*-other-window () |
960 "Go to corresponding object." | 1124 "Go to corresponding object." |
961 (interactive) | 1125 (interactive) |
962 (yahtml-goto-corresponding-* t)) | 1126 (yahtml-goto-corresponding-* t)) |
963 | 1127 |
1128 (defun yahtml-visit-main () | |
1129 "Go to parent file from where you visit current file." | |
1130 (interactive) | |
1131 (if YaTeX-parent-file (YaTeX-switch-to-buffer YaTeX-parent-file))) | |
1132 | |
964 ;;; ---------- killing ---------- | 1133 ;;; ---------- killing ---------- |
965 (defun yahtml-kill-begend (&optional whole) | 1134 (defun yahtml-kill-begend (&optional whole) |
966 (let ((tag (yahtml-on-begend-p)) (p (make-marker)) (q (make-marker))) | 1135 (let ((tag (yahtml-on-begend-p)) p q r) |
967 (if tag | 1136 (if tag |
968 (progn | 1137 (save-excursion |
969 (or (looking-at "<") | 1138 (or (looking-at "<") |
970 (progn (skip-chars-backward "^<") (forward-char -1))) | 1139 (progn (skip-chars-backward "^<") (forward-char -1))) |
971 (set-marker p (point)) | 1140 (setq p (point)) |
972 (yahtml-goto-corresponding-begend) | 1141 (yahtml-goto-corresponding-begend) |
973 (or (looking-at "<") | 1142 (or (looking-at "<") |
974 (progn (skip-chars-backward "^<") (forward-char -1))) | 1143 (progn (skip-chars-backward "^<") (forward-char -1))) |
975 (delete-region (point) (progn (forward-list 1) (point))) | 1144 (if (< (point) p) ;if on the opening tag |
976 (set-marker q (point)) | 1145 (progn (setq q p p (point)) |
977 (beginning-of-line) | 1146 (goto-char q)) |
978 (if (looking-at "^\\s *$") | 1147 (setq q (point))) ;now q has end-line's (point) |
979 (delete-region (point) (progn (forward-line 1) (point)))) | 1148 (if (not whole) |
1149 (kill-region | |
1150 (progn (skip-chars-backward " \t") (if (bolp) (point) q)) | |
1151 (progn (forward-list 1) | |
1152 (setq r (point)) | |
1153 (skip-chars-forward " \t") | |
1154 (if (and (eolp) (not (eobp))) (1+ (point)) r)))) | |
980 (goto-char p) | 1155 (goto-char p) |
981 (delete-region (point) (progn (forward-list 1) (point))) | 1156 (skip-chars-backward " \t") |
982 (if (looking-at "^\\s *$") | 1157 (if (not whole) |
983 (delete-region (point) (progn (forward-line 1) (point)))) | 1158 (progn |
984 (if whole (delete-region p q)) | 1159 (kill-append |
1160 (buffer-substring | |
1161 (setq p (if (bolp) (point) p)) | |
1162 (setq q (progn | |
1163 (forward-list 1) | |
1164 (setq r (point)) | |
1165 (skip-chars-forward " \t") | |
1166 (if (and (eolp) (not (eobp))) (1+ (point)) r)))) | |
1167 t) | |
1168 (delete-region p q)) | |
1169 (kill-region | |
1170 (if (bolp) (point) p) | |
1171 (progn (goto-char q) | |
1172 (forward-list 1) | |
1173 (setq r (point)) | |
1174 (skip-chars-forward " \t") | |
1175 (if (and (eolp) (not (eobp))) (1+ (point)) r)))) | |
985 tag)))) | 1176 tag)))) |
986 | 1177 |
987 (defun yahtml-kill-* (whole) | 1178 (defun yahtml-kill-* (whole) |
988 "Kill current position's HTML tag (set)." | 1179 "Kill current position's HTML tag (set)." |
989 (interactive "P") | 1180 (interactive "P") |
1022 (cond | 1213 (cond |
1023 ((and (string-match "^a$" tag) | 1214 ((and (string-match "^a$" tag) |
1024 (save-excursion | 1215 (save-excursion |
1025 (and | 1216 (and |
1026 (re-search-backward "<a\\b" nil t) | 1217 (re-search-backward "<a\\b" nil t) |
1027 (goto-char (match-end 0)) | 1218 (progn |
1028 (skip-chars-forward " \t\n") | 1219 (goto-char (match-end 0)) |
1029 (setq b1 (point)) | 1220 (skip-chars-forward " \t\n") |
1030 (search-forward ">" nil t) | 1221 (setq b1 (point)) |
1222 (search-forward ">" nil t)) | |
1031 (setq e1 (match-beginning 0)) | 1223 (setq e1 (match-beginning 0)) |
1032 (goto-char b1) | 1224 (goto-char b1) |
1033 (re-search-forward "href\\s *=" e1 t) | 1225 (re-search-forward "href\\s *=" e1 t) |
1034 (>= p (point)) | 1226 (>= p (point)) |
1035 (goto-char (match-end 0)) | 1227 (progn |
1036 (skip-chars-forward " \t\n") | 1228 (goto-char (match-end 0)) |
1037 (looking-at "\"?\\([^\"> \t\n]+\\)\"?") | 1229 (skip-chars-forward " \t\n") |
1230 (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) | |
1038 (< p (match-end 0))))) | 1231 (< p (match-end 0))))) |
1039 (setq b1 (match-beginning 1) e1 (match-end 1) | 1232 (setq b1 (match-beginning 1) e1 (match-end 1) |
1040 yahtml-completing-buffer (current-buffer) | 1233 yahtml-completing-buffer (current-buffer) |
1234 ;; yahtml-urls-local is buffer-local, so we must put | |
1235 ;; that into yahtml-urls here | |
1236 yahtml-urls (append yahtml-urls-private yahtml-urls-local) | |
1041 href (read-from-minibuffer | 1237 href (read-from-minibuffer |
1042 "Change href to: " "" yahtml-url-completion-map)) | 1238 "Change href to: " "" yahtml-url-completion-map)) |
1043 (if (string< "" href) | 1239 (if (string< "" href) |
1044 (progn | 1240 (progn |
1045 ;;(setq href ;?? | 1241 ;;(setq href ;?? |
1121 ((yahtml-change-begend)) | 1317 ((yahtml-change-begend)) |
1122 ((yahtml-change-command)) | 1318 ((yahtml-change-command)) |
1123 )) | 1319 )) |
1124 | 1320 |
1125 ;;; ---------- commenting ---------- | 1321 ;;; ---------- commenting ---------- |
1126 (defun yahtml-comment-region (beg end) | 1322 (defun yahtml-comment-region (&optional uncom) |
1127 (interactive "r") | 1323 "Comment out region or environment." |
1128 (comment-region beg end nil)) | 1324 (interactive) |
1129 | 1325 (let (e beg p) |
1130 (defun yahtml-uncomment-region (beg end) | 1326 (cond |
1131 (interactive "r") | 1327 ((setq e (yahtml-on-begend-p)) |
1132 (comment-region beg end '(4))) | 1328 (save-excursion |
1329 (setq p (point)) | |
1330 (if (string-match "^/" e) | |
1331 (setq beg (progn (forward-line 1) (point))) | |
1332 (setq beg (progn (beginning-of-line) (point)))) | |
1333 (goto-char p) | |
1334 (yahtml-goto-corresponding-begend) | |
1335 (if (string-match "^/" e) | |
1336 (beginning-of-line) | |
1337 (forward-line 1)) | |
1338 (comment-region beg (point) (if uncom (list 4))))) | |
1339 (t (comment-region (region-beginning) (region-end) | |
1340 (if uncom (list 4))))))) | |
1341 | |
1342 (defun yahtml-uncomment-region () | |
1343 (interactive) | |
1344 (yahtml-comment-region t)) | |
1133 | 1345 |
1134 | 1346 |
1135 | 1347 |
1136 (defun yahtml-inner-environment-but (exclude &optional quick) | 1348 (defun yahtml-inner-environment-but (exclude &optional quick) |
1137 "Return the inner environment but matches with EXCLUDE tag." | 1349 "Return the inner environment but matches with EXCLUDE tag." |
1138 (let (e) | 1350 (let (e (case-fold-search t)) |
1139 (save-excursion | 1351 (save-excursion |
1140 (while (and (setq e (YaTeX-inner-environment quick)) | 1352 (while (and (setq e (YaTeX-inner-environment quick)) |
1141 (string-match exclude e)) | 1353 (string-match exclude e)) |
1142 (goto-char (get 'YaTeX-inner-environment 'point)))) | 1354 (goto-char (get 'YaTeX-inner-environment 'point)))) |
1143 e)) | 1355 e)) |
1190 (if prep | 1402 (if prep |
1191 (fset 'move-to-column 'yahtml-move-to-column)) | 1403 (fset 'move-to-column 'yahtml-move-to-column)) |
1192 (fill-region-as-paragraph | 1404 (fill-region-as-paragraph |
1193 (progn (re-search-backward paragraph-start nil t) | 1405 (progn (re-search-backward paragraph-start nil t) |
1194 (or (save-excursion | 1406 (or (save-excursion |
1195 (goto-char (match-end 0)) | 1407 (goto-char (match-beginning 0)) |
1196 (skip-chars-forward " \t>") | 1408 (if (looking-at "<") |
1409 (forward-list) | |
1410 (goto-char (match-end 0)) | |
1411 (skip-chars-forward " \t>")) | |
1197 (if (looking-at "[ \t]*$") | 1412 (if (looking-at "[ \t]*$") |
1198 (progn (forward-line 1) (point)))) | 1413 (progn (forward-line 1) (point)))) |
1199 (point))) | 1414 (point))) |
1200 (progn (goto-char p) | 1415 (progn (goto-char p) |
1201 (re-search-forward ps2 nil t) | 1416 (re-search-forward ps2 nil t) |
1211 | 1426 |
1212 ;;; | 1427 ;;; |
1213 ;;; ---------- indentation ---------- | 1428 ;;; ---------- indentation ---------- |
1214 ;;; | 1429 ;;; |
1215 (defun yahtml-indent-line () | 1430 (defun yahtml-indent-line () |
1216 (interactive) | 1431 "Indent a line (faster wrapper)" |
1217 (let ((envs "[uod]l\\|table\\|t[rhd]\\|select\\|blockquote") | 1432 (interactive) |
1433 (let (indent) | |
1434 (if (and (save-excursion | |
1435 (beginning-of-line) (skip-chars-forward "\t ") | |
1436 (not (looking-at "<"))) | |
1437 (save-excursion | |
1438 (forward-line -1) | |
1439 (while (and (not (bobp)) (looking-at "^\\s *$")) | |
1440 (forward-line -1)) | |
1441 (skip-chars-forward "\t ") | |
1442 (setq indent (current-column)) | |
1443 (not (looking-at "<")))) | |
1444 (progn | |
1445 (save-excursion | |
1446 (beginning-of-line) | |
1447 (skip-chars-forward " \t") | |
1448 (or (= (current-column) indent) | |
1449 (YaTeX-reindent indent))) | |
1450 (and (bolp) (skip-chars-forward " \t"))) | |
1451 (yahtml-indent-line-real)))) | |
1452 | |
1453 (defun yahtml-indent-line-real () | |
1454 (interactive) | |
1455 (let ((envs "[uod]l\\|table\\|[ht][rhd0-6]\\|select\\|blockquote\\|center\\|menu\\|dir") | |
1456 (itemizing-envs "^\\([uod]l\\|menu\\|dir\\)$") | |
1218 (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\|option\\)\\b") | 1457 (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\|option\\)\\b") |
1219 inenv p col peol (case-fold-search t)) | 1458 inenv p col peol (case-fold-search t)) |
1220 (save-excursion | 1459 (save-excursion |
1221 (beginning-of-line) | 1460 (beginning-of-line) |
1222 (setq inenv (or (yahtml-inner-environment-but "^\\(a\\|p\\)\\b" t) | 1461 (setq inenv (or (yahtml-inner-environment-but "^\\(a\\|p\\)\\b" t) |
1223 "html") | 1462 "html") |
1224 col (get 'YaTeX-inner-environment 'indent) | 1463 col (get 'YaTeX-inner-environment 'indent) |
1225 p (get 'YaTeX-inner-environment 'point) | 1464 p (get 'YaTeX-inner-environment 'point) |
1226 op)) | 1465 op nil)) |
1227 (save-excursion | 1466 (save-excursion |
1228 (cond | 1467 (cond |
1229 ((string-match envs inenv) | 1468 ((string-match envs inenv) |
1230 (save-excursion | 1469 (save-excursion |
1231 (beginning-of-line) | 1470 (beginning-of-line) |
1232 (skip-chars-forward " \t") | 1471 (skip-chars-forward " \t") |
1233 (cond | 1472 (cond ;lookup current line's tag |
1234 ((looking-at (concat "</\\(" envs "\\)>")) | 1473 ((looking-at (concat "</\\(" envs "\\)>")) |
1235 (YaTeX-reindent col)) | 1474 (YaTeX-reindent col)) |
1236 ((or (looking-at itms) | 1475 ((looking-at itms) |
1237 (and yahtml-hate-too-deep-indentation | |
1238 (looking-at (concat "<" envs)))) | |
1239 (YaTeX-reindent (+ col yahtml-environment-indent))) | 1476 (YaTeX-reindent (+ col yahtml-environment-indent))) |
1477 ((and yahtml-hate-too-deep-indentation | |
1478 (looking-at (concat "<\\(" envs "\\)"))) | |
1479 (YaTeX-reindent (+ col (* 2 yahtml-environment-indent)))) | |
1240 ((and (< p (point)) | 1480 ((and (< p (point)) |
1481 (string-match itemizing-envs inenv) | |
1241 (save-excursion | 1482 (save-excursion |
1242 (and | 1483 (and |
1243 ;;(re-search-backward itms p t) | 1484 ;;(re-search-backward itms p t) |
1244 (setq op (point)) | 1485 (setq op (point)) |
1245 (goto-char p) | 1486 (goto-char p) |
1246 (re-search-forward itms op t) | 1487 (re-search-forward itms op t) |
1247 ;(goto-char (match-end 0)) | 1488 (progn |
1248 (skip-chars-forward "^>") | 1489 (skip-chars-forward "^>") |
1249 (skip-chars-forward ">") | 1490 (skip-chars-forward ">") |
1250 (skip-chars-forward " \t") | 1491 (skip-chars-forward " \t") |
1251 (setq col (current-column))))) | 1492 (setq col (if (looking-at "$") |
1493 (+ col yahtml-environment-indent) | |
1494 (current-column))))))) | |
1252 (YaTeX-reindent col)) | 1495 (YaTeX-reindent col)) |
1253 (t | 1496 (t |
1254 (YaTeX-reindent (+ col yahtml-environment-indent))))))) | 1497 (YaTeX-reindent (+ col yahtml-environment-indent))))))) |
1255 (and (bolp) (skip-chars-forward " \t")) | 1498 (and (bolp) (skip-chars-forward " \t")) |
1256 (if (and (setq inenv (yahtml-on-begend-p)) | 1499 (if (and (setq inenv (yahtml-on-begend-p)) |
1257 (string-match (concat "^\\(" envs "\\)") inenv)) | 1500 (string-match |
1501 (concat "^\\<\\(" yahtml-struct-name-regexp "\\)") inenv)) | |
1258 (save-excursion | 1502 (save-excursion |
1259 (setq peol (point-end-of-line)) | 1503 (setq peol (point-end-of-line)) |
1260 (or (= (char-after (point)) ?<) | 1504 (or (= (char-after (point)) ?<) |
1261 (progn (skip-chars-backward "^<") (forward-char -1))) | 1505 (progn (skip-chars-backward "^<") (forward-char -1))) |
1262 (setq col (current-column)) | 1506 (setq col (current-column)) |
1310 | 1554 |
1311 (defvar yahtml-lint-buffer "*weblint*") | 1555 (defvar yahtml-lint-buffer "*weblint*") |
1312 | 1556 |
1313 (defun yahtml-lint-buffer (buf) | 1557 (defun yahtml-lint-buffer (buf) |
1314 "Call lint on buffer BUF." | 1558 "Call lint on buffer BUF." |
1559 (require 'yatexprc) | |
1315 (interactive "bCall lint on buffer: ") | 1560 (interactive "bCall lint on buffer: ") |
1316 (setq buf (get-buffer buf)) | 1561 (setq buf (get-buffer buf)) |
1317 (YaTeX-save-buffers) | 1562 (YaTeX-save-buffers) |
1318 (YaTeX-typeset | 1563 (YaTeX-typeset |
1319 (concat yahtml-lint-program " " | 1564 (concat yahtml-lint-program " " |
1327 (if (file-directory-p file) | 1572 (if (file-directory-p file) |
1328 (setq file (expand-file-name yahtml-directory-index file)) | 1573 (setq file (expand-file-name yahtml-directory-index file)) |
1329 (setq file (expand-file-name file))) | 1574 (setq file (expand-file-name file))) |
1330 (if (string-match "^[A-Za-z]:/" file) | 1575 (if (string-match "^[A-Za-z]:/" file) |
1331 (progn | 1576 (progn |
1332 ;; (aset file 1 ?|) ;$B$3$l$OMW$i$J$$$i$7$$!D(B | 1577 ;; (aset file 1 ?|) ;これは要らないらしい… |
1333 (setq file (concat "///" file)))) | 1578 (setq file (concat "///" file)))) |
1334 (while list | 1579 (while list |
1335 (if (string-match (concat "^" (regexp-quote (car (car list)))) file) | 1580 (if (string-match (concat "^" (regexp-quote (car (car list)))) file) |
1336 (setq url (cdr (car list)) | 1581 (setq url (cdr (car list)) |
1337 file (substring file (match-end 0)) | 1582 file (substring file (match-end 0)) |
1354 (progn | 1599 (progn |
1355 (setq url (cdr (car list))) | 1600 (setq url (cdr (car list))) |
1356 (if (string-match "\\(http://[^/]*\\)/" url) | 1601 (if (string-match "\\(http://[^/]*\\)/" url) |
1357 (setq docroot (substring url (match-end 1))) | 1602 (setq docroot (substring url (match-end 1))) |
1358 (setq docroot url)) | 1603 (setq docroot url)) |
1359 (if (string-match (concat "^" (regexp-quote docroot)) file) | 1604 (cond |
1360 (setq realpath | 1605 ((string-match (concat "^" (regexp-quote docroot)) file) |
1361 (expand-file-name | 1606 (setq realpath |
1362 (substring | 1607 (expand-file-name |
1363 file | 1608 (substring |
1364 (if (= (aref file (1- (match-end 0))) ?/) | 1609 file |
1365 (match-end 0) ; "/foo" | 1610 (if (= (aref file (1- (match-end 0))) ?/) |
1366 (min (1+ (match-end 0)) (length file)))) ; "/~foo" | 1611 (match-end 0) ; "/foo" |
1367 (car (car list))))) | 1612 (min (1+ (match-end 0)) (length file)))) ; "/~foo" |
1613 (car (car list)))))) | |
1368 (if realpath | 1614 (if realpath |
1369 (progn (setq list nil) | 1615 (progn (setq list nil) |
1370 (if (and dirsufp (not (string-match "/$" realpath))) | 1616 (if (and dirsufp (not (string-match "/$" realpath))) |
1371 (setq realpath (concat realpath "/"))))))) | 1617 (setq realpath (concat realpath "/"))))))) |
1372 (setq list (cdr list))) | 1618 (setq list (cdr list))) |
1404 (defun yahtml-intelligent-newline (arg) | 1650 (defun yahtml-intelligent-newline (arg) |
1405 "Intelligent newline for HTML" | 1651 "Intelligent newline for HTML" |
1406 (interactive "P") | 1652 (interactive "P") |
1407 (let (env func) | 1653 (let (env func) |
1408 (end-of-line) | 1654 (end-of-line) |
1409 (setq env (downcase (or (YaTeX-inner-environment) "html"))) | 1655 (setq env (downcase (or (yahtml-inner-environment-but "^\\(a\\|p\\)\\b" t) |
1656 "html"))) | |
1410 (setq func (intern-soft (concat "yahtml-intelligent-newline-" env))) | 1657 (setq func (intern-soft (concat "yahtml-intelligent-newline-" env))) |
1411 (newline) | 1658 (newline) |
1412 (if (and env func (fboundp func)) | 1659 (if (and env func (fboundp func)) |
1413 (funcall func)))) | 1660 ;; if intelligent line function is defined, call that |
1414 | 1661 (funcall func) |
1662 ;; else do the default action | |
1663 (if (string-match yahtml-p-prefered-env-regexp env) | |
1664 (yahtml-insert-p))))) | |
1665 | |
1666 (defvar yahtml-faithful-to-htmllint nil) | |
1415 (defun yahtml-intelligent-newline-ul () | 1667 (defun yahtml-intelligent-newline-ul () |
1416 (interactive) | 1668 (interactive) |
1417 (insert (if yahtml-prefer-upcases "<LI> " "<li> ")) | 1669 (yahtml-insert-single "li") |
1670 (or yahtml-faithful-to-htmllint (insert " ")) | |
1418 (yahtml-indent-line)) | 1671 (yahtml-indent-line)) |
1419 | 1672 |
1420 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) | 1673 (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) |
1421 | 1674 |
1422 (defun yahtml-intelligent-newline-dl () | 1675 (defun yahtml-intelligent-newline-dl () |
1425 (if (save-excursion | 1678 (if (save-excursion |
1426 (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)>" | 1679 (re-search-backward "<\\(\\(dt\\)\\|\\(dd\\)\\)>" |
1427 (get 'YaTeX-inner-environment 'point) t)) | 1680 (get 'YaTeX-inner-environment 'point) t)) |
1428 (cond | 1681 (cond |
1429 ((match-beginning 2) | 1682 ((match-beginning 2) |
1430 (insert (if yahtml-prefer-upcases "<DD> " "<dd> ")) | 1683 (yahtml-insert-single "dd") |
1684 (or yahtml-faithful-to-htmllint (insert " ")) | |
1431 (setq yahtml-last-single-cmd "dt")) | 1685 (setq yahtml-last-single-cmd "dt")) |
1432 ((match-beginning 3) | 1686 ((match-beginning 3) |
1433 (insert (if yahtml-prefer-upcases "<DT> " "<dt> ")) | 1687 (yahtml-insert-single "dt") |
1688 (or yahtml-faithful-to-htmllint (insert " ")) | |
1434 (setq yahtml-last-single-cmd "dd"))) | 1689 (setq yahtml-last-single-cmd "dd"))) |
1435 (insert (if yahtml-prefer-upcases "<DT> " "<dt> "))) | 1690 (insert (if yahtml-prefer-upcases "<DT> " "<dt> ")) |
1436 (yahtml-indent-line))) | 1691 (setq yahtml-last-single-cmd "dd")) |
1692 (yahtml-indent-line) | |
1693 (and (string-match yahtml-p-prefered-env-regexp "dl") | |
1694 (string-equal yahtml-last-single-cmd "dt") | |
1695 (yahtml-insert-p nil)))) | |
1437 | 1696 |
1438 (defun yahtml-intelligent-newline-select () | 1697 (defun yahtml-intelligent-newline-select () |
1439 (interactive) | 1698 (interactive) |
1440 (insert "<" (if yahtml-prefer-upcases "OPTION" "option") "> ") | 1699 (insert "<" (if yahtml-prefer-upcases "OPTION" "option") "> ") |
1441 (yahtml-indent-line)) | 1700 (yahtml-indent-line)) |
1476 "Jump to previous error seeing lint buffer." | 1735 "Jump to previous error seeing lint buffer." |
1477 (interactive) | 1736 (interactive) |
1478 (or (get-buffer yahtml-lint-buffer) | 1737 (or (get-buffer yahtml-lint-buffer) |
1479 (error "No lint program ran.")) | 1738 (error "No lint program ran.")) |
1480 (YaTeX-showup-buffer yahtml-lint-buffer nil t) | 1739 (YaTeX-showup-buffer yahtml-lint-buffer nil t) |
1481 (yahtml-jump-to-error-line)) | 1740 (yahtml-jump-to-error-line t)) |
1482 | 1741 |
1483 (defun yahtml-jump-to-error-line () | 1742 (defun yahtml-jump-to-error-line (&optional sit) |
1484 (interactive) | 1743 (interactive "P") |
1485 (let ((p (point)) (e (point-end-of-line))) | 1744 (let ((p (point)) (e (point-end-of-line))) |
1486 (end-of-line) | 1745 (end-of-line) |
1487 (if (re-search-backward yahtml-error-line-regexp nil t) | 1746 (if (re-search-backward yahtml-error-line-regexp nil t) |
1488 (let ((f (YaTeX-match-string 1)) | 1747 (let ((f (YaTeX-match-string 1)) |
1489 (l (string-to-int (YaTeX-match-string 2)))) | 1748 (l (string-to-int (YaTeX-match-string 2)))) |
1749 (if sit (sit-for 1)) | |
1490 (forward-line -1) | 1750 (forward-line -1) |
1491 (YaTeX-showup-buffer f nil t) | 1751 (YaTeX-showup-buffer (YaTeX-switch-to-buffer f t) nil t) |
1492 (goto-line l)) | 1752 (goto-line l)) |
1493 (message "No line number usage")))) | 1753 (message "No line number usage")))) |
1494 | 1754 |
1495 ;;; ---------- ---------- | 1755 ;;; ---------- ---------- |
1496 | 1756 |
1511 (hilit-string-find 39 string) | 1771 (hilit-string-find 39 string) |
1512 (yahtml-hilit-region-tag "\\(em\\|strong\\)" bold) | 1772 (yahtml-hilit-region-tag "\\(em\\|strong\\)" bold) |
1513 ("</?[uod]l>" 0 decl) | 1773 ("</?[uod]l>" 0 decl) |
1514 ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label) | 1774 ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label) |
1515 ("<a\\s +href" "</a>" crossref) | 1775 ("<a\\s +href" "</a>" crossref) |
1516 ("</?\\sw+>" 0 decl) | 1776 (yahtml-hilit-region-tag-itself "</?\\sw+\\>" decl) |
1517 ("<form" "</form" form) | |
1518 )) | 1777 )) |
1519 | 1778 |
1520 (defun yahtml-hilit-region-tag (tag) | 1779 (defun yahtml-hilit-region-tag (tag) |
1521 "Return list of start/end point of <TAG> form." | 1780 "Return list of start/end point of <TAG> form." |
1522 (if (re-search-forward (concat "<" tag ">") nil t) | 1781 (if (re-search-forward (concat "<" tag ">") nil t) |
1524 (skip-chars-forward " \t\n") | 1783 (skip-chars-forward " \t\n") |
1525 (cons (point) | 1784 (cons (point) |
1526 (progn (re-search-forward (concat "</" tag ">") nil t) | 1785 (progn (re-search-forward (concat "</" tag ">") nil t) |
1527 (match-beginning 0)))))) | 1786 (match-beginning 0)))))) |
1528 | 1787 |
1788 (defun yahtml-hilit-region-tag-itself (ptn) | |
1789 "Return list of start/end point of <tag options...> itself." | |
1790 (if (re-search-forward ptn nil t) | |
1791 (let ((m0 (match-beginning 0))) | |
1792 (skip-chars-forward "^>") | |
1793 (cons m0 (1+ (point) ))))) | |
1794 | |
1529 ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist)) | 1795 ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist)) |
1530 (cond | 1796 (and (featurep 'hilit19) |
1531 ((and (featurep 'hilit19) (featurep 'yatex19)) | 1797 (or (assq 'yahtml-mode hilit-patterns-alist) |
1532 (or (assq 'yahtml-mode hilit-patterns-alist) | 1798 (setq hilit-patterns-alist |
1533 (setq hilit-patterns-alist | 1799 (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist) |
1534 (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist) | 1800 hilit-patterns-alist)))) |
1535 hilit-patterns-alist))))) | |
1536 | 1801 |
1537 (provide 'yahtml) | 1802 (provide 'yahtml) |
1538 | 1803 |
1539 ; Local variables: | 1804 ; Local variables: |
1540 ; fill-prefix: ";;; " | 1805 ; fill-prefix: ";;; " |