Mercurial > hgrepos > hgweb.cgi > yatex
changeset 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 | 6ad4a2399731 |
children | df0bf1465254 |
files | docs/htmlqa docs/yatexj.tex yahtml.el yatex.el yatex.new yatex19.el yatexadd.el yatexenv.el yatexlib.el yatexmth.el yatexprc.el yatexsec.el |
diffstat | 12 files changed, 1416 insertions(+), 880 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/htmlqa Tue Dec 16 13:28:38 1997 +0000 @@ -0,0 +1,98 @@ +%% +%% Q and A on yahtml +%% +%% C-u C-x $ とすると質問項目だけ表示されます。C-x $ で元に戻ります。 +%% + + +■インストール関連 +・LaTeX使わないんだけど野鳥も入れなきゃダメですか? + + そうなにょ。野鳥のライブラリ関数を使っているので野鳥も棲まわせて + やって下さいまし。 + +■カスタマイズ関連 +・いつもは EUC にしてたまに JIS コードのファイルを作りたいんだけど。 + + ~/.emacs で + (setq yahtml-kanji-code 3) ;3はEUC + しておけば普段のhtmlコードはEUCになります。JISにしたいときは、 + htmlソースのお尻に、 + + <!-- Local Variables: --> + <!-- file-coding-system: *junet* --> + <!-- End: --> + + と書いておけばそのファイルだけJISになります。 + +■どうにかならんかなあ関連 +・長い文書の下の方だとインデントがめちゃ遅いんだけど。 + + 今は直ってるはずです…。 + +・いつも雛型として使っている template.html を簡単に入れたい + + autoinsert.el (Emacs19/Mule2付属)を使いましょう。もしくは、それ + の機能強化版 auto-insert-tkld を使いましょう。後者は、 + ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z + で入手できます。 + http://www-nagao.kuee.kyoto-u.ac.jp/member/tsuchiya/elisp-tips.html#yahtml-mode-hook + に設定例が書いてあります。 + +■その他 +・yahtmlってなんてよむの? + + がーん、良く聞かれます。 + 作者も良く分かってません。えへん。 + というかかちょいい読み方が思い浮かばないもので。 + なんかいい読み方ないすか? + 突然思い付きました。正しい呼称は + + 『HTML屋』 + + とします。 + +・メイリングリストはないんですか? + + っていう質問項目があるくらいだからあります。「yahtml」およびそのVz + への移植版「laihtml」(by katsura@prc.tsukuba.ac.jp)、Wzへの移植版 + 「hackhtml」(by lh57024@hongo.ecc.u-tokyo.ac.jp) に関する情報交換の + ためのメイリングリスト「fj野鳥の会」がそれです。 + + To: yatex-control@jaist.ac.jp + Subject: append + ----- + たぐでーし。明けましておめでとうございまーす。 + + のようにメイルを送れば加入できます。この時本文に書いた内容がプロ + フィールとして登録されます(変更可)。手続きは全て自動で行われ、登 + 録が完了すると確認とともに、参加/休止/脱会等の制御コマンドの利用 + 方法が返送されます。是非参加して一緒に野鳥/雷鳥/白鳥を育ててくだ + さい。 + +・yahtmlの最新情報は? + + もしあなたが、WWWにアクセスできるなら、 + http://www.comp.ae.keio.ac.jp/~yuuji/yatex/ + を覗いてみて下さい。このなかの、「yatex-current」というリンクを + たどると最新版の野鳥を入手することができます。ただし、正式リリー + ス版ではなく、作者がデバッグ中だったりして正常に動作しない可能性 + があるので、current版に関する問い合わせは受けかねますのでご注意 + 下さい。 + +・とにかくわかりませーん! + + 回答を得るまでの早い順に + + ・近くにいる詳しい人に聞く + ・メイリングリストに質問を出す + ・yuuji@ae.keio.ac.jp に質問を出す + + でしょうか。お好きな方法でどうぞ。 + + +Local Variables: +mode: indented-text +fill-column: 72 +fill-prefix: " " +End:
--- a/docs/yatexj.tex Sat Dec 13 12:41:43 1997 +0000 +++ b/docs/yatexj.tex Tue Dec 16 13:28:38 1997 +0000 @@ -5,6 +5,9 @@ @iftex @c @syncodeindex fn cp +@c いつも忘れるのでここに書いとくか。 +@c ノードいじったら C-l C-u C-e +@c メニュー増やしたら C-l C-u C-m @syncodeindex vr cp @end iftex @@ -14,7 +17,7 @@ @subtitle Yet Another tex-mode for emacs @title 『野鳥』 @subtitle // YaTeX // -@author @copyright{} 1991-1996 by HIROSE, Yuuji [yuuji@@ae.keio.ac.jp] +@author @copyright{} 1991-1997 by HIROSE, Yuuji [yuuji@@ae.keio.ac.jp] @end titlepage @node Top, Intro, (dir), (dir) @@ -227,7 +230,9 @@ @item dvi2-command @dots{} 起動するプレヴューアのコマンド名 @item NTT-jTeX - @dots{} NTT jTeX を使用するなら t + @dots{} 改行+インデントによって、タイプセット後の字間が空いてしま + うのを抑制する場合にtにする(古いNTT-jTeXで顕著に現れる)。具体的には、 + fillするときに各行の終わりに%を付加するようになる。 @item YaTeX-kanji-code @dots{} 文書を作成する時の漢字コード @item dviprint-command-format @@ -1247,7 +1252,7 @@ いる拡張子を「ファイル名」の後ろに足したファイルが存在するか順次調べて、存 在した場合car部に入っているコマンドを起動する。 @item -以上どれかにマッチしなければあきる。 +以上どれかにマッチしなければあきらめる。 @end enumerate @@ -1865,7 +1870,9 @@ @end defvar @defvar NTT-jTeX -NTT-j@TeX{}使用時は@code{t}にする (@code{nil}) +古いNTT-j@TeX{}使用時のようにインデントした行の先頭と前の行の +(タイプセット後の)字間が空いてしまうのを嫌う場合は@code{t}にする +(@code{nil}) @end defvar @defvar YaTeX-item-regexp @@ -1976,6 +1983,10 @@ AMS-LaTeX を使用する場合は @code{t} に設定する (@code{nil}) @end defvar +@defvar YaTeX-template-file +新規ファイル作成時に自動挿入するファイル名 (@code{~/work/template.tex}) +@end defvar + @node Sample definitions, Hook variables, All customizable variables, Lisp variables @comment node-name, next, previous, up @subsection カスタマイズ変数設定例
--- a/yahtml.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yahtml.el Tue Dec 16 13:28:38 1997 +0000 @@ -1,6 +1,6 @@ ;;; -*- Emacs-Lisp -*- ;;; (c ) 1994-1997 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] -;;; Last modified Mon Apr 7 16:58:32 1997 on crx +;;; Last modified Tue Dec 16 21:10:05 1997 on crx ;;; $Id$ ;;;[Installation] @@ -18,6 +18,22 @@ ;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) ;;; ;Write correspondence alist from ABSOLUTE unix path name to URL path. ;;; +;;;[インストール方法] +;;; +;;; yahtml.el, yatexlib.el, yatexprc.el を load-path の通ったディレクト +;;; リにインストールしてください。その後、以下を参考に ~/.emacs に設定を +;;; 追加して下さい。 +;;; +;;; (setq auto-mode-alist +;;; (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) +;;; (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) +;;; (setq yahtml-www-browser "netscape") +;;; ;お気に入りのブラウザを書いて下さい。netscapeが便利です。 +;;; (setq yahtml-path-url-alist +;;; '(("/home/yuuji/public_html" . "http://www.mynet/~yuuji") +;;; ("/home/staff/yuuji/html" . "http://www.othernet/~yuuji"))) +;;; ;UNIXの絶対パスと対応するURLのリストを書いて下さい。 +;;; ;;;[Commentary] ;;; ;;; It is assumed you are already familiar with YaTeX. The following @@ -29,15 +45,16 @@ ;;; this group ;;; When input `href=...', you can complete file ;;; name or label(href="#foo") by typing TAB. -;;; * [prefix] s Complete declarative notations such as -;;; `<img src="foo.gif">' -;;; `<input name="var" ...>' ;;; * [prefix] l Complete typeface-changing commands such as ;;; `<i> ... </i>' or `<samp> ... </samp>' ;;; This completion can be used to make in-line ;;; tags which is normally completed with [prefix] b. +;;; * [prefix] s Complete declarative notations such as +;;; `<img src="foo.gif">' +;;; `<input name="var" ...>' ;;; * [prefix] m Complete single commands such as ;;; `<br>' or `<hr> or <li>...' +;;; * [prefix] p Insert <p></p> on the point ;;; * M-RET Intelligent newline; if current TAG is one of ;;; ul, ol, or dl. insert newline and <li> or ;;; <dt> or <dd> suitable for current condition. @@ -59,35 +76,116 @@ ;;; * [prefix] a YaTeX's accent mark's equivalent of yahtml. ;;; This function can input $lt, $gt or so. ;;; +;;;[キーの説明] +;;; +;;; 以下の説明において、特にカスタマイズをしていない限り、[prefix] は +;;; C-c キーを意味します。 +;;; +;;; * [prefix] b X `</H1>' といった終了タグが必要となる`H1'のよう +;;; な環境を補完入力します。<a href=foo> ... </a> +;;; もこのグループです。 +;;; `href=...' と入力した後、TABキーを押すことで、 +;;; ファイル名や (href="#foo") のようなラベルも補完 +;;; できます。 +;;; * [prefix] s 以下のような宣言の補完を行います。 +;;; `<img src="foo.gif">' +;;; `<input name="var" ...>' +;;; * [prefix] l `<i> ... </i>' や `<samp> ... </samp>' のよう +;;; なテキストスタイル指定のタグを補完します。 +;;; この補完機能は通常 [prefix] b で補完できるものを +;;; 一行内で書きたいときにも用いることが出来ます。 +;;; * [prefix] m `<br>' や `<hr> '、`<li>' 等の単体タグの補完 +;;; を行います。 +;;; * [prefix] p カーソル位置に<p></p>を挿入します。 +;;; * M-RET おまかせ改行; もしul、ol、dl等のタグ(リスト)を +;;; 使っている場合に、環境に合わせて改行と <li>、 +;;; <dt>、<dd>を入力します。 +;;; * menu-bar yahtml 選択したアイテムをメニューより補完できます。 +;;; (私はメニューが嫌いなんですが、htmlに関してはメ +;;; ニューは一番ありがたいかも) +;;; * [prefix] g 対応するタグ、<dl> <-> </dl> や href="xxx" の +;;; ような TAG にジャンプします。 +;;; <img src=...> の場合はイメージビューワを呼び出 +;;; します。href=hoge.html の場合はhoge.htmlに飛びま +;;; す。 +;;; * [prefix] k ポイント上の HTML タグを消去します。 +;;; もし universal-argument を付けた場合(C-uを先に押 +;;; す)HTMLタグで囲まれた内容も同時に消去します。 +;;; * [prefix] c ポイント上のタグを変更します。 +;;; `href="xxx"'の上で [prefix] c を利用した場合は、 +;;; 参照しているリンクを補完機能を使いながら変更で +;;; きます。 +;;; * [prefix] t j カレントファイルに対して jweblint を呼び出しま +;;; す。 +;;; * [prefix] t p WWW ブラウザでカレントファイルを表示します。 +;;; (lisp変数 yahtml-www-browser の設定をお忘れな +;;; く。お推めは "netscape" で、ねすけの場合既にねす +;;; けが起動されていた場合そのねすけに Reload 命令を +;;; 送るという芸当が出来ます。ただし今のところX版の +;;; ねすけちゃんだけ) +;;; * [prefix] a YaTeX のアクセント記号補完と同じです。 +;;; < > 等が入力できます。 +;;; +;;; [謝辞] +;;; +;;; fj野鳥の会の皆さんには貴重な助言を頂きました。また、下に示す方々には +;;; 特に大きな協力を頂きました。あわせてここに感謝申し上げます。 +;;; +;;; * 横田和也さん(マツダ) +;;; マニュアルの和訳をして頂きました。 +;;; * 吉田尚志さん(NTT Data) +;;; Mule for Win32 での動作のさせ方を教えて頂きました。 +;;; (というかほとんどやってもらった ^^;) +;;; -(require 'yatex) +;(require 'yatex) +(require 'yatexlib) ;;; --- customizable variable starts here --- +(defvar yahtml-prefix "\C-c" + "*Prefix key stroke of yahtml functions.") (defvar yahtml-image-viewer "xv" "*Image viewer program") (defvar yahtml-www-browser "netscape" "*WWW Browser command") (defvar yahtml-kanji-code 2 - "Kanji coding system of html file; 1=sjis, 2=jis, 3=euc") + "*Kanji coding system number of html file; 1=sjis, 2=jis, 3=euc") +(defvar yahtml-coding-system + (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist)) + "Kanji coding system") +(defvar yahtml-fill-column 72 "*fill culumn used for yahtml-mode") +(defvar yahtml-fill-prefix nil "*fill prefix for yahtml-mode") + ;;(defvar yahtml-www-server "www" "*Host name of your domain's WWW server") (defvar yahtml-path-url-alist nil "*Alist of unix path name vs. URL name of WWW server. Ex. '((\"/usr/home/yuuji/http\" . \"http://www.comp.ae.keio.ac.jp/~yuuji\") - (\"/usr/home/yuuji/darts/http\" . \"http://inspire.comp.ae.keio.ac.jp/~darts\"))") + (\"/usr/home/yuuji/darts/http\" . \"http://darts.comp.ae.keio.ac.jp/~darts\"))") (defvar yahtml-directory-index "index.html" "*Directory index file name; Consult your site's WWW administrator.") -(defvar yahtml-environment-indent YaTeX-environment-indent +(defvar yahtml-environment-indent 1 "*Indentation depth of HTML's listing environment") +(defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) YaTeX-emacs-20) + "Whether yatex mode is running on Japanese environment or not.") + (defvar yahtml-lint-program (if YaTeX-japan "jweblint" "weblint") "*Program name to lint HTML file") (defvar yahtml-hate-too-deep-indentation nil "*Non-nil for this variable suppress deep indentation in listing environments.") +(defvar yahtml-always-/p nil + "*Those who always use <p> with </p> set this to t.") + +(defvar yahtml-p-prefered-env-regexp "^\\(body\\|dl\\)" + "*Regexp of envs where paragraphed sentences are prefered.") + +(defvar yahtml-template-file "~/http/template.html" + "*Template HTML file. It'll be inserted to empty file.") + ;;; --- customizable variable ends here --- - (defvar yahtml-prefix-map nil) (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.") (defvar yahtml-lint-buffer-map nil "Keymap used in lint buffer.") @@ -121,7 +219,7 @@ (if yahtml-mode-map nil (setq yahtml-mode-map (make-sparse-keymap) yahtml-prefix-map (make-sparse-keymap)) - (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map) + (define-key yahtml-mode-map yahtml-prefix yahtml-prefix-map) (define-key yahtml-mode-map "\M-\C-@" 'yahtml-mark-begend) (if (and (boundp 'window-system) (eq window-system 'x) YaTeX-emacs-19) (define-key yahtml-mode-map [?\M-\C- ] 'yahtml-mark-begend)) @@ -129,7 +227,6 @@ (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment) (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline) (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line) - (define-key yahtml-mode-map YaTeX-prefix yahtml-prefix-map) (let ((map yahtml-prefix-map)) (YaTeX-define-key "^" 'yahtml-visit-main map) (YaTeX-define-key "4^" 'yahtml-visit-main-other-window map) @@ -150,6 +247,7 @@ (YaTeX-define-key "m" 'yahtml-insert-single map) (YaTeX-define-key "n" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<BR>" "<br>"))) map) (YaTeX-define-key "-" '(lambda () (interactive) (insert (if yahtml-prefer-upcases "<HR>" "<hr>") "\n")) map) + (YaTeX-define-key "p" 'yahtml-insert-p map) (if YaTeX-no-begend-shortcut (progn (YaTeX-define-key "B" 'yahtml-insert-begend-region map) @@ -197,7 +295,7 @@ "^$\\|<!--\\|^[ \t]*</?\\(h[1-6]\\|p\\|[bhtd][ldt]\\|li\\|body\\|html\\|head\\|title\\|ul\\|ol\\|dl\\|pre\\|table\\|center\\|blockquote\\|!--\\)\\b") "*Regexp of html paragraph separater") (defvar yahtml-syntax-table nil - "*Syntax table for typesetting buffer") + "*Syntax table for yahtml-mode") (if yahtml-syntax-table nil (setq yahtml-syntax-table @@ -214,6 +312,7 @@ '(("img") ("input"))) (defvar yahtml-user-form-table nil) (defvar yahtml-tmp-form-table nil) +(defvar yahtml-last-form "img") (defvar yahtml-env-table '(("html") ("head") ("title") ("body") ("dl") ("ul") ("ol") ("pre") @@ -224,7 +323,8 @@ ("Preformatted" . "pre") ("table") ("tr") ("th") ("td") ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") - ("p"))) + ;; ("p") ;This makes indentation screwed up! + )) (defvar yahtml-itemizing-regexp "\\(ul\\|ul\\|dl\\)" @@ -234,15 +334,19 @@ (defvar yahtml-tmp-env-table nil) ;;; Completion tables for typeface designator +(and yahtml-always-/p + (or (assoc "p" yahtml-env-table) + (setq yahtml-env-table (cons '("p") yahtml-env-table)))) + (defvar yahtml-typeface-table (append '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") - ("strong") ("var") ("b") ("i") ("tt") ("u") ("address")) + ("strong") ("var") ("b") ("i") ("tt") ("u") ("address") ("font")) yahtml-env-table) "Default completion table of typeface designator") (defvar yahtml-user-typeface-table nil) (defvar yahtml-tmp-typeface-table nil) -(defvar yahtml-last-typeface-cmd "address") +(defvar yahtml-last-typeface-cmd "a") (defvar yahtml-single-cmd-table '(("hr") ("br") ("option") ("p") @@ -269,57 +373,80 @@ (mapconcat (function (lambda (x) (car x))) yahtml-typeface-table "\\|") "\\)\\b") "Regexp of structure beginning.") +(or (assoc "p" yahtml-env-table) + (setq yahtml-env-table (cons '("p") yahtml-env-table))) (defun yahtml-mode () (interactive) - (yatex-mode) (cond - ((boundp 'MULE) - (set-file-coding-system - (cdr (assq yahtml-kanji-code YaTeX-kanji-code-alist)))) + ((and YaTeX-emacs-20 (fboundp 'coding-system-equal)) + (if t (or (coding-system-equal + yahtml-coding-system buffer-file-coding-system) + (set-buffer-file-coding-system yahtml-coding-system)) + ;;^v which is better? + (let ((bmp (buffer-modified-p))) + (set-buffer-file-coding-system yahtml-coding-system) + (set-buffer-modified-p bmp)))) + ((featurep 'mule) + (set-file-coding-system yahtml-coding-system)) ((boundp 'NEMACS) (make-local-variable 'kanji-fileio-code) (setq kanji-fileio-code yahtml-kanji-code))) (setq major-mode 'yahtml-mode mode-name "yahtml") - (make-local-variable 'YaTeX-kanji-code) - (make-local-variable 'YaTeX-ec) (setq YaTeX-ec "") - (make-local-variable 'YaTeX-struct-begin) - (setq YaTeX-struct-begin "<%1%2") - (make-local-variable 'YaTeX-struct-end) (setq YaTeX-struct-end "</%1>") - (make-local-variable 'YaTeX-struct-name-regexp) - (setq YaTeX-struct-name-regexp yahtml-struct-name-regexp) - (make-local-variable 'YaTeX-prefix-map) - (make-local-variable 'YaTeX-command-token-regexp) - (setq YaTeX-command-token-regexp yahtml-command-regexp) - (make-local-variable 'YaTeX-comment-prefix) - (setq YaTeX-comment-prefix "<!--") - ;;(make-local-variable 'YaTeX-environment-indent) - ;;(setq YaTeX-environment-indent 0) - (make-local-variable 'fill-prefix) - (setq fill-prefix nil) - (make-local-variable 'paragraph-separate) - (setq paragraph-start yahtml-paragraph-start - paragraph-separate yahtml-paragraph-separate) - (make-local-variable 'comment-start) - (make-local-variable 'comment-end) - (setq comment-start "<!-- " comment-end " -->") - (make-local-variable 'indent-line-function) - (setq indent-line-function 'yahtml-indent-line) - (make-local-variable 'YaTeX-item-regexp) - (setq YaTeX-item-regexp "<\\(li\\|d[td]\\)>") - (make-local-variable 'YaTeX-typesetting-mode-map) - (setq YaTeX-typesetting-mode-map yahtml-lint-buffer-map) + (mapcar + (function (lambda (x) + (make-local-variable (car x)) + (set (car x) (if (and (symbolp (cdr x)) + (boundp (cdr x))) + (symbol-value (cdr x)) + (cdr x))))) + '((YaTeX-ec . "") + (YaTeX-struct-begin . "<%1%2") + (YaTeX-struct-end . "</%1>") + (YaTeX-struct-name-regexp . yahtml-struct-name-regexp) + (YaTeX-comment-prefix . "<!--") + (YaTeX-coding-system . yahtml-coding-system) + (YaTeX-typesetting-mode-map . yahtml-lint-buffer-map) + (fill-prefix . yahtml-fill-prefix) (fill-column . yahtml-fill-column) + (paragraph-start . yahtml-paragraph-start) + (paragraph-separate . yahtml-paragraph-separate) + (comment-start . "<!-- ") (comment-end . " -->") + (comment-start-skip . comment-start) + (indent-line-function . yahtml-indent-line))) + (set-syntax-table yahtml-syntax-table) (use-local-map yahtml-mode-map) - (run-hooks 'yahtml-mode-hook)) + (YaTeX-read-user-completion-table) + (turn-on-auto-fill) ;Sorry, this is prerequisite + (and (= 0 (buffer-size)) (file-exists-p yahtml-template-file) + (y-or-n-p (format "Insert %s?" yahtml-template-file)) + (insert-file-contents (expand-file-name yahtml-template-file))) + (run-hooks 'text-mode-hook 'yahtml-mode-hook)) (defun yahtml-define-menu (keymap bindlist) - (mapcar - (function - (lambda (bind) - (define-key keymap (vector (car bind)) (cdr bind)))) - bindlist)) + (cond + ((featurep 'xemacs) + (let ((name (keymap-name (symbol-value keymap)))) + (set keymap nil) + (mapcar + (function + (lambda (bind) + (setq bind (cdr bind)) + (if (eq (car (cdr bind)) 'lambda) + (setcar (cdr bind) 'progn)) + (if (stringp (car (cdr bind))) + (set keymap (cons (cdr bind) (symbol-value keymap))) + (set keymap (cons (vector (car bind) (cdr bind) t) + (symbol-value keymap)))))) + bindlist) + (set keymap (cons name (symbol-value keymap))))) + (t + (mapcar + (function + (lambda (bind) + (define-key (symbol-value keymap) (vector (car bind)) (cdr bind)))) + bindlist)))) (defvar yahtml-menu-map nil "Menu map of yahtml") (defvar yahtml-menu-map-sectioning nil "Menu map of yahtml(sectioning)") @@ -329,15 +456,15 @@ ;;; Variables for mosaic url history (defvar yahtml-urls nil "Alist of global history") -(defvar yahtml-url-history-file "~/.mosaic-global-history" - "File name of url history") +(defvar yahtml-urls-private nil) +(defvar yahtml-urls-local nil) (cond ((and YaTeX-emacs-19 (null yahtml-menu-map)) - (setq yahtml-menu-map (make-sparse-keymap "yahtml menu")) + (setq yahtml-menu-map (make-sparse-keymap "yahtml")) (setq yahtml-menu-map-sectioning (make-sparse-keymap "sectioning menu")) - (yahtml-define-menu - yahtml-menu-map-sectioning + (YaTeX-define-menu + 'yahtml-menu-map-sectioning (nreverse '((1 "H1" . (lambda () (interactive) (yahtml-insert-begend nil "H1"))) (2 "H2" . (lambda () (interactive) (yahtml-insert-begend nil "H2"))) @@ -347,8 +474,8 @@ (6 "H6" . (lambda () (interactive) (yahtml-insert-begend nil "H6"))) ))) (setq yahtml-menu-map-logical (make-sparse-keymap "logical tags")) - (yahtml-define-menu - yahtml-menu-map-logical + (YaTeX-define-menu + 'yahtml-menu-map-logical (nreverse '((em "Embolden" . (lambda () (interactive) (yahtml-insert-tag nil "EM"))) @@ -368,8 +495,8 @@ (lambda () (interactive) (yahtml-insert-tag nil "VAR"))) ))) (setq yahtml-menu-map-typeface (make-sparse-keymap "typeface tags")) - (yahtml-define-menu - yahtml-menu-map-typeface + (YaTeX-define-menu + 'yahtml-menu-map-typeface (nreverse '((b "Bold" . (lambda () (interactive) (yahtml-insert-tag nil "B"))) @@ -381,8 +508,8 @@ (lambda () (interactive) (yahtml-insert-tag nil "U"))) ))) (setq yahtml-menu-map-listing (make-sparse-keymap "listing")) - (yahtml-define-menu - yahtml-menu-map-listing + (YaTeX-define-menu + 'yahtml-menu-map-listing (nreverse '((ul "Unordered" . (lambda () (interactive) (yahtml-insert-begend nil "UL"))) @@ -392,8 +519,8 @@ (lambda () (interactive) (yahtml-insert-begend nil "DL"))) ))) (setq yahtml-menu-map-item (make-sparse-keymap "item")) - (yahtml-define-menu - yahtml-menu-map-item + (YaTeX-define-menu + 'yahtml-menu-map-item (nreverse '((li "Simple item" . (lambda () (interactive) (yahtml-insert-single "li"))) @@ -408,8 +535,8 @@ (while keys (define-key yahtml-mode-map (car keys) 'yahtml-fill-paragraph) (setq keys (cdr keys)))) - (yahtml-define-menu - yahtml-menu-map + (YaTeX-define-menu + 'yahtml-menu-map (nreverse (list (cons (list 'sect "Sectioning") @@ -423,26 +550,15 @@ (cons (list 'type "Typeface tags") (cons "typeface" yahtml-menu-map-typeface)) ))) + (if (featurep 'xemacs) + (add-hook 'yahtml-mode-hook + '(lambda () + (or (assoc "yahtml" current-menubar) + (progn + (set-buffer-menubar (copy-sequence current-menubar)) + (add-submenu nil yahtml-menu-map)))))) )) -(defun yahtml-collect-url-history () - "Collect urls from global history file." - (interactive) - (save-excursion - (set-buffer - (find-file-noselect (expand-file-name yahtml-url-history-file))) - (goto-char (point-min)) - (setq yahtml-urls) - (message "Collecting global history...") - (while (re-search-forward "^[A-Za-z]+:" nil t) - (setq yahtml-urls - (cons (list - (buffer-substring - (progn (beginning-of-line) (point)) - (progn (skip-chars-forward "^ ") (point)))) - yahtml-urls))) - (message "Collecting global history...Done"))) - ;;; ----------- Completion ---------- (defvar yahtml-last-begend "html") (defun yahtml-insert-begend (&optional region env) @@ -476,7 +592,10 @@ (insert "\n") (indent-to-column cc) (insert (format "</%s>" cmd))) - (yahtml-intelligent-newline nil)))) + (if (string-match "^a\\|p$" cmd) ;aとp決め打ちってのが美しくない… + (newline) + (yahtml-intelligent-newline nil)) + (yahtml-indent-line)))) (defun yahtml-insert-begend-region () "Call yahtml-insert-begend in the region mode." @@ -491,10 +610,12 @@ (let ((completion-ignore-case t)) (setq form (YaTeX-cplread-with-learning - "Form: " + (format "Form(default %s): " yahtml-last-form) 'yahtml-form-table 'yahtml-user-form-table 'yahtml-tmp-form-table)))) (let ((p (point)) q) + (if (string= form "") (setq form yahtml-last-form)) + (setq yahtml-last-form form) (if yahtml-prefer-upcases (setq form (upcase form))) (insert (format "<%s%s>" form (yahtml-addin form))) ;;(indent-relative-maybe) @@ -509,7 +630,7 @@ (if (and (intern-soft addin) (fboundp (intern-soft addin)) (stringp (setq s (funcall (intern addin)))) (string< "" s)) - (concat " " s) + (if (eq (aref s 0) ? ) s (concat " " s)) ""))) @@ -528,9 +649,10 @@ (setq bound (match-end 0)) (search-forward ">" nil t) (if (and (re-search-backward "\\(name\\|id\\)=" bound t) - (goto-char (match-end 0)) - (skip-chars-forward " \t\n") - (looking-at "\"?#?\\([^\">]+\\)\"?\\b")) + (progn + (goto-char (match-end 0)) + (skip-chars-forward " \t\n") + (looking-at "\"?#?\\([^\">]+\\)\"?\\b"))) (setq list (cons (list (concat "#" (YaTeX-match-string 1))) list)))) @@ -548,7 +670,7 @@ (defun yahtml-complete-url () "Complete external URL from history or local file name." (interactive) - (let (initial i2 cmpl path dir file listfunc beg labels (p (point))) + (let ((p (point)) initial i2 cmpl path dir file listfunc beg labels) (setq initial (buffer-string)) (cond ((string-match "^http:" initial) @@ -571,7 +693,7 @@ beg (+ (point-min) beg))) (t (setq path (if (string-match "^/" initial) - (yahtml-url-to-path initial) + (or (yahtml-url-to-path initial) initial) initial)) (setq dir (or (file-name-directory path) ".") file (file-name-nondirectory path) @@ -602,20 +724,23 @@ (defun yahtml:a () "Add-in function for <a>" - (let ((l yahtml-prefer-upcases)) - (or yahtml-urls (yahtml-collect-url-history)) - (setq yahtml-completing-buffer (current-buffer)) -; (concat "href=\"" -; (completing-read "href: " yahtml-urls) -; "\"") - (message "(H)ref (N)ame?") - (cond - ((string-match "[nN]" (char-to-string (read-char))) - (concat (if l "NAME" "name") "=\"" (read-string "name: ") "\"")) - (t - (concat (if l "HREF" "href") "=\"" - (read-from-minibuffer "href: " "" yahtml-url-completion-map) - "\""))))) + (let ((href "")) + (setq yahtml-completing-buffer (current-buffer) + href (read-from-minibuffer "href: " "" yahtml-url-completion-map) + ;; yahtml-urls-local is buffer-local, so we must put + ;; that into yahtml-urls here + yahtml-urls (append yahtml-urls-private yahtml-urls-local)) + (prog1 + (concat (yahtml-make-optional-argument + "href" href) + (yahtml-make-optional-argument + "name" (read-string "name: "))) + (if (and (string-match "^http://" href) + (null (assoc href yahtml-urls))) + (YaTeX-update-table + (list href) + 'yahtml-urls-private 'yahtml-urls-private 'yahtml-urls-local)) + ))) (defvar yahtml-parameters-completion-alist '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center")) @@ -635,19 +760,37 @@ (t (read-string prompt))))) - +(defun yahtml-make-optional-argument (opt arg) + "Make optional argument string." + (if (string= "" arg) + "" + (concat " " (if yahtml-prefer-upcases (upcase opt) (downcase opt)) + "=\"" arg "\""))) + +(defun yahtml:body () + "Add-in function for <body>" + (let ((b (read-string "bgcolor=")) + (x (read-string "text color=")) + (l (read-string "link color=")) + (v (read-string "vlink color="))) + (concat + (yahtml-make-optional-argument "bgcolor" b) + (yahtml-make-optional-argument "text" x) + (yahtml-make-optional-argument "link" l) + (yahtml-make-optional-argument "vlink" v)))) + + (defun yahtml:img () "Add-in function for <img>" - (or yahtml-urls (yahtml-collect-url-history)) (let ((src (yahtml-read-parameter "src")) (alg (yahtml-read-parameter "align")) (alt (yahtml-read-parameter "alt")) + (brd (read-string "border=")) (l yahtml-prefer-upcases)) (concat (if l "SRC" "src") "=\"" src "\"" - (if (string< "" alg) - (concat " " (if l "ALIGN" "align") "=\"" alg "\"")) - (if (string< "" alt) - (concat " " (if l "ALT" "alt") "=\"" alt "\""))))) + (yahtml-make-optional-argument "align" alg) + (yahtml-make-optional-argument "alt" alt) + (yahtml-make-optional-argument "border" brd)))) (defun yahtml:form () "Add-in function `form' input format" @@ -675,10 +818,8 @@ (defun yahtml:p () (let ((alg (yahtml-read-parameter "align"))) - (if (string< "" alg) - (setq alg (concat "align=" alg) - alg (if yahtml-prefer-upcases (upcase alg) (downcase alg))) - ""))) + (yahtml-make-optional-argument "align" alg) +)) (defvar yahtml-input-types '(("text") ("password") ("checkbox") ("radio") ("submit") @@ -697,14 +838,10 @@ maxlength (read-string "maxlength: "))) (concat (if l "NAME" "name") "=\"" name "\"" - (if (string< "" type) - (concat " " (if l "TYPE" "type") "=\"" type "\"")) - (if (string< "" value) - (concat " " (if l "VALUE" "value") "=\"" value "\"")) - (if (string< "" size) - (concat " " (if l "SIZE" "size") "=\"" size "\"")) - (if (string< "" maxlength) - (concat " " (if l "MAXLENGTH" "maxlength") "=\"" maxlength "\"")) + (yahtml-make-optional-argument "type" type) + (yahtml-make-optional-argument "value" value) + (yahtml-make-optional-argument "size" size) + (yahtml-make-optional-argument "maxlength" maxlength) ))) (defun yahtml:textarea () @@ -717,11 +854,16 @@ (concat (concat (if yahtml-prefer-upcases "NAME=" "name=") "\"" name "\"") - (if (string< "" cols) - (concat " " (if yahtml-prefer-upcases "COLS" "cols") "=" cols)) - (if (string< "" rows) - (concat " " (if yahtml-prefer-upcases "ROWS" "rows") "=" rows))))) + (yahtml-make-optional-argument "cols" cols) + (yahtml-make-optional-argument "rows" rows)))) +(defun yahtml:table () + "Add-in function for `table'" + (yahtml-make-optional-argument "border" (read-string "border="))) + +(defun yahtml:font () + "Add-in function for `font'" + (yahtml-make-optional-argument "color" (read-string "color="))) ;;; ---------- Simple tag ---------- (defun yahtml-insert-tag (region-mode &optional tag) @@ -731,7 +873,7 @@ (let ((completion-ignore-case t)) (setq tag (YaTeX-cplread-with-learning - (format "Tag %s(default %s): " + (format "Tag %s(default %s): " (if region-mode "region: " "") yahtml-last-typeface-cmd) 'yahtml-typeface-table 'yahtml-user-typeface-table 'yahtml-tmp-typeface-table)))) @@ -755,6 +897,7 @@ (interactive) (yahtml-insert-tag t tag)) + (defun yahtml-insert-single (cmd) "Insert <CMD>." (interactive @@ -773,6 +916,14 @@ yahtml-last-single-cmd)) (insert (format "<%s>" cmd))) +(defun yahtml-insert-p (&optional arg) + "Convenient function to insert <p></p>" + (interactive "P") + (if arg (yahtml-insert-tag nil "p") + (insert "<p>") + (save-excursion + (insert "</p>")))) + ;;; ---------- Jump ---------- (defun yahtml-on-href-p () "Check if point is on href clause." @@ -785,8 +936,9 @@ (goto-char (get 'YaTeX-inner-environment 'point)) (search-forward "href" e t) (search-forward "=" e t) - (skip-chars-forward " \t\n") - (looking-at "\"?\\([^\"> \t\n]+\\)\"?") + (progn + (skip-chars-forward " \t\n") + (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) (< p (match-end 0)) (YaTeX-match-string 1) )))) @@ -816,6 +968,16 @@ "Call WWW Browser to see HREF." (let ((pb "* WWW Browser *") (cb (current-buffer))) (cond + ((string-match "^start\\>" yahtml-www-browser) + (if (get-buffer pb) + (progn (set-buffer pb) (erase-buffer) (set-buffer cb))) + (put 'yahtml-netscape-sentinel 'url href) + (set-process-sentinel + (setq yahtml-browser-process + (start-process + "browser" pb shell-file-name yahtml-shell-command-option + (format "%s \"%s\"" yahtml-www-browser href))) + 'yahtml-netscape-sentinel)) ((and (string-match "[Nn]etscape" yahtml-www-browser) (not (eq system-type 'windows-nt))) (if (get-buffer pb) @@ -843,7 +1005,7 @@ (defun yahtml-goto-corresponding-href (&optional other) "Go to corresponding name." - (let ((href (yahtml-on-href-p)) file name) + (let ((href (yahtml-on-href-p)) file name (parent buffer-file-name)) (if href (cond ((string-match "^\\(ht\\|f\\)tp:" href) @@ -858,7 +1020,8 @@ (if (string-match "^/" file) (setq file (yahtml-url-to-path file))) (if other (YaTeX-switch-to-buffer-other-window file) - (YaTeX-switch-to-buffer file)))) + (YaTeX-switch-to-buffer file)) + (or YaTeX-parent-file (setq YaTeX-parent-file parent)))) (if name (progn (set-mark-command nil) (yahtml-jump-to-name name))) t))))) @@ -954,6 +1117,7 @@ ((yahtml-goto-corresponding-href other)) ((yahtml-goto-corresponding-img)) ((yahtml-goto-corresponding-begend)) + (t (message "I don't know where to go.")) )) (defun yahtml-goto-corresponding-*-other-window () @@ -961,27 +1125,54 @@ (interactive) (yahtml-goto-corresponding-* t)) +(defun yahtml-visit-main () + "Go to parent file from where you visit current file." + (interactive) + (if YaTeX-parent-file (YaTeX-switch-to-buffer YaTeX-parent-file))) + ;;; ---------- killing ---------- (defun yahtml-kill-begend (&optional whole) - (let ((tag (yahtml-on-begend-p)) (p (make-marker)) (q (make-marker))) + (let ((tag (yahtml-on-begend-p)) p q r) (if tag - (progn + (save-excursion (or (looking-at "<") (progn (skip-chars-backward "^<") (forward-char -1))) - (set-marker p (point)) + (setq p (point)) (yahtml-goto-corresponding-begend) (or (looking-at "<") (progn (skip-chars-backward "^<") (forward-char -1))) - (delete-region (point) (progn (forward-list 1) (point))) - (set-marker q (point)) - (beginning-of-line) - (if (looking-at "^\\s *$") - (delete-region (point) (progn (forward-line 1) (point)))) + (if (< (point) p) ;if on the opening tag + (progn (setq q p p (point)) + (goto-char q)) + (setq q (point))) ;now q has end-line's (point) + (if (not whole) + (kill-region + (progn (skip-chars-backward " \t") (if (bolp) (point) q)) + (progn (forward-list 1) + (setq r (point)) + (skip-chars-forward " \t") + (if (and (eolp) (not (eobp))) (1+ (point)) r)))) (goto-char p) - (delete-region (point) (progn (forward-list 1) (point))) - (if (looking-at "^\\s *$") - (delete-region (point) (progn (forward-line 1) (point)))) - (if whole (delete-region p q)) + (skip-chars-backward " \t") + (if (not whole) + (progn + (kill-append + (buffer-substring + (setq p (if (bolp) (point) p)) + (setq q (progn + (forward-list 1) + (setq r (point)) + (skip-chars-forward " \t") + (if (and (eolp) (not (eobp))) (1+ (point)) r)))) + t) + (delete-region p q)) + (kill-region + (if (bolp) (point) p) + (progn (goto-char q) + (forward-list 1) + (setq r (point)) + (skip-chars-forward " \t") + (if (and (eolp) (not (eobp))) (1+ (point)) r)))) tag)))) (defun yahtml-kill-* (whole) @@ -1024,20 +1215,25 @@ (save-excursion (and (re-search-backward "<a\\b" nil t) - (goto-char (match-end 0)) - (skip-chars-forward " \t\n") - (setq b1 (point)) - (search-forward ">" nil t) + (progn + (goto-char (match-end 0)) + (skip-chars-forward " \t\n") + (setq b1 (point)) + (search-forward ">" nil t)) (setq e1 (match-beginning 0)) (goto-char b1) (re-search-forward "href\\s *=" e1 t) (>= p (point)) - (goto-char (match-end 0)) - (skip-chars-forward " \t\n") - (looking-at "\"?\\([^\"> \t\n]+\\)\"?") + (progn + (goto-char (match-end 0)) + (skip-chars-forward " \t\n") + (looking-at "\"?\\([^\"> \t\n]+\\)\"?")) (< p (match-end 0))))) (setq b1 (match-beginning 1) e1 (match-end 1) yahtml-completing-buffer (current-buffer) + ;; yahtml-urls-local is buffer-local, so we must put + ;; that into yahtml-urls here + yahtml-urls (append yahtml-urls-private yahtml-urls-local) href (read-from-minibuffer "Change href to: " "" yahtml-url-completion-map)) (if (string< "" href) @@ -1123,19 +1319,35 @@ )) ;;; ---------- commenting ---------- -(defun yahtml-comment-region (beg end) - (interactive "r") - (comment-region beg end nil)) +(defun yahtml-comment-region (&optional uncom) + "Comment out region or environment." + (interactive) + (let (e beg p) + (cond + ((setq e (yahtml-on-begend-p)) + (save-excursion + (setq p (point)) + (if (string-match "^/" e) + (setq beg (progn (forward-line 1) (point))) + (setq beg (progn (beginning-of-line) (point)))) + (goto-char p) + (yahtml-goto-corresponding-begend) + (if (string-match "^/" e) + (beginning-of-line) + (forward-line 1)) + (comment-region beg (point) (if uncom (list 4))))) + (t (comment-region (region-beginning) (region-end) + (if uncom (list 4))))))) -(defun yahtml-uncomment-region (beg end) - (interactive "r") - (comment-region beg end '(4))) +(defun yahtml-uncomment-region () + (interactive) + (yahtml-comment-region t)) (defun yahtml-inner-environment-but (exclude &optional quick) "Return the inner environment but matches with EXCLUDE tag." - (let (e) + (let (e (case-fold-search t)) (save-excursion (while (and (setq e (YaTeX-inner-environment quick)) (string-match exclude e)) @@ -1192,8 +1404,11 @@ (fill-region-as-paragraph (progn (re-search-backward paragraph-start nil t) (or (save-excursion - (goto-char (match-end 0)) - (skip-chars-forward " \t>") + (goto-char (match-beginning 0)) + (if (looking-at "<") + (forward-list) + (goto-char (match-end 0)) + (skip-chars-forward " \t>")) (if (looking-at "[ \t]*$") (progn (forward-line 1) (point)))) (point))) @@ -1213,8 +1428,32 @@ ;;; ---------- indentation ---------- ;;; (defun yahtml-indent-line () + "Indent a line (faster wrapper)" (interactive) - (let ((envs "[uod]l\\|table\\|t[rhd]\\|select\\|blockquote") + (let (indent) + (if (and (save-excursion + (beginning-of-line) (skip-chars-forward "\t ") + (not (looking-at "<"))) + (save-excursion + (forward-line -1) + (while (and (not (bobp)) (looking-at "^\\s *$")) + (forward-line -1)) + (skip-chars-forward "\t ") + (setq indent (current-column)) + (not (looking-at "<")))) + (progn + (save-excursion + (beginning-of-line) + (skip-chars-forward " \t") + (or (= (current-column) indent) + (YaTeX-reindent indent))) + (and (bolp) (skip-chars-forward " \t"))) + (yahtml-indent-line-real)))) + +(defun yahtml-indent-line-real () + (interactive) + (let ((envs "[uod]l\\|table\\|[ht][rhd0-6]\\|select\\|blockquote\\|center\\|menu\\|dir") + (itemizing-envs "^\\([uod]l\\|menu\\|dir\\)$") (itms "<\\(dt\\|dd\\|li\\|t[rdh]\\|option\\)\\b") inenv p col peol (case-fold-search t)) (save-excursion @@ -1223,38 +1462,43 @@ "html") col (get 'YaTeX-inner-environment 'indent) p (get 'YaTeX-inner-environment 'point) - op)) + op nil)) (save-excursion (cond ((string-match envs inenv) (save-excursion (beginning-of-line) (skip-chars-forward " \t") - (cond + (cond ;lookup current line's tag ((looking-at (concat "</\\(" envs "\\)>")) (YaTeX-reindent col)) - ((or (looking-at itms) - (and yahtml-hate-too-deep-indentation - (looking-at (concat "<" envs)))) + ((looking-at itms) (YaTeX-reindent (+ col yahtml-environment-indent))) + ((and yahtml-hate-too-deep-indentation + (looking-at (concat "<\\(" envs "\\)"))) + (YaTeX-reindent (+ col (* 2 yahtml-environment-indent)))) ((and (< p (point)) + (string-match itemizing-envs inenv) (save-excursion (and ;;(re-search-backward itms p t) (setq op (point)) (goto-char p) (re-search-forward itms op t) - ;(goto-char (match-end 0)) - (skip-chars-forward "^>") - (skip-chars-forward ">") - (skip-chars-forward " \t") - (setq col (current-column))))) + (progn + (skip-chars-forward "^>") + (skip-chars-forward ">") + (skip-chars-forward " \t") + (setq col (if (looking-at "$") + (+ col yahtml-environment-indent) + (current-column))))))) (YaTeX-reindent col)) (t (YaTeX-reindent (+ col yahtml-environment-indent))))))) (and (bolp) (skip-chars-forward " \t")) (if (and (setq inenv (yahtml-on-begend-p)) - (string-match (concat "^\\(" envs "\\)") inenv)) + (string-match + (concat "^\\<\\(" yahtml-struct-name-regexp "\\)") inenv)) (save-excursion (setq peol (point-end-of-line)) (or (= (char-after (point)) ?<) @@ -1312,6 +1556,7 @@ (defun yahtml-lint-buffer (buf) "Call lint on buffer BUF." + (require 'yatexprc) (interactive "bCall lint on buffer: ") (setq buf (get-buffer buf)) (YaTeX-save-buffers) @@ -1329,7 +1574,7 @@ (setq file (expand-file-name file))) (if (string-match "^[A-Za-z]:/" file) (progn - ;; (aset file 1 ?|) ;$B$3$l$OMW$i$J$$$i$7$$!D(B + ;; (aset file 1 ?|) ;これは要らないらしい… (setq file (concat "///" file)))) (while list (if (string-match (concat "^" (regexp-quote (car (car list)))) file) @@ -1356,15 +1601,16 @@ (if (string-match "\\(http://[^/]*\\)/" url) (setq docroot (substring url (match-end 1))) (setq docroot url)) - (if (string-match (concat "^" (regexp-quote docroot)) file) - (setq realpath - (expand-file-name - (substring - file - (if (= (aref file (1- (match-end 0))) ?/) - (match-end 0) ; "/foo" - (min (1+ (match-end 0)) (length file)))) ; "/~foo" - (car (car list))))) + (cond + ((string-match (concat "^" (regexp-quote docroot)) file) + (setq realpath + (expand-file-name + (substring + file + (if (= (aref file (1- (match-end 0))) ?/) + (match-end 0) ; "/foo" + (min (1+ (match-end 0)) (length file)))) ; "/~foo" + (car (car list)))))) (if realpath (progn (setq list nil) (if (and dirsufp (not (string-match "/$" realpath))) @@ -1406,15 +1652,22 @@ (interactive "P") (let (env func) (end-of-line) - (setq env (downcase (or (YaTeX-inner-environment) "html"))) + (setq env (downcase (or (yahtml-inner-environment-but "^\\(a\\|p\\)\\b" t) + "html"))) (setq func (intern-soft (concat "yahtml-intelligent-newline-" env))) (newline) (if (and env func (fboundp func)) - (funcall func)))) + ;; if intelligent line function is defined, call that + (funcall func) + ;; else do the default action + (if (string-match yahtml-p-prefered-env-regexp env) + (yahtml-insert-p))))) +(defvar yahtml-faithful-to-htmllint nil) (defun yahtml-intelligent-newline-ul () (interactive) - (insert (if yahtml-prefer-upcases "<LI> " "<li> ")) + (yahtml-insert-single "li") + (or yahtml-faithful-to-htmllint (insert " ")) (yahtml-indent-line)) (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul) @@ -1427,13 +1680,19 @@ (get 'YaTeX-inner-environment 'point) t)) (cond ((match-beginning 2) - (insert (if yahtml-prefer-upcases "<DD> " "<dd> ")) + (yahtml-insert-single "dd") + (or yahtml-faithful-to-htmllint (insert " ")) (setq yahtml-last-single-cmd "dt")) ((match-beginning 3) - (insert (if yahtml-prefer-upcases "<DT> " "<dt> ")) + (yahtml-insert-single "dt") + (or yahtml-faithful-to-htmllint (insert " ")) (setq yahtml-last-single-cmd "dd"))) - (insert (if yahtml-prefer-upcases "<DT> " "<dt> "))) - (yahtml-indent-line))) + (insert (if yahtml-prefer-upcases "<DT> " "<dt> ")) + (setq yahtml-last-single-cmd "dd")) + (yahtml-indent-line) + (and (string-match yahtml-p-prefered-env-regexp "dl") + (string-equal yahtml-last-single-cmd "dt") + (yahtml-insert-p nil)))) (defun yahtml-intelligent-newline-select () (interactive) @@ -1478,17 +1737,18 @@ (or (get-buffer yahtml-lint-buffer) (error "No lint program ran.")) (YaTeX-showup-buffer yahtml-lint-buffer nil t) - (yahtml-jump-to-error-line)) + (yahtml-jump-to-error-line t)) -(defun yahtml-jump-to-error-line () - (interactive) +(defun yahtml-jump-to-error-line (&optional sit) + (interactive "P") (let ((p (point)) (e (point-end-of-line))) (end-of-line) (if (re-search-backward yahtml-error-line-regexp nil t) (let ((f (YaTeX-match-string 1)) (l (string-to-int (YaTeX-match-string 2)))) + (if sit (sit-for 1)) (forward-line -1) - (YaTeX-showup-buffer f nil t) + (YaTeX-showup-buffer (YaTeX-switch-to-buffer f t) nil t) (goto-line l)) (message "No line number usage")))) @@ -1513,8 +1773,7 @@ ("</?[uod]l>" 0 decl) ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label) ("<a\\s +href" "</a>" crossref) - ("</?\\sw+>" 0 decl) - ("<form" "</form" form) + (yahtml-hilit-region-tag-itself "</?\\sw+\\>" decl) )) (defun yahtml-hilit-region-tag (tag) @@ -1526,13 +1785,19 @@ (progn (re-search-forward (concat "</" tag ">") nil t) (match-beginning 0)))))) +(defun yahtml-hilit-region-tag-itself (ptn) + "Return list of start/end point of <tag options...> itself." + (if (re-search-forward ptn nil t) + (let ((m0 (match-beginning 0))) + (skip-chars-forward "^>") + (cons m0 (1+ (point) ))))) + ;(setq hilit-patterns-alist (delq (assq 'yahtml-mode hilit-patterns-alist) hilit-patterns-alist)) -(cond - ((and (featurep 'hilit19) (featurep 'yatex19)) - (or (assq 'yahtml-mode hilit-patterns-alist) - (setq hilit-patterns-alist - (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist) - hilit-patterns-alist))))) +(and (featurep 'hilit19) + (or (assq 'yahtml-mode hilit-patterns-alist) + (setq hilit-patterns-alist + (cons (cons 'yahtml-mode yahtml-hilit-patterns-alist) + hilit-patterns-alist)))) (provide 'yahtml)
--- a/yatex.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatex.el Tue Dec 16 13:28:38 1997 +0000 @@ -1,8 +1,8 @@ ;;; -*- Emacs-Lisp -*- ;;; Yet Another tex-mode for emacs. -;;; yatex.el rev. 1.64 +;;; yatex.el rev. 1.65 ;;; (c )1991-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Tue Apr 8 05:07:31 1997 on crx +;;; Last modified Tue Dec 16 22:15:26 1997 on crx ;;; $Id$ ;; This program is free software; you can redistribute it and/or modify @@ -20,10 +20,10 @@ ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. (require 'comment) -(defconst YaTeX-revision-number "1.64" +(require 'yatexlib) +(defconst YaTeX-revision-number "1.65" "Revision number of running yatex.el" ) - ;---------- Local variables ---------- ;;; ;; Initialize local variable for yatex-mode. @@ -39,9 +39,9 @@ (defvar YaTeX-environment-indent 1 "*Indentation depth at column width in LaTeX environments." ) -(defvar YaTeX-fill-prefix "" +(defvar YaTeX-fill-prefix nil "*fill-prefix used for auto-fill-mode. -The default value is null string." +The default value is nil." ) (defvar YaTeX-fill-column 72 "*fill-column used for auto-fill-mode." @@ -57,21 +57,12 @@ return to the editing paragraph by calling register-to-point with argument YaTeX-current-position-register." ) -(defvar YaTeX-dos (eq system-type 'ms-dos)) -(defvar YaTeX-emacs-19 (string= "19" (substring emacs-version 0 2))) -(defvar YaTeX-user-completion-table - (if YaTeX-dos "~/_yatexrc" "~/.yatexrc") - "*Default filename in which user completion table is saved." -) ;;(defvar YaTeX-tmp-dic-unit 'main-file ;; "*Default switching unit of temporary dictionary. ;;There are two switching unit: ;;'main-file : switch tmp-dic according to main-file directory. ;;'directory : switch tmp-dic dir by dir." ;;) -(defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE)) - "Whether yatex mode is running on Japanese environment or not." -) (defvar tex-command (if YaTeX-japan "jlatex" "latex") "*Default command for typesetting LaTeX text." ) @@ -134,19 +125,19 @@ "*Kanji coding system latex command types out. 1 = Shift JIS, 2 = JIS, 3 = EUC." ) -(defvar YaTeX-inhibit-prefix-letter nil - "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter." -) (defvar NTT-jTeX nil - "*Use NTT-jTeX for latex command." + "*T for using NTT-jTeX for latex command. +More precisely, setting t to this variables inhibits inter-word break on +typeset document by line-break of source text. That is, YaTeX automatically +put % after each line at filling. +改行+インデントによって、タイプセット後の字間が空いてしまうのを抑制する場合に +tにする(古いNTT-jTeXで顕著に現れる)。具体的には、fillするときに各行の終わりに +%を付加する。" ) -(defvar YaTeX-item-regexp (concat (regexp-quote "\\") "\\(sub\\)*item") +(defvar YaTeX-item-regexp + (concat (regexp-quote "\\") "\\(sub\\|bib\\)*item") "*Regular expression of item command." ) -(defvar YaTeX-nervous t - "*If you are nervous about maintenance of yatexrc, set this value to T. -And you will have the local dictionary." -) (defvar YaTeX-sectioning-regexp "\\(part\\|chapter\\*?\\|\\(sub\\)*\\(section\\|paragraph\\)\\*?\\)\\b" "*LaTeX sectioning commands regexp." @@ -182,7 +173,7 @@ Define those environments as a form of list." ) (defvar YaTeX-itemizing-env-regexp - "itemize\\|enumerate\\|description\\|list" + "itemize\\|enumerate\\|description\\|list\\|thebibliography" "*Regexp of itemizing environments") (defvar YaTeX-equation-env-regexp "array\\*?\\|equation\\*?" @@ -197,18 +188,9 @@ "*T for removing all continuous commenting character(%). Nil for removing only one commenting character at the beginning-of-line." ) -(defvar YaTeX-default-pop-window-height 10 - "Default typesetting buffer height. -If integer, sets the window-height of typesetting buffer. -If string, sets the percentage of it. -If nil, use default pop-to-buffer." -) (defvar YaTeX-close-paren-always t "Close parenthesis always when YaTeX-modify-mode is nil." ) -(defvar YaTeX-no-begend-shortcut nil - "*T for disabling shortcut of begin-type completion, [prefix] b d, etc." -) (defvar YaTeX-greek-by-maketitle-completion nil "*T for greek letters completion by maketitle-type completion." ) @@ -234,22 +216,22 @@ (append YaTeX-math-key-list-private YaTeX-math-key-list-default) "Key sequence to invoke math-mode's image completion." ) -(defvar YaTeX-create-file-prefix-g nil - "*Non-nil creates new file when [prefix] g on \\include{foo}." -) (defvar YaTeX-skip-default-reader nil "Non-nil skips default argument reader of section-type completion." ) (defvar YaTeX-simple-messages nil "Non-nil makes minibuffer messages simpler." ) +(defvar YaTeX-template-file "~/work/template.tex" + "*Template TeX source file. This will be inserted to empty file." +) (defvar YaTeX-addin-prefix "YaTeX:") ;------------ Completion table ------------ ; Set tex-section-like command possible completion (defvar section-table '(("part") ("chapter") ("section") ("subsection") ("subsubsection") ("paragraph") ("subparagraph") - ("author") ("thanks") ("documentstyle") ("pagestyle") + ("author") ("thanks") ("documentstyle") ("documentclass") ("pagestyle") ("title") ("underline") ("label") ("makebox") ("footnote") ("footnotetext") ("hspace*") ("vspace*") ("bibliography") ("bibitem") ("cite") @@ -258,7 +240,8 @@ ("setcounter" 2) ("addtocounter" 2) ("stepcounter" 2) ("newcommand" 2) ("renewcommand" 2) ("setcounter" 2) ("newenvironment" 3) ("newtheorem" 2) - ("cline") ("framebox") ("savebox" 2) ("date") ("put") ("ref") + ("cline") ("framebox") ("savebox" 2) ("sbox" 2) ("newsavebox") ("usebox") + ("date") ("put") ("ref") ("frac" 2) ("multicolumn" 3) ("shortstack") ) "Default completion table for section-type completion." @@ -324,9 +307,6 @@ (defvar YaTeX-mode-map nil "Keymap used in YaTeX mode" ) -(defvar YaTeX-typesetting-mode-map nil - "Keymap used in YaTeX typesetting buffer" -) (defvar YaTeX-prefix-map nil "Keymap used when YaTeX-prefix key pushed" ) @@ -343,39 +323,6 @@ (defvar YaTeX-math-mode nil "Holds whether current mode is math-mode." ) -;---------- Define default key bindings on YaTeX mode map ---------- -(defun YaTeX-define-key (key binding &optional map) - "Define key on YaTeX-prefix-map." - (if YaTeX-inhibit-prefix-letter - (let ((c (aref key 0))) - (cond - ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a)))) - ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter)) - (aset key 0 (1+ (- c ?A)))) - (t nil)))) - (define-key (or map YaTeX-prefix-map) key binding) -) -(defun YaTeX-define-begend-key-normal (key env &optional map) - "Define short cut YaTeX-make-begin-end key." - (YaTeX-define-key - key - (list 'lambda '(arg) '(interactive "P") - (list 'YaTeX-insert-begin-end env 'arg)) - map) -) -(defun YaTeX-define-begend-region-key (key env &optional map) - "Define short cut YaTeX-make-begin-end-region key." - (YaTeX-define-key key (list 'lambda nil '(interactive) - (list 'YaTeX-insert-begin-end env t)) map) -) -(defun YaTeX-define-begend-key (key env &optional map) - "Define short cut key for begin type completion both for normal -and region mode. To customize YaTeX, user should use this function." - (YaTeX-define-begend-key-normal key env map) - (if YaTeX-inhibit-prefix-letter nil - (YaTeX-define-begend-region-key - (concat (upcase (substring key 0 1)) (substring key 1)) env)) -) ;;; ;; Define key table ;;; @@ -473,16 +420,6 @@ YaTeX-math-key-list) ) -(if YaTeX-typesetting-mode-map nil - (setq YaTeX-typesetting-mode-map (make-keymap)) - ;(suppress-keymap YaTeX-typesetting-mode-map t) - (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line) - (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string) - (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows) - (define-key YaTeX-typesetting-mode-map "0" 'delete-window) - (define-key YaTeX-typesetting-mode-map "q" 'delete-window) -) - (defvar YaTeX-section-completion-map nil "*Key map used at YaTeX completion in the minibuffer.") (if YaTeX-section-completion-map nil @@ -503,53 +440,34 @@ (setq YaTeX-recursive-map (copy-keymap global-map)) (define-key YaTeX-recursive-map YaTeX-prefix YaTeX-prefix-map)) -;; (define-key YaTeX-recursive-map -;; (concat YaTeX-prefix (if YaTeX-inhibit-prefix-letter "\C-s" "s")) -;; 'YaTeX-make-section) -;; (define-key map -;; (concat YaTeX-prefix (if YaTeX-inhibit-prefix-letter "\C-m" "m")) -;; 'YaTeX-make-singlecmd) -;; (define-key map -;; (concat YaTeX-prefix (if YaTeX-inhibit-prefix-letter "\C-l" "l")) -;; 'YaTeX-make-fontsize) - - ;---------- Define other variable ---------- (defvar env-name "document" "*Initial tex-environment completion") (defvar section-name "documentstyle" "*Initial tex-section completion") (defvar fontsize-name "large" "*Initial fontsize completion") (defvar single-command "maketitle" "*Initial LaTeX single command") -(defvar YaTeX-user-table-is-read nil - "Flag that means whether user completion table has been read or not." -) -(defvar YaTeX-kanji-code-alist nil - "Kanji-code expression translation table." -) -(if (boundp 'MULE) - (setq YaTeX-kanji-code-alist - (list (cons - 1 - (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos) - *sjis*)) - '(2 . *junet*) '(3 . *euc-japan*)) -)) (defvar YaTeX-kanji-code (if YaTeX-dos 1 2) "*File kanji code used by Japanese TeX." ) (defvar YaTeX-coding-system nil "File coding system used by Japanese TeX.") -(defvar YaTeX-latex-message-code "Process coding system for LaTeX.") (cond + (YaTeX-emacs-20 + (setq YaTeX-coding-system + (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))) ((boundp 'MULE) (setq YaTeX-coding-system - (symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist)))) - (if (not YaTeX-dos) - (setq YaTeX-latex-message-code *autoconv*))) + (symbol-value (cdr (assoc YaTeX-kanji-code YaTeX-kanji-code-alist))))) ((boundp 'NEMACS) - (setq YaTeX-latex-message-code latex-message-kanji-code)) + (setq YaTeX-latex-message-code latex-message-kanji-code))) + +(defvar YaTeX-mode-syntax-table nil + "*Syntax table for yatex-mode") + +(if YaTeX-mode-syntax-table nil + (setq YaTeX-mode-syntax-table (make-syntax-table (standard-syntax-table))) + (modify-syntax-entry ?\< "(>" YaTeX-mode-syntax-table) + (modify-syntax-entry ?\> ")<" YaTeX-mode-syntax-table) + (modify-syntax-entry ?\n " " YaTeX-mode-syntax-table) ) -(defvar YaTeX-parent-file nil - "*Main LaTeX source file name used when %#! expression doesn't exist.") -(make-variable-buffer-local 'YaTeX-parent-file) ;---------- Provide YaTeX-mode ---------- ;;; @@ -628,6 +546,12 @@ )) (cond ((boundp 'MULE) (set-file-coding-system YaTeX-coding-system)) + ((and YaTeX-emacs-20 (fboundp 'coding-system-equal)) + (or (coding-system-equal + YaTeX-coding-system buffer-file-coding-system) + (set-buffer-file-coding-system YaTeX-coding-system))) + ((featurep 'mule) + (set-file-coding-system YaTeX-coding-system)) ((boundp 'NEMACS) (make-local-variable 'kanji-fileio-code) (setq kanji-fileio-code YaTeX-kanji-code))) @@ -641,10 +565,14 @@ ;;comment-start-skip "[^\\\\]%+[ \t]*" ) (use-local-map YaTeX-mode-map) + (set-syntax-table YaTeX-mode-syntax-table) (if YaTeX-dos (setq YaTeX-saved-screen-height (screen-height))) (YaTeX-read-user-completion-table) (and (fboundp 'YaTeX-19-collect-macros) (YaTeX-19-collect-macros)) (turn-on-auto-fill) ;1.63 + (and (= 0 (buffer-size)) (file-exists-p YaTeX-template-file) + (y-or-n-p (format "Insert %s?" YaTeX-template-file)) + (insert-file-contents (expand-file-name YaTeX-template-file))) (run-hooks 'text-mode-hook 'yatex-mode-hook) ) @@ -653,9 +581,10 @@ (defvar YaTeX-ec-regexp (regexp-quote YaTeX-ec)) (defvar YaTeX-struct-begin (concat YaTeX-ec "begin{%1}%2") - "Keyword to begin environment.") -(defvar YaTeX-struct-end (concat YaTeX-ec "end{%1}") - "Keyword to end environment.") + "Keyword format of begin-environment.") +(defvar YaTeX-struct-end + (concat YaTeX-ec "end{%1}") + "Keyword format of end-environment.") (defvar YaTeX-struct-name-regexp "[^}]+" "Environment name regexp.") (defvar YaTeX-TeX-token-regexp @@ -672,25 +601,6 @@ ;;; ;; autoload section ;;; -;;autoload from yatexlib(general functions). -(autoload 'YaTeX-showup-buffer "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-window-list "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-search-active-forward "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-search-active-backward "yatexlib" "YaTeX library" t) -(autoload 'substitute-all-key-definition "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-switch-to-buffer "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-switch-to-buffer-other-window "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-replace-format "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-replace-format-args "yatexlib" "YaTeX library" t) -(autoload 'rindex "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-match-string "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-minibuffer-complete "yatexlib" "YaTeX library" t) -(autoload 'goto-buffer-window "yatexlib" "YaTeX library" t) -(autoload 'split-window-calculate-height "yatexlib" "YaTeX library" t) -(autoload 'read-string-with-history "yatexlib" "YaTeX library" t) -(autoload 'read-from-minibuffer-with-history "yatexlib" "YaTeX library" t) -(autoload 'completing-read-with-history "yatexlib" "YaTeX library" t) -(autoload 'YaTeX-switch-to-window "yatexlib" "For windows.el" t) ;;autoload from yatexprc.el (autoload 'YaTeX-visit-main "yatexprc" "Visit main LaTeX file." t) @@ -782,7 +692,8 @@ (insert "\n") (or exchange (exchange-point-and-mark))) (goto-char beg2) - (YaTeX-intelligent-newline nil)) + (YaTeX-intelligent-newline nil) + (YaTeX-indent-line)) (if YaTeX-current-position-register (point-to-register YaTeX-current-position-register))) ) @@ -813,93 +724,6 @@ (YaTeX-make-begin-end t) ) -(defun YaTeX-inner-environment (&optional quick) - "Return current inner-most environment. -Non-nil for optional argument QUICK restricts search bound to most -recent sectioning command. Matching point is stored to property 'point -of 'YaTeX-inner-environment, which can be referred by - (get 'YaTeX-inner-environment 'point)." - (let*((nest 0) - (beg (YaTeX-replace-format-args - (regexp-quote YaTeX-struct-begin) - YaTeX-struct-name-regexp - (if (eq major-mode 'yahtml-mode) "\\s *.*" "") - "")) - (end (YaTeX-replace-format-args - (regexp-quote YaTeX-struct-end) - YaTeX-struct-name-regexp "" "")) - (begend (concat "\\(" beg "\\)\\|\\(" end "\\)")) - bound m0 - (open - (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{"))) - (close - (concat "^" - (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}")))) - (save-excursion - (if quick - (setq bound - (save-excursion - (YaTeX-re-search-active-backward - (concat YaTeX-ec-regexp - "\\(" YaTeX-sectioning-regexp "\\)\\*?\\{") - YaTeX-comment-prefix nil 1) - (or (bobp) (end-of-line)) - (point)))) - (if (catch 'begin - (if (and (numberp bound) (< (point) bound)) (throw 'begin nil)) - (while (YaTeX-re-search-active-backward - begend YaTeX-comment-prefix bound t) - (setq m0 (match-beginning 0)) - (if (looking-at end) ;;(match-beginning 2) - (setq nest (1+ nest)) - (setq nest (1- nest))) - (if (< nest 0) - (progn - (put 'YaTeX-inner-environment 'point m0) - (goto-char m0) - (put 'YaTeX-inner-environment 'indent (current-column)) - (throw 'begin t))))) - (buffer-substring - (progn (skip-chars-forward open) (1+ (point))) - (progn (skip-chars-forward close) (point)))))) -) - -(defun YaTeX-end-environment () - "Close opening environment" - (interactive) - (let ((env (YaTeX-inner-environment))) - (if (not env) (error "No premature environment") - (save-excursion - (if (YaTeX-search-active-forward - (YaTeX-replace-format-args YaTeX-struct-end env "" "") - YaTeX-comment-prefix nil t) - (if (y-or-n-p - (concat "Environment `" env - "' may be already closed. Force close?")) - nil - (error "end environment aborted.")))) - (message "") ;Erase (y or n) message. - (YaTeX-insert-struc 'end env) - (save-excursion - (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0))) - (if (pos-visible-in-window-p) - (sit-for (if YaTeX-dos 2 1)) - (message "Matches with %s at line %d" - (YaTeX-replace-format-args YaTeX-struct-begin env "" "") - (count-lines (point-min) (point))))))) -) - -;;;VER2 -(defun YaTeX-insert-struc (what env) - (cond - ((eq what 'begin) - (insert (YaTeX-replace-format-args - YaTeX-struct-begin env (YaTeX-addin env)))) - ((eq what 'end) - (insert (YaTeX-replace-format-args YaTeX-struct-end env))) - (t nil)) -) - (defun YaTeX-make-section (arg &optional beg end cmd) "Make LaTeX \\section{} type command with completing read. With numeric ARG, you can specify the number of arguments of @@ -955,7 +779,8 @@ (goto-char (marker-position e))) (use-global-map YaTeX-recursive-map) (if (= numarg 0) (YaTeX-make-singlecmd section-name) - (insert YaTeX-ec section-name (YaTeX-addin section-name))) + (progn (insert YaTeX-ec section-name) + (insert (YaTeX-addin section-name)))) (while (<= j numarg) (insert "{" @@ -1629,10 +1454,10 @@ ") (defvar YaTeX-processed-file-regexp-alist-default - '(("\\\\epsfile{[^},]*file=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 1) + '(("\\\\epsfile\\(\\[[^]]+\\]\\)?{[^},]*file=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) ("\\\\epsfig{[^},]*fi\\(le\\|gure\\)=\\(\\([^,} ]*/\\)?[^,}. ]+\\)\\(\\.e?ps\\)?[^}]*}" 2) ("\\\\postscriptbox{[^}]*}{[^}]*}{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 1) - ("\\\\\\(epsfbox\\|includegraphics\\){\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 2) + ("\\\\\\(epsfbox\\|includegraphics\\|epsfig\\)\\*?{\\(\\([^,} ]*/\\)?[^}. ]+\\)\\(\\.e?ps\\)?}" 2) ;\epsfbox{hoge.ps} or \includegraphics{hoge.eps} ("\\\\\\(psbox\\)\\(\\[[^]]+\\]\\)?{\\(\\([^,} ]*/\\)?[^} ]+\\)\\(\\.e?ps\\)}" 3) ;\psbox[options...]{hoge.eps} (97/1/11) ) "See the documentation of YaTeX-processed-file-regexp-alist." @@ -1985,34 +1810,55 @@ (if once (end-of-line))) ) -(defun YaTeX-kill-option-string () - (if (and (eq predicate 'YaTeX-on-begin-end-p) - (looking-at "\\(\\[.*\\]\\)*\\({.*}\\)*")) - (delete-region (match-beginning 0) (match-end 0))) -) - (defun YaTeX-kill-some-pairs (predicate gofunc kill-contents) "Kill some matching pair. -This function assumes that pairs occupy each line where they resid." - ;;(interactive) +This function assumes that pairs occupy whole of each line where they resid." (if (not (funcall predicate)) nil - (let ((beg (make-marker)) (end (make-marker)) (p (make-marker))) - (set-marker end (match-end 0)) - (if (match-beginning 2) - (set-marker beg (match-beginning 2)) - (set-marker beg (match-beginning 1)) - (goto-char (match-end 0)) - (YaTeX-kill-option-string)) + (let ((b1 (match-beginning 0)) (e1 (match-end 0)) + b2 e2) (save-excursion (funcall gofunc) - (delete-region (point-beginning-of-line) (match-end 0)) - (YaTeX-kill-option-string) - (if (and (eolp) (not (eobp))) (delete-char 1)) - (set-marker p (point)) - (goto-char beg) - (delete-region (point-beginning-of-line) end) - (if (and (eolp) (not (eobp))) (delete-char 1)) - (if kill-contents (delete-region p (point)))) + (funcall predicate) ;get match data + (if (< (point) e1) ;if currently on begin-line + (progn + (setq b2 b1 e2 e1 + b1 (match-beginning 0) e1 (match-end 0)) + (goto-char e2)) ;goto end-line's end + (setq b2 (match-beginning 0) + e2 (match-end 0)) + (goto-char e2)) ;now e2 has surely end-line's end + (skip-chars-forward " \t") + (and (eolp) + (not (eobp)) + (setq e2 (1+ (point)))) + (if (not kill-contents) + (kill-region + (progn + (goto-char b2) + (skip-chars-backward " \t") + (if (bolp) (point) b2)) + e2)) + (goto-char b1) + (skip-chars-backward " \t") + (if (not kill-contents) + (progn + (kill-append + (buffer-substring + (setq b1 (if (bolp) (point) b1)) + (setq e1 + (progn + (goto-char e1) + (while (looking-at "{\\| \t") + (forward-list 1)) + (skip-chars-forward " \t") + (if (and (eolp) (not (eobp))) + (1+ (point)) + (point))))) + t) + (delete-region b1 e1)) + (kill-region + (if (bolp) (point) b1) + e2))) t)) ) @@ -2094,7 +1940,9 @@ (require 'yatexsec) ;some case needs this (if (> (minibuffer-depth) 1) (error "Too many minibuffer levels for overview.")) - (let ((sw (selected-window))(enable-recursive-minibuffers t) sect) + (let ((sw (selected-window)) + (minibuffer-max-depth nil) ; for XEmacs20 + (enable-recursive-minibuffers t) sect) (unwind-protect (progn (select-window source-window) @@ -2622,17 +2470,6 @@ (skip-chars-forward " \t") (current-column))) -(defun YaTeX-reindent (col) - "Remove current indentation and reindento to COL column." - (save-excursion - (beginning-of-line) - (skip-chars-forward " \t") - (if (/= col (current-column)) - (progn - (delete-region (point) (progn (beginning-of-line) (point))) - (indent-to col)))) - (skip-chars-forward " \t" (point-end-of-line))) - (defun YaTeX-indent-line () "Indent corrent line referrin current environment." (interactive) @@ -2706,8 +2543,14 @@ ((and (bolp) fill-prefix) (insert fill-prefix)) (t (save-excursion (beginning-of-line) - (skip-chars-forward " \t") - (indent-relative-maybe)) + (if fill-prefix + (progn + (delete-region (point) + (progn (skip-chars-forward " \t") + (point))) + (insert fill-prefix)) + (skip-chars-forward " \t") + (indent-relative-maybe))) (skip-chars-forward " \t"))) ;;if current line is \begin, re-indent \end too (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) @@ -2747,179 +2590,6 @@ (insert YaTeX-comment-prefix)))))) ) -(defun YaTeX-local-table-symbol (symbol) - "Return the lisp symbol which keeps local completion table of SYMBOL." - (intern (concat "YaTeX$" - default-directory - (symbol-name symbol))) -) - -(defun YaTeX-sync-local-table (symbol) - "Synchronize local variable SYMBOL. -Copy its corresponding directory dependent completion table to SYMBOL." - (if (boundp (YaTeX-local-table-symbol symbol)) - (set symbol (symbol-value (YaTeX-local-table-symbol symbol)))) -) - -(defun YaTeX-read-user-completion-table (&optional forcetoread) - "Append user completion table of LaTeX macros" - (let*((user-table (expand-file-name YaTeX-user-completion-table)) - (local-table (expand-file-name (file-name-nondirectory user-table))) - var localvar localbuf (curbuf (current-buffer)) sexp) - (if YaTeX-user-table-is-read nil - (message "Loading user completion table") - (if (file-exists-p user-table) (load-file user-table) - (message "Welcome to the field of YaTeX. I'm glad to see you!"))) - (setq YaTeX-user-table-is-read t) - (cond - ((file-exists-p local-table) - (set-buffer (setq localbuf (find-file-noselect local-table))) - (widen) - (goto-char (point-min)) - (while (re-search-forward "(setq \\([^ ]+\\)" nil t) - (setq var (intern (buffer-substring - (match-beginning 1) (match-end 1))) - localvar (YaTeX-local-table-symbol var)) - (goto-char (match-beginning 0)) - (setq sexp (buffer-substring (point) - (progn (forward-sexp) (point)))) - (set-buffer curbuf) - (or (assq var (buffer-local-variables)) (make-local-variable var)) - (eval (read sexp)) - (or (and (boundp localvar) - (symbol-value localvar) - (not forcetoread)) - (set localvar (symbol-value var))) - (set-buffer localbuf)) - (kill-buffer localbuf))) - (set-buffer curbuf)) -) - -(defun YaTeX-reload-dictionary () - "Reload local dictionary. -Use this function after editing ./.yatexrc." - (interactive) - (let ((YaTeX-user-table-is-read nil)) - (YaTeX-read-user-completion-table t)) -) - -(defun YaTeX-lookup-table (word type) - "Lookup WORD in completion table whose type is TYPE. -This function refers the symbol tmp-TYPE-table, user-TYPE-table, TYPE-table. -Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd." - (if (symbolp type) (setq type (symbol-name type))) - (or (assoc word (symbol-value (intern (concat "tmp-" type "-table")))) - (assoc word (symbol-value (intern (concat "user-" type "-table")))) - (assoc word (symbol-value (intern (concat type "-table")))))) - -(defun YaTeX-update-table (vallist default-table user-table local-table) - "Update completion table if the car of VALLIST is not in current tables. -Second argument DEFAULT-TABLE is the quoted symbol of default completion -table, third argument USER-TABLE is user table which will be saved in -YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the -completion which is valid during current Emacs's session. If you -want to make LOCAL-TABLE valid longer span (but restrict in this directory) -create the file in current directory which has the same name with -YaTeX-user-completion-table." - (let ((car-v (car vallist)) key answer - (file (file-name-nondirectory YaTeX-user-completion-table))) - (cond - ((assoc car-v (symbol-value default-table)) - nil) ;Nothing to do - ((setq key (assoc car-v (symbol-value user-table))) - (if (equal (cdr vallist) (cdr key)) nil - ;; if association hits, but contents differ. - (message - "%s's attributes turned into %s" (car vallist) (cdr vallist)) - (set user-table (delq key (symbol-value user-table))) - (set user-table (cons vallist (symbol-value user-table))) - (YaTeX-update-dictionary - YaTeX-user-completion-table user-table "user"))) - ((setq key (assoc car-v (symbol-value local-table))) - (if (equal (cdr vallist) (cdr key)) nil - (message - "%s's attributes turned into %s" (car vallist) (cdr vallist)) - (set local-table (delq key (symbol-value local-table))) - (set local-table (cons vallist (symbol-value local-table))) - (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) - (YaTeX-update-dictionary file local-table))) - ;; All of above cases, there are some completion in tables. - ;; Then update tables. - (t - (if (not YaTeX-nervous) - (setq answer "u") - (message - "`%s' is not in table. Register into: U)serDic L)ocalDic N)one D)iscard" - (car vallist)) - (setq answer (char-to-string (read-char)))) - (cond - ((string-match answer "uy") - (set user-table (cons vallist (symbol-value user-table))) - (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user") - ) - ((string-match answer "tl") - (set local-table (cons vallist (symbol-value local-table))) - (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) - (YaTeX-update-dictionary file local-table)) - ((string-match answer "d") nil) ;discard it - (t (set default-table - (cons vallist (symbol-value default-table)))))))) -) - -(defun YaTeX-cplread-with-learning - (prom default-table user-table local-table - &optional pred reqmatch init hsym) - "Completing read with learning. -Do a completing read with prompt PROM. Completion table is what -DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order. -Note that these tables are passed by the symbol. -Optional arguments PRED, REQMATH and INIT are passed to completing-read -as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively. -If optional 8th argument HSYM, history symbol, is passed, use it as -history list variable." - (YaTeX-sync-local-table local-table) - (let*((table (append (symbol-value local-table) - (symbol-value user-table) - (symbol-value default-table))) - (word (completing-read-with-history - prom table pred reqmatch init hsym))) - (if (and (string< "" word) (not (assoc word table))) - (YaTeX-update-table (list word) default-table user-table local-table)) - word) -) - -(defun YaTeX-update-dictionary (file symbol &optional type) - (let ((local-table-buf (find-file-noselect file)) - (name (symbol-name symbol)) - (value (symbol-value symbol))) - (save-excursion - (message "Updating %s dictionary..." (or type "local")) - (set-buffer local-table-buf) - (goto-char (point-max)) - (search-backward (concat "(setq " name) nil t) - (delete-region (point) (progn (forward-sexp) (point))) - (delete-blank-lines) - (insert "(setq " name " '(\n") - (mapcar '(lambda (s) - (insert (format "%s\n" (prin1-to-string s)))) - value) - (insert "))\n\n") - (delete-blank-lines) - (basic-save-buffer) - (kill-buffer local-table-buf) - (message "Updating %s dictionary...Done" (or type "local")))) -) - -;; --------------- General sub functions --------------- -(defun point-beginning-of-line () - (save-excursion (beginning-of-line)(point)) -) - -(defun point-end-of-line () - (save-excursion (end-of-line)(point)) -) - - (provide 'yatex) (defvar yatex-mode-load-hook nil "*List of functions to be called when yatex.el is loaded.")
--- a/yatex.new Sat Dec 13 12:41:43 1997 +0000 +++ b/yatex.new Tue Dec 16 13:28:38 1997 +0000 @@ -1,6 +1,27 @@ What's new in YaTeX 野鳥/yahtml - 各バージョンの変更点について +1.65 yahtmlのお任せ改行のバグフィクス。 + a, body, img タグのオプション引数入力アドインの強化。 + section型マクロの第一引数が改行によって分断されていても正しく + hilitするようにした。 + yahtmlの行インデント関数の高速化。カレント行がタグで始まらないと + きは直前の非空行のインデントを真似するようにした。副作用あるかも。 + thebibliography環境でitemize系インデントが効いていなかったのを修正。 + GNU Emacs 20 対応(by竹中さん&me)。 + XEmacs 20 対応。 + yahtmlパッケージの独立性強化。 + [prefix] k で環境を消したときはkill-ringに追加するようにした。 + yahtml-hate-too-deep-indentation がtのときにインデントが浅くなり + すぎるのを修正。 + href 補完の http:// ヒストリを .mosaic-global-history から取るの + を廃止し、ユーザ辞書に登録するようにした。 + yahtmlの [prefix] p で <p></p> が出るようにした。 + yahtmlのおまかせ改行で、yahtml-p-prefered-env-regexp にマッチす + るタグ環境内のときは<p></p>を自動挿入するようにした。 + YaTeX-fill-prefix, yahtml-fill-prefix(新設)のデフォルトをnilに。 + YaTeX-template-file, yahtml-template-file を新規ファイルに挿入。 + 1.64 yahtmlを起動するとYaTeXで [prefix] Bc が<center>などになってしま うのを修正。 NTT-jTeX が t のときにfillがうまく行かないことがあるのを修正。 @@ -20,14 +41,14 @@ \のあとに{を入れたときは\}を入れるようにした。 yahtmlでブラウザにIEを指定したときの不具合を修正。 -1.62 \ref の引数が二行に渡る時行末に%を付けるようにした - yahtmlでおまかせ改行が不必要に起動するのを修正 - href の補完文字列に # が含まれる時は name を補完 +1.62 \ref の引数が二行に渡る時行末に%を付けるようにした。 + yahtmlでおまかせ改行が不必要に起動するのを修正。 + href の補完文字列に # が含まれる時は name を補完。 \epsfile{file=foo.eps} などで [prefix] g した場合、foo.epsの元絵 - を編集しているお絵書きソフトを起動するようにした - yahtmlで [prefix] a で < などが入るようにした - verbatim環境の [prefix] g がうまく飛ばなかったのを修正 - sectionのオプション引数をつけた時の色づけが無効だったのを修正 + を編集しているお絵書きソフトを起動するようにした。 + yahtmlで [prefix] a で < などが入るようにした。 + verbatim環境の [prefix] g がうまく飛ばなかったのを修正。 + sectionのオプション引数をつけた時の色づけが無効だったのを修正。 1.61 AMS-LaTeX 対応 xdvi -remote によるサーチに対応 [prefix] t s
--- a/yatex19.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatex19.el Tue Dec 16 13:28:38 1997 +0000 @@ -1,7 +1,7 @@ ;;; -*- Emacs-Lisp -*- ;;; YaTeX facilities for Emacs 19 ;;; (c )1994-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Fri Feb 14 13:52:54 1997 on supra +;;; Last modified Sun Dec 14 21:51:14 1997 on firestorm ;;; $Id$ ;;; とりあえず hilit19 を使っている時に色が付くようにして @@ -9,146 +9,117 @@ ;;; いったい誰がメニューバー使ってLaTeXソース書くんだろうか? ;;; まあいいや練習練習。後ろの方にちょっとコメントあり。 ;;; 真中辺にあるけど、hilit19.el 対応の方は結構本気。 - -(require 'yatex) +;;; とかいってるうちに hilit19 って obsolete になってしまった… -(defun YaTeX-19-define-sub-menu (map vec &rest bindings) - "Define sub-menu-item in MAP at vector VEC as BINDINGS. -BINDINGS is a form with optional length: (symbol title binding). -When you defined menu-bar keymap such like: - (define-key foo-map [menu-bar foo] (make-sparse-keymap \"foo menu\")) -and you want to define sub menu for `foo menu' as followings. - foo -> menu1 (calling function `func1') - menu2 (doing interactive call `(func2 ...)' -Call this function like this: - (YaTeX-19-define-sub-menu foo-map [menu-bar foo] - '(m1 \"Function 1\" func1) - '(m2 \"Function 2\" (lambda () (interactive) (func2 ...)))) -where - `m1' and `m2' are the keymap symbol for sub-menu of `[menu-bar foo]. - `Funtion 1' and `Function 2' are the title strings for sub-menu. -" - (let ((i 0) (vec2 (make-vector (1+ (length vec)) nil))) - (while (< i (length vec)) - (aset vec2 i (aref vec i)) - (setq i (1+ i))) - (setq bindings (reverse bindings)) - (mapcar - (function - (lambda (bind) - (aset vec2 (1- (length vec2)) (car bind)) ;set menu-symbol - (define-key map vec2 - (cons (car (cdr bind)) - (car (cdr (cdr bind))))))) - bindings))) +;(require 'yatex) -;; Menu for Typeset relating processes ---------------------------------------- +(defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX")) +(defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process")) (define-key YaTeX-mode-map [menu-bar yatex] - (cons "YaTeX" (make-sparse-keymap "YaTeX"))) -(define-key YaTeX-mode-map [menu-bar yatex process] - (cons "Process" (make-sparse-keymap "Process"))) -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex process] - '(buffer "LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?j))) - '(kill "Kill LaTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?k))) - '(bibtex "BibTeX" (lambda () (interactive) (YaTeX-typeset-menu nil ?b))) - '(makeindex "makeindex" (lambda () (interactive) (YaTeX-typeset-menu nil ?i))) - '(preview "Preview" (lambda () (interactive) (YaTeX-typeset-menu nil ?p))) - '(lpr "lpr" (lambda () (interactive) (YaTeX-typeset-menu nil ?l))) - '(lpq "lpq" (lambda () (interactive) (YaTeX-typeset-menu nil ?q))) -) + (cons "YaTeX" YaTeX-mode-menu-map)) +(YaTeX-define-menu + 'YaTeX-mode-menu-map-process + (nreverse + '((buffer "LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?j))) + (kill "Kill LaTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?k))) + (bibtex "BibTeX" . (lambda () (interactive) (YaTeX-typeset-menu nil ?b))) + (mindex "makeindex" . (lambda () (interactive) (YaTeX-typeset-menu nil ?i))) + (preview "Preview" . (lambda () (interactive) (YaTeX-typeset-menu nil ?p))) + (lpr "lpr" . (lambda () (interactive) (YaTeX-typeset-menu nil ?l))) + (lpq "lpq" . (lambda () (interactive) (YaTeX-typeset-menu nil ?q)))))) +(defvar YaTeX-mode-menu-map-modes (make-sparse-keymap "Modes")) +(YaTeX-define-menu + 'YaTeX-mode-menu-map-modes + (delq nil + (nreverse + (list + (if YaTeX-auto-math-mode nil + (cons 'math (cons "Toggle math-mode" + '(lambda () (interactive) + (YaTeX-switch-mode-menu nil ?t))))) + (cons 'mod (cons "Toggle Modify Mode" + '(lambda () (interactive) + (YaTeX-switch-mode-menu nil ?m)))))))) +(defvar YaTeX-mode-menu-map-percent (make-sparse-keymap "percent")) +(YaTeX-define-menu + 'YaTeX-mode-menu-map-percent + (nreverse + '((! "Change LaTeX typesetter(%#!)" + . (lambda () (interactive) (YaTeX-%-menu nil nil ?!))) + (begend "Set %#BEGIN-%#END on region" + . (lambda () (interactive) (YaTeX-%-menu nil nil ?b))) + (lpr "Change LPR format" + . (lambda () (interactive) (YaTeX-%-menu nil nil ?l)))))) -;; Help for LaTeX ------------------------------------------------------------ -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex] - '(sephelp "--") - '(help "Help on LaTeX commands" YaTeX-help) - '(apropos "Apropos on LaTeX commands" YaTeX-apropos)) - -;; Switch modes -------------------------------------------------------------- -(define-key YaTeX-mode-map [menu-bar yatex switch] - (cons "Switching YaTeX's modes" (make-sparse-keymap "modes"))) -(or YaTeX-auto-math-mode - (define-key YaTeX-mode-map [menu-bar yatex switch math] - '("Toggle math mode" . (lambda () (interactive) - (YaTeX-switch-mode-menu nil ?t))))) -(define-key YaTeX-mode-map [menu-bar yatex switch mod] - '("Toggle modify mode" . (lambda () (interactive) - (YaTeX-switch-mode-menu nil ?m)))) +(defvar YaTeX-mode-menu-map-jump (make-sparse-keymap "jump")) +(YaTeX-define-menu + 'YaTeX-mode-menu-map-jump + (nreverse + '((corres "Goto corersponding position" . YaTeX-goto-corresponding-*) + (main "Visit main source" + . (lambda () (interactive) (YaTeX-visit-main))) + (main-other "Visit main source other window" + . YaTeX-visit-main-other-window)))) -;; % menu -------------------------------------------------------------------- -(define-key YaTeX-mode-map [menu-bar yatex percent] - (cons "Edit %# notation" (make-sparse-keymap "Edit %# notation"))) -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex percent] - '(! "Change LaTeX typesetter(%#!)" - (lambda () (interactive) (YaTeX-%-menu nil nil ?!))) - '(begend "Set %#BEGIN-%#END on region" - (lambda () (interactive) (YaTeX-%-menu nil nil ?b))) - '(lpr "Change LPR format" - (lambda () (interactive) (YaTeX-%-menu nil nil ?l)))) - -;; What position ------------------------------------------------------------- -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex] - '(what "What column in tabular" YaTeX-what-column)) - -;; Document hierarchy ------------------------------------------------------ -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex] - '(hier "Display document hierarchy" YaTeX-display-hierarchy-directly)) - -;; Jump cursor --------------------------------------------------------------- -(define-key YaTeX-mode-map [menu-bar yatex jump] - (cons "Jump cursor" - (make-sparse-keymap "Jump cursor"))) -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex jump] - '(corres "Goto corersponding position" YaTeX-goto-corresponding-*) - '(main "Visit main source" (lambda () (interactive) (YaTeX-visit-main))) - '(main-other "Visit main source other window" YaTeX-visit-main-other-window) - ) - -;; =========================================================================== -(define-key YaTeX-mode-map [menu-bar yatex sepcom] - '("---" . nil)) +(defvar YaTeX-mode-menu-map-comment (make-sparse-keymap "comment")) +(YaTeX-define-menu + 'YaTeX-mode-menu-map-comment + (nreverse + '((comment "Comment region or environment" . YaTeX-comment-region) + (uncomment "Unomment region or environment" . YaTeX-uncomment-region) + (commentp "Comment paragraph" . YaTeX-comment-paragraph) + (uncommentp "Uncomment paragraph" . YaTeX-uncomment-paragraph)))) -;; Comment/Uncomment --------------------------------------------------------- -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex] - '(comment "Comment region or environment" YaTeX-comment-region) - '(uncomment "Unomment region or environment" YaTeX-uncomment-region) - '(commentp "Comment paragraph" YaTeX-comment-paragraph) - '(uncommentp "Uncomment paragraph" YaTeX-uncomment-paragraph) - '(sepcom "--" nil) -) - +(YaTeX-define-menu + 'YaTeX-mode-menu-map + (nreverse + (list + ;; Change/Kill/Fill ------------------------------------------------------- + (cons (list 'chg "Change") (cons "Change macros" 'YaTeX-change-*)) + (cons (list 'kill "Kill") (cons "Kill macros" 'YaTeX-kill-*)) + (cons (list 'fill "Fill") (cons "Fill \\item" 'YaTeX-fill-item)) + (cons (list 'nl "Newline") (cons "Newline" 'YaTeX-intelligent-newline)) + ;; ======================================================================== + (cons (list 'sep1 "---") (cons "---" nil)) + ;; Comment/Uncomment ------------------------------------------------------ + (cons (list 'comment "comment") (cons "Comment region or environment" + 'YaTeX-comment-region)) + (cons (list 'uncomment "uncomment") (cons "Uncomment region or environment" + 'YaTeX-uncomment-region)) + (cons (list 'commentp "commentp") (cons "Comment paragraph" + 'YaTeX-comment-paragraph)) + (cons (list 'uncommentp "uncommentp") (cons "Uncomment paragraph" + 'YaTeX-uncomment-paragraph)) + ;; ======================================================================== + (cons (list 'sep2 "---") (cons "---" nil)) + ;; Jump cursor ------------------------------------------------------------ + (cons (list 'jump "jump") (cons "Jump Cursor" YaTeX-mode-menu-map-jump)) + ;; Document hierarchy --------------------------------------------------- + (cons (list 'hier "hier") (cons "Display Document hierarchy" + 'YaTeX-display-hierarchy)) + ;; What position ---------------------------------------------------------- + (cons (list 'col "column") (cons "What column in tabular" + 'YaTeX-what-column)) + ;; % menu ----------------------------------------------------------------- + (cons (list 'percent "percent") (cons "Edit %# notation" + YaTeX-mode-menu-map-percent)) + ;; Switch modes ----------------------------------------------------------- + (cons (list 'mode "mode") (cons "Switching YaTeX's modes" + YaTeX-mode-menu-map-modes)) + ;; ======================================================================== + (cons (list 'sep "---") (cons "---" nil)) + ;; Help for LaTeX --------------------------------------------------------- + (cons (list 'ap "apr") (cons "Apropos on LaTeX commands" 'YaTeX-apropos)) + (cons (list 'help "help") (cons "Help on LaTeX commands" 'YaTeX-help)) + ;; Menu for Typeset relating processes ------------------------------------ + (cons (list 'process "Process menu") + (cons "Process" YaTeX-mode-menu-map-process))) +)) -;; =========================================================================== -;; Change/Kill/Fill -(YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex] - '(change "Change macros" YaTeX-change-*) - '(kill "Kill macros" YaTeX-kill-*) - '(fillitem "Fill \\item" YaTeX-fill-item) - '(newline "Newline" YaTeX-intelligent-newline) - '(sepchg "--" nil) -) - -;; Menu for completions ------------------------------------------------------ - - -;;;(YaTeX-19-define-sub-menu -;;; YaTeX-mode-map [menu-bar yatex] -;;; '(secr "Section-type command on region" YaTeX-make-section-region) -;;; '(sec "Section-type command" YaTeX-make-section)) - -(define-key YaTeX-mode-map [menu-bar yatex sectionr] - (cons "Section-type region(long name)" - (make-sparse-keymap "Enclose region with section-type macro"))) -(define-key YaTeX-mode-map [menu-bar yatex section] - (cons "Section-type(long name)" - (make-sparse-keymap "Section-type macro"))) +;; Make section-type commands menu ------------------------------------------- +(defvar YaTeX-mode-menu-map-sectionr + (make-sparse-keymap "Enclose region with section-type macro")) +(defvar YaTeX-mode-menu-map-section (make-sparse-keymap "Section-type macro")) (let ((sorted-section (sort (delq nil @@ -157,56 +128,91 @@ (car s)))) (append section-table user-section-table))) 'string<))) - (apply 'YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex section] - (mapcar (function (lambda (secname) - (list (intern secname) secname - (list 'lambda () - (list 'interactive) - (list 'YaTeX-make-section - nil nil nil secname))))) - sorted-section)) - (apply 'YaTeX-19-define-sub-menu - YaTeX-mode-map [menu-bar yatex sectionr] - (mapcar (function (lambda (secname) - (list (intern secname) secname - (list 'lambda () - (list 'interactive) - (list 'YaTeX-make-section - nil - (list 'region-beginning) - (list 'region-end) - secname))))) - sorted-section))) + (YaTeX-define-menu + 'YaTeX-mode-menu-map-section + (mapcar + (function (lambda (secname) + (cons (intern secname) + (cons secname + (list 'lambda () + (list 'interactive) + (list 'YaTeX-make-section + nil nil nil + secname)))))) + sorted-section)) + (YaTeX-define-menu + 'YaTeX-mode-menu-map-sectionr + (mapcar + (function (lambda (secname) + (cons (intern secname) + (cons secname + (list 'lambda () + (list 'interactive) + (list 'YaTeX-make-section + nil + (list 'region-beginning) + (list 'region-end) + secname)))))) + sorted-section))) + +(YaTeX-define-menu + 'YaTeX-mode-menu-map + (nreverse + (list + (cons '(sectionr "Section-type (long name)") + (cons "Section type" YaTeX-mode-menu-map-section)) + (cons '(section "Section-type region (long name)") + (cons "Section type region (long name)" + YaTeX-mode-menu-map-sectionr))))) + +;; Make large-type commands menu --------------------------------------------- +(defvar YaTeX-mode-menu-map-envr (make-sparse-keymap "Environment region")) +(defvar YaTeX-mode-menu-map-env (make-sparse-keymap "Environment")) -(define-key YaTeX-mode-map [menu-bar yatex envr] - (cons "Environment region" (make-sparse-keymap "Environment region"))) -(define-key YaTeX-mode-map [menu-bar yatex env] - (cons "Environment" (make-sparse-keymap "Environment"))) -(let (prev envname) - (mapcar - (function - (lambda (envalist) - (setq envname (car envalist)) - (define-key-after - (lookup-key YaTeX-mode-map [menu-bar yatex env]) - (vector (intern envname)) - (cons envname - (list 'lambda () (list 'interactive) - (list 'YaTeX-insert-begin-end - envname nil))) - prev) - (define-key-after - (lookup-key YaTeX-mode-map [menu-bar yatex envr]) - (vector (intern envname)) - (cons envname - (list 'lambda () (list 'interactive) - (list 'YaTeX-insert-begin-end - envname t))) - prev) - (setq prev (intern envname)))) - (sort (append env-table user-env-table) - '(lambda (x y) (string< (car x) (car y)))))) +(let ((sorted-env + (sort + (mapcar (function (lambda (s) (car s))) + (append env-table user-env-table)) + 'string<))) + (YaTeX-define-menu + 'YaTeX-mode-menu-map-env + (mapcar + (function (lambda (envname) + (cons (intern envname) + (cons envname + (list 'lambda () + (list 'interactive) + (list 'YaTeX-insert-begin-end + envname nil)))))) + sorted-env)) + (YaTeX-define-menu + 'YaTeX-mode-menu-map-envr + (mapcar + (function (lambda (envname) + (cons (intern envname) + (cons envname + (list 'lambda () + (list 'interactive) + (list 'YaTeX-insert-begin-end + envname t)))))) + sorted-env))) +(YaTeX-define-menu + 'YaTeX-mode-menu-map + (nreverse + (list + (cons '(envr "Environment") + (cons "Environment" YaTeX-mode-menu-map-env)) + (cons '(env "Environment region") + (cons "Environment region" + YaTeX-mode-menu-map-envr))))) + +(and (featurep 'xemacs) + (add-hook 'yatex-mode-hook + '(lambda () + (or (assoc "YaTeX" current-menubar) + (progn + (set-buffer-menubar (copy-sequence current-menubar)) + (add-submenu nil YaTeX-mode-menu-map)))))) ;; Other key bindings for window-system ;(YaTeX-define-key [?\C- ] 'YaTeX-do-completion) @@ -225,10 +231,10 @@ "Return list of starting and end point of section-type commands of PATTERN." (if (re-search-forward pattern nil t) (let ((m0 (match-beginning 0)) cmd (argc 1)) - (setq cmd (substring (YaTeX-match-string 0) 1 -1) + (setq cmd (substring (YaTeX-match-string 0) 1) argc (or (car (cdr (YaTeX-lookup-table cmd 'section))) argc)) (cons m0 - (progn (skip-chars-backward "^{") (forward-char -2) + (progn ;(skip-chars-backward "^{") (forward-char -2) (while (> argc 0) (skip-chars-forward "^{") (forward-list 1) @@ -264,23 +270,23 @@ ;; comments (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment) - (YaTeX-19-region-section-type "\\\\footnote\\(mark\\|text\\)?{" keyword) + (YaTeX-19-region-section-type "\\\\footnote\\(mark\\|text\\)?\\>" keyword) ("\\\\[a-z]+box" 0 keyword) - (YaTeX-19-region-section-type "\\\\\\(v\\|h\\)space\\(\*\\)?{" keyword) + (YaTeX-19-region-section-type "\\\\\\(v\\|h\\)space\\>" keyword) ;; (re-)define new commands/environments/counters (YaTeX-19-region-section-type - "\\\\\\(re\\)?new\\(environment\\|command\\|theorem\\|length\\|counter\\){" + "\\\\\\(re\\)?new\\(environment\\|command\\|theorem\\|length\\|counter\\)\\>" defun) (YaTeX-19-region-section-type - "\\\\textbf{" bold) + "\\\\textbf\\>" bold) ;; various declarations/definitions (YaTeX-19-region-section-type - "\\\\\\(set\\|setto\\|addto\\)\\(length\\|width\\|counter\\){" + "\\\\\\(set\\|setto\\|addto\\)\\(length\\|width\\|counter\\)\\>" define) (YaTeX-19-region-section-type - "\\\\\\(title\\|author\\|date\\|thanks\\){" define) + "\\\\\\(title\\|author\\|date\\|thanks\\)\\>" define) ("\\\\document\\(style\\|class\\)\\(\\[.*\\]\\)?{" "}" decl) ("\\\\\\(begin\\|end\\|nofiles\\|includeonly\\){" "}" decl) @@ -295,11 +301,11 @@ ;;this should be customized by YaTeX-item-regexp ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label) (YaTeX-19-region-section-type - "\\\\caption\\(\\[[^]]*\\]\\)?{" label) + "\\\\caption\\(\\[[^]]*\\]\\)?\\>" label) ;; things that do some sort of cross-reference (YaTeX-19-region-section-type - "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\){" + "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\)\\>" crossref) ;; things that bring in external files @@ -373,7 +379,9 @@ list YaTeX-sectioning-level) (while list (setq pat (concat YaTeX-ec-regexp (car (car list)) - "\\*?\\(\\[[^]]*\\]\\)?{") + ;"\\*?\\(\\[[^]]*\\]\\)?\\>" + "\\>" + ) level (cdr (car list)) fg (format "hex-%02x%02x%02x" (- fR (/ (* level fR fmin) lm 100)) @@ -416,7 +424,7 @@ (lambda (s) (regexp-quote (car s)))) sect "\\|") - "\\){"))) + "\\)\\>"))) (if (setq single (append user-singlecmd-table tmp-singlecmd-table)) (setq single (concat "\\\\\\(" (mapconcat @@ -511,6 +519,7 @@ ;;; formula 'khaki ;;; label 'yellow-underlined)) (and YaTeX-emacs-19 + (not (featurep 'xemacs)) (boundp 'byte-compile-current-file) (if (and (boundp 'window-system) window-system) (require 'hilit19)
--- a/yatexadd.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatexadd.el Tue Dec 16 13:28:38 1997 +0000 @@ -2,7 +2,7 @@ ;;; YaTeX add-in functions. ;;; yatexadd.el rev.13 ;;; (c )1991-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Fri Jan 24 18:00:45 1997 on supra +;;; Last modified Wed Jun 25 21:21:13 1997 on domani ;;; $Id$ ;;; @@ -140,6 +140,11 @@ "{" (read-string "Width: ") "}") ) +(defun YaTeX:thebibliography () + (setq section-name "bibitem") + "" +) + ;;; ;;Sample functions for section-type command. ;;; @@ -282,7 +287,7 @@ ) (defun YaTeX:bibitem () - (let ((label (read-string "Citation label: "))) + (let ((label (read-string "Citation label for bibitem: "))) (if (string= label "") "" (concat "[" label "]"))) )
--- a/yatexenv.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatexenv.el Tue Dec 16 13:28:38 1997 +0000 @@ -2,7 +2,7 @@ ;;; YaTeX environment-specific functions. ;;; yatexenv.el ;;; (c ) 1994-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Mon Apr 7 15:19:05 1997 on crx +;;; Last modified Wed Jun 25 21:30:45 1997 on domani ;;; $Id$ ;;; @@ -188,6 +188,12 @@ (YaTeX-indent-line) ) +(defun YaTeX-intelligent-newline-thebibliography () + "Insert '\\bibitem '." + (YaTeX-indent-line) + (YaTeX-make-section nil nil nil "bibitem") + (YaTeX-indent-line) +) ;;; ;; Intelligent newline
--- a/yatexlib.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatexlib.el Tue Dec 16 13:28:38 1997 +0000 @@ -1,10 +1,283 @@ ;;; -*- Emacs-Lisp -*- -;;; YaTeX library of general functions. +;;; YaTeX and yahtml common libraries, general functions and definitions ;;; yatexlib.el -;;; (c )1994-1995 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Fri Apr 5 17:56:43 1996 on supra +;;; (c )1994-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] +;;; Last modified Tue Dec 16 14:48:22 1997 on firestorm ;;; $Id$ +;; General variables +(defvar YaTeX-dos (memq system-type '(ms-dos windows-nt OS/2))) +(defvar YaTeX-emacs-19 (>= (string-to-int emacs-version) 19)) +(defvar YaTeX-emacs-20 (>= (string-to-int emacs-version) 20)) +(defvar YaTeX-user-completion-table + (if YaTeX-dos "~/_yatexrc" "~/.yatexrc") + "*Default filename in which user completion table is saved.") + +(defvar YaTeX-japan (or (boundp 'NEMACS) (boundp 'MULE) YaTeX-emacs-20) + "Whether yatex mode is running on Japanese environment or not.") + +(defvar YaTeX-kanji-code-alist + (cond + ((boundp '*junet*) + (list (cons + 1 + (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos) + *sjis*)) + '(2 . *junet*) '(3 . *euc-japan*))) + (YaTeX-emacs-20 + ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist))) + (list (cons + 1 (cond (YaTeX-dos 'shift_jis-dos) + ((member 'shift_jis (coding-system-list)) 'shift_jis-unix) + (t 'sjis))) + '(2 . iso-2022-7bit-unix) + '(3 . euc-japan)))) + "Kanji-code expression translation table.") +(defvar YaTeX-inhibit-prefix-letter nil + "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.") + +(defvar YaTeX-no-begend-shortcut nil + "*T for disabling shortcut of begin-type completion, [prefix] b d, etc.") + +(defvar YaTeX-default-pop-window-height 10 + "Default typesetting buffer height. +If integer, sets the window-height of typesetting buffer. +If string, sets the percentage of it. +If nil, use default pop-to-buffer.") + +(defvar YaTeX-create-file-prefix-g nil + "*Non-nil creates new file when [prefix] g on \\include{foo}.") + +(defvar YaTeX-nervous t + "*If you are nervous about maintenance of yatexrc, set this value to T. +And you will have the local dictionary.") + +;----------- work variables ---------------------------------------- +(defvar YaTeX-typesetting-mode-map nil + "Keymap used in YaTeX typesetting buffer" +) +(if YaTeX-typesetting-mode-map nil + (setq YaTeX-typesetting-mode-map (make-keymap)) + ;(suppress-keymap YaTeX-typesetting-mode-map t) + (define-key YaTeX-typesetting-mode-map " " 'YaTeX-jump-error-line) + (define-key YaTeX-typesetting-mode-map "\C-m" 'YaTeX-send-string) + (define-key YaTeX-typesetting-mode-map "1" 'delete-other-windows) + (define-key YaTeX-typesetting-mode-map "0" 'delete-window) + (define-key YaTeX-typesetting-mode-map "q" 'delete-window)) + +(defvar YaTeX-parent-file nil + "*Main LaTeX source file name used when %#! expression doesn't exist.") +(make-variable-buffer-local 'YaTeX-parent-file) + +;---------- Define default key bindings on YaTeX mode map ---------- +;;;###autoload +(defun YaTeX-define-key (key binding &optional map) + "Define key on YaTeX-prefix-map." + (if YaTeX-inhibit-prefix-letter + (let ((c (aref key 0))) + (cond + ((and (>= c ?a) (<= c ?z)) (aset key 0 (1+ (- c ?a)))) + ((and (>= c ?A) (<= c ?Z) (numberp YaTeX-inhibit-prefix-letter)) + (aset key 0 (1+ (- c ?A)))) + (t nil)))) + (define-key (or map YaTeX-prefix-map) key binding)) + +;;;###autoload +(defun YaTeX-local-table-symbol (symbol) + "Return the lisp symbol which keeps local completion table of SYMBOL." + (intern (concat "YaTeX$" + default-directory + (symbol-name symbol)))) + +;;;###autoload +(defun YaTeX-sync-local-table (symbol) + "Synchronize local variable SYMBOL. +Copy its corresponding directory dependent completion table to SYMBOL." + (if (boundp (YaTeX-local-table-symbol symbol)) + (set symbol (symbol-value (YaTeX-local-table-symbol symbol))))) + +(defvar YaTeX-user-table-is-read nil + "Flag that means whether user completion table has been read or not.") +;;;###autoload +(defun YaTeX-read-user-completion-table (&optional forcetoread) + "Append user completion table of LaTeX macros" + (let*((user-table (expand-file-name YaTeX-user-completion-table)) + (local-table (expand-file-name (file-name-nondirectory user-table))) + var localvar localbuf (curbuf (current-buffer)) sexp) + (if YaTeX-user-table-is-read nil + (message "Loading user completion table") + (if (file-exists-p user-table) (load-file user-table) + (message "Welcome to the field of YaTeX. I'm glad to see you!"))) + (setq YaTeX-user-table-is-read t) + (cond + ((file-exists-p local-table) + (set-buffer (setq localbuf (find-file-noselect local-table))) + (widen) + (goto-char (point-min)) + (while (re-search-forward "(setq \\([^ ]+\\)" nil t) + (setq var (intern (buffer-substring + (match-beginning 1) (match-end 1))) + localvar (YaTeX-local-table-symbol var)) + (goto-char (match-beginning 0)) + (setq sexp (buffer-substring (point) + (progn (forward-sexp) (point)))) + (set-buffer curbuf) + (or (assq var (buffer-local-variables)) (make-local-variable var)) + (eval (read sexp)) + (or (and (boundp localvar) + (symbol-value localvar) + (not forcetoread)) + (set localvar (symbol-value var))) + (set-buffer localbuf)) + (kill-buffer localbuf))) + (set-buffer curbuf))) + +;;;###autoload +(defun YaTeX-reload-dictionary () + "Reload local dictionary. +Use this function after editing ./.yatexrc." + (interactive) + (let ((YaTeX-user-table-is-read nil)) + (YaTeX-read-user-completion-table t))) + +;;;###autoload +(defun YaTeX-lookup-table (word type) + "Lookup WORD in completion table whose type is TYPE. +This function refers the symbol tmp-TYPE-table, user-TYPE-table, TYPE-table. +Typically, TYPE is one of 'env, 'section, 'fontsize, 'singlecmd." + (if (symbolp type) (setq type (symbol-name type))) + (or (assoc word (symbol-value (intern (concat "tmp-" type "-table")))) + (assoc word (symbol-value (intern (concat "user-" type "-table")))) + (assoc word (symbol-value (intern (concat type "-table")))))) + +;;;###autoload +(defun YaTeX-update-table (vallist default-table user-table local-table) + "Update completion table if the car of VALLIST is not in current tables. +Second argument DEFAULT-TABLE is the quoted symbol of default completion +table, third argument USER-TABLE is user table which will be saved in +YaTeX-user-completion-table, fourth argument LOCAL-TABLE should have the +completion which is valid during current Emacs's session. If you +want to make LOCAL-TABLE valid longer span (but restrict in this directory) +create the file in current directory which has the same name with +YaTeX-user-completion-table." + (let ((car-v (car vallist)) key answer + (file (file-name-nondirectory YaTeX-user-completion-table))) + (cond + ((assoc car-v (symbol-value default-table)) + nil) ;Nothing to do + ((setq key (assoc car-v (symbol-value user-table))) + (if (equal (cdr vallist) (cdr key)) nil + ;; if association hits, but contents differ. + (message + "%s's attributes turned into %s" (car vallist) (cdr vallist)) + (set user-table (delq key (symbol-value user-table))) + (set user-table (cons vallist (symbol-value user-table))) + (YaTeX-update-dictionary + YaTeX-user-completion-table user-table "user"))) + ((setq key (assoc car-v (symbol-value local-table))) + (if (equal (cdr vallist) (cdr key)) nil + (message + "%s's attributes turned into %s" (car vallist) (cdr vallist)) + (set local-table (delq key (symbol-value local-table))) + (set local-table (cons vallist (symbol-value local-table))) + (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) + (YaTeX-update-dictionary file local-table))) + ;; All of above cases, there are some completion in tables. + ;; Then update tables. + (t + (if (not YaTeX-nervous) + (setq answer "u") + (message + (cond + (YaTeX-japan + "`%s'$B$NEPO?@h(B: U)$B%f!<%6<-=q(B L)$B%m!<%+%k<-=q(B N)$B%a%b%j(B D)$B$7$J$$(B") + (t + "Register `%s' into: U)serDic L)ocalDic N)one D)iscard")) + (if (> (length car-v) 23) + (concat (substring car-v 0 10) "..." (substring car-v -10)) + car-v)) + (setq answer (char-to-string (read-char)))) + (cond + ((string-match answer "uy") + (set user-table (cons vallist (symbol-value user-table))) + (YaTeX-update-dictionary YaTeX-user-completion-table user-table "user") + ) + ((string-match answer "tl") + (set local-table (cons vallist (symbol-value local-table))) + (set (YaTeX-local-table-symbol local-table) (symbol-value local-table)) + (YaTeX-update-dictionary file local-table)) + ((string-match answer "d") nil) ;discard it + (t (set default-table + (cons vallist (symbol-value default-table))))))))) + +;;;###autoload +(defun YaTeX-cplread-with-learning + (prom default-table user-table local-table + &optional pred reqmatch init hsym) + "Completing read with learning. +Do a completing read with prompt PROM. Completion table is what +DEFAULT-TABLE, USER-TABLE, LOCAL table are appended in reverse order. +Note that these tables are passed by the symbol. +Optional arguments PRED, REQMATH and INIT are passed to completing-read +as its arguments PREDICATE, REQUIRE-MATCH and INITIAL-INPUT respectively. +If optional 8th argument HSYM, history symbol, is passed, use it as +history list variable." + (YaTeX-sync-local-table local-table) + (let*((table (append (symbol-value local-table) + (symbol-value user-table) + (symbol-value default-table))) + (word (completing-read-with-history + prom table pred reqmatch init hsym))) + (if (and (string< "" word) (not (assoc word table))) + (YaTeX-update-table (list word) default-table user-table local-table)) + word)) + +;;;###autoload +(defun YaTeX-update-dictionary (file symbol &optional type) + (let ((local-table-buf (find-file-noselect file)) + (name (symbol-name symbol)) + (value (symbol-value symbol))) + (save-excursion + (message "Updating %s dictionary..." (or type "local")) + (set-buffer local-table-buf) + (goto-char (point-max)) + (search-backward (concat "(setq " name) nil t) + (delete-region (point) (progn (forward-sexp) (point))) + (delete-blank-lines) + (insert "(setq " name " '(\n") + (mapcar '(lambda (s) + (insert (format "%s\n" (prin1-to-string s)))) + value) + (insert "))\n\n") + (delete-blank-lines) + (basic-save-buffer) + (kill-buffer local-table-buf) + (message "Updating %s dictionary...Done" (or type "local"))))) + +;;;###autoload +(defun YaTeX-define-begend-key-normal (key env &optional map) + "Define short cut YaTeX-make-begin-end key." + (YaTeX-define-key + key + (list 'lambda '(arg) '(interactive "P") + (list 'YaTeX-insert-begin-end env 'arg)) + map)) + +;;;###autoload +(defun YaTeX-define-begend-region-key (key env &optional map) + "Define short cut YaTeX-make-begin-end-region key." + (YaTeX-define-key key (list 'lambda nil '(interactive) + (list 'YaTeX-insert-begin-end env t)) map)) + +;;;###autoload +(defun YaTeX-define-begend-key (key env &optional map) + "Define short cut key for begin type completion both for normal +and region mode. To customize YaTeX, user should use this function." + (YaTeX-define-begend-key-normal key env map) + (if YaTeX-inhibit-prefix-letter nil + (YaTeX-define-begend-region-key + (concat (upcase (substring key 0 1)) (substring key 1)) env))) + ;;;###autoload (defun YaTeX-search-active-forward (string cmntrx &optional bound err cnt func) "Search STRING which is not commented out by CMNTRX. @@ -16,7 +289,8 @@ (setq found (funcall sfunc string bound err cnt)) (setq md (match-data))) (or - (YaTeX-in-verb-p (match-beginning 0)) + (and (eq major-mode 'yatex-mode) + (YaTeX-in-verb-p (match-beginning 0))) (save-excursion (beginning-of-line) (re-search-forward cmntrx (match-beginning 0) t))))) @@ -119,8 +393,16 @@ (setq index pos) (setq pos -1)) (t (setq pos (1- pos)))) ) - index) -) + index)) + +;;;###autoload +(defun point-beginning-of-line () + (save-excursion (beginning-of-line)(point))) + +;;;###autoload +(defun point-end-of-line () + (save-excursion (end-of-line)(point))) + ;;;###autoload (defun YaTeX-showup-buffer (buffer &optional func select) @@ -371,11 +653,158 @@ (or (featurep 'windows) (error "Why don't you use `windows.el'?")) (win-switch-to-window 1 (- last-command-char win:base-key))) +;;;###autoload +(defun YaTeX-reindent (col) + "Remove current indentation and reindento to COL column." + (save-excursion + (beginning-of-line) + (skip-chars-forward " \t") + (if (/= col (current-column)) + (progn + (delete-region (point) (progn (beginning-of-line) (point))) + (indent-to col)))) + (skip-chars-forward " \t" (point-end-of-line))) + +(defun YaTeX-inner-environment (&optional quick) + "Return current inner-most environment. +Non-nil for optional argument QUICK restricts search bound to most +recent sectioning command. Matching point is stored to property 'point +of 'YaTeX-inner-environment, which can be referred by + (get 'YaTeX-inner-environment 'point)." + (let*((nest 0) + (beg (YaTeX-replace-format-args + (regexp-quote YaTeX-struct-begin) + ;YaTeX-struct-begin ;=== TENTATIVE!! == + YaTeX-struct-name-regexp + (if (eq major-mode 'yahtml-mode) "\\s *.*" "") + "")) + (end (YaTeX-replace-format-args + (regexp-quote YaTeX-struct-end) + YaTeX-struct-name-regexp "" "")) + (begend (concat "\\(" beg "\\)\\|\\(" end "\\)")) + bound m0 + (htmlp (eq major-mode 'yahtml-mode)) + (open + (concat "^" (or (cdr (assq major-mode '((yahtml-mode . "<")))) "{"))) + (close + (concat "^" + (or (cdr(assq major-mode '((yahtml-mode . "\n\t >")))) "}")))) + (save-excursion + (if quick + (setq bound + (save-excursion + (if htmlp + ;;(re-search-backward YaTeX-sectioning-regexp nil 1) + (goto-char (point-min)) ;Is this enough? 97/6/26 + (YaTeX-re-search-active-backward + (concat YaTeX-ec-regexp + "\\(" YaTeX-sectioning-regexp "\\)\\*?{") + YaTeX-comment-prefix nil 1)) + (or (bobp) (end-of-line)) + (point)))) + (if (catch 'begin + (if (and (numberp bound) (< (point) bound)) (throw 'begin nil)) + (while (YaTeX-re-search-active-backward + begend YaTeX-comment-prefix bound t) + (setq m0 (match-beginning 0)) + (if (looking-at end) ;;(match-beginning 2) + (setq nest (1+ nest)) + (setq nest (1- nest))) + (if (< nest 0) + (progn + (put 'YaTeX-inner-environment 'point m0) + (goto-char m0) + (put 'YaTeX-inner-environment 'indent (current-column)) + (throw 'begin t))))) + (buffer-substring + (progn (skip-chars-forward open) (1+ (point))) + (progn (skip-chars-forward close) (point)))))) +) + +(defun YaTeX-end-environment () + "Close opening environment" + (interactive) + (let ((env (YaTeX-inner-environment))) + (if (not env) (error "No premature environment") + (save-excursion + (if (YaTeX-search-active-forward + (YaTeX-replace-format-args YaTeX-struct-end env "" "") + YaTeX-comment-prefix nil t) + (if (y-or-n-p + (concat "Environment `" env + "' may be already closed. Force close?")) + nil + (error "end environment aborted.")))) + (message "") ;Erase (y or n) message. + (YaTeX-insert-struc 'end env) + (save-excursion + (goto-char (or (get 'YaTeX-inner-environment 'point) (match-end 0))) + (if (pos-visible-in-window-p) + (sit-for (if YaTeX-dos 2 1)) + (message "Matches with %s at line %d" + (YaTeX-replace-format-args YaTeX-struct-begin env "" "") + (count-lines (point-min) (point))))))) +) + +;;;VER2 +(defun YaTeX-insert-struc (what env) + (cond + ((eq what 'begin) + (insert (YaTeX-replace-format-args + YaTeX-struct-begin env (YaTeX-addin env)))) + ((eq what 'end) + (insert (YaTeX-replace-format-args YaTeX-struct-end env))) + (t nil)) +) + +;;; Function for menu support +(defun YaTeX-define-menu (keymap bindlist) + "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST. +KEYMAP should be a quoted symbol of newly allocated keymap. +BINDLIST consists of binding list. Each element is as follows. + + '(menusymbol DOC_String . contents) + +CONTENTS is one of lambda-form, interactive function, or other keymap. +See yatex19.el for example." + (cond + ((featurep 'xemacs) + (let (name) + (if (keymapp (symbol-value keymap)) + (progn + (setq name (keymap-name (symbol-value keymap))) + (set keymap nil)) + (setq name (car (symbol-value keymap))) + (set keymap (cdr (symbol-value keymap)))) + (mapcar + (function + (lambda (bind) + (setq bind (cdr bind)) + (if (eq (car-safe (cdr bind)) 'lambda) + (setcar (cdr bind) 'progn)) + (if (stringp (car-safe (cdr bind))) + (set keymap + (cons (cdr bind) (symbol-value keymap))) + (set keymap + (cons (vector (car bind) (cdr bind) t) + (symbol-value keymap)))))) + bindlist) + (set keymap (cons name (symbol-value keymap))))) + (t + (mapcar + (function + (lambda (bind) + (define-key (symbol-value keymap) (vector (car bind)) (cdr bind)))) + bindlist)))) + + + (defun bcf-and-exit () "Byte compile rest of argument and kill-emacs." (if command-line-args-left (progn (mapcar 'byte-compile-file command-line-args-left) (kill-emacs)))) + (provide 'yatexlib)
--- a/yatexmth.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatexmth.el Tue Dec 16 13:28:38 1997 +0000 @@ -1,8 +1,8 @@ ;;; -*- Emacs-Lisp -*- ;;; YaTeX math-mode-specific functions. -;;; yatexmth.el rev.4 +;;; yatexmth.el ;;; (c )1993-1997 by HIROSE Yuuji [yuuji@ae.keio.ac.jp] -;;; Last modified Fri Jan 24 18:00:08 1997 on supra +;;; Last modified Tue Nov 25 12:33:05 1997 on firestorm ;;; $Id$ ;;; [Customization guide] @@ -211,6 +211,7 @@ ("->" "rightarrow" ("->" "→")) ("\C-f" "rightarrow" ("->" "→")) ("-->" "longrightarrow" ("-->" "--→")) + ("=>" "Rightarrow" "=>") ("==>" "Longrightarrow" "==>") ("<->" "leftrightarrow" ("<->" "←→")) ("<-->" "longleftrightarrow" ("<---->" "←--→"))
--- a/yatexprc.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatexprc.el Tue Dec 16 13:28:38 1997 +0000 @@ -2,10 +2,11 @@ ;;; YaTeX process handler. ;;; yatexprc.el ;;; (c )1993-1997 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp] -;;; Last modified Mon Jan 27 10:22:06 1997 on crx +;;; Last modified Thu Dec 11 16:16:21 1997 on crx ;;; $Id$ -(require 'yatex) +;(require 'yatex) +(require 'yatexlib) (defvar YaTeX-typeset-process nil "Process identifier for jlatex" @@ -24,6 +25,18 @@ (if YaTeX-dos "/c" "-c")) "Shell option for command execution.") +(defvar YaTeX-latex-message-code + (cond + (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist))) + ((and YaTeX-emacs-20 (member 'undecided (coding-system-list)) + 'undecided)) + ((featurep 'mule) + (or (and (boundp '*autoconv*) *autoconv*) + (and (fboundp 'coding-system-list) 'automatic-conversion))) + ((boundp 'NEMACS) + (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist)))) + "Process coding system for LaTeX.") + (if YaTeX-typeset-buffer-syntax nil (setq YaTeX-typeset-buffer-syntax (make-syntax-table (standard-syntax-table))) @@ -38,7 +51,10 @@ (interactive) (save-excursion (let ((p (point)) (window (selected-window)) execdir (cb (current-buffer)) - (map YaTeX-typesetting-mode-map)) + (map YaTeX-typesetting-mode-map) + (outcode + (cond ((eq major-mode 'yatex-mode) YaTeX-coding-system) + ((eq major-mode 'yahtml-mode) yahtml-coding-system)))) (if (and YaTeX-typeset-process (eq (process-status YaTeX-typeset-process) 'run)) ;; if tex command is halting. @@ -57,12 +73,9 @@ (cd execdir) (erase-buffer) (cond - (YaTeX-dos ;if MS-DOS - ;(YaTeX-put-nonstopmode) + ((not (fboundp 'start-process)) ;YaTeX-dos;if MS-DOS (call-process - shell-file-name nil buffer nil YaTeX-shell-command-option command) - ;(YaTeX-remove-nonstopmode) - ) + shell-file-name nil buffer nil YaTeX-shell-command-option command)) (t ;if UNIX (set-process-buffer (setq YaTeX-typeset-process @@ -76,9 +89,15 @@ (set-syntax-table YaTeX-typeset-buffer-syntax) (setq mode-name modename) (if YaTeX-typeset-process ;if process is running (maybe on UNIX) - (cond ((boundp 'MULE) + (cond ((fboundp 'set-current-process-coding-system) (set-current-process-coding-system - YaTeX-latex-message-code YaTeX-coding-system)) + YaTeX-latex-message-code outcode)) + ((fboundp 'set-process-coding-system) + (set-process-coding-system + YaTeX-typeset-process YaTeX-latex-message-code outcode)) + (YaTeX-emacs-20 + (set-buffer-process-coding-system + YaTeX-latex-message-code outcode)) ((boundp 'NEMACS) (set-kanji-process-code YaTeX-latex-message-code)))) (if YaTeX-dos (message "Done.") @@ -213,7 +232,7 @@ (set-buffer (find-file-noselect texput))) ;;(find-file YaTeX-texput-file) (erase-buffer) - (if YaTeX-need-nonstop + (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) (insert "\\nonstopmode{}\n")) (insert preamble "\n" subpreamble "\n") (setq lineinfo (list (count-lines 1 (point-end-of-line)) lineinfo)) @@ -340,7 +359,7 @@ (setq default-directory df) (cd df)) (erase-buffer) - (if YaTeX-dos + (if (not (fboundp 'start-process)) (call-process shell-file-name nil buffer nil YaTeX-shell-command-option command) (if (and (get-buffer-process buffer) @@ -386,7 +405,7 @@ (setq default-directory dir) ;for 18 (cd dir) ;for 19 (cond - (YaTeX-dos ;if MS-DOS + ((not (fboundp 'start-process)) ;if MS-DOS (send-string-to-terminal "\e[2J\e[>5h") ;CLS & hide cursor (call-process shell-file-name "con" "*dvi-preview*" nil YaTeX-shell-command-option @@ -573,7 +592,7 @@ ) (defun YaTeX-put-nonstopmode () - (if (and YaTeX-need-nonstop (eq major-mode 'yatex-mode)) + (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) (if (re-search-backward "\\\\nonstopmode{}" (point-min) t) nil ;if already written in text then do nothing (save-excursion @@ -585,7 +604,7 @@ ) (defun YaTeX-remove-nonstopmode () - (if (and YaTeX-need-nonstop (eq major-mode 'yatex-mode)) ;for speed + (if (and (eq major-mode 'yatex-mode) YaTeX-need-nonstop) ;for speed (save-excursion (YaTeX-visit-main t) (goto-char (point-min)) @@ -692,7 +711,7 @@ (erase-buffer) (cd dir) ;for 19 (cond - (YaTeX-dos + ((not (fboundp 'start-process)) (call-process shell-file-name "con" "*dvi-printing*" nil YaTeX-shell-command-option cmd)) (t
--- a/yatexsec.el Sat Dec 13 12:41:43 1997 +0000 +++ b/yatexsec.el Tue Dec 16 13:28:38 1997 +0000 @@ -277,6 +277,7 @@ ) (defvar YaTeX-sectioning-buffer "*Sectioning lines*") +(defvar YaTeX-sectioning-indent 1) (defun YaTeX-colloect-sections () "Collect all the lines which contains sectioning command." (let ((cw (selected-window)) level indent begp (prevp 1) (prevl 1) @@ -296,7 +297,7 @@ begp (match-beginning 0)) ;;(beginning-of-line) ;;(skip-chars-forward " \t") - (setq indent (format "%%%ds" level)) + (setq indent (format "%%%ds" (* level YaTeX-sectioning-indent))) (princ (format indent "")) (if (YaTeX-on-comment-p) (princ "%")) (princ (buffer-substring begp (progn (forward-list 1) (point)))) @@ -393,7 +394,8 @@ (let (buffer-read-only) (delete-region (point) (progn (skip-chars-forward " \t") (point))) - (indent-to-column (cdr (assoc nsc YaTeX-sectioning-level))) + (indent-to-column (* (cdr (assoc nsc YaTeX-sectioning-level)) + YaTeX-sectioning-indent)) (skip-chars-forward "^\\\\") (delete-region (1+ (point)) (progn (skip-chars-forward "^*{") (point)))