yatex

changeset 80:9b4354af748c

Too many changes from 1.72. See yatex.new. (Japanese)
author yuuji
date Sun, 24 Dec 2006 06:16:52 +0000
parents 0734be649cb8
children dacfb49eec6e
files docs/htmlqa docs/htmlqa.eng docs/qanda docs/yatex.ref docs/yatexe.tex docs/yatexj.tex help/YATEXHLP.eng help/YATEXHLP.jp yahtml.el yatex.new yatex19.el yatexadd.el yatexenv.el yatexhks.el yatexhlp.el yatexlib.el yatexmth.el yatexpkg.el yatexprc.el
diffstat 19 files changed, 2517 insertions(+), 543 deletions(-) [+]
line diff
     1.1 --- a/docs/htmlqa	Thu Dec 25 04:10:32 2003 +0000
     1.2 +++ b/docs/htmlqa	Sun Dec 24 06:16:52 2006 +0000
     1.3 @@ -126,7 +126,7 @@
     1.4  	の機能強化版 auto-insert-tkld を使いましょう。後者は、
     1.5  	ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z
     1.6  	で入手できます。
     1.7 -	http://www-nagao.kuee.kyoto-u.ac.jp/member/tsuchiya/elisp/yahtml-mode.html
     1.8 +	http://namazu.org/~tsuchiya/elisp/yahtml-mode.html
     1.9  	に設定例が書いてあります。
    1.10  	
    1.11  ■その他
     2.1 --- a/docs/htmlqa.eng	Thu Dec 25 04:10:32 2003 +0000
     2.2 +++ b/docs/htmlqa.eng	Sun Dec 24 06:16:52 2006 +0000
     2.3 @@ -63,7 +63,7 @@
     2.4  	option is to use auto-insert-tkld.  The latter can be found at
     2.5  	ftp://ftp.ae.keio.ac.jp/pub/emacs-lisp/util/auto-inset-tkld.tar.Z
     2.6  	Examples in Japanese are at
     2.7 -	http://www-nagao.kuee.kyoto-u.ac.jp/member/tsuchiya/elisp/yahtml-mode.html
     2.8 +	http://namazu.org/~tsuchiya/elisp/yahtml-mode.html
     2.9  	
    2.10  [ETC]
    2.11  ============
     3.1 --- a/docs/qanda	Thu Dec 25 04:10:32 2003 +0000
     3.2 +++ b/docs/qanda	Sun Dec 24 06:16:52 2006 +0000
     3.3 @@ -4,7 +4,9 @@
     3.4  %% C-u C-x $ とすると質問項目だけ表示されます。C-x $ で元に戻ります。
     3.5  %%
     3.6  
     3.7 -(新項目:・font-lock はどうやって使えばいいんでしょ?
     3.8 +(新項目:・RefTeXは使えますか?
     3.9 +	・自分で定義したカウンタを\ref補完でのラベル候補対象として認識させたい
    3.10 +	・font-lock はどうやって使えばいいんでしょ?
    3.11  	・XEmacsでも色は着きますか?
    3.12  	・{\it }内部では斜体に {\bf }では太字になるという噂を聞いたんですが…)
    3.13  
    3.14 @@ -277,6 +279,96 @@
    3.15  	を .emacs に入れてみましょう。
    3.16  	
    3.17  	
    3.18 +・RefTeXは使えますか?
    3.19 +	
    3.20 +	使っている人はいるみたいですから使えるんじゃないでしょうか。でも
    3.21 +	ですね、野鳥の \ref 補完があれば、RefTeXなんぞ要らないと思います
    3.22 +	よ。これからは\label{}はいちいち自分では作らずにいきなり[prefix]
    3.23 +	s で \ref を打ち込みましょう。勝手にラベルを打てそうなところを探
    3.24 +	して勝手にラベルを打ってその名前を\refに入れてくれます。\ref補完
    3.25 +	は \label{} と \ref{} 両方同時に補完入力します。
    3.26 +	
    3.27 +	でですね、\ref補完の方がしょぼいと思うなら改良しますよ。「RefTeX
    3.28 +	の方が色がついてかっちょええ」という問題以外ならすぐに頑張ります。
    3.29 +	
    3.30 +・自分で定義したカウンタを\ref補完でのラベル候補対象として認識させたい
    3.31 +	
    3.32 +	おお、これは高度な質問でござるよ。ちみすごいね。え、質問の意味が
    3.33 +	分からん? じゃLaTeXのおべんきょーから。
    3.34 +	
    3.35 +	たとえば、プログラムリストなんかには図表と同じように番号を付けた
    3.36 +	い。そゆときあるっしょ。そういうときには定理型環境を newtheorem 
    3.37 +	で定義するですよ。たとえば、セクション番号に連動してつくようなプ
    3.38 +	ログラムリスト環境を作りたいとしましょ−。そしたらこうします。
    3.39 +	
    3.40 +	\newtheorem{Program}{リスト}[section]
    3.41 +	
    3.42 +	こうすると \begin{Program} ... \end{Program} とするとタイプセッ
    3.43 +	ト結果が
    3.44 +	
    3.45 +		リスト 2.4.1 ...
    3.46 +	
    3.47 +	なんてなるわけですな。かっちょえー。さて、このままだとこの2.4.1 
    3.48 +	という番号を\refで引っ張るためには\labelを作らないとあかんわけで
    3.49 +	すよ。でもどうせ自分で環境を定義するならlabelも自動的に定義しちゃ
    3.50 +	うようなマクロを定義しちゃった方が御便利なわけですよ。 もっとい
    3.51 +	うと独自に定義したカウンタのどの位置に \label を打たせるかを野鳥
    3.52 +	に判断させるためのパターンを書くのはものすごくむずかしいので、ラ
    3.53 +	ベルを定義するためのマクロのパターンを教えた方がやりやすいわけで
    3.54 +	す。ということで、暗黙でラベルも打たせるような環境を定義すると、
    3.55 +	こんな感じ。
    3.56 +
    3.57 +	\newenvironment{program}[1]{
    3.58 +	\begin{table}[tbp]
    3.59 +	\begin{Program}\filename{#1}\nopagebreak[4]\label{#1}\end{Program}
    3.60 +	\nopagebreak[4]
    3.61 +	\begin{breakbox}\small
    3.62 +	}{
    3.63 +	\end{breakbox}
    3.64 +	\end{table}
    3.65 +	}
    3.66 +	
    3.67 +	この小文字 program 環境は
    3.68 +	
    3.69 +	\begin{program}{foo.c}
    3.70 +	\begin{verbatim}
    3.71 +	#include <stdio.h>
    3.72 +	\end{verbatim}
    3.73 +	\end{program}
    3.74 +	
    3.75 +	みたいにするとタイプセット結果が
    3.76 +	
    3.77 +		リスト 2.4.1 foo.c
    3.78 +		┌──────────────┐
    3.79 +		│#include <stdio.h>          │
    3.80 +		└──────────────┘
    3.81 +	
    3.82 +	てな具合になるわけですよ。おおかちょええ。さて、小文字program環
    3.83 +	境のマクロ定義を良く見ると環境に渡した foo.c はそのまま
    3.84 +	\label{#1} でラベルとして自動的に打たれることになる。あ、pLaTeX 
    3.85 +	のラベルは日本語もOKよ。で、その暗黙のうちに打たれたラベル名を野
    3.86 +	鳥に教えるというのがスマートなやり方です。これを定義するのが変数
    3.87 +	YaTeX::ref-labeling-regexp-alist-private なり。これには
    3.88 +	
    3.89 +	(正規表現 . ラベル名のグループ番号)
    3.90 +	
    3.91 +	という組(consセル)がたくさん集まったリストを定義する。たとえば、
    3.92 +	上記のprogram環境の第1引数を拾わせるには
    3.93 +	
    3.94 +	(setq YaTeX::ref-labeling-regexp-alist-private
    3.95 +	      '(("\\\\begin{program}{\\([^}]+\\)}" . 1)))
    3.96 +	
    3.97 +	とします。program環境の第一引数の部分の正規表現が
    3.98 +	
    3.99 +		{\\([^}]+\\)}
   3.100 +	
   3.101 +	の部分で、\\( \\) のグループ化された正規表現 [^}]+ つまり、閉じ
   3.102 +	中括弧以外の文字が続くところ、がラベル名として取り出せるわけです。
   3.103 +	ということで、上記のようなLaTeXマクロの定義と
   3.104 +	YaTeX::ref-labeling-regexp-alist-private の定義で無事、自分なり
   3.105 +	のカウンタとそのラベル名を\ref補完に取り込めるわけです。最初は面
   3.106 +	倒臭いけど、一度定義しちゃえば一生モノでっせ!
   3.107 +	
   3.108  ■Mule2 関連
   3.109  ・Mule2+hilit19を使っている時に数式が暗くて良く読めない。
   3.110  	
   3.111 @@ -493,7 +585,7 @@
   3.112  	Emacs.Font: fontset-tt
   3.113  	
   3.114  	これにより、やはり野鳥が自動的に和文 italic, bold フォントを検索
   3.115 -	し、
   3.116 +	し、画面表示上の見映えを変えるようにしてくれます。
   3.117  	
   3.118  	Windowsではもっとフォント環境が充実しているのでより簡単に設定で
   3.119  	きるのではないかと思いますが、私はそのやり方を知りません。ご存知
   3.120 @@ -556,8 +648,8 @@
   3.121  	  n や p でごちゃごちゃやります。
   3.122  	
   3.123  	こんな感じですかね。
   3.124 -	あとは、イメージ補完、数式モード自動判定なんてのもAUCにはありま
   3.125 -	せん。
   3.126 +	あとは、イメージ補完、数式モード自動判定、先回りusepackageなんて
   3.127 +	のもAUCにはありません。
   3.128  	
   3.129  ・なんで構成ファイルがいまさらSJISなの? だっせー。
   3.130  	
   3.131 @@ -572,13 +664,6 @@
   3.132  	慮してしまう可能性を考えると、やはり野鳥はSJISであり続けるべきだ
   3.133  	と思います。
   3.134  	
   3.135 -	Emacs20の一部のバージョンで、文字列に漢字を含むEmacs-Lispファイ
   3.136 -	ルをバイトコンパイルすると化けてしまうものがあるのは知っています
   3.137 -	が、それはEmacs20の非です。しかしそれはいずれ直されるであろうバ
   3.138 -	グであり、Emacs20を使いこなしているヴェテランのちょっとした手間
   3.139 -	を軽減するためにJISコードなどに変更して、Emacs初心者に対する益を
   3.140 -	失いたくありません。
   3.141 -	
   3.142  	そういうわけで、野鳥ではダサくても嫌いでも、SJISを使います。
   3.143  	
   3.144  ・メイリングリストはないんですか?
     4.1 --- a/docs/yatex.ref	Thu Dec 25 04:10:32 2003 +0000
     4.2 +++ b/docs/yatex.ref	Sun Dec 24 06:16:52 2006 +0000
     4.3 @@ -157,6 +157,7 @@
     4.4  
     4.5  
     4.6  	◆インクルード構造ブラウズ	[prefix] d
     4.7 +	◆font-lockし直しメニュー	[prefix] u
     4.8  
     4.9  							       広瀬雄二
    4.10  						       yuuji@yatex.org
     5.1 --- a/docs/yatexe.tex	Thu Dec 25 04:10:32 2003 +0000
     5.2 +++ b/docs/yatexe.tex	Sun Dec 24 06:16:52 2006 +0000
     5.3 @@ -5,7 +5,7 @@
     5.4  
     5.5  @iftex
     5.6  @c @syncodeindex fn cp
     5.7 -@c Last modified Fri Sep 12 12:04:11 2003 on firestorm
     5.8 +@c Last modified Wed Jul 20 21:27:50 2005 on firestorm
     5.9  @syncodeindex vr cp
    5.10  @end iftex
    5.11  
    5.12 @@ -88,6 +88,10 @@
    5.13  @item Online help for the popular La@TeX{} commands
    5.14        (@kbd{C-c ?}, @kbd{C-c /})
    5.15  @item Document files hierarchy browser (@kbd{C-c d})
    5.16 +@item Adding automatically \usepackage corresponding to inputting LaTeX
    5.17 +      macro with completion
    5.18 +@item Allow you to forget creating \label{}s, \ref or \cite completion
    5.19 +      automatically generate labels.
    5.20  @end itemize
    5.21  
    5.22  @node Installation, Typesetting, Main features, Top
    5.23 @@ -268,6 +272,10 @@
    5.24  @noindent
    5.25  Note that YaTeX  assumes the component  before the  last period of
    5.26  the last word in this line as base name of the main La@TeX{} source.
    5.27 +The @code{%f} notation in this line is replaced by main file name, and
    5.28 +@code{%r} replaced by root name of main file name.  If you specify
    5.29 +@code{%f} or @code{%r}, YaTeX always ask you the name of main file at the
    5.30 +first typesetting.
    5.31  
    5.32    To make best use of the feature of inter-file jumping by
    5.33  @kbd{[prefix] g} (see @ref{Cursor jump}), take described below into
    5.34 @@ -1812,6 +1820,53 @@
    5.35  Consult the value of @code{YaTeX-package-alist-default} as an example.
    5.36  @end defvar
    5.37  
    5.38 +@defvar YaTeX-tabular-indentation
    5.39 +At indentation by @kbd{C-i} in tabular or array environment, 
    5.40 +YaTeX put the additional spaces to the normail indentation depth.
    5.41 +The number of additional spaces is the product of YaTeX-tabular-indentation
    5.42 +and the number of column position in tabular.
    5.43 +@end defvar
    5.44 +
    5.45 +@defvar YaTeX-noindent-env-regexp
    5.46 +Regexp of environment names that should begin with no indentation.
    5.47 +All verbatime-like environment name should match with.
    5.48 +@end defvar
    5.49 +
    5.50 +@defvar YaTeX-ref-default-label-string
    5.51 +Default \\ref time string format.
    5.52 +This format is like strftime(3) but allowed conversion char are as follows;
    5.53 +%y -> Last 2 digit of year,  %b -> Month name,  %m -> Monthe number(1-12),
    5.54 +%d -> Day,  %H -> Hour,  %M -> Minute,  %S -> Second,
    5.55 +%qx -> alphabetical-decimal conversion of yymmdd.
    5.56 +%qX -> alphabetical-decimal conversion of HHMMSS.
    5.57 +Beware defualt label-string should be always unique.  So this format string
    5.58 +should have both time part (%H+%M+%S or %qX) and date
    5.59 +part (%y+(%b|%m)+%d or %qx).
    5.60 +@end defvar
    5.61 +
    5.62 +@defvar YaTeX-ref-generate-label-function
    5.63 +Function to generate default label string for unnamed \\label{}s.
    5.64 +The function pointed to this value should take two arguments.
    5.65 +First argument is LaTeX macro's name, second is macro's argument.
    5.66 +Here is an example for using this value.
    5.67 +@lisp
    5.68 +  (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label)
    5.69 +  (defun my-yatex-generate-label (command value)
    5.70 +    (and (string= command "caption")
    5.71 +         (re-search-backward "\\\\begin{\\(figure\\|table\\)}" nil t)
    5.72 +         (setq command (match-string 1)))
    5.73 +    (let ((alist '(("chapter" . "chap")
    5.74 +                   ("section" . "sec")
    5.75 +                   ("subsection" . "subsec")
    5.76 +                   ("figure" . "fig")
    5.77 +                   ("table" . "tbl"))))
    5.78 +      (if (setq command (cdr (assoc command alist)))
    5.79 +          (concat command ":" value)
    5.80 +        (YaTeX::ref-generate-label nil nil))))
    5.81 +@end lisp
    5.82 +@end defvar
    5.83 +
    5.84 +
    5.85  @node Sample definitions, Hook variables, All customizable variables, Lisp variables
    5.86  @comment  node-name,  next,  previous,  up
    5.87  @subsection Sample definitions
    5.88 @@ -2315,16 +2370,18 @@
    5.89  @comment  node-name,  next,  previous,  up
    5.90  @chapter Copying
    5.91  
    5.92 -  This program  is distributed   as a   free  software.   You  can
    5.93 -redistribute this software freely but with NO warranty to anything
    5.94 -as a result  of using this  software.   However, any  reports  and
    5.95 -suggestions are  welcome as  long as I   feel  interests in   this
    5.96 -software.   My possible  e-mail address is  `yuuji@@yatex.org'.
    5.97 -(up to Sep.2003 at least)  And there is mailing list for YaTeX.
    5.98 -Although the common language is Japanese, questions in English will be
    5.99 -welcome.  To join the ML, send the mail whose subject is `append' to
   5.100 -the address `yatex@@yatex.org.  If you have some
   5.101 -question, please ask to `yatex-admin@@yatex.org'.
   5.102 +  This   program   is  distributed   as   a   free   software.   You   can
   5.103 +use/copy/modify/redistribute this software freely  but with NO warranty to
   5.104 +anything  as a result  of using  this software.   Adopting code  from this
   5.105 +program is  also free.  But  I would not  do contract act.
   5.106 +
   5.107 +Any reports  and suggestions are  welcome as long  as I feel  interests in
   5.108 +this software.  My possible  e-mail address is `yuuji@@yatex.org'.  (as of
   5.109 +Jan.2004)  And there  is  mailing  list for  YaTeX.   Although the  common
   5.110 +language is Japanese,  questions in English will be  welcome.  To join the
   5.111 +ML,   send  the   mail  whose   subject   is  `append'   to  the   address
   5.112 +`yatex@@yatex.org.    If   you  have   some   question,   please  ask   to
   5.113 +`yatex-admin@@yatex.org'.
   5.114  
   5.115    The specification of this software will be surely modified
   5.116  (depending on my feelings) without notice :-p.
     6.1 --- a/docs/yatexj.tex	Thu Dec 25 04:10:32 2003 +0000
     6.2 +++ b/docs/yatexj.tex	Sun Dec 24 06:16:52 2006 +0000
     6.3 @@ -10,7 +10,7 @@
     6.4  @c ノードいじったら C-l C-u C-n 全部のノード更新 C-l C-u C-e
     6.5  @c メニュー増やしたら C-l C-u C-m 全部のメニュー更新 C-l C-u C-a
     6.6  @c フォーマットするときは C-l C-e C-b
     6.7 -@c Last modified Fri Aug 29 01:55:00 2003 on firestorm
     6.8 +@c Last modified Wed Jul 20 21:25:48 2005 on firestorm
     6.9  @syncodeindex vr cp
    6.10  @end iftex
    6.11  
    6.12 @@ -20,7 +20,7 @@
    6.13  @subtitle Yet Another tex-mode for emacs
    6.14  @title 『野鳥』
    6.15  @subtitle // YaTeX //
    6.16 -@author @copyright{} 1991-2003 by    HIROSE, Yuuji [yuuji@@yatex.org]
    6.17 +@author @copyright{} 1991-2004 by    HIROSE, Yuuji [yuuji@@yatex.org]
    6.18  @end titlepage
    6.19  
    6.20  @node Top, Intro, (dir), (dir)
    6.21 @@ -139,6 +139,9 @@
    6.22  @item 標準的 La@TeX{} コマンドのオンラインヘルプ(@kbd{C-c ?}, @kbd{C-c /})
    6.23  @item ドキュメントのインクルード構造の視覚的表示とバッファ切り替え
    6.24  (@kbd{C-c d})
    6.25 +@item 補完入力したマクロに応じて必要な \userpackage を入れてくれる先回り
    6.26 +userpackage
    6.27 +@item \labelを打つことはもう忘れよう! refやcite補完入力で自動生成します
    6.28  @end itemize
    6.29  
    6.30  @node Installation, Invocation, Main features, Top
    6.31 @@ -368,6 +371,10 @@
    6.32  
    6.33  なお、この行の最後の単語のピリオド以前を「メインファイル」のベース
    6.34  ネームであると仮定します(上の2つの場合どちらも@file{main})。
    6.35 +この行に記述した、@code{%f}はメインファイル名に、
    6.36 +@code{%r} はメインファイルの拡張子を取り除いた部分に置換されます。
    6.37 +ただし、@code{%f,%r}を利用した場合、初回タイプセット時に必ずメインファイル
    6.38 +名の入力を促されます。
    6.39  
    6.40    @kbd{[prefix] g} (@ref{Cursor jump}参照) での
    6.41  ファイル間ジャンプを有効に機能させるため、入力ファイル分割時には次のことに
    6.42 @@ -712,6 +719,7 @@
    6.43  * Enclose section-type command::  括り補完
    6.44  * Recursive completion::        再帰補完
    6.45  * view-sectioning::             セクション区切りのアウトライン表示
    6.46 +* label-generation::            ラベル自動生成
    6.47  @end menu
    6.48  
    6.49  @node 2個以上の引数をとる section型コマンド, Enclose section-type command, section型補完, section型補完
    6.50 @@ -765,7 +773,7 @@
    6.51  型コマンドの引数に更に La@TeX{} コマンドが来る場合にはミニバッファで野鳥の
    6.52  補完キーを再帰的に入力することで引数の入力も効率的に行なえます。
    6.53  
    6.54 -@node view-sectioning,  , Recursive completion, section型補完
    6.55 +@node view-sectioning, label-generation, Recursive completion, section型補完
    6.56  @comment  node-name,  next,  previous,  up
    6.57  @subsection セクション区切りのアウトライン表示
    6.58  @cindex アウトライン[あうとらいん]
    6.59 @@ -817,6 +825,19 @@
    6.60  @cindex セクション区切り[せくしよんくきり]
    6.61  @cindex ジャンプ[しやんふ]
    6.62  
    6.63 +@node label-generation,  , view-sectioning, section型補完
    6.64 +@comment  node-name,  next,  previous,  up
    6.65 +@subsection ラベル自動生成
    6.66 +@cindex ラベル自動生成[らへるしとうせいせい]
    6.67 +
    6.68 +  @code{\ref@{@}} や @code{\cite{@@}} マクロをsection型補完で入れた場合
    6.69 +参照先となり得るものを全て探してメニューにして選択できます。参照先には
    6.70 +@code{\label@{@}}をつけておく必要はありません。もしあれば、そのラベルを
    6.71 +使い、なければその場で参照先に@code{\label@{@}}を作らせてくれます。
    6.72 +ラベル名を考えるのは苦痛に感じるものです。全てのカウンタにラベルを
    6.73 +つけるのもたいへんです。もうラベル名に何をつけるか、ラベルをつけるかつけま
    6.74 +いか、などということは忘れましょう!
    6.75 +
    6.76  @node large型補完, maketitle型補完, section型補完, Completion
    6.77  @comment  node-name,  next,  previous,  up
    6.78  @section large型補完
    6.79 @@ -1554,6 +1575,7 @@
    6.80  いでしょう。@file{yatexenv.el}内の関数 
    6.81  @code{YaTeX-intelligent-newline-itemize} の定義などを参考にしてください。
    6.82  
    6.83 +
    6.84  @node Usepackage cheker, Changing mode of YaTeX, Intelligent newline, Top
    6.85  @comment  node-name,  next,  previous,  up
    6.86  @chapter 先回りusepackage
    6.87 @@ -2017,6 +2039,50 @@
    6.88  の値参照。
    6.89  @end defvar
    6.90  
    6.91 +@defvar YaTeX-tabular-indentation
    6.92 +tabular/array 環境で現在行の先頭位置が表の第Nカラムのときは
    6.93 +標準インデント位置から N*YaTeX-tabular-indentation 桁下げた
    6.94 +インデントにする。
    6.95 +@end defvar
    6.96 +
    6.97 +@defvar YaTeX-noindent-env-regexp
    6.98 +別の環境内にあっても \begin{} が行頭から始まるべき環境名の正規表現。
    6.99 +verbatim環境などを指定する。
   6.100 +@end defvar
   6.101 +
   6.102 +@defvar YaTeX-ref-default-label-string
   6.103 +\ref{} のラベル補完でラベル未設定のものに自動的に生成する
   6.104 +ラベル名の書式。strftime(3)関数に似た日付ベースで指定する。
   6.105 +利用できる書式は以下のとおり。
   6.106 +%y -> 西暦下二桁,  %b -> 月の英名,  %m -> 月(1〜12)
   6.107 +%d -> 日,  %H -> 時,  %M -> 分,  %S -> 秒,
   6.108 +%qx -> アルファベットで26進数化した yymmdd.
   6.109 +%qX -> アルファベットで26進数化した HHMMSS.
   6.110 +デフォルトは "%H%M%S_%d%b%y"
   6.111 +@end defvar
   6.112 +
   6.113 +@defvar YaTeX-ref-generate-label-function
   6.114 +\ref{}のラベル名自動生成のときに使う関数のシンボル。
   6.115 +デフォルトは標準の YaTeX::ref-generate-label 関数が割り当ててある。
   6.116 +引数を2つ取る関数を定義して、この変数にセットするとその関数を呼んだ
   6.117 +結果をデフォルトのラベル名候補とする。設定例:
   6.118 +@lisp
   6.119 +  (setq YaTeX-ref-generate-label-function 'my-yatex-generate-label)
   6.120 +  (defun my-yatex-generate-label (command value)
   6.121 +    (and (string= command "caption")
   6.122 +         (re-search-backward "\\\\begin{\\(figure\\|table\\)}" nil t)
   6.123 +         (setq command (match-string 1)))
   6.124 +    (let ((alist '(("chapter" . "chap")
   6.125 +                   ("section" . "sec")
   6.126 +                   ("subsection" . "subsec")
   6.127 +                   ("figure" . "fig")
   6.128 +                   ("table" . "tbl"))))
   6.129 +      (if (setq command (cdr (assoc command alist)))
   6.130 +          (concat command ":" value)
   6.131 +        (YaTeX::ref-generate-label nil nil))))
   6.132 +@end lisp
   6.133 +@end defvar
   6.134 +
   6.135  @node Sample definitions, Hook variables, All customizable variables, Lisp variables
   6.136  @comment  node-name,  next,  previous,  up
   6.137  @subsection カスタマイズ変数設定例
   6.138 @@ -2104,11 +2170,15 @@
   6.139  
   6.140    本プログラムはフリーソフトウェアです。本プログラムを使用して生じたいかな
   6.141  る結果に対しても作者は責任を負わないこととします。転載等に関しては制限いた
   6.142 -しません。常識的に扱ってください。また、使用している旨をメイルでお知らせい
   6.143 -ただくと、作者は喜んでサポートに励むことでしょう。
   6.144 +しません。常識的に扱ってください。また、本プログラムに含まれるコードを利用
   6.145 +すること、改造することも自由に行なって構いませんが、流用することにより契約
   6.146 +締結の必要が生じる場合、私はいかなる契約も締結しません。具体的にはGPLへの
   6.147 +サインはしませんので、GNUに寄贈するものを作っている場合私の作品から取り込
   6.148 +んだコードを流用すると苦労するかもしれません。いかなるコード流用も拒否しま
   6.149 +せんが契約締結は辞退します。
   6.150  
   6.151    苦情、希望、バグ報告、感想等は歓迎いたします。
   6.152 -連絡は yuuji@@yatex.org まで(2003年9月現在)。
   6.153 +連絡は yuuji@@yatex.org まで(2004年1月現在)。
   6.154  継続的に使用してくださる方はメイリングリスト「fj野鳥の会」に
   6.155  是非加入してください。加入方法については本パッケージの @file{docs/qanda}
   6.156  ファイルの「その他」の章を御覧ください。
     7.1 --- a/help/YATEXHLP.eng	Thu Dec 25 04:10:32 2003 +0000
     7.2 +++ b/help/YATEXHLP.eng	Sun Dec 24 06:16:52 2006 +0000
     7.3 @@ -2,7 +2,8 @@
     7.4  %%% YaTeX-LaTeX Help File(c)HIROSE Yuuji [yuuji@yatex.org]
     7.5  %%% You can translate this file for any device other than YaTeX via
     7.6  %%% any filter program.  But it is not allowed to remove copyright
     7.7 -%%% notice and any existing dictionary entiries.
     7.8 +%%% notice and any existing dictionary entiries which describes the
     7.9 +%%% source of this file.
    7.10  %%%
    7.11  
    7.12  textfloatsep
    7.13 @@ -374,16 +375,30 @@
    7.14  \setcounter{FOO}{VAL}
    7.15  Set counter FOO's value to VAL.
    7.16  
    7.17 +<refer How to Introduce new counter>
    7.18 +
    7.19  addtocounter
    7.20  \addtocounter{FOO}{VAL}
    7.21  Add value VAL to counter FOO.
    7.22  
    7.23 +<refer How to Introduce new counter>
    7.24 +
    7.25  newcounter
    7.26  \newcounter{COUNTER}[OLDCTR]
    7.27  Defines a new counter COUNTER.
    7.28  If an optional argument OLDCTR is given, COUNTER's value will be reset
    7.29  every time OLDCTR's value is changed by \stepcounter or \addtocounter.
    7.30  
    7.31 +<refer How to Introduce new counter>
    7.32 +
    7.33 +How to Introduce new counter
    7.34 +You'll get `Question n.' increasing n with \mondai, by setting as below.
    7.35 +
    7.36 +\newcounter{toi}
    7.37 +\renewcommand{\thetoi}{Question \arabic{toi}.~ }
    7.38 +\setcounter{toi}{0}
    7.39 +\newcommand{\mondai}{\refstepcounter{toi}\thetoi}
    7.40 +
    7.41  value
    7.42  \value{COUNTER}
    7.43  Returns value of COUNTER.  Must not be preceded by \protect.
    7.44 @@ -442,7 +457,7 @@
    7.45  LABELs set in an item of the enumerate environment.
    7.46  
    7.47  pageref
    7.48 -pageref{LABEL}
    7.49 +\pageref{LABEL}
    7.50  Refer to the page number where \label{LABEL} exists.
    7.51  
    7.52  (
    7.53 @@ -669,11 +684,13 @@
    7.54  makebox
    7.55  \makebox[WID][POS]{OBJECT}	\makebox(X,Y)[POS]{OBJECT}
    7.56  First form will place OBJECT at position POS and width WID in a \box.
    7.57 -For POS, object will be placed flush-left if l, flush-right if r, and
    7.58 -centered if nothing is given
    7.59 -In the second form, object will be placed in a \hbox sized (X,Y) (in
    7.60 +For POS, object will be placed flush-left if `l', flush-right if `r', 
    7.61 +splattering words in the same space if `s', and centered if nothing is given
    7.62 +in the second form, object will be placed in a \hbox sized (X,Y) (in
    7.63  \unitlength) within a picture environment.  POS is the same as the first form.
    7.64  
    7.65 +
    7.66 +
    7.67  mbox
    7.68  \mbox{OBJECT}
    7.69  Same as \makebox{OBJECT}.
    7.70 @@ -695,7 +712,7 @@
    7.71  Same as \savebox.  \sbox is robust, and \savebox is fragile.
    7.72  
    7.73  framebox
    7.74 -\framebox{OBJECT}
    7.75 +\framebox[WID][POS]{OBJECT}	\framebox(X,Y)[POS]{OBJECT}
    7.76  Do the same thing as \makebox with a frame.
    7.77  The frame's width and space between the object are decided by \framerule
    7.78  and \framesep.  If used as \framebox(X,Y){OBJECT} in a picture
    7.79 @@ -708,6 +725,13 @@
    7.80  Same as \framebox{OBJECT}.
    7.81  \fbox is robust, \framebox fragile.
    7.82  
    7.83 +Rule width of \fbox can be controled by setting \fboxrule
    7.84 +
    7.85 +  {
    7.86 +    \fboxrule=2\fboxrule
    7.87 +    \fbox{contents of double width of rule}
    7.88 +  }
    7.89 +
    7.90  parbox
    7.91  \parbox[POS]{WIDTH}{TEXT}
    7.92  Make a box of width WIDTH using TEXT.  The box's position by POS is;
    7.93 @@ -1218,8 +1242,17 @@
    7.94  
    7.95  documentstyle
    7.96  \documentstyle[OPTION1,OPTION2, ... ,OPTIONn]{STYLE}
    7.97 -The user starts his file with the command as above
    7.98 -which saves the OPTION's and \input's the file STYLE.STY.
    7.99 +The user starts one's file with the command as above
   7.100 +which loads the OPTION's respectively and \input's the file STYLE.sty.
   7.101 +
   7.102 +documentclass
   7.103 +\documentclass[OPTION1,OPTION2, ... ,OPTIONn]{STYLE}
   7.104 +In LaTeX2e, user starts one's file with the command as above
   7.105 +which loads the OPTION's respectively and \input's the file STYLE.cls.
   7.106 +
   7.107 +usepackage
   7.108 +\usepackage[OPTIONS]{PACKAGE}
   7.109 +Use additional package `PACKAGE' with option `OPTION'.
   7.110  
   7.111  verb
   7.112  \verb#CONTENTS#
   7.113 @@ -1287,6 +1320,17 @@
   7.114  \twocolumn[STRING]
   7.115  Clear page and start two-column typesetting.
   7.116  Optional argument [STRING] specifies the page-acrossing title.
   7.117 +
   7.118 +If you want to output one-column title page with two-column body,
   7.119 +describe like this;
   7.120 +\twocolumn[
   7.121 +\begin{titlepage}
   7.122 +{\LARGE YourTitle}
   7.123 +\vspace*{1em}
   7.124 +\begin{abstract} Your Abstract blah blah... \end{abstract}
   7.125 +\end{titlepage}
   7.126 +]
   7.127 +
   7.128  ->onecolumn
   7.129  
   7.130  onecolumn
   7.131 @@ -1457,7 +1501,255 @@
   7.132  
   7.133  <ref fancybox>
   7.134  
   7.135 +quote
   7.136 +\begin{quote} ... \end{quote}
   7.137 +quotation without paragraph
   7.138  
   7.139 +quotation
   7.140 +\begin{quotation} ... \end{quotation}
   7.141 +quoted environment which might contains paragraphs
   7.142 +
   7.143 +textcircled
   7.144 +\textcircled{CHAR}
   7.145 +Enclose `char' with small circle.  Because this circle is as large as one
   7.146 +character, you had better encolose `CHAR' with {\small ...}, {\tiny ...},
   7.147 +{\scriptsize ...}.
   7.148 +
   7.149 +hfill
   7.150 +\hfill
   7.151 +Insert a space as wide as possible.  Same as \hspace{\fill}.
   7.152 +
   7.153 +foo\hfill bar
   7.154 +produces;
   7.155 +        foo                                                     bar
   7.156 +
   7.157 +foo\hfill bar\hfill baz
   7.158 +produces;
   7.159 +        foo                        bar                          baz
   7.160 +
   7.161 +\hfill can't produce space at the beginning of the line because \hfill
   7.162 +is a kind of \hspace{}.  If you make right-justified world in a line,
   7.163 +write \hspace*{\fill}.
   7.164 +
   7.165 +hfil
   7.166 +\hfil
   7.167 +Same as \hfill, but little bit weak.
   7.168 +
   7.169 +vfill
   7.170 +\vfill
   7.171 +Make vertical space in utmost length , the same as \vspace{\fill}.
   7.172 +cf. \hfill
   7.173 +
   7.174 +hrulefill
   7.175 +\hrulefill
   7.176 +Draw underline in utmost length.
   7.177 +
   7.178 +backslashbox
   7.179 +\usepackage{slashbox}   \backslashbox{A}{B}
   7.180 +Draw a back-slash in a column of tabular.
   7.181 +\begin{tabular}
   7.182 +\hline
   7.183 +\backslashbox{A}{B} & hoge \\ \hline
   7.184 +\end{tabular}
   7.185 +
   7.186 +     +----+--------+
   7.187 +     | \ B|        |
   7.188 +     | A\ |  hoge  |
   7.189 +     +----+--------+
   7.190 +
   7.191 +
   7.192 +slashbox
   7.193 +\slashbox{A}{B}
   7.194 +Draw long slash line in a column of tabular.
   7.195 +See also backslashbox.
   7.196 +
   7.197 +ooalign
   7.198 +{\ooalign{String1\crcr String2...}
   7.199 +Set line spacing to zero and shift to double-strike mode.
   7.200 +This can be used for generating circled character.
   7.201 +Look this;
   7.202 +
   7.203 +\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
   7.204 +
   7.205 +\crcr is the equivalent of \\ for tabulars.
   7.206 +Note that \ooalign change the spacing parameters.  So you should enclose
   7.207 +\ooalign itself with { }.
   7.208 +
   7.209 +maru
   7.210 +\maru{R}
   7.211 +Circle one character.
   7.212 +Declare the \newcommand as below;
   7.213 +\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
   7.214 +
   7.215 +today
   7.216 +\date{\today}
   7.217 +Use this as the argument of \date{}.
   7.218 +Set the document's date in title to today.
   7.219 +
   7.220 +NamedColor
   7.221 +\textcolor[named]{COLOR}{TEXT}, for example.
   7.222 +With `\usepackage{color}', you can use colors listed below.
   7.223 +
   7.224 +GreenYellow Yellow Goldenrod Dandelion Apricot Peach Melon YellowOrange
   7.225 +Orange BurntOrange Bittersweet RedOrange Mahogany Maroon BrickRed Red
   7.226 +OrangeRed RubineRed WildStrawberry Salmon CarnationPink Magenta
   7.227 +VioletRed Rhodamine Mulberry RedViolet Fuchsia Lavender Thistle
   7.228 +OrchidDarkOrchid Purple Plum Violet RoyalPurple BlueViolet Periwinkle
   7.229 +CadetBlue CornflowerBlue MidnightBlue NavyBlue RoyalBlue Blue Cerulean
   7.230 +Cyan ProcessBlue SkyBlue Turquoise TealBlue Aquamarine BlueGreen Emerald
   7.231 +JungleGreen SeaGreen Green ForestGreen PineGreen LimeGreen YellowGreen
   7.232 +SpringGreen OliveGreen RawSienna Sepia Brown Tan Gray Black White)
   7.233 +
   7.234 +See also http://www.yatex.org/help/color.tex
   7.235 +
   7.236 +textcolor
   7.237 +\textcolor{COLOR}{TEXT}
   7.238 +Put the TEXT colored with COLOR.
   7.239 +
   7.240 +<refer NamedColor>
   7.241 +
   7.242 +pagecolor
   7.243 +\pagecolor{COLOR}
   7.244 +Set background color of the page to COLOR.
   7.245 +
   7.246 +<refer NamedColor>
   7.247 +
   7.248 +color
   7.249 +\color{COLOR}
   7.250 +Set text color of the page to COLOR.
   7.251 +
   7.252 +<refer NamedColor>
   7.253 +
   7.254 +colorbox
   7.255 +\colorbox{COLOR}{TEXT}
   7.256 +Put TEXT in the box whose background color is COLRO.
   7.257 +
   7.258 +<refer NamedColor>
   7.259 +
   7.260 +fcolorbox
   7.261 +\fcolorbox{FCOLOR}{BGCOLOR}{TEXT}
   7.262 +Put text int the box whose frame color is FCOLOR and background BGCOLOR.
   7.263 +
   7.264 +<refer NamedColor>
   7.265 +
   7.266 +rotatebox
   7.267 +\rotatebox{ANGLE}{TEXT}
   7.268 +Put TEXT with rotated by ANGLE-degrees, unclockwise.
   7.269 +Require `\usepackage{graphicx}'.
   7.270 +
   7.271 +resizebox
   7.272 +\resizebox{WIDTH}{HEIGHT}{TEXT}
   7.273 +Put TEXT enlarging/shrinking to WIDTH and HEIGHT.
   7.274 +You can omit either of WIDHT or HEIGHT.  In that case, specify `!'.
   7.275 +\resizebox{!}{40mm}{TEXT} outputs TEXT with 40mm in height.
   7.276 +Require `\usepackage{graphicx}'.
   7.277 +
   7.278 +scalebox
   7.279 +\scalebox{MAG}[V-MAG]{TEXT}
   7.280 +Put TEXT maginifiyng by MAG.  V-MAG for vertical magnification factor is
   7.281 +optional.  Negative values for magnification factor flip the TEXT
   7.282 +in that direction.
   7.283 +
   7.284 +Require `\usepackage{graphicx}'.
   7.285 +
   7.286 +reflectbox
   7.287 +\reflectbox{TEXT}
   7.288 +Flip TEXT horizontally.
   7.289 +Equivalent to \scalebox{-1}[1]{TEXT}.
   7.290 +Require `\usepackage{graphicx}'.
   7.291 +
   7.292 +ulem
   7.293 +\usepackage{ulem}
   7.294 +\usepackage{ulem}
   7.295 +The `ulem' package provides macros listed below.
   7.296 +\uline{Underlined Text}
   7.297 +\uwave{Waved-Unlderlined Text}
   7.298 +\uuline{Double Underlined Text} 
   7.299 +
   7.300 +(Information by TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>)
   7.301 +uline
   7.302 +\uline{TEXT}
   7.303 +Put TEXT with underline.
   7.304 +
   7.305 +<refer ulem>
   7.306 +
   7.307 +uwave
   7.308 +\uwave{TEXT}
   7.309 +Put TEXT with waved underline.
   7.310 +
   7.311 +<refer ulem>
   7.312 +
   7.313 +uuline
   7.314 +\uuline{TEXT}
   7.315 +Put TEXT with double underline.
   7.316 +
   7.317 +<refer ulem>
   7.318 +showkeys.sty
   7.319 +\usepackage[options]{showkeys}
   7.320 +In margin area, output `(?)' marks for unlabeled math-expressions,
   7.321 +`?label?' marks for unreferred labels.
   7.322 +Optional arguments are one of;
   7.323 +showrefs, norefs, showcites, nocites, msgs, nomsgs, chkunlbld,
   7.324 +ignoreunlbld.
   7.325 +msgs/nomsgs specifies whether output messages in  *.log file or not.
   7.326 +
   7.327 +`\usepackage{showkeys}' should be located before the declaration
   7.328 +for AMS-LaTeX or HyperRef, if any.
   7.329 +
   7.330 +Another style `refcheck.sty' can also output labeling information
   7.331 +including `\ref{***}' macros themselves.
   7.332 +
   7.333 +(Information by Masaki Shigemori <mshige@ucla.edu>)
   7.334 +
   7.335 +table*
   7.336 +\begin{table*} ... \end{table*}
   7.337 +Put tabular in one column at the top of page even if in twocolumn mode.
   7.338 +
   7.339 +figure*
   7.340 +\begin{figure*} ... \end{figure*}
   7.341 +Put figure in one column at the top of page even if in twocolumn mode.
   7.342 +If you put figure bottom of page instead of top, use nidanfloat.sty
   7.343 +instead.
   7.344 +\begin{figure*}[b]
   7.345 + \includegraphics{blahblahblah}
   7.346 + \caption{foo bar baz}
   7.347 +\end{figure*}
   7.348 +
   7.349 +includegraphics
   7.350 +\usepackage{graphicx}  ... \includegraphics[Options]{graphicfile.eps}
   7.351 +Include graphics$B!#(BRequires `graphicx' package.
   7.352 +Possible [Options] are as follows.
   7.353 +scale=X
   7.354 +width=W
   7.355 +height=H
   7.356 +draft     (Frame only)
   7.357 +angle=R
   7.358 +origin=RotationOrigin  (One of `c', `tl', `tr', `bl' or `br')
   7.359 +bb=llx lly urx ury    (Specify BoundingBox)
   7.360 +viewport=llx lly urx ury  (Rerative to BoundingBox)
   7.361 +trim=left bottom right top
   7.362 +
   7.363 +abstract
   7.364 +\begin{abstract} ... \end{abstract}
   7.365 +Output abstract
   7.366 +
   7.367 +\langle
   7.368 +$\langle$
   7.369 +         
   7.370 +`<' in math-modes.
   7.371 +
   7.372 +\langle
   7.373 +$rlangle$
   7.374 +         
   7.375 +`>' in math-modes.
   7.376 +
   7.377 +\slash
   7.378 +\slash
   7.379 +slash(/) itself.
   7.380 +
   7.381 +\textbackslash
   7.382 +\textbackslash
   7.383 +backslash(\) itself.
   7.384  
   7.385  YaTeX
   7.386  (setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist))
     8.1 --- a/help/YATEXHLP.jp	Thu Dec 25 04:10:32 2003 +0000
     8.2 +++ b/help/YATEXHLP.jp	Sun Dec 24 06:16:52 2006 +0000
     8.3 @@ -44,6 +44,9 @@
     8.4  {}内の内容を\\で区切られた単位毎に積み重ねて表示する。
     8.5  [場所]は、l(左寄せ)、c(センタリング)、r(右寄せ)のいずれか。
     8.6  
     8.7 +表(tabular)の中で縦書きに項目を入れたいときにも便利。
     8.8 +
     8.9 +
    8.10  newlength
    8.11  \newlength{NAME}
    8.12  NAMEという長さコマンドを新たに宣言する。
    8.13 @@ -390,10 +393,15 @@
    8.14  \setcounter{FOO}{VAL}
    8.15  カウンタFOOの値をVALに設定する。
    8.16  
    8.17 +<refer 新しいカウンタの作り方>
    8.18 +
    8.19  addtocounter
    8.20  \addtocounter{FOO}{VAL}
    8.21  カウンタFOOの値にVALを加える。
    8.22  
    8.23 +<refer 新しいカウンタの作り方>
    8.24 +
    8.25 +
    8.26  newcounter
    8.27  \newcounter{COUNTER}[OLDCTR]
    8.28  新しいカウンタCOUNTERを設定する。
    8.29 @@ -401,6 +409,18 @@
    8.30  \stepcounter もしくは \addtocounter で変更されるたびにCOUNTERの値もリセッ
    8.31  トされる。
    8.32  
    8.33 +<refer 新しいカウンタの作り方>
    8.34 +
    8.35 +新しいカウンタの作り方
    8.36 +以下の定義で \mondai とすると、自動的にnをインクリメントして「第n問」を
    8.37 +出力する。
    8.38 +
    8.39 +\newcounter{toi}
    8.40 +\renewcommand{\thetoi}{第\arabic{toi}問~ }
    8.41 +\setcounter{toi}{0}
    8.42 +\newcommand{\mondai}{\refstepcounter{toi}\thetoi}
    8.43 +
    8.44 +
    8.45  value
    8.46  \value{COUNTER}
    8.47  COUNTERの値を返す。\protect を前置してはならない。
    8.48 @@ -459,7 +479,7 @@
    8.49  enumerateされたitemで設定されたラベルにたいしては、item番号が返される。
    8.50  
    8.51  pageref
    8.52 -pageref{LABEL}
    8.53 +\pageref{LABEL}
    8.54  \label{LABEL}の存在するページ番号を参照する。
    8.55  
    8.56  (
    8.57 @@ -692,6 +712,18 @@
    8.58  第2の書式では、picuture環境で大きさ(X,Y)の(\unitlengthを基準とする)
    8.59  \hbox にオブジェクトを配置する。配置位置POSは第1の書式と同様。
    8.60  
    8.61 +LaTeX2e以降では第1の書式のPOSにsを指定でき、ボックス内に文字を均等割り付け
    8.62 +してくれる。ボックスの幅は全角1字を表すzwを単位にすると便利だろう。
    8.63 +\makebox[7zw][s]{山田太郎}\\
    8.64 +\makebox[7zw][s]{木村花}\\
    8.65 +\makebox[7zw][s]{広瀬 雄二}
    8.66 +とすると
    8.67 +	|山  田  太  郎|
    8.68 +	|木    村    花|
    8.69 +	|広 瀬    雄 二|
    8.70 +
    8.71 +という感じになる。
    8.72 +
    8.73  mbox
    8.74  \mbox{オブジェクト}
    8.75  \makebox{オブジェクト}と同じ。
    8.76 @@ -718,17 +750,40 @@
    8.77  \saveboxで\CMDに保存されたテキストを配置する。
    8.78  
    8.79  framebox
    8.80 -\framebox{オブジェクト}
    8.81 +\framebox[WID][POS]{オブジェクト}	\framebox(X,Y)[POS]{オブジェクト}
    8.82  「オブジェクト」に枠をつけて\makeboxと同様の処理をする。
    8.83  枠の線の太さは \framerule、オブジェクトとの間隔は \framesep で決まる。た
    8.84  だしpicture環境で \framebox(X,Y){オブジェクト}とした場合は、picture環境
    8.85  用の線の太さに従い、外枠とオブジェクトとの間隔は空けられない。
    8.86  
    8.87 +LaTeX2e以降では第1の書式のPOSにsを指定でき、ボックス内に文字を均等割付
    8.88 +してくれる。ボックスの幅は全角1字を表すzwを単位にすると便利だろう。
    8.89 +\framebox[7zw][s]{山田太郎}\\
    8.90 +\framebox[7zw][s]{木村花}\\
    8.91 +\framebox[7zw][s]{広瀬 雄二}
    8.92 +とすると
    8.93 +	+--------------+
    8.94 +	|山  田  太  郎|
    8.95 +	+--------------+
    8.96 +	|木    村    花|
    8.97 +	+--------------+
    8.98 +	|広 瀬    雄 二|
    8.99 +	+--------------+
   8.100 +
   8.101 +という感じになる。
   8.102 +
   8.103  fbox
   8.104  \fbox{オブジェクト}
   8.105  \framebox{オブジェクト}と同じ。
   8.106  \fboxはrobust, \frameboxはfragile
   8.107  
   8.108 +\fbox の罫線の太さを変えるには,\fboxrule を変更します.
   8.109 +
   8.110 +  {
   8.111 +    \fboxrule=2\fboxrule
   8.112 +    \fbox{2倍の太さの罫線で囲まれたボックス}
   8.113 +  }
   8.114 +
   8.115  parbox
   8.116  \parbox[POS]{WIDTH}{TEXT}
   8.117  TEXTをWIDThの幅で組んでボックスを作成する。ボックスの位置はPOSによって
   8.118 @@ -895,6 +950,18 @@
   8.119  tabular環境は、ページを跨ることができない。これを可能にするスタイルファ
   8.120  イルとして、supertab.styがある。
   8.121  
   8.122 +l, c, r 指定した1つのカラムに2行以上の項目を入れたいときはparboxを利用する
   8.123 +(shortstackを利用すると上にずれるのでraiseboxで調整しなければならない)。
   8.124 +\begin{tabular}{lp{0.5\columnwidth}}
   8.125 + \parbox[t]{7em}{あ\\い} & あぶらかだぶらあぶらかだぶらあぶらかだぶら
   8.126 +\end{tabular}
   8.127 +は、以下のようにレイアウトされる。
   8.128 +
   8.129 +	あ	あぶらかだ
   8.130 +	い	ぶらあぶら
   8.131 +		かだぶら
   8.132 +
   8.133 +
   8.134  tabular*
   8.135  \begin{tabular*}{幅}{プリアンブル} ... \end{tabular*}
   8.136  幅を指定してtabular環境を作成。
   8.137 @@ -1166,6 +1233,17 @@
   8.138  [OPTION...] を指定すると、STYLE.sty を読んだ後に、
   8.139  OPTIONn.sty が順次読み込まれる。
   8.140  
   8.141 +documentclass
   8.142 +\documentclass[OPTION1,OPTION2, ... ,OPTIONn]{STYLE}
   8.143 +文書スタイルを指定する(LaTeX2e)。
   8.144 +[OPTION...] を指定すると、STYLE.cls を読んだ後に、
   8.145 +OPTIONn.sty が順次読み込まれる。
   8.146 +
   8.147 +usepackage
   8.148 +\usepackage[オプション]{パッケージ}
   8.149 +LaTeX2e の記法を拡張する「パッケージ」をロードする。
   8.150 +
   8.151 +
   8.152  verb
   8.153  \verb#内容#
   8.154  \verbの直後に来る文字と、次にあらわれる同じ文字とのあいだに挟まれたもの
   8.155 @@ -1215,6 +1293,8 @@
   8.156  mm		ミリメートル
   8.157  pc		パイカ(=12pt)
   8.158  pt		ポイント(72.27pt=1インチ)
   8.159 +zw		日本語全角1字の幅
   8.160 +zh		日本語全角1字の高さ
   8.161  \fill		自然長は0だが、任意の長さに伸びることのできる伸縮長
   8.162  \stretch{X}	\fill のX倍
   8.163  
   8.164 @@ -1226,6 +1306,17 @@
   8.165  \twocolumn[STRING]
   8.166  改頁したあと二段組みでの組版を開始する。
   8.167  [STRING]を指定すると、STRINGを二段ぶち抜きのタイトルとして出力。
   8.168 +本文が二段組みでタイトルとアブストラクトのみを1段組にしたい場合は
   8.169 +\twocolumn[
   8.170 +\begin{titlepage}
   8.171 +{\LARGE 和文タイトル等}
   8.172 +\vspace*{1em}
   8.173 +\begin{abstract} 和文抄録 \end{abstract}
   8.174 +\renewcommand{\abstractname}{\textbf{Abstract}}
   8.175 +\begin{abstract} 英文アブストラクト \end{abstract}
   8.176 +\end{titlepage}
   8.177 +]
   8.178 +のようにすると良い。
   8.179  →onecolumn
   8.180  
   8.181  onecolumn
   8.182 @@ -1396,10 +1487,288 @@
   8.183  \doublebox{STRING}
   8.184  二重四角枠で STRING を囲む。
   8.185  
   8.186 +quote
   8.187 +\begin{quote} ... \end{quote}
   8.188 +段落を含まない引用
   8.189 +
   8.190 +quotation
   8.191 +\begin{quotation} ... \end{quotation}
   8.192 +段落を含む引用
   8.193 +
   8.194 +
   8.195  要 `\usepackage{fancybox}`
   8.196  
   8.197  <ref fancybox>
   8.198  
   8.199 +textcircled
   8.200 +\textcircled{文字}
   8.201 +「文字」を丸枠で囲む。1文字と同じ大きさの丸枠なので
   8.202 +{\small ...}, {\tiny ...}, {\scriptsize ...} などで括った方が良い。
   8.203 +
   8.204 +hfill
   8.205 +\hfill
   8.206 +できるだけ広い間隔を開ける。\hspace{\fill} と同じ。
   8.207 +あ\hfill い
   8.208 +とすると
   8.209 +        あ                                                      い
   8.210 +
   8.211 +あ\hfill い\hfill う
   8.212 +とすると
   8.213 +        あ                         い                           う
   8.214 +
   8.215 +のように最大限に間隔を延ばしてくれる。ただし \hspace{} 相当なので
   8.216 +行頭だとうまく行かない。右寄せしたいなら \hspace*{\fill} とする。
   8.217 +
   8.218 +hfil
   8.219 +\hfil
   8.220 +\hfill より弱い間隔開け。
   8.221 +\hfill も参照のこと。
   8.222 +
   8.223 +vfill
   8.224 +\vfill
   8.225 +縦方向に最大限の空白を開ける。\vspace{\fill} と同じ。
   8.226 +\hfill も参照のこと。
   8.227 +
   8.228 +hrulefill
   8.229 +\hrulefill
   8.230 +可能な限り長い下付罫線を引く。
   8.231 +あんまりいい説明じゃないな。
   8.232 +
   8.233 +backslashbox
   8.234 +\backslashbox{A}{B}
   8.235 +tabular環境の(主に)左上のカラムで用いて右下がり斜線で区切った2項目を書く。
   8.236 +要 \usepackage{slashbox}
   8.237 +\begin{tabular}
   8.238 +\hline
   8.239 +\backslashbox{A}{B} & hoge \\ \hline
   8.240 +\end{tabular}
   8.241 +
   8.242 +     +------+--------+
   8.243 +     | \ B |        |
   8.244 +     | A \ |  hoge  |
   8.245 +     +------+--------+
   8.246 +
   8.247 +
   8.248 +slashbox
   8.249 +\slashbox{A}{B}
   8.250 +tabular環境の(主に)右上のカラムで用いて右上がり斜線で区切った2項目を書く。
   8.251 +backslashboxも参照せよ。
   8.252 +
   8.253 +ooalign
   8.254 +{\ooalign{文字列1\crcr 文字列2……}
   8.255 +行送りゼロの設定に変更して文字の重ね打ちを可能にする。
   8.256 +○つき文字を作るための有名なマクロ \maru{} は便利。
   8.257 +
   8.258 +\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
   8.259 +
   8.260 +\crcr は\ooalign内での改行を意味する。\hfill は「最大に延びる空白」とい
   8.261 +うことで、文字の左右に配置することでセンタリングの効果が得られる。
   8.262 +\ooalign は改行幅などの長さパラメータをいじってしまうので全体を {} で
   8.263 +括る必要があることに注意。
   8.264 +
   8.265 +maru
   8.266 +\maru{あ}
   8.267 +文字(1文字に限る)を○で囲む。プリアンブルで以下の \newcommand をせよ。
   8.268 +\newcommand{\maru}[1]{{\ooalign {\hfill$\scriptstyle#1$\hfill\crcr$\bigcirc$}}}
   8.269 +
   8.270 +today
   8.271 +\date{\today}
   8.272 +作成日の日付けの出力を指定する。プリアンブルで \date とともに使う。
   8.273 +
   8.274 +和暦
   8.275 +\和暦
   8.276 +\和暦 は日付けを元号での表記にする。
   8.277 +\西暦 は西暦での表記にする。
   8.278 +\maketitle より先に指定する。
   8.279 +
   8.280 +西暦
   8.281 +\西暦
   8.282 +<refer 和暦>
   8.283 +
   8.284 +colorの名前つきカラー
   8.285 +\textcolor[named]{色名}{内容} など、[named] を指定する。
   8.286 +
   8.287 +\usepackage{color} によって使用可能。
   8.288 +使える色は以下の通り。
   8.289 +GreenYellow Yellow Goldenrod Dandelion Apricot Peach Melon YellowOrange
   8.290 +Orange BurntOrange Bittersweet RedOrange Mahogany Maroon BrickRed Red
   8.291 +OrangeRed RubineRed WildStrawberry Salmon CarnationPink Magenta
   8.292 +VioletRed Rhodamine Mulberry RedViolet Fuchsia Lavender Thistle
   8.293 +OrchidDarkOrchid Purple Plum Violet RoyalPurple BlueViolet Periwinkle
   8.294 +CadetBlue CornflowerBlue MidnightBlue NavyBlue RoyalBlue Blue Cerulean
   8.295 +Cyan ProcessBlue SkyBlue Turquoise TealBlue Aquamarine BlueGreen Emerald
   8.296 +JungleGreen SeaGreen Green ForestGreen PineGreen LimeGreen YellowGreen
   8.297 +SpringGreen OliveGreen RawSienna Sepia Brown Tan Gray Black White)
   8.298 +
   8.299 +色見本を出すソースが
   8.300 +http://www.yatex.org/help/color.tex にあるので、試すと良い。
   8.301 +
   8.302 +textcolor
   8.303 +\textcolor{色}{内容}
   8.304 +文字の色を「色」に設定して「内容」を出力。
   8.305 +
   8.306 +<refer colorの名前つきカラー>
   8.307 +
   8.308 +pagecolor
   8.309 +\pagecolor{色}
   8.310 +ページの背景色を「色」に設定する。
   8.311 +
   8.312 +<refer colorの名前つきカラー>
   8.313 +
   8.314 +color
   8.315 +\color{色}
   8.316 +
   8.317 +ページの文字食を「色」に設定する。
   8.318 +
   8.319 +<refer colorの名前つきカラー>
   8.320 +
   8.321 +colorbox
   8.322 +\colorbox{色}{内容}
   8.323 +「色」が背景のボックスを作りその中に「内容」を出力。
   8.324 +
   8.325 +
   8.326 +<refer colorの名前つきカラー>
   8.327 +
   8.328 +fcolorbox
   8.329 +\fcolorbox{枠の色}{背景色}{内容}
   8.330 +枠と背景色を指定して「内容」を出力。
   8.331 +
   8.332 +<refer colorの名前つきカラー>
   8.333 +
   8.334 +rotatebox
   8.335 +\rotatebox{角度}{内容}
   8.336 +「内容」を「角度」回転して出力。
   8.337 +要 `\usepackage{graphicx}'
   8.338 +
   8.339 +resizebox
   8.340 +\resizebox{横の長さ}{縦の長さ}{内容}
   8.341 +縦か横を省略したいときは ! を指定する。
   8.342 +\resizebox{!}{40mm}{内容} とすると縦が40mmで縦横比を保存して拡大する。
   8.343 +要 `\usepackage{graphicx}'
   8.344 +
   8.345 +scalebox
   8.346 +\scalebox{倍率}[縦倍率]{内容}
   8.347 +「内容」を「倍率」倍して出力。縦倍率は省略可能。
   8.348 +倍率として負の数を指定すると反転。
   8.349 +要 `\usepackage{graphicx}'
   8.350 +
   8.351 +reflectbox
   8.352 +\reflectbox{内容}
   8.353 +「内容」を左右反転して出力。\scalebox{-1}[1]{内容} と同じ。
   8.354 +要 `\usepackage{graphicx}'
   8.355 +
   8.356 +ulem
   8.357 +\usepackage{ulem}
   8.358 +\usepackage{ulem} すると 以下のマクロが使える。
   8.359 +\uline{通常の下線}
   8.360 +\uwave{波線}
   8.361 +\uuline{二重の下線} 
   8.362 +
   8.363 +\underlineと\ulineは前後に単語空白が挿入されるかどうかが異なっている。
   8.364 +
   8.365 +前\underline{中}後
   8.366 +前\uline{中}後
   8.367 +
   8.368 +を typeset して比較してみると分かる。
   8.369 +
   8.370 +(情報提供 TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>)
   8.371 +
   8.372 +uline
   8.373 +\uline{内容}
   8.374 +「内容」にアンダーラインをつける。
   8.375 +
   8.376 +<refer ulem>
   8.377 +
   8.378 +uwave
   8.379 +\uwave{内容}
   8.380 +「内容」に波下線をつける。
   8.381 +
   8.382 +<refer ulem>
   8.383 +
   8.384 +uuline
   8.385 +\uuline{内容}
   8.386 +「内容」に二重アンダーラインをつける。
   8.387 +
   8.388 +<refer ulem>
   8.389 +
   8.390 +showkeys.sty
   8.391 +\usepackage[options]{showkeys}
   8.392 +ラベルが無い(unlabeled)数式には {?} がマージンに印刷される。
   8.393 +引用されなかったラベルは ?label? のように印刷される。
   8.394 +オプションには showrefs, norefs, showcites, nocites, msgs, nomsgs,
   8.395 +chkunlbld, ignoreunlbld がある。msgs/nomsgs は .log ファイルに
   8.396 +メッセージを書き込むか否か。その他のオプションは自明。
   8.397 +
   8.398 +AMS-LaTeX や HyperRef と同時に使えるが、これらよりも後に
   8.399 +\usepackage しなくてはならない。
   8.400 +
   8.401 +似たような package に refcheck.sty というのがある。
   8.402 +これだと \ref まで見える(でもかえってうざったいかも)。
   8.403 +(情報提供 Masaki Shigemori <mshige@ucla.edu>)
   8.404 +
   8.405 +dots
   8.406 +\dots
   8.407 +点々
   8.408 +\dotsにはいくつも種類があるので適切に使いわけましょう。
   8.409 +
   8.410 +\dotsc ... コンマで区切られた列が続くことを表わす点々. $A_1, A_2, \dotsc$
   8.411 +\dotsb ... 二項演算子(+など)が続くことを表わす点々.$A_1+A_2+\dotsb$
   8.412 +\dotsm ... 掛け算(演算子省略)が続くことを表わす点々.$A_1 A_2 \dotsm$
   8.413 +\dotsi ... 積分が続くことを表わす点々 \[ \int_{A_1} int_{A_2} \dotsi \]
   8.414 +
   8.415 +(情報提供 Ryohei SETO <setoryohei@mac.com>)
   8.416 +
   8.417 +table*
   8.418 +\begin{table*} ... \end{table*}
   8.419 +二段組環境でも表を上段ぶち抜きで配置
   8.420 +
   8.421 +figure*
   8.422 +\begin{figure*} ... \end{figure*}
   8.423 +二段組環境でも図を上段ぶち抜きで配置([t]のみ)。
   8.424 +下段([b])に置きたいときは nidanfloat.sty を使う。
   8.425 +\begin{figure*}[b]
   8.426 + 〜〜\includegraphicsとか図をいれるマクロ〜〜
   8.427 + \caption{標題}
   8.428 +\end{figure*}
   8.429 +
   8.430 +includegraphics
   8.431 +\usepackage{graphicx}  ... \includegraphics[オプション]{graphicfile.eps}
   8.432 +画像を取り込む。要 graphicx パッケージ。
   8.433 +「オプション」は以下のものが指定可能。
   8.434 +scale=拡大率
   8.435 +width=幅
   8.436 +height=高さ
   8.437 +draft     (草稿モード; 枠だけ表示)
   8.438 +angle=回転角
   8.439 +origin=回転の中心位置  (c, tl, tr, bl, brのどれか)
   8.440 +bb=llx lly urx ury    (BoundingBoxとなる矩形対角座標を指定)
   8.441 +viewport=llx lly urx ury  (BoundingBox内の相対的座標で切り取る)
   8.442 +trim=left bottom right top  (指定した幅を切り取る)
   8.443 +
   8.444 +abstract
   8.445 +\begin{abstract} ... \end{abstract}
   8.446 +抄録(アブストラクト)を出力する。
   8.447 +和文抄録から英文に切り替えたいときは和文のabstract環境を終えたあとで
   8.448 +\renewcommand{\abstractname}{\textbf{Abstract}}
   8.449 +としてから再度abstract環境を始めると良い。
   8.450 +
   8.451 +\langle
   8.452 +$\langle$
   8.453 +         
   8.454 +数式モードでの`〈'
   8.455 +
   8.456 +\langle
   8.457 +$rlangle$
   8.458 +         
   8.459 +数式モードでの`〉'
   8.460 +
   8.461 +\slash
   8.462 +\slash
   8.463 +スラッシュそのもの
   8.464 +
   8.465 +\textbackslash
   8.466 +\textbackslash
   8.467 +バックスラッシュそのもの
   8.468  
   8.469  LaiTeX
   8.470  a Little Assistant Interface for TeX on Vz
   8.471 @@ -1633,6 +2002,16 @@
   8.472  山尾貴則さん(東北大)
   8.473  	Meadowユーザのための詳細インストールドキュメントを書いて下さいました。
   8.474  
   8.475 +重森正樹さん(東京大)
   8.476 +	数え切れないバグレポートとコメントを頂きました。
   8.477 +
   8.478 +瀬戸亮平さん(立命館大)
   8.479 +	Carbon Emacs(MacOS X) での使用のための情報をたくさん頂きました。
   8.480 +	AMS-LaTeXで使う重要なマクロの情報をたくさん頂きました。
   8.481 +
   8.482 +
   8.483 +
   8.484 +
   8.485  yatex
   8.486  (setq auto-mode-alist (cons '("\\.tex$" . yatex-mode) auto-mode-alist))
   8.487  <refer YaTeX>
     9.1 --- a/yahtml.el	Thu Dec 25 04:10:32 2003 +0000
     9.2 +++ b/yahtml.el	Sun Dec 24 06:16:52 2006 +0000
     9.3 @@ -1,9 +1,9 @@
     9.4  ;;; -*- Emacs-Lisp -*-
     9.5 -;;; (c) 1994-2003 by HIROSE Yuuji [yuuji@yatex.org]
     9.6 -;;; Last modified Mon Nov 17 18:28:50 2003 on firestorm
     9.7 +;;; (c) 1994-2006 by HIROSE Yuuji [yuuji@yatex.org]
     9.8 +;;; Last modified Sun Dec 24 15:12:35 2006 on firestorm
     9.9  ;;; $Id$
    9.10  
    9.11 -(defconst yahtml-revision-number "1.70"
    9.12 +(defconst yahtml-revision-number "1.72"
    9.13    "Revision number of running yahtml.el")
    9.14  
    9.15  ;;;[Installation]
    9.16 @@ -173,9 +173,8 @@
    9.17  ;;; --- customizable variable starts here ---
    9.18  (defvar yahtml-prefix "\C-c"
    9.19    "*Prefix key stroke of yahtml functions.")
    9.20 -(defvar yahtml-image-viewer "xv" "*Image viewer program")
    9.21 -(defvar yahtml-www-browser "netscape"
    9.22 -  "*WWW Browser command")
    9.23 +(defvar yahtml-image-viewer "display" "*Image viewer program")
    9.24 +(defvar yahtml-www-browser "firefox" "*WWW Browser command")
    9.25  (defvar yahtml-kanji-code 2
    9.26    "*Kanji coding system number of html file; 1=sjis, 2=jis, 3=euc")
    9.27  ;;(defvar yahtml-coding-system
    9.28 @@ -208,13 +207,19 @@
    9.29  (defvar yahtml-hate-too-deep-indentation nil
    9.30    "*Non-nil for this variable suppress deep indentation in listing environments.")
    9.31  
    9.32 -(defvar yahtml-always-/p nil
    9.33 +(defvar yahtml-always-/p t
    9.34    "*Those who always use <p> with </p> set this to t.")
    9.35 +(defvar yahtml-always-/li nil
    9.36 +  "*Those who always use <li> with </li> set this to t.")
    9.37 +(defvar yahtml-always-/dt nil
    9.38 +  "*Those who always use <dt> with </dt> set this to t.")
    9.39 +(defvar yahtml-always-/dd nil
    9.40 +  "*Those who always use <dd> with </dd> set this to t.")
    9.41  
    9.42  (defvar yahtml-p-prefered-env-regexp "^\\(body\\|dl\\|blockquote\\)"
    9.43    "*Regexp of envs where paragraphed sentences are prefered.")
    9.44  
    9.45 -(defvar yahtml-template-file "~/http/template.html"
    9.46 +(defvar yahtml-template-file "~/public_html/template.html"
    9.47    "*Template HTML file.  It'll be inserted to empty file.")
    9.48  
    9.49  (defvar yahtml-prefer-upcases nil
    9.50 @@ -223,8 +228,7 @@
    9.51  (defvar yahtml-prefer-upcase-attributes nil
    9.52    "*Non-nil for preferring upcase attributes")
    9.53  
    9.54 -(defvar yahtml-server-type 'apache
    9.55 -  "*WWW server program type")
    9.56 +(defvar yahtml-server-type 'apache "*WWW server program type")
    9.57  
    9.58  (defvar yahtml-apache-access-file ".htaccess"
    9.59    "*Server access file name for apache")
    9.60 @@ -265,6 +269,10 @@
    9.61  (defvar yahtml-indentation-boundary "^\\s *<h[1-3]>"
    9.62    "*Boundary regexp for indentation calculation.")
    9.63  
    9.64 +(defvar yahtml-html4-strict t
    9.65 +  "*Non-nil means editing HTML 4.01 Strict.
    9.66 +Completing read for obsoleted attributes disabled.")
    9.67 +
    9.68  ;;; --- customizable variable ends here ---
    9.69  (defvar yahtml-prefix-map nil)
    9.70  (defvar yahtml-mode-map nil "Keymap used in yahtml-mode.")
    9.71 @@ -305,6 +313,7 @@
    9.72    (define-key yahtml-mode-map "\M-\C-a" 'YaTeX-beginning-of-environment)
    9.73    (define-key yahtml-mode-map "\M-\C-e" 'YaTeX-end-of-environment)
    9.74    (define-key yahtml-mode-map "\M-\C-m" 'yahtml-intelligent-newline)
    9.75 +  (define-key yahtml-mode-map "\M-\C-j" 'yahtml-intelligent-newline)
    9.76    (define-key yahtml-mode-map "\C-i" 'yahtml-indent-line)
    9.77    (define-key yahtml-mode-map "&" 'yahtml-insert-amps)
    9.78    (let ((map yahtml-prefix-map))
    9.79 @@ -337,6 +346,7 @@
    9.80        (yahtml-define-begend-key "bc" "center" map)
    9.81        (yahtml-define-begend-key "bd" "dl" map)
    9.82        (yahtml-define-begend-key "bu" "ul" map)
    9.83 +      (yahtml-define-begend-key "bo" "ol" map)
    9.84        (yahtml-define-begend-key "b1" "h1" map)
    9.85        (yahtml-define-begend-key "b2" "h2" map)
    9.86        (yahtml-define-begend-key "b3" "h3" map)
    9.87 @@ -344,7 +354,7 @@
    9.88        (yahtml-define-begend-key "bf" "form" map)
    9.89        (yahtml-define-begend-key "bs" "select" map)
    9.90        (yahtml-define-begend-key "bv" "div" map)
    9.91 -      (yahtml-define-begend-key "bS" "div" map)
    9.92 +      (yahtml-define-begend-key "bS" "span" map)
    9.93        (yahtml-define-begend-key "bp" "pre" map)
    9.94        (YaTeX-define-key "b " 'yahtml-insert-begend map)
    9.95        (YaTeX-define-key "B " 'yahtml-insert-begend-region map)
    9.96 @@ -409,13 +419,17 @@
    9.97      ("UnorderedList" . "ul")
    9.98      ("DefinitionList" . "dl")
    9.99      ("Preformatted" . "pre")
   9.100 -    ("table") ("thead") ("tbody") ("tfoot") ("caption") ("tr") ("th") ("td")
   9.101 +    ("table") ("thead") ("tbody") ("tfoot") ("tr") ("th") ("td")
   9.102      ("address") 
   9.103      ("h1") ("h2") ("h3") ("h4") ("h5") ("h6")
   9.104      ;; ("p") ;This makes indentation screwed up!
   9.105 -    ("style") ("div") ("object")
   9.106 +    ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del")
   9.107      ))
   9.108  
   9.109 +(if yahtml-html4-strict
   9.110 +    (setq yahtml-env-table
   9.111 +	  (delete (assoc "center" yahtml-env-table) yahtml-env-table)))
   9.112 +
   9.113  ;(defvar yahtml-itemizing-regexp
   9.114  ;  "\\(ul\\|ol\\|dl\\)"
   9.115  ;  "Regexp of itemizing forms")
   9.116 @@ -427,12 +441,23 @@
   9.117  (and yahtml-always-/p
   9.118       (or (assoc "p" yahtml-env-table)
   9.119  	 (setq yahtml-env-table (cons '("p") yahtml-env-table))))
   9.120 +(and yahtml-always-/li
   9.121 +     (or (assoc "li" yahtml-env-table)
   9.122 +	 (setq yahtml-env-table (cons '("li") yahtml-env-table))))
   9.123 +(and yahtml-always-/dt
   9.124 +     (or (assoc "dt" yahtml-env-table)
   9.125 +	 (setq yahtml-env-table (cons '("dt") yahtml-env-table))))
   9.126 +(and yahtml-always-/dd
   9.127 +     (or (assoc "dd" yahtml-env-table)
   9.128 +	 (setq yahtml-env-table (cons '("dd") yahtml-env-table))))
   9.129  
   9.130  (defvar yahtml-typeface-table
   9.131    (append
   9.132 -   '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") ("strike") ("s")
   9.133 -     ("strong") ("var") ("b") ("i") ("tt") ("u") ("big") ("small") ("font")
   9.134 -     ("sup") ("sub") ("span"))
   9.135 +   '(("dfn") ("em") ("cite") ("code") ("kbd") ("samp") ("caption")
   9.136 +     ("strong") ("var") ("b") ("i") ("tt") ("big") ("small")
   9.137 +     ("sup") ("sub") ("span") ("abbr"))
   9.138 +   (if (not yahtml-html4-strict)
   9.139 +       '(("strike") ("s") ("u") ("font")))
   9.140     yahtml-env-table)
   9.141    "Default completion table of typeface designator")
   9.142  (defvar yahtml-user-typeface-table nil)
   9.143 @@ -440,14 +465,17 @@
   9.144  (defvar yahtml-last-typeface-cmd "a")
   9.145  
   9.146  (defvar yahtml-single-cmd-table
   9.147 -  '(("hr") ("br") ("option") ("p")
   9.148 -    ("HorizontalLine" . "hr")
   9.149 +  '(("hr") ("br") ("option")
   9.150 +    ("HorizontalRule" . "hr")
   9.151      ("BreakLine" . "br")
   9.152 -    ("Paragraph" . "p")
   9.153 -    ("Item" . "li")
   9.154 -    ("DefineTerm" . "dt")
   9.155 -    ("Description" . "dd")
   9.156 -    ("dd") ("dt") ("li")
   9.157 +    ("exec" . "!--#exec")
   9.158 +    ("!--#exec")
   9.159 +    ("include" . "!--#include")
   9.160 +    ("!--#include")
   9.161 +;;     ("Item" . "li")
   9.162 +;;     ("DefineTerm" . "dt")
   9.163 +;;     ("Description" . "dd")
   9.164 +;;     ("dd") ("dt") ("li")
   9.165      )
   9.166    "Default completion table of HTML single command.")
   9.167  (defvar yahtml-user-single-cmd-table nil)
   9.168 @@ -537,6 +565,8 @@
   9.169  	    (setq charset 3))
   9.170  	   ((string-match "shift_jis" charset)
   9.171  	    (setq charset 1))
   9.172 +	   ((string-match "utf-8" charset)
   9.173 +	    (setq charset 4))
   9.174  	   (t (setq charset nil)))
   9.175  	  (setq dir "")))
   9.176      (if (featurep 'mule)
   9.177 @@ -576,7 +606,9 @@
   9.178       ((and YaTeX-emacs-20 (boundp 'buffer-file-coding-system))
   9.179        (setq buffer-file-coding-system
   9.180  	    (or (and (fboundp 'set-auto-coding) buffer-file-name
   9.181 -		     (save-excursion (set-auto-coding buffer-file-name (buffer-size))))
   9.182 +		     (save-excursion
   9.183 +		       (goto-char (point-min))
   9.184 +		       (set-auto-coding buffer-file-name (buffer-size))))
   9.185  		coding)))
   9.186       ((featurep 'mule)
   9.187        (set-file-coding-system coding))
   9.188 @@ -599,7 +631,7 @@
   9.189       (YaTeX-struct-begin . "<%1%2")
   9.190       (YaTeX-struct-end . "</%1>")
   9.191       (YaTeX-struct-name-regexp . yahtml-closable-regexp)
   9.192 -     (YaTeX-comment-prefix . "<!--")
   9.193 +     (YaTeX-comment-prefix . "<!--[^#]")
   9.194       (YaTeX-coding-system . yahtml-kanji-code) ;necessary?
   9.195       (YaTeX-typesetting-mode-map . yahtml-lint-buffer-map)
   9.196       (fill-prefix . yahtml-fill-prefix) (fill-column . yahtml-fill-column)
   9.197 @@ -854,6 +886,16 @@
   9.198  	 (save-excursion (insert (format "</%s>" form))))
   9.199       (if (search-backward "\"\"" p t) (forward-char 1))))
   9.200  
   9.201 +(defun yahtml-read-css (alist)
   9.202 +  (let ((completion-ignore-case t) (delim " ")
   9.203 +	(minibuffer-completion-table alist))
   9.204 +    (read-from-minibuffer
   9.205 +     (substitute-command-keys
   9.206 +      (if YaTeX-japan
   9.207 +	  "クラス(複数指定は\\[quoted-insert] SPCで区切る): "
   9.208 +	"class(or class list delimited by \\[quoted-insert] SPC): "))
   9.209 +     nil YaTeX-minibuffer-completion-map nil)))
   9.210 +  
   9.211  ;;; ---------- Add-in ----------
   9.212  (defun yahtml-addin (form)
   9.213    "Check add-in function's existence and call it if exists."
   9.214 @@ -863,9 +905,7 @@
   9.215  	   (not (equal last-command-char ?\C-j))
   9.216  	   (memq yahtml-current-completion-type '(multiline inline))
   9.217  	   (yahtml-make-optional-argument ;should be made generic?
   9.218 -	    "class"
   9.219 -	    (let ((completion-ignore-case t))
   9.220 -	      (completing-read "class: " a))))
   9.221 +	    "class" (yahtml-read-css a)))
   9.222        (if (and (intern-soft addin) (fboundp (intern-soft addin))
   9.223  	       (stringp (setq s (funcall (intern addin))))
   9.224  	       (string< "" s))
   9.225 @@ -1060,7 +1100,8 @@
   9.226  (defvar yahtml-parameters-completion-alist
   9.227    '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center"))
   9.228      ("clear" ("left") ("right") ("center") ("all") ("none"))
   9.229 -    ("src" . file)
   9.230 +    ("lang" ("ja") ("en") ("kr") ("ch") ("fr"))
   9.231 +    ("src" . file) ("file" . file)
   9.232      ("background" . file)
   9.233      ("class file name" . file) ("data" . file)
   9.234      ("method" ("POST") ("GET"))
   9.235 @@ -1078,6 +1119,7 @@
   9.236  (defvar yahtml-content-types-alist
   9.237    '(("text/css") ("text/html") ("text/plain") ("text/richtext")
   9.238      ("text/sgml") ("text/xml")
   9.239 +    ("text/javascript") ("text/tcl") ("text/vbscript")
   9.240      ("application/octet-stream") ("application/postscript") ("application/pdf")
   9.241      ("application/java")
   9.242      ("image/jpeg") ("image/gif") ("image/tiff") ("image/png") ("video/mpeg"))
   9.243 @@ -1091,7 +1133,8 @@
   9.244  	 v)
   9.245      (cond
   9.246       ((eq alist 'file)
   9.247 -      (read-file-name prompt "" default nil ""))
   9.248 +      (let ((insert-default-directory))
   9.249 +	(read-file-name prompt "" default nil "")))
   9.250       ((and alist (symbolp alist))
   9.251        (completing-read prompt (symbol-value alist) nil nil default))
   9.252       (alist
   9.253 @@ -1101,25 +1144,47 @@
   9.254        
   9.255  (defun yahtml-make-optional-argument (opt arg)
   9.256    "Make optional argument string."
   9.257 -  (if (string= "" arg)
   9.258 +  (if (or (null arg) (string= "" arg))
   9.259        ""
   9.260      (concat " "
   9.261  	    (if yahtml-prefer-upcase-attributes (upcase opt) (downcase opt))
   9.262  	    "=\"" arg "\"")))
   9.263  
   9.264 +(defun yahtml:html ()
   9.265 +  "Add-in for <html>"
   9.266 +  (setq yahtml-last-begend "head" yahtml-last-typeface-cmd "head")
   9.267 +  (yahtml-make-optional-argument
   9.268 +   "lang" (yahtml-read-parameter "lang" (if YaTeX-japan "ja"))))
   9.269 +
   9.270 +(defun yahtml:head ()
   9.271 +  "Add-in for <head>"
   9.272 +  (setq yahtml-last-begend "title" yahtml-last-typeface-cmd "title")
   9.273 +  "")
   9.274 +
   9.275  (defun yahtml:body ()
   9.276    "Add-in function for <body>"
   9.277 -  (let ((b (read-string "bgcolor="))
   9.278 -	(bg (yahtml-read-parameter "background" ""))
   9.279 -	(x (read-string "text color="))
   9.280 -	(l (read-string "link color="))
   9.281 -	(v (read-string "vlink color=")))
   9.282 -    (concat
   9.283 -     (yahtml-make-optional-argument "bgcolor" b)
   9.284 -     (yahtml-make-optional-argument "background" bg)
   9.285 -     (yahtml-make-optional-argument "text" x)
   9.286 -     (yahtml-make-optional-argument "link" l)
   9.287 -     (yahtml-make-optional-argument "vlink" v))))
   9.288 +  (cond
   9.289 +   (yahtml-html4-strict nil)
   9.290 +   (t
   9.291 +    (let ((b (read-string "bgcolor="))
   9.292 +	  (bg (yahtml-read-parameter "background" ""))
   9.293 +	  (x (read-string "text color="))
   9.294 +	  (l (read-string "link color="))
   9.295 +	  (v (read-string "vlink color=")))
   9.296 +      (concat
   9.297 +       (yahtml-make-optional-argument "bgcolor" b)
   9.298 +       (yahtml-make-optional-argument "background" bg)
   9.299 +       (yahtml-make-optional-argument "text" x)
   9.300 +       (yahtml-make-optional-argument "link" l)
   9.301 +       (yahtml-make-optional-argument "vlink" v))))))
   9.302 +
   9.303 +(defun yahtml-make-style-parameter (proplist)
   9.304 +  "Make CSS property definitions in style attribute."
   9.305 +  (mapconcat
   9.306 +   '(lambda (x) (if (and (cdr x) (string< "" (cdr x)))
   9.307 +		    (format "%s: %s;" (car x) (cdr x))))
   9.308 +   (delq nil proplist)
   9.309 +   " "))
   9.310  
   9.311  (defun yahtml:img ()
   9.312    "Add-in function for <img>"
   9.313 @@ -1150,11 +1215,23 @@
   9.314      (setq width (yahtml-read-parameter "width" width)
   9.315  	  height (yahtml-read-parameter "height" height))
   9.316      (concat (if l "SRC" "src") "=\"" src "\""
   9.317 -	    (yahtml-make-optional-argument "align" alg)
   9.318  	    (yahtml-make-optional-argument "alt" alt)
   9.319  	    (yahtml-make-optional-argument "width" width)
   9.320  	    (yahtml-make-optional-argument "height" height)
   9.321 -	    (yahtml-make-optional-argument "border" brd))))
   9.322 +	    (if yahtml-html4-strict
   9.323 +		(yahtml-make-optional-argument
   9.324 +		 "style"
   9.325 +		 (if (or brd alg)
   9.326 +		     (yahtml-make-style-parameter
   9.327 +		      (list
   9.328 +		       (if (string< "" alg)
   9.329 +			   (cons "align" alg))
   9.330 +		       (if (string< "" brd)
   9.331 +			   (cons "border"
   9.332 +				 (format "%dpx" (string-to-int brd))))))))
   9.333 +	      (concat
   9.334 +	       (yahtml-make-optional-argument "border" brd)
   9.335 +	       (yahtml-make-optional-argument "align" alg))))))
   9.336  
   9.337  (defun yahtml-file-truename (file)
   9.338    (cond
   9.339 @@ -1301,9 +1378,9 @@
   9.340    (setq yahtml-last-single-cmd "dd") "")
   9.341  
   9.342  (defun yahtml:p ()
   9.343 -  (let ((alg (yahtml-read-parameter "align")))
   9.344 -    (yahtml-make-optional-argument "align" alg)
   9.345 -))
   9.346 +  (if yahtml-html4-strict nil
   9.347 +    (let ((alg (yahtml-read-parameter "align")))
   9.348 +      (yahtml-make-optional-argument "align" alg))))
   9.349  
   9.350  (defvar yahtml-input-types
   9.351    '(("text") ("password") ("checkbox") ("radio") ("submit")
   9.352 @@ -1344,15 +1421,39 @@
   9.353  (defun yahtml:table ()
   9.354    "Add-in function for `table'"
   9.355    (let ((b (read-string "border="))
   9.356 -	(a (yahtml-read-parameter "align")))
   9.357 -    (concat
   9.358 -     (yahtml-make-optional-argument "border" b)
   9.359 -     (yahtml-make-optional-argument "align" a))))
   9.360 +	(a (yahtml-read-parameter
   9.361 +	    "align" nil '(("align" ("right")("center"))))))
   9.362 +    (if yahtml-html4-strict
   9.363 +	(yahtml-make-optional-argument
   9.364 +	 "style"
   9.365 +	 (if (or (string< "" b) (string< "" a))
   9.366 +	     (yahtml-make-style-parameter
   9.367 +	      (append
   9.368 +	       (if (string< "" b)
   9.369 +		   (list
   9.370 +		    (cons "border" (format "%dpx solid" (string-to-int b)))
   9.371 +		    (cons "border-collapse" "collapse")))
   9.372 +	       (if (string< "" a)
   9.373 +		   (cond
   9.374 +		    ((string-match "right" a)
   9.375 +		     (list (cons "margin-left" "auto")
   9.376 +			   (cons "margin-right" "0")))
   9.377 +		    ((string-match "center" a)
   9.378 +		     (list (cons "margin-left" "auto")
   9.379 +			   (cons "margin-right" "auto")))))))))
   9.380 +      (concat
   9.381 +       (yahtml-make-optional-argument "border" b)
   9.382 +       (yahtml-make-optional-argument "align" a)))))
   9.383 +
   9.384  ;(fset 'yahtml:caption 'yahtml:p)
   9.385  (defun yahtml:caption ()
   9.386    "Add-in function for `caption' in table tag"
   9.387 -  (let ((yahtml-parameters-completion-alist '(("align" ("top") ("bottom")))))
   9.388 -    (yahtml-make-optional-argument "align" (yahtml-read-parameter "align"))))
   9.389 +  (let ((par (yahtml-read-parameter "align")))
   9.390 +    (if yahtml-html4-strict
   9.391 +	(yahtml-make-optional-argument
   9.392 +	 "style" (if par (yahtml-make-style-parameter
   9.393 +			  (list (cons "caption-side" par)))))
   9.394 +      (yahtml-make-optional-argument "align" par))))
   9.395  
   9.396  (defun yahtml:font ()
   9.397    "Add-in function for `font'"
   9.398 @@ -1365,6 +1466,14 @@
   9.399    (yahtml-make-optional-argument
   9.400     "type" (read-string "type=" "text/css")))
   9.401  
   9.402 +(defun yahtml:script ()
   9.403 +  "Add-in function for `script'"
   9.404 +  (concat
   9.405 +   (yahtml-make-optional-argument
   9.406 +    "type" (yahtml-read-parameter "type" "text/javascript"))
   9.407 +   (yahtml-make-optional-argument
   9.408 +    "src" (yahtml-read-parameter "src" ""))))
   9.409 +
   9.410  (defun yahtml:tr ()
   9.411    "Add-in function for `tr'"
   9.412    (setq ;yahtml-last-begend "td"		;; which do you prefer?
   9.413 @@ -1400,8 +1509,14 @@
   9.414  			  (yahtml-url-to-path href) yahtml-css-class-alist)))
   9.415  	       (message "")
   9.416  	       (yahtml-make-optional-argument "href" href))))))
   9.417 -     (t ;;??
   9.418 -      ))))
   9.419 +     (t
   9.420 +      (concat
   9.421 +       (yahtml-make-optional-argument "rel" rel)
   9.422 +       (yahtml-make-optional-argument
   9.423 +	"type" (yahtml-read-parameter "type" "text/css"))
   9.424 +       (yahtml-make-optional-argument
   9.425 +	"href" (read-from-minibuffer "href: " "" yahtml-url-completion-map))
   9.426 +       )))))
   9.427  
   9.428  (defvar yahtml:meta-names
   9.429    '(("name" ("keywords")("author")("copyright")("date")("GENERATOR"))))
   9.430 @@ -1468,6 +1583,10 @@
   9.431        ""
   9.432        ))))
   9.433  
   9.434 +(defun yahtml:abbr ()
   9.435 +  "Add-in function for abbr."
   9.436 +  (yahtml-make-optional-argument "title" (yahtml-read-parameter "title")))
   9.437 +
   9.438  ;;; ---------- Simple tag ----------
   9.439  (defun yahtml-insert-tag (region-mode &optional tag)
   9.440    "Insert <TAG> </TAG> and put cursor inside of them."
   9.441 @@ -1502,6 +1621,7 @@
   9.442    (yahtml-insert-tag t tag))
   9.443  
   9.444  
   9.445 +(defvar yahtml-need-single-closer nil)	;for test
   9.446  (defun yahtml-insert-single (cmd)
   9.447    "Insert <CMD>."
   9.448    (interactive
   9.449 @@ -1518,14 +1638,19 @@
   9.450  	(or (cdr (assoc cmd yahtml-single-cmd-table)) cmd))
   9.451    (setq cmd (funcall (if yahtml-prefer-upcases 'upcase 'downcase)
   9.452  		     yahtml-last-single-cmd))
   9.453 -  (insert (format "<%s>" cmd)))
   9.454 +  (insert (format "<%s%s%s>"
   9.455 +		  cmd
   9.456 +		  (yahtml-addin cmd)
   9.457 +		  (if (and yahtml-need-single-closer
   9.458 +			   (assoc cmd '(("br")("hr"))))
   9.459 +		      " /" "")))
   9.460 +  (if (assoc cmd yahtml-env-table)
   9.461 +      (save-excursion (insert (format "</%s>" cmd)))))
   9.462  
   9.463  (defun yahtml-insert-p (&optional arg)
   9.464    "Convenient function to insert <p></p>"
   9.465    (interactive "P")
   9.466 -  (if arg (yahtml-insert-tag arg "p")
   9.467 -    (save-excursion			;insert "/p" first to memorize "p"
   9.468 -      (yahtml-insert-single "/p"))	;in the last-completion variable
   9.469 +  (if (or yahtml-always-/p arg) (yahtml-insert-tag arg "p")
   9.470      (yahtml-insert-single "p")))
   9.471  
   9.472  (defun yahtml-insert-amps (arg)
   9.473 @@ -1551,6 +1676,13 @@
   9.474        (insert ?&))
   9.475       (t (insert (format "&#%d;" c))))))
   9.476  
   9.477 +(defun yahtml:!--\#include ()
   9.478 +  (let ((file (yahtml-read-parameter "file" "")))
   9.479 +    (format "%s=\"%s\"--" (if (string-match "/" file) "virtual" "file") file)))
   9.480 +
   9.481 +(defun yahtml:!--\#exec ()
   9.482 +  (format "cmd=\"%s\"--" (yahtml-read-parameter "cmd" "" '(("cmd" . file)))))
   9.483 +
   9.484  ;;; ---------- Jump ----------
   9.485  (defun yahtml-on-href-p ()
   9.486    "Check if point is on href clause."
   9.487 @@ -1637,7 +1769,7 @@
   9.488    (let ((href (yahtml-on-href-p)) file name (parent buffer-file-name))
   9.489      (if href
   9.490  	(cond
   9.491 -	 ((string-match "^\\(ht\\|f\\)tp:" href)
   9.492 +	 ((string-match "^\\(ht\\|f\\)tps?:" href)
   9.493  	  (yahtml-browse-html href))
   9.494  	 (t (setq file (substring href 0 (string-match "#" href)))
   9.495  	    (if (string-match "#" href)
   9.496 @@ -1716,7 +1848,7 @@
   9.497       (t nil))))
   9.498  
   9.499  (defun yahtml-current-tag ()
   9.500 -  "Return the current tag name."
   9.501 +  "Return the current tag name including #exec and #include."
   9.502    (save-excursion
   9.503      (let ((p (point)) b tag)
   9.504        (or (bobp)
   9.505 @@ -1724,32 +1856,12 @@
   9.506  	  (progn (skip-chars-backward "^<") (forward-char -1)))
   9.507        (setq b (point))
   9.508        (skip-chars-forward "<")
   9.509 -      (setq tag (buffer-substring
   9.510 +      (setq tag (YaTeX-buffer-substring
   9.511  		 (point) (progn (skip-chars-forward "^ \t\n") (point))))
   9.512        (goto-char b)
   9.513        (forward-list 1)
   9.514        (and (< p (point)) tag))))
   9.515        
   9.516 -
   9.517 -(defun yahtml-goto-corresponding-img ()
   9.518 -  "View image on point"
   9.519 -  (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t))
   9.520 -    (if (and tag
   9.521 -	     (string-match "img" tag)
   9.522 -	     (save-excursion
   9.523 -	       (re-search-backward "<\\s *img" nil t)
   9.524 -	       (re-search-forward "src=\"?\\([^\"> ]+\\)\"?")
   9.525 -	       (match-beginning 1)
   9.526 -	       (setq image
   9.527 -		     (buffer-substring (match-beginning 1) (match-end 1)))))
   9.528 -	(progn
   9.529 -	  (message "Invoking %s %s..." yahtml-image-viewer image)
   9.530 -	  (start-process
   9.531 -	   "Viewer" " * Image Viewer *"
   9.532 -	   shell-file-name yahtml-shell-command-option ;"-c"
   9.533 -	   (concat yahtml-image-viewer " " image))
   9.534 -	  (message "Invoking %s %s...Done" yahtml-image-viewer image)))))
   9.535 -
   9.536  (defun yahtml-get-attrvalue (attr)
   9.537    "Extract current tag's attribute value from buffer."
   9.538    (let (e (case-fold-search t))
   9.539 @@ -1763,8 +1875,22 @@
   9.540  		  (looking-at "\"?\\([^\"> \t\n]+\\)\"?")))
   9.541  	  (YaTeX-match-string 1)))))
   9.542  
   9.543 +(defun yahtml-goto-corresponding-img ()
   9.544 +  "View image on point"
   9.545 +  (let ((tag (yahtml-current-tag)) image (p (point)) (case-fold-search t))
   9.546 +    (if (and tag
   9.547 +	     (string-match "img" tag)
   9.548 +	     (setq image (yahtml-get-attrvalue "src")))
   9.549 +	(progn
   9.550 +	  (message "Invoking %s %s..." yahtml-image-viewer image)
   9.551 +	  (start-process
   9.552 +	   "Viewer" " * Image Viewer *"
   9.553 +	   shell-file-name yahtml-shell-command-option ;"-c"
   9.554 +	   (concat yahtml-image-viewer " " image))
   9.555 +	  (message "Invoking %s %s...Done" yahtml-image-viewer image)))))
   9.556 +
   9.557  (defun yahtml-goto-corresponding-source (&optional other)
   9.558 -  "Goto applet's source."
   9.559 +  "Goto applet's or script's source."
   9.560    (let ((env (yahtml-current-tag)) s (p (point)))
   9.561      (cond
   9.562       ((string-match "applet" env)
   9.563 @@ -1780,6 +1906,13 @@
   9.564  	(message "No applet source specified")
   9.565  	(sit-for 1)
   9.566  	nil))
   9.567 +     ((string-match "script" env)
   9.568 +      (if (setq s (yahtml-get-attrvalue "src"))
   9.569 +	  (progn
   9.570 +	    (funcall (if other 'YaTeX-switch-to-buffer-other-window
   9.571 +		       'YaTeX-switch-to-buffer)
   9.572 +		     (yahtml-url-to-path s))
   9.573 +	    s)))
   9.574       ((string-match "!--#include" env)
   9.575        (cond
   9.576         ((setq s (yahtml-get-attrvalue "file")) ;<!--#include file="foo"-->
   9.577 @@ -1807,12 +1940,12 @@
   9.578  
   9.579  (defun yahtml-goto-corresponding-* (&optional other)
   9.580    "Go to corresponding object."
   9.581 -  (interactive)
   9.582 +  (interactive "P")
   9.583    (cond
   9.584     ((yahtml-goto-corresponding-href other))
   9.585     ((yahtml-goto-corresponding-img))
   9.586 +   ((yahtml-goto-corresponding-source other))
   9.587     ((yahtml-goto-corresponding-begend))
   9.588 -   ((yahtml-goto-corresponding-source other))
   9.589     (t (message "I don't know where to go."))
   9.590     ))
   9.591  
   9.592 @@ -1945,8 +2078,8 @@
   9.593         ((setq attr (yahtml-on-assignment-p)) ;if on the assignment to attr
   9.594  	(if (and (equal attr "class")	     ;treat "class" attribute specially
   9.595  		 (setq css (yahtml-css-get-element-completion-alist tag)))
   9.596 -	    (setq new (yahtml-read-parameter ;should be made generic?
   9.597 -		       attr nil (list (cons "class" css))))
   9.598 +	    
   9.599 +	    (setq new (yahtml-read-css css))
   9.600  	  ;;other than "class", read parameter normally
   9.601  	  (setq new (yahtml-read-parameter attr)))
   9.602  	(goto-char (car (get 'yahtml-on-assignment-p 'region)))
   9.603 @@ -2478,7 +2611,7 @@
   9.604  (defun yahtml-intelligent-newline-ul ()
   9.605    (interactive)
   9.606    (yahtml-insert-single "li")
   9.607 -  (or yahtml-faithful-to-htmllint (insert " "))
   9.608 +  (or yahtml-always-/li yahtml-faithful-to-htmllint (insert " "))
   9.609    (yahtml-indent-line))
   9.610  
   9.611  (fset 'yahtml-intelligent-newline-ol 'yahtml-intelligent-newline-ul)
   9.612 @@ -2492,11 +2625,11 @@
   9.613  	(cond
   9.614  	 ((match-beginning 2)
   9.615  	  (yahtml-insert-single "dd")
   9.616 -	  (or yahtml-faithful-to-htmllint (insert " "))
   9.617 +	  (or yahtml-always-/dd yahtml-faithful-to-htmllint (insert " "))
   9.618  	  (setq yahtml-last-single-cmd "dt"))
   9.619  	 ((match-beginning 3)
   9.620  	  (yahtml-insert-single "dt")
   9.621 -	  (or yahtml-faithful-to-htmllint (insert " "))
   9.622 +	  (or yahtml-always-/dt yahtml-faithful-to-htmllint (insert " "))
   9.623  	  (setq yahtml-last-single-cmd "dd")))
   9.624        (insert (if yahtml-prefer-upcases "<DT> " "<dt> "))
   9.625        (setq yahtml-last-single-cmd "dd"))
   9.626 @@ -2526,6 +2659,35 @@
   9.627  	(open-line 1)
   9.628  	(YaTeX-reindent c))))
   9.629  
   9.630 +(defun yahtml-intelligent-newline-head ()
   9.631 +  (let ((title (read-string "Document title: "))
   9.632 +	(b "<title>") (e "</title>") p)
   9.633 +    (yahtml-indent-line)
   9.634 +    (insert (format "%s" (if yahtml-prefer-upcases (upcase b) b)))
   9.635 +    (setq p (point))
   9.636 +    (insert (format "%s%s" title (if yahtml-prefer-upcases (upcase e) e)))
   9.637 +    (if (string= "" title) (goto-char p))
   9.638 +    (setq yahtml-last-begend "body")))
   9.639 +
   9.640 +(defun yahtml-intelligent-newline-script ()
   9.641 +  (let ((p (point)) b)
   9.642 +    (if (save-excursion
   9.643 +	  (and
   9.644 +	   (setq b (re-search-backward "<script\\>" nil t))
   9.645 +	   (re-search-forward
   9.646 +	    "\\(javascript\\)\\|\\(tcl\\)\\|\\(vbscript\\)" p t)))
   9.647 +	(let ((js (match-end 1)) (tcl (match-end 2)) (vb (match-end 3))
   9.648 +	      c (srcp (re-search-backward "src=" b t)))
   9.649 +	  (goto-char p)
   9.650 +	  (yahtml-indent-line)
   9.651 +	  (setq c (current-column))
   9.652 +	  (if srcp
   9.653 +	      nil
   9.654 +	    (insert "<!--\n" (cond (js "//") (tcl "#") (vb "'")) " -->")
   9.655 +	    (beginning-of-line)
   9.656 +	    (open-line 1)
   9.657 +	    (YaTeX-reindent c))))))
   9.658 +
   9.659  ;;; ---------- Marking ----------
   9.660  (defun yahtml-mark-begend ()
   9.661    "Mark current tag"
   9.662 @@ -2591,23 +2753,32 @@
   9.663        (goto-char (point-min))
   9.664        (let ((alist initial) b e element class a)
   9.665  	(setq b (point))
   9.666 -	(while (search-forward "{" nil t)
   9.667 -	  (setq e (point))
   9.668 -	  (goto-char b)
   9.669 -	  (while (re-search-forward	;ちょといい加減なREGEXP
   9.670 -		  "\\([a-z][-a-z0-9]*\\)?\\.\\([-a-z0-9][-a-z0-9]*\\)\\>" e t)
   9.671 -	    (setq element (YaTeX-match-string 1)
   9.672 -		  class (YaTeX-match-string 2))
   9.673 -	    ;;if starts with period (match-string 1 is nil),
   9.674 -	    ;;this is global class
   9.675 -	    (setq element (downcase (or element "global")))
   9.676 -	    (if (setq a (assoc element alist))
   9.677 -		(or (assoc class (cdr a))
   9.678 -		    (setcdr a (cons (list class) (cdr a))))
   9.679 -	      (setq alist (cons (list element (list class)) alist))))
   9.680 -	  (goto-char (1- e))
   9.681 -	  (search-forward "}" nil t)
   9.682 -	  (setq b (point)))
   9.683 +	(while (re-search-forward "\\({\\)\\|\\(@import\\)" nil t)
   9.684 +	  (if (match-beginning 2)
   9.685 +	      (let ((f (YaTeX-buffer-substring
   9.686 +			(progn (skip-chars-forward "^\"")(1+ (point)))
   9.687 +			(progn (forward-char 1)
   9.688 +			       (skip-chars-forward "^\"")(point)))))
   9.689 +		(if (file-exists-p f)
   9.690 +		    (setq alist
   9.691 +			  (append alist (yahtml-css-collect-classes-file f)))))
   9.692 +	    (setq e (point))
   9.693 +	    (goto-char b)
   9.694 +	    (while (re-search-forward	;ちょといい加減なREGEXP
   9.695 +		    "\\([a-z][-a-z0-9]*\\)?\\.\\([-a-z0-9][-a-z0-9]*\\)\\>"
   9.696 +		    e t)
   9.697 +	      (setq element (YaTeX-match-string 1)
   9.698 +		    class (YaTeX-match-string 2))
   9.699 +	      ;;if starts with period (match-string 1 is nil),
   9.700 +	      ;;this is global class
   9.701 +	      (setq element (downcase (or element "global")))
   9.702 +	      (if (setq a (assoc element alist))
   9.703 +		  (or (assoc class (cdr a))
   9.704 +		      (setcdr a (cons (list class) (cdr a))))
   9.705 +		(setq alist (cons (list element (list class)) alist))))
   9.706 +	    (goto-char (1- e))
   9.707 +	    (search-forward "}" nil t)
   9.708 +	    (setq b (point))))
   9.709  	alist))))
   9.710  	    
   9.711  (defun yahtml-css-collect-classes-buffer (&optional initial)
   9.712 @@ -2676,10 +2847,10 @@
   9.713      ("<!--#\\(include\\|exec\\|config\\|fsize\\|flastmod\\)" "-->" include)
   9.714      ;; string
   9.715      (hilit-string-find ?\\ string)
   9.716 -    (yahtml-hilit-region-tag "<\\(em\\|strong\\|b\\)\\>" bold)
   9.717 +    (yahtml-hilit-region-tag "<\\(strong\\|b\\)\\>" bold)
   9.718      ("</?[uod]l>" 0 decl)
   9.719      ("<\\(di\\|dt\\|li\\|dd\\)>" 0 label)
   9.720 -    (yahtml-hilit-region-tag "<\\(i\\>\\)" italic)
   9.721 +    (yahtml-hilit-region-tag "<\\(em\\|i\\>\\)" italic)
   9.722      ;("<a\\s +href" "</a>" crossref) ;good for hilit19, but odd for font-lock..
   9.723      (yahtml-hilit-region-tag "<\\(a\\)\\s +href" crossref)
   9.724      (yahtml-hilit-region-tag-itself "</?\\sw+\\>" decl)
   9.725 @@ -2777,5 +2948,5 @@
   9.726  ; fill-prefix: ";;; "
   9.727  ; paragraph-start: "^$\\|\\|;;;$"
   9.728  ; paragraph-separate: "^$\\|\\|;;;$"
   9.729 -; buffer-file-coding-system: sjis
   9.730 +; coding: sjis
   9.731  ; End:
    10.1 --- a/yatex.new	Thu Dec 25 04:10:32 2003 +0000
    10.2 +++ b/yatex.new	Sun Dec 24 06:16:52 2006 +0000
    10.3 @@ -1,6 +1,49 @@
    10.4  	What's new in YaTeX/yahtml
    10.5  	野鳥/yahtml - 各バージョンの変更点について
    10.6  
    10.7 +1.73	=== yatex ===
    10.8 +	C-i (YaTeX-indent-line) のtabular/array環境対応。行頭位置の
    10.9 +	tabular的カラム位置に応じてインデントの深さを4桁ずつ深くする。
   10.10 +	深くする桁数を制御する変数 YaTeX-tabular-indentation 新設。
   10.11 +	\ref補完で出る一覧で数式は\label文字列も出すようにした。
   10.12 +	\ref補完で自動的に生成するラベル名を短くした。カスタマイズも可。
   10.13 +	生成するラベル名の書式を変える変数YaTeX-ref-default-label-string新設。
   10.14 +	ラベル名生成関数そのものは YaTeX-ref-generate-label-function で変更可。
   10.15 +	AMS-LaTeX独自のカウンタつき数式環境も全てref補完でlabel打ち可能
   10.16 +	な場所を検出できるようにした。
   10.17 +	AMS-LaTeX独自の数式環境でのお任せ改行サポート。
   10.18 +	tabularのお任せ改行で *{N}{REP} もカラム数を取れるようにした。
   10.19 +	verbatim環境/alltt環境宣言はTABインデントで行頭に来るようにした。
   10.20 +	インデントなしの環境宣言を決める変数 YaTeX-noindent-env-regexp 新設。
   10.21 +	[prefix] c, [prefix] g などがセクション型マクロの英字のみの引数
   10.22 +	で動かないのを修正。
   10.23 +	先回りusepackageでパッケージのオプションを確認できるようにした。
   10.24 +	[prefix] k でセクション型マクロの引数の数を考慮して消すようにした。
   10.25 +	[prefix] k ではマクロの最後の引数の中味のみを残すようにした。
   10.26 +	[prefix] S ではリジョンをセクション型マクロの最後の引数に括り入
   10.27 +	れるようにしてそれ以前の引数入力にアドイン関数を呼ぶようにした。
   10.28 +	数式モード内の _添字 ^上字 を変えるfaceを作成。とりあえず色だけ
   10.29 +	変えるようにした(Emacs21.4なら上下にスライドできるだろう)。
   10.30 +	変数 YaTeX-dvi2-command-ext-alist 新設。Previewerコマンドと、そ
   10.31 +	れでPreviewするファイルのデフォルト拡張子を指定できるようにした。
   10.32 +	tabular中のカラム内に\begin\endがある場合はfill-paragraph境界を
   10.33 +	そこまでに絞るようにした。
   10.34 +	\cite上での[prefix] g で\bibliography{}で指定したBibファイルの対
   10.35 +	応エントリに飛べるようにした。
   10.36 +
   10.37 +	=== yahtml ===
   10.38 +	cssの @import に対応(たぶん)。
   10.39 +	class補完でクラス名をSPCで区切った複数指定の補完入力を可能に。
   10.40 +	Emacs-21.3 以降のため insert-default-directory をnilに。
   10.41 +	single-cmd-tableから p を削除。
   10.42 +	変数 yahtml-html4-strict を新設。HTML4Strict準拠をできるだけ補助。
   10.43 +	script, noscript要素の補完を追加。script要素のアドインも追加。
   10.44 +	[prefix] m に <!--#include ...--> <!--#exec ...--> 補完を追加。
   10.45 +	[prefix] m でもアドイン補完を呼ぶようにしたので M-C-m の<li>挿入
   10.46 +	でクラス名補完が起きる。これを回避するために M-C-j にも intelligent
   10.47 +	newline を割り当ててクラス名補完を飛ばせるようにした。
   10.48 +	[prefix] g に universal arg を指定しても隣窓で開かないのを修正。
   10.49 +
   10.50  1.72	=== yatex ===
   10.51  	YaTeX-kanji-code が nil なら coding-system に感知しない
   10.52  	補完したマクロがLaTeX2eの特定のpackageに依存している場合
    11.1 --- a/yatex19.el	Thu Dec 25 04:10:32 2003 +0000
    11.2 +++ b/yatex19.el	Sun Dec 24 06:16:52 2006 +0000
    11.3 @@ -1,7 +1,7 @@
    11.4  ;;; -*- Emacs-Lisp -*-
    11.5  ;;; YaTeX facilities for Emacs 19
    11.6 -;;; (c)1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
    11.7 -;;; Last modified Fri Jun 27 12:07:46 2003 on firestorm
    11.8 +;;; (c)1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
    11.9 +;;; Last modified Mon Jun 26 11:31:34 2006 on firestorm
   11.10  ;;; $Id$
   11.11  
   11.12  ;(require 'yatex)
   11.13 @@ -13,21 +13,23 @@
   11.14  (defvar YaTeX-use-highlighting (or YaTeX-use-font-lock YaTeX-use-hilit19)
   11.15    "*Use highlighting buffer or not.")
   11.16  (defvar YaTeX-background-mode
   11.17 -  (cond
   11.18 -   ((boundp 'hilit-background-mode) hilit-background-mode)
   11.19 -   ((boundp 'frame-background-mode) frame-background-mode)
   11.20 -   ((fboundp 'get-frame-background-mode)
   11.21 -    (get-frame-background-mode (selected-frame)))
   11.22 -   ((face-background 'default)
   11.23 -    (if (> (+ 32768 32768 32768)
   11.24 -	   (apply '+
   11.25 -		  (funcall (if (fboundp 'color-rgb-components)
   11.26 -			       'color-rgb-components
   11.27 -			     'x-color-values)
   11.28 -			   (face-background 'default))))
   11.29 -	'dark
   11.30 -      'light))
   11.31 -   (t nil)))
   11.32 +  (or (if (fboundp 'get-frame-background-mode)
   11.33 +          (get-frame-background-mode (selected-frame)))
   11.34 +      (if (fboundp 'frame-parameters)
   11.35 +          (cdr (assq 'background-mode (frame-parameters))))
   11.36 +      (if (boundp 'frame-background-mode)
   11.37 +          frame-background-mode)
   11.38 +      (if (boundp 'hilit-background-mode)
   11.39 +          hilit-background-mode)
   11.40 +      (if (face-background 'default)
   11.41 +          (if (> (+ 32768 32768 32768)
   11.42 +                 (apply '+
   11.43 +                        (funcall (if (fboundp 'color-rgb-components)
   11.44 +                                     'color-rgb-components
   11.45 +                                   'x-color-values)
   11.46 +                                 (face-background 'default))))
   11.47 +              'dark
   11.48 +            'light))))
   11.49  
   11.50  (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX"))
   11.51  (defvar YaTeX-mode-menu-map-process (make-sparse-keymap "Process"))
   11.52 @@ -250,7 +252,7 @@
   11.53  ;; 引数を数えて正しい位置までピカピカさせるよ〜ん!
   11.54  
   11.55  (defun YaTeX-19-region-section-type (pattern)
   11.56 -  "Return list of starting and end point of section-type commands of PATTERN."
   11.57 +  "Return cons of starting and end point of section-type commands of PATTERN."
   11.58    (if (re-search-forward pattern nil t)
   11.59        (let ((m0 (match-beginning 0)) (e0 (match-end 0)) cmd (argc 1))
   11.60  	(setq cmd (substring (YaTeX-match-string 0) 1)
   11.61 @@ -277,7 +279,7 @@
   11.62  	    (goto-char e0))))))
   11.63  
   11.64  (defun YaTeX-19-region-large-type (pattern)
   11.65 -  "Return list of large-type contents.
   11.66 +  "Return cons of large-type contents.
   11.67  Assumes PATTERN begins with `{'."
   11.68    (if (re-search-forward pattern nil t)
   11.69        (let ((m0 (match-beginning 0)) (e0 (match-end 0))p)
   11.70 @@ -292,6 +294,60 @@
   11.71  	  ;;move to re-search end not to make font-lock confused
   11.72  	  (goto-char e0)))))
   11.73  
   11.74 +(defun YaTeX-19-region-env-type (envptn)
   11.75 +  "Return cons of environment contents specified by ENVPTN as regexp."
   11.76 +  (if (and (looking-at envptn) ;;re-search-forward envptn nil t)
   11.77 +	   (save-excursion
   11.78 +	     (not(search-backward YaTeX-comment-prefix
   11.79 +				  (point-beginning-of-line) t))))
   11.80 +      (let ((m0 (match-beginning 0)) (e0 (match-end 0))
   11.81 +	    (env (YaTeX-match-string 1))
   11.82 +	    (nextline (progn (forward-line 1) (point))))
   11.83 +	(goto-char m0)
   11.84 +	;(message "max=%d" (point-max))(sit-for 2)
   11.85 +	(condition-case err
   11.86 +	    (if (YaTeX-goto-corresponding-environment)
   11.87 +		(prog1
   11.88 +		    (cons nextline (match-beginning 0))
   11.89 +		  (goto-char e0)))
   11.90 +	  (error nil)))))
   11.91 +
   11.92 +(defun YaTeX-19-region-paren-math (ptn)
   11.93 +  "Return cons of \(...\) or \[...\] type math environment."
   11.94 +  (if (looking-at "\\\\\\([\[(]\\)")
   11.95 +      (let*((ptype (cdr (assoc (YaTeX-match-string 1)
   11.96 +			       '(("(" . ")") ("[" "]")))))
   11.97 +	    (b (match-beginning 0))
   11.98 +	    (e (match-end 0)))
   11.99 +	(condition-case err
  11.100 +	    (if (re-search-forward
  11.101 +		 (concat "[^\\]\\\\" (regexp-quote ptype))
  11.102 +		 nil t)
  11.103 +		(prog1 (cons b (match-beginning 0))
  11.104 +		  (goto-char e)))
  11.105 +	  (error nil)))))
  11.106 +
  11.107 +(defun YaTeX-19-region-math-sub (ptn)
  11.108 +  "Return cons of _{...}"
  11.109 +  (if (and (looking-at ptn) 
  11.110 +	   (eq YaTeX-font-lock-formula-face
  11.111 +	       (get-text-property (point) 'face)))
  11.112 +      (let ((e (match-end 0)) (p (point)))
  11.113 +	(goto-char e)
  11.114 +	(prog1
  11.115 +	    (condition-case ()
  11.116 +		(if (looking-at "{")
  11.117 +		    (cons (1+ (point))
  11.118 +			  (progn (forward-list 1) (1- (point))))
  11.119 +		  (cons e
  11.120 +			(cond
  11.121 +			 ((looking-at (concat YaTeX-ec-regexp
  11.122 +					      YaTeX-TeX-token-regexp))
  11.123 +			  (match-end 0))
  11.124 +			 ;; other case??
  11.125 +			 (t (1+ (point)))))))
  11.126 +	  (goto-char e)))))
  11.127 +
  11.128  ;; 些細なことだが % の前の文字もピカリとさせてしまうようで… >hilit19
  11.129  ;; ↓この関数は下の hilit-set-mode-patterns の "[^\\]\\(%\\).*$" に
  11.130  ;; 依存している
  11.131 @@ -300,12 +356,38 @@
  11.132    (if (re-search-forward pattern nil t)
  11.133        (cons (match-beginning 2) (match-end 0))))
  11.134  
  11.135 +;; 2006/6/23 match only if it's in specified envrironment.
  11.136 +(defun YaTeX-19-re-search-in-env (ptn_env)
  11.137 +  (catch 'done
  11.138 +    ;; For font-lock, this function should find it.
  11.139 +    (let (md r)
  11.140 +      (while (YaTeX-re-search-active-forward
  11.141 +	      (car ptn_env) YaTeX-comment-prefix nil t)
  11.142 +	(setq md (match-data)
  11.143 +	      r (string-match (cdr ptn_env)
  11.144 +			      (or (YaTeX-inner-environment 'quick) "")))
  11.145 +	(store-match-data md)
  11.146 +	(if r (setq r (cons (match-beginning 0) (match-end 0))))
  11.147 +	(if (or YaTeX-use-hilit19 r) (throw 'done r))
  11.148 +	(goto-char (match-end 0)))
  11.149 +      (throw 'done r))))
  11.150 +
  11.151  ;;(make-face 'tt)
  11.152  ;;(set-face-font 'tt "-schumacher-clean-medium-r-normal--*-*-*-*-*-*-*-*")
  11.153  ;;(hilit-translate 'tt "white")
  11.154  
  11.155 +;; font-lockの関数呼びパターンの場合は正規表現が行末までマッチすると
  11.156 +;; hilit候補対象外にされてしまうので1字手前で正規表現を止める
  11.157  (defvar YaTeX-hilit-patterns-alist
  11.158    '(
  11.159 +    ;; formulas
  11.160 +    (YaTeX-19-region-math-sub "[^\\]^" YaTeX-font-lock-math-sup-face overwrite)
  11.161 +    (YaTeX-19-region-math-sub "[^\\]_" YaTeX-font-lock-math-sub-face overwrite)
  11.162 +    (YaTeX-19-region-env-type
  11.163 +     "\\\\begin{\\(equation\\|eqnarray\\|displaymath\\|\\(x?x?\\|fl\\)align\\|multline\\|gather\\)" formula)
  11.164 +    ;(YaTeX-19-region-paren-math "\\\\" formula)
  11.165 +    ;;("[^\\]\\\\("  "\\\\)" formula)                   ; \( \)
  11.166 +    ;;("[^\\]\\\\\\[" "\\\\\\]" formula)                ; \[ \]
  11.167      ;; comments
  11.168      (YaTeX-19-region-comment "\\([^\\]\\|^\\)\\(%\\).*$" comment)
  11.169  
  11.170 @@ -341,22 +423,19 @@
  11.171      ;;this should be customized by YaTeX-item-regexp
  11.172      ("\\\\\\(sub\\)*item\\b\\(\\[[^]]*\\]\\)?" 0 label)
  11.173      (YaTeX-19-region-section-type
  11.174 -     "\\\\caption\\(\\[[^]]*\\]\\)?\\>" label)
  11.175 +     "\\\\\\(caption\\|bibitem\\)\\(\\[[^]]*\\]\\)?\\>" label)
  11.176  
  11.177      ;; things that do some sort of cross-reference
  11.178      (YaTeX-19-region-section-type
  11.179 -     "\\\\\\(\\(no\\)?cite\\|\\(page\\)?ref\\|label\\|index\\|glossary\\)\\>"
  11.180 +     "\\\\\\(\\(no\\|possessive\\)?cite[a-z]*\\|[a-z]*ref\\|label\\|index\\|glossary\\)\\>"
  11.181       crossref)
  11.182  
  11.183      ;; things that bring in external files
  11.184 -    ("\\\\\\(include\\|input\\|bibliography\\){" "}" include)
  11.185 +    ("\\\\\\(include\\|input\\|bibliography\\(style\\)?\\){" "}" include)
  11.186  
  11.187 -    ;; formulas
  11.188 -    ("[^\\]\\\\("  "\\\\)" formula)                   ; \( \)
  11.189 -    ("[^\\]\\\\\\[" "\\\\\\]" formula)                ; \[ \]
  11.190 -    ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)"
  11.191 -     "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}"
  11.192 -     formula)
  11.193 +   ;; ("\\\\begin{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\)"
  11.194 +   ;;  "\\\\end{\\(eqn\\|equation\\|x?x?align\\|split\\|multline\\|gather\\).*}"
  11.195 +   ;;  formula)
  11.196      ("\\([^\\$]\\|^\\)\\($\\($[^$]*\\$\\|[^$]*\\)\\$\\)" 2 formula); '$...$' or '$$...$$'
  11.197  
  11.198      ;; "wysiwyg" emphasis -- these don't work on nested expressions
  11.199 @@ -365,7 +444,13 @@
  11.200      ;;;(YaTeX-19-region-large-type "{\\\\tt" tt)
  11.201      ;;;("\\\\begin{verbatim" "\\\\end{verbatim" tt)
  11.202  
  11.203 -    ("``" "''" string))
  11.204 +    ("``" "''" string)
  11.205 +    ("\\\\\\(new\\|clear\\(double\\)?\\)page\\>\\|\\\\\\(\\\\\\|cr\\)\\>"
  11.206 +     0 delimiter)
  11.207 +    (YaTeX-19-re-search-in-env
  11.208 +     ("&\\|\\\\hline" . "tabular\\|equation\\|eqn\\|array\\|align") delimiter)
  11.209 +    (YaTeX-19-re-search-in-env ("\\\\[+-=><'`]" . "tabbing") delimiter)
  11.210 +    )
  11.211    "*Hiliting pattern alist for LaTeX text.")
  11.212  
  11.213  ;;(defvar YaTeX-hilit-pattern-adjustment-default nil)
  11.214 @@ -419,7 +504,15 @@
  11.215      sym)
  11.216     ((and YaTeX-use-hilit19 (and (fboundp 'hilit-translate)))
  11.217      (let ((face (intern (concat fgcolor "/" bgcolor))))
  11.218 -      (hilit-translate sym face)
  11.219 +      (if (facep sym)
  11.220 +	  (hilit-translate sym face)
  11.221 +	(make-face sym)
  11.222 +	(or (memq sym hilit-predefined-face-list)
  11.223 +	    (progn
  11.224 +	      (set-face-foreground sym fgcolor)
  11.225 +	      (set-face-background sym bgcolor)
  11.226 +	      (setq hilit-predefined-face-list
  11.227 +		    (cons sym hilit-predefined-face-list)))))
  11.228        face))))
  11.229  
  11.230  (cond
  11.231 @@ -533,6 +626,10 @@
  11.232  			      sect
  11.233  			      'keyword))
  11.234  		    (if single (list single 0 'macro))))))))))
  11.235 +
  11.236 +;;2006/6/23 new face, `delimiter' introduced
  11.237 +(YaTeX-19-create-face 'delimiter "saddlebrown" "ivory")
  11.238 +
  11.239  ;;(YaTeX-19-collect-macros)	;causes an error
  11.240  (defun YaTeX-hilit-setup-alist ()
  11.241    (cond
  11.242 @@ -575,13 +672,48 @@
  11.243    (setq YaTeX-font-lock-keywords
  11.244  	(YaTeX-convert-pattern-hilit2fontlock
  11.245  	 (cdr (YaTeX-19-collect-macros)))
  11.246 -	font-lock-keywords nil)
  11.247 -  ;(save-excursion
  11.248 -   ; (font-lock-fontify-region (window-start) (window-end)))
  11.249 +;;; Keep this section for debugging.
  11.250 +;;    YaTeX-font-lock-keywords
  11.251 +;;    (append (YaTeX-convert-pattern-hilit2fontlock
  11.252 +;; 	    (cdr (YaTeX-19-collect-macros)))
  11.253 +;; 	   '(((lambda (lim)
  11.254 +;; 		(YaTeX-19-re-search-in-env '("foo" . "tabular"))
  11.255 +;; 		;(search-forward "foo" nil t)
  11.256 +;; 	       )
  11.257 +;; 	      (0 YaTeX-font-lock-delimiter-face))))
  11.258 +	;;font-lock-keywords nil
  11.259 +	font-lock-set-defaults nil)
  11.260 +  ;;(save-excursion
  11.261 +  ;; (font-lock-fontify-region (window-start) (window-end))
  11.262    (font-lock-mode -1)			;is stupid, but sure.
  11.263    (font-lock-mode 1)
  11.264    (recenter arg))
  11.265  
  11.266 +(defun YaTeX-font-lock-fontify-region (beg end)
  11.267 +  (interactive "r")
  11.268 +  (save-excursion (font-lock-fontify-region beg end)))
  11.269 +
  11.270 +(defun YaTeX-font-lock-fontify-environment ()
  11.271 +  (interactive)
  11.272 +  (save-excursion
  11.273 +    (save-match-data			;is safe after emacs-19
  11.274 +      (YaTeX-mark-environment)
  11.275 +      (message "")
  11.276 +      (YaTeX-font-lock-fontify-region (region-beginning) (region-end)))))
  11.277 +
  11.278 +(defun YaTeX-font-lock-highlight-menu ()
  11.279 +  (interactive)
  11.280 +  (message "Force Highlight: R)egion E)nvironment")
  11.281 +  (let ((c (read-char)))
  11.282 +    (cond
  11.283 +     ((memq c '(?R ?r))
  11.284 +      (YaTeX-font-lock-fontify-region (region-beginning) (region-end)))
  11.285 +     ((memq c '(?e ?e))
  11.286 +      (YaTeX-font-lock-fontify-environment)))))
  11.287 +
  11.288 +(if YaTeX-use-font-lock
  11.289 +    (YaTeX-define-key "u" 'YaTeX-font-lock-highlight-menu))
  11.290 +
  11.291  (defvar YaTeX-font-lock-keywords nil
  11.292    "Pattern-face alist of yahtml-mode for font-lock")
  11.293  
  11.294 @@ -678,5 +810,5 @@
  11.295  ; fill-prefix: ";;; "
  11.296  ; paragraph-start: "^$\\|\\|;;;$"
  11.297  ; paragraph-separate: "^$\\|\\|;;;$"
  11.298 -; buffer-file-coding-system: sjis
  11.299 +; coding: sjis
  11.300  ; End:
    12.1 --- a/yatexadd.el	Thu Dec 25 04:10:32 2003 +0000
    12.2 +++ b/yatexadd.el	Sun Dec 24 06:16:52 2006 +0000
    12.3 @@ -1,8 +1,8 @@
    12.4  ;;; -*- Emacs-Lisp -*-
    12.5  ;;; YaTeX add-in functions.
    12.6 -;;; yatexadd.el rev.17
    12.7 -;;; (c)1991-2003 by HIROSE Yuuji.[yuuji@yatex.org]
    12.8 -;;; Last modified Thu Nov 27 11:11:30 2003 on firestorm
    12.9 +;;; yatexadd.el rev.18
   12.10 +;;; (c)1991-2006 by HIROSE Yuuji.[yuuji@yatex.org]
   12.11 +;;; Last modified Sun Dec 24 15:12:30 2006 on firestorm
   12.12  ;;; $Id$
   12.13  
   12.14  ;;;
   12.15 @@ -56,9 +56,18 @@
   12.16      (format "%s%s{%s}" width loc rule)))
   12.17  
   12.18  (fset 'YaTeX:tabular* 'YaTeX:tabular)
   12.19 +(fset 'YaTeX:supertabular 'YaTeX:tabular)
   12.20 +(defun YaTeX:alignat ()
   12.21 +  (concat "{" (read-string "Number of columns: ") "}"))
   12.22  (defun YaTeX:array ()
   12.23    (concat (YaTeX:read-position "tb")
   12.24  	  "{" (read-string "Column format: ") "}"))
   12.25 +(defun YaTeX:subequations ()
   12.26 +  (message (if YaTeX-japan "分かりやすいコメントに変えるとref補完が楽よ"
   12.27 +	     "Changing comment string reduces effort at `ref' completion"))
   12.28 +  (concat " " YaTeX-comment-prefix
   12.29 +	  (YaTeX::ref-default-label "%H:%M")
   12.30 +	  (if YaTeX-japan "の式群" "equations")))
   12.31  
   12.32  (defun YaTeX:read-oneof (oneof &optional quick allow-dup)
   12.33    (let ((pos "") loc (guide ""))
   12.34 @@ -137,6 +146,12 @@
   12.35  	  YaTeX:alignat YaTeX:alignat* YaTeX:xalignat YaTeX:xalignat*
   12.36  	  YaTeX:xxalignat YaTeX:xxalignat*))
   12.37  
   12.38 +(defun YaTeX:alignat ()
   12.39 +  (YaTeX:equation)
   12.40 +  (concat "{" (read-string "Number of cols: ") "}"))
   12.41 +
   12.42 +
   12.43 +
   12.44  (defun YaTeX:list ()
   12.45    "%\n{} %default label\n{} %formatting parameter")
   12.46  
   12.47 @@ -148,6 +163,9 @@
   12.48    (setq YaTeX-section-name "bibitem")
   12.49    (concat "{" (read-string "Longest label: ") "}"))
   12.50  
   12.51 +(defun YaTeX:multicols ()
   12.52 +  (concat "{" (read-string "Number of columns: ") "}"))
   12.53 +
   12.54  ;;;
   12.55  ;;Sample functions for section-type command.
   12.56  ;;;
   12.57 @@ -163,23 +181,33 @@
   12.58    (cond
   12.59     ((YaTeX-in-environment-p "picture")
   12.60      (concat (YaTeX:read-coordinates "Dimension")
   12.61 -	    (YaTeX:read-position "lrtb")))
   12.62 +	    (YaTeX:read-position "lsrtb")))
   12.63     (t
   12.64      (let ((width (read-string "Width: ")))
   12.65        (if (string< "" width)
   12.66  	  (progn
   12.67  	    (or (equal (aref width 0) ?\[)
   12.68  		(setq width (concat "[" width "]")))
   12.69 -	    (concat width (YaTeX:read-position "lr"))))))))
   12.70 +	    (concat width (YaTeX:read-position
   12.71 +			   (if YaTeX-use-LaTeX2e "lrs" "lr")))))))))
   12.72  
   12.73 -(defun YaTeX:framebox ()
   12.74 -  (if (YaTeX-quick-in-environment-p "picture")
   12.75 -      (YaTeX:makebox)))
   12.76 +;; (defun YaTeX:framebox ()
   12.77 +;;   (if (YaTeX-quick-in-environment-p "picture")
   12.78 +;;       (YaTeX:makebox)))
   12.79 +(fset 'YaTeX:framebox 'YaTeX:makebox)
   12.80 +
   12.81 +(defun YaTeX:parbox ()
   12.82 +  (YaTeX:read-position "tbc"))
   12.83  
   12.84  (defun YaTeX:dashbox ()
   12.85    (concat "{" (read-string "Dash dimension: ") "}"
   12.86  	  (YaTeX:read-coordinates "Dimension")))
   12.87  
   12.88 +(defun YaTeX:savebox (argp)
   12.89 +  (cond
   12.90 +   ((= argp 1) (read-string "Saved into name: " "\\"))
   12.91 +   ((= argp 2) (read-string "Text: "))))
   12.92 +
   12.93  (defvar YaTeX-minibuffer-quick-map nil)
   12.94  (if YaTeX-minibuffer-quick-map nil
   12.95    (setq YaTeX-minibuffer-quick-map
   12.96 @@ -220,6 +248,10 @@
   12.97  
   12.98  (fset 'YaTeX:right 'YaTeX:left)
   12.99  
  12.100 +(defun YaTeX:langle ()
  12.101 +  (setq YaTeX-single-command "rangle")
  12.102 +  nil)
  12.103 +
  12.104  (defun YaTeX:read-coordinates (&optional mes varX varY)
  12.105    (concat
  12.106     "("
  12.107 @@ -471,29 +503,90 @@
  12.108  ; 	    (bury-buffer YaTeX-label-buffer)))
  12.109  ; 	label)))))
  12.110  
  12.111 -(defun YaTeX::ref-generate-label ()
  12.112 +(defvar YaTeX-ref-default-label-string "%H%M%S_%d%b%y"
  12.113 +  "*Default \\ref time string format.
  12.114 +This format is like strftime(3) but allowed conversion char are as follows;
  12.115 +%y -> Last 2 digit of year,  %b -> Month name,  %m -> Monthe number(1-12),
  12.116 +%d -> Day,  %H -> Hour,  %M -> Minute,  %S -> Second,
  12.117 +%qx -> alphabetical-decimal conversion of yymmdd.
  12.118 +%qX -> alphabetical-decimal conversion of HHMMSS.
  12.119 +Beware defualt label-string should be always unique.  So this format string
  12.120 +should have both time part (%H+%M+%S or %qX) and date
  12.121 +part (%y+(%b|%m)+%d or %qx).")
  12.122 +
  12.123 +(defun YaTeX::ref-alphabex (n)
  12.124 +  (let ((alphabex ""))
  12.125 +    (while (> n 0)
  12.126 +      (setq alphabex (concat (char-to-string (+ ?a (% n 26))) alphabex)
  12.127 +	    n (/ n 26)))
  12.128 +    alphabex))
  12.129 +
  12.130 +(defun YaTeX::ref-default-label (&optional format)
  12.131 +  "Default auto-genarated label string."
  12.132 +  ;; We do not use (format-time-string) for emacs-19
  12.133 +  (let*((ts (substring (current-time-string) 4))
  12.134 +	(y (substring ts -2))
  12.135 +	(b (substring ts 0 3))
  12.136 +	(d (format "%d" (string-to-int (substring ts 4 6))))
  12.137 +	(H (substring ts 7 9))
  12.138 +	(M (substring ts 10 12))
  12.139 +	(S (substring ts 13 15))
  12.140 +	(HMS (+ (* 10000 (string-to-int H))
  12.141 +		(* 100 (string-to-int M))
  12.142 +		(string-to-int S)))
  12.143 +	(talphabex (YaTeX::ref-alphabex HMS))
  12.144 +	(mnames "JanFebMarAprMayJunJulAugSepOctNovDec")
  12.145 +	(m (format "%02d" (/ (string-match b mnames) 3)))
  12.146 +	(ymd (+ (* 10000 (string-to-int y))
  12.147 +		(* 100 (string-to-int m))
  12.148 +		(string-to-int d)))
  12.149 +	(dalphabex (YaTeX::ref-alphabex ymd)))
  12.150 +    (YaTeX-replace-formats
  12.151 +     (or format YaTeX-ref-default-label-string)
  12.152 +     (list (cons "y" y)
  12.153 +	   (cons "b" b)
  12.154 +	   (cons "m" m)
  12.155 +	   (cons "d" d)
  12.156 +	   (cons "H" H)
  12.157 +	   (cons "M" M)
  12.158 +	   (cons "S" S)
  12.159 +	   (cons "qX" talphabex)
  12.160 +	   (cons "qx" dalphabex)))))
  12.161 +
  12.162 +(defvar YaTeX-ref-generate-label-function 'YaTeX::ref-generate-label
  12.163 +  "*Function to generate default label for unnamed \\label{}s.
  12.164 +The function pointed to this value should take two arguments.
  12.165 +First argument is LaTeX macro's name, second is macro's argument.")
  12.166 +
  12.167 +(defun YaTeX::ref-generate-label (command arg)
  12.168    "Generate a label string which is unique in current buffer."
  12.169 -  (let ((default (substring (current-time-string) 4)))
  12.170 +  (let ((default (condition-case nil
  12.171 +		     (YaTeX::ref-default-label)
  12.172 +		   (error (substring (current-time-string) 4)))))
  12.173      (read-string "Give a label for this line: "
  12.174  		 (if YaTeX-emacs-19 (cons default 1) default))))
  12.175  
  12.176 -(defun YaTeX::ref-getset-label (buffer point)
  12.177 +(defun YaTeX::ref-getset-label (buffer point &optional noset)
  12.178    "Get label string in the BUFFER near the POINT.
  12.179 -Make \\label{xx} if no label."
  12.180 +Make \\label{xx} if no label.
  12.181 +If optional third argument NOSET is non-nil, do not generate new label."
  12.182    ;;Here, we rewrite the LaTeX source.  Therefore we should be careful
  12.183    ;;to decide the location suitable for \label.  Do straightforward!
  12.184 -  (let (boundary inspoint cc newlabel (labelholder "label") mathp env
  12.185 -       (r-escape (regexp-quote YaTeX-comment-prefix)))
  12.186 -    ;;(set-buffer buffer)
  12.187 -    (switch-to-buffer buffer)
  12.188 +  (let (boundary inspoint cc newlabel (labelholder "label") mathp exp1 env
  12.189 +       (r-escape (regexp-quote YaTeX-comment-prefix))
  12.190 +       command arg alreadysought foundpoint)
  12.191 +    (set-buffer buffer)
  12.192      (save-excursion
  12.193        (goto-char point)
  12.194        (setq cc (current-column))
  12.195        (if (= (char-after (point)) ?\\) (forward-char 1))
  12.196        (cond
  12.197         ((looking-at YaTeX-sectioning-regexp)
  12.198 +	(setq command (YaTeX-match-string 0))
  12.199  	(skip-chars-forward "^{")
  12.200 -	(forward-list 1)
  12.201 +	(setq arg (buffer-substring
  12.202 +		   (1+ (point))
  12.203 +		   (progn (forward-list 1) (1- (point)))))
  12.204  	(skip-chars-forward " \t\n")
  12.205  	;(setq boundary "[^\\]")
  12.206  	(setq inspoint (point))
  12.207 @@ -507,7 +600,8 @@
  12.208  		    (match-beginning 0)
  12.209  		  (1- (point))))))
  12.210         ((looking-at "item\\s ")
  12.211 -	(setq cc (+ cc 6))
  12.212 +	(setq command "item"
  12.213 +	      cc (+ cc 6))
  12.214  	;(setq boundary (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b"))
  12.215  	(setq boundary
  12.216  	      (save-excursion
  12.217 @@ -518,7 +612,8 @@
  12.218  		  (1- (point))))
  12.219  	      inspoint boundary))
  12.220         ((looking-at "bibitem")
  12.221 -	(setq labelholder "bibitem")	; label holder is bibitem itself
  12.222 +	(setq labelholder "bibitem"	; label holder is bibitem itself
  12.223 +	      command "bibitem")
  12.224  	(setq boundary
  12.225  	      (save-excursion
  12.226  		(if (YaTeX-re-search-active-forward
  12.227 @@ -527,19 +622,50 @@
  12.228  		    (match-beginning 0)
  12.229  		  (1- (point))))
  12.230  	      inspoint boundary))
  12.231 -       ((string-match YaTeX::ref-mathenv-regexp
  12.232 +       ((string-match YaTeX::ref-nestable-counter-regexp
  12.233  		      (setq env (or (YaTeX-inner-environment t) "document")))
  12.234 -	(setq mathp t)
  12.235 +	(let ((curtop (get 'YaTeX-inner-environment 'point))
  12.236 +	      (end (point-max)) label)
  12.237 +	  (skip-chars-forward " \t\n")
  12.238 +	  (setq inspoint (point)	;initial candidate
  12.239 +		cc (current-column)
  12.240 +		command env
  12.241 +		alreadysought t)
  12.242 +	  (if (condition-case nil
  12.243 +		  (progn
  12.244 +		    (goto-char curtop)
  12.245 +		    (YaTeX-goto-corresponding-environment))
  12.246 +		(error nil))
  12.247 +	      (setq end (point)))
  12.248 +	  (goto-char inspoint)
  12.249 +	  (while (YaTeX-re-search-active-forward
  12.250 +		  (concat YaTeX-ec-regexp "label{\\([^}]+\\)}" )
  12.251 +		  r-escape end t)
  12.252 +	    (setq label (YaTeX-match-string 1))
  12.253 +	    (if (and (equal env (YaTeX-inner-environment t))
  12.254 +		     (= curtop (get 'YaTeX-inner-environment 'point)))
  12.255 +		;;I found the label
  12.256 +		(setq alreadysought label
  12.257 +		      foundpoint (match-end 0))))
  12.258 +	  ))
  12.259 +       ((string-match YaTeX::ref-mathenv-regexp env) ;env is set in above case
  12.260 +	(setq command env
  12.261 +	      mathp t
  12.262 +	      exp1 (string-match YaTeX::ref-mathenv-exp1-regexp env))
  12.263  	;;(setq boundary (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)"))
  12.264  	(setq boundary
  12.265  	      (save-excursion
  12.266  		(if (YaTeX-re-search-active-forward
  12.267 -		     (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")
  12.268 +		     (concat
  12.269 +		      YaTeX-ec-regexp "\\("
  12.270 +		      (if exp1 "" "\\\\\\|")
  12.271 +		      "end{" env "}\\)")
  12.272  		     r-escape nil 1)
  12.273  		    (match-beginning 0)
  12.274  		  (1- (point))))
  12.275  	      inspoint boundary))
  12.276         ((looking-at "footnote\\s *{")
  12.277 +	(setq command "footnote")
  12.278  	(skip-chars-forward "^{")	;move onto `{'
  12.279  	(setq boundary
  12.280  	      (save-excursion
  12.281 @@ -550,10 +676,13 @@
  12.282  		(1- (point)))
  12.283  	      inspoint boundary))
  12.284         ((looking-at "caption\\|\\(begin\\)")
  12.285 +	(setq command (YaTeX-match-string 0))
  12.286  	(skip-chars-forward "^{")
  12.287  	;;;;;;(if (match-beginning 1) (forward-list 1))
  12.288  	;; caption can be treated as mathenv, is it right??
  12.289 -	(forward-list 1)
  12.290 +	(setq arg (buffer-substring
  12.291 +		   (1+ (point))
  12.292 +		   (progn (forward-list 1) (1- (point)))))
  12.293  	;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b"))
  12.294  	(setq inspoint (point))
  12.295  	(setq boundary
  12.296 @@ -566,55 +695,81 @@
  12.297         (t ))
  12.298        (if (save-excursion (skip-chars-forward " \t") (looking-at "%"))
  12.299  	  (forward-line 1))
  12.300 -      (if (and (save-excursion
  12.301 -		 (YaTeX-re-search-active-forward
  12.302 -		  ;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)")
  12.303 -		  labelholder
  12.304 -		  (regexp-quote YaTeX-comment-prefix)
  12.305 -		  boundary 1))
  12.306 -	       (match-beginning 0))
  12.307 +      (cond
  12.308 +       ((stringp alreadysought)
  12.309 +	(put 'YaTeX::ref-getset-label 'foundpoint foundpoint) ;ugly...
  12.310 +	alreadysought)
  12.311 +       ((and (null alreadysought)
  12.312 +	     (> boundary (point))
  12.313 +	     (save-excursion
  12.314 +	       (YaTeX-re-search-active-forward
  12.315 +		;;(concat "\\(" labelholder "\\)\\|\\(" boundary "\\)")
  12.316 +		labelholder
  12.317 +		(regexp-quote YaTeX-comment-prefix)
  12.318 +		boundary 1))
  12.319 +	     (match-beginning 0))
  12.320  	  ;; if \label{hoge} found, return it
  12.321 -	  (buffer-substring
  12.322 -	   (progn
  12.323 -	     (goto-char (match-end 0))
  12.324 -	     (skip-chars-forward "^{") (1+ (point)))
  12.325 -	   (progn
  12.326 -	     (forward-sexp 1) (1- (point))))
  12.327 +	(put 'YaTeX::ref-getset-label 'foundpoint (1- (match-beginning 0)))
  12.328 +	(buffer-substring
  12.329 +	 (progn
  12.330 +	   (goto-char (match-end 0))
  12.331 +	   (skip-chars-forward "^{") (1+ (point)))
  12.332 +	 (progn
  12.333 +	   (forward-sexp 1) (1- (point)))))
  12.334  	;;else make a label
  12.335  	;(goto-char (match-beginning 0))
  12.336 +       (noset    nil)				;do not set label if noset
  12.337 +       (t
  12.338  	(goto-char inspoint)
  12.339  	(skip-chars-backward " \t\n")
  12.340 -	(save-excursion (setq newlabel (YaTeX::ref-generate-label)))
  12.341 +	(save-excursion
  12.342 +	  (setq newlabel
  12.343 +		(funcall YaTeX-ref-generate-label-function command arg)))
  12.344  	(delete-region (point) (progn (skip-chars-backward " \t") (point)))
  12.345  	(if mathp nil 
  12.346  	  (insert "\n")
  12.347  	  (YaTeX-reindent cc))
  12.348  	(insert (format "\\label{%s}" newlabel))
  12.349 -	newlabel))))
  12.350 +	newlabel)))))
  12.351  
  12.352 +(defvar YaTeX::ref-labeling-regexp-alist-default
  12.353 +  '(("\\\\begin{\\(java\\|program\\)}{\\([^}]+\\)}" . 2)
  12.354 +    ("\\\\label{\\([^}]+\\)}" . 1))
  12.355 +  "Alist of labeling regexp vs. its group number points to label string.
  12.356 +This alist is used in \\ref's argument's completion.")
  12.357 +(defvar YaTeX::ref-labeling-regexp-alist-private nil
  12.358 +  "*Private extesion to YaTeX::ref-labeling-regexp-alist.
  12.359 +See the documetation of YaTeX::ref-labeling-regexp-alist.")
  12.360  (defvar YaTeX::ref-labeling-regexp-alist
  12.361 -  '(("\\\\begin{java}{\\([^}]+\\)}" . 1)
  12.362 -    ("\\\\label{\\([^}]+\\)}" . 1)))
  12.363 +  (append YaTeX::ref-labeling-regexp-alist-default
  12.364 +	  YaTeX::ref-labeling-regexp-alist-private))
  12.365  (defvar YaTeX::ref-labeling-regexp
  12.366    (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|"))
  12.367  (defvar YaTeX::ref-mathenv-regexp
  12.368 -  "equation\\|eqnarray\\|align\\|gather\\|alignat\\|xalignat")
  12.369 +  ;; See also YaTeX-ams-math-begin-alist in yatex.el
  12.370 +  ;; Define only envs which has counter.(without *)
  12.371 +  "equation\\|eqnarray\\|align\\(at\\)?\\|flalign\\|gather\\|xx?alignat\\|multline")
  12.372 +(defvar YaTeX::ref-mathenv-exp1-regexp
  12.373 +  "\\(equation\\|multline\\)\\b"
  12.374 +  "*Regexp of math-envname which has only one math-expression.")
  12.375  (defvar YaTeX::ref-enumerateenv-regexp
  12.376    "enumerate")
  12.377 +(defvar YaTeX::ref-nestable-counter-regexp
  12.378 +  "subequations")
  12.379  
  12.380  (defvar YaTeX::ref-labeling-section-level 2
  12.381    "*ref補完で収集するセクショニングコマンドの下限レベル
  12.382  YaTeX-sectioning-levelの数値で指定.")
  12.383  
  12.384 -(defun YaTeX::ref (argp &optional labelcmd refcmd)
  12.385 +(defun YaTeX::ref (argp &optional labelcmd refcmd predf)
  12.386    (setplist 'YaTeX::ref-labeling-regexp nil) ;erase memory cache
  12.387    (require 'yatexsec)
  12.388    (cond
  12.389     ((= argp 1)
  12.390 -    (let*((lnum 0) e0 x cmd label match-point point-list boundary
  12.391 +    (let*((lnum 0) m0 e0 x cmd label match-point point-list boundary
  12.392  	  (buf (current-buffer))
  12.393  	  (llv YaTeX::ref-labeling-section-level)
  12.394 -	  (mathenvs YaTeX::ref-mathenv-regexp)
  12.395 +	  (mathenvs YaTeX::ref-mathenv-regexp) envname endrx
  12.396  	  (enums YaTeX::ref-enumerateenv-regexp)
  12.397  	  (counter
  12.398  	   (or labelcmd
  12.399 @@ -631,7 +786,12 @@
  12.400  			YaTeX-sectioning-level))
  12.401  		 "\\|")
  12.402  		"\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){"
  12.403 -		"\\|\\(begin{\\(" mathenvs "\\|" enums  "\\)\\)\\)")))
  12.404 +		"\\|\\(begin{\\(" mathenvs "\\|" enums  "\\)}\\)"
  12.405 +		(if YaTeX-use-AMS-LaTeX
  12.406 +		    (concat
  12.407 +		     "\\|\\(begin{"
  12.408 +		     YaTeX::ref-nestable-counter-regexp "}\\)"))
  12.409 +		"\\)")))
  12.410  	  (regexp (concat "\\(" counter
  12.411  			  "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)"))
  12.412  	  (itemsep (concat YaTeX-ec-regexp
  12.413 @@ -642,9 +802,9 @@
  12.414  	  (output
  12.415  	   (function
  12.416  	    (lambda (label p)
  12.417 -	      (while (setq x (string-match "\n" label))
  12.418 +	      (while (setq x (string-match "[\n\t]" label))
  12.419  		(aset label x ? ))
  12.420 -	      (while (setq x (string-match "[ \t\n][ \t\n]+" label))
  12.421 +	      (while (setq x (string-match "  +" label))
  12.422  		(setq label (concat
  12.423  			     (substring label 0 (1+ (match-beginning 0)))
  12.424  			     (substring label (match-end 0)))))
  12.425 @@ -652,6 +812,7 @@
  12.426  	      (setq point-list (cons p point-list))
  12.427  	      (message "Collecting labels... %d" lnum)
  12.428  	      (setq lnum (1+ lnum)))))
  12.429 +	  (me (if (boundp 'me) me 'YaTeX::ref))
  12.430  	  )
  12.431        (message "Collecting labels...")
  12.432        (save-window-excursion
  12.433 @@ -665,12 +826,16 @@
  12.434  	      (set-buffer buf)))
  12.435  	(save-excursion
  12.436  	  (set-buffer (get-buffer-create YaTeX-label-buffer))
  12.437 +	  (condition-case ()
  12.438 +	      (if (and YaTeX-use-font-lock (fboundp 'font-lock-mode))
  12.439 +		  (font-lock-mode 1))
  12.440 +	    (error nil))
  12.441  	  (setq buffer-read-only nil)
  12.442  	  (erase-buffer))
  12.443  	(save-excursion
  12.444  	  (set-buffer buf)
  12.445  	  (goto-char (point-min))
  12.446 -	  (let ((standard-output (get-buffer YaTeX-label-buffer)))
  12.447 +	  (let ((standard-output (get-buffer YaTeX-label-buffer)) existlabel)
  12.448  	    (princ (format "=== LABELS in [%s] ===\n" (buffer-name buf)))
  12.449  	    (while (YaTeX-re-search-active-forward
  12.450  		    regexp ;;counter
  12.451 @@ -678,28 +843,118 @@
  12.452  	      ;(goto-char (match-beginning 0))
  12.453  	      (setq e0 (match-end 0))
  12.454  	      (cond
  12.455 +	       ;; 
  12.456 +	       ;;2005/10/21 Skip it if predicate function returns nil
  12.457 +	       ((and predf
  12.458 +		     (let ((md (match-data)))
  12.459 +		       (prog1
  12.460 +			   (condition-case nil
  12.461 +			       (not (funcall predf))
  12.462 +			     (error nil))
  12.463 +			 (store-match-data md)))))
  12.464  	       ((YaTeX-literal-p) nil)
  12.465  	       ((YaTeX-match-string 1)
  12.466  		;;if standard counter commands found 
  12.467 -		(setq cmd (YaTeX-match-string 2))
  12.468 +		(setq cmd (YaTeX-match-string 2)
  12.469 +		      m0 (match-beginning 0))
  12.470  		(setq match-point (match-beginning 0))
  12.471  		(or initl
  12.472  		    (if (< p (point)) (setq initl lnum)))
  12.473  		(cond
  12.474 +		 ;; In any case, variables e0 should be set
  12.475 +		 ((and YaTeX-use-AMS-LaTeX
  12.476 +		       (string-match YaTeX::ref-nestable-counter-regexp cmd))
  12.477 +		  (let (label)
  12.478 +		    (skip-chars-forward "}")
  12.479 +		    (setq label (buffer-substring
  12.480 +				 (point) (min (+ 80 (point)) (point-max))))
  12.481 +		    ;; to skip (maybe)auto-generated comment
  12.482 +		    (skip-chars-forward " \t")
  12.483 +		    (if (looking-at YaTeX-comment-prefix)
  12.484 +			(forward-line 1))
  12.485 +		    (setq e0 (point))
  12.486 +		    (skip-chars-forward " \t\n")
  12.487 +		    (if (looking-at "\\\\label{\\([^}]+\\)}")
  12.488 +			(setq label (format "(labe:%s)" (YaTeX-match-string 1))
  12.489 +			      e0 (match-end 1)))
  12.490 +		    (funcall output (format "--subequation--%s" label) e0)))
  12.491  		 ((string-match mathenvs cmd) ;;if matches mathematical env
  12.492  		  ;(skip-chars-forward "} \t\n")
  12.493 -		  (forward-line 1)
  12.494 -		  (setq x (point))
  12.495 -		  (catch 'scan
  12.496 -		    (while (YaTeX-re-search-active-forward
  12.497 -			    (concat "\\\\\\\\$\\|\\\\end{\\(" mathenvs "\\)")
  12.498 -			    percent nil t)
  12.499 -		      (let ((quit (match-beginning 1)))
  12.500 -			(funcall output
  12.501 -				 (buffer-substring x (match-beginning 0))
  12.502 -				 x)
  12.503 -			(if quit (throw 'scan t)))
  12.504 -		      (setq x (point))))
  12.505 +		  ;(forward-line 1) ;2004/1/25
  12.506 +		  (skip-chars-forward "}")
  12.507 +		  (setq x (point)
  12.508 +			envname (substring
  12.509 +				 cmd (match-beginning 0) (match-end 0)))
  12.510 +		  (save-restriction
  12.511 +		    (narrow-to-region
  12.512 +		     m0
  12.513 +		     (save-excursion
  12.514 +		       (YaTeX-re-search-active-forward
  12.515 +			(setq endrx (format "%send{%s}" YaTeX-ec-regexp
  12.516 +					    (regexp-quote envname)))
  12.517 +			percent nil t)))
  12.518 +		    (catch 'scan
  12.519 +		      (while (YaTeX-re-search-active-forward
  12.520 +			      (concat
  12.521 +			       "\\\\end{\\(" (regexp-quote envname) "\\)";;(1)
  12.522 +			       (if YaTeX-use-AMS-LaTeX
  12.523 +				   "\\|\\\\\\(notag\\)") ;;2
  12.524 +			       (if (string-match
  12.525 +				    YaTeX::ref-mathenv-exp1-regexp  cmd)
  12.526 +				   "" "\\|\\\\\\\\$")
  12.527 +			       )
  12.528 +			      percent nil t)
  12.529 +			(let*((quit (match-beginning 1))
  12.530 +			      (notag (match-beginning 2))
  12.531 +			      (label ".......................") l2
  12.532 +			      (e (point)) (m0 (match-beginning 0))
  12.533 +			      (ln (YaTeX-string-width label)))
  12.534 +			  (cond
  12.535 +			   (notag
  12.536 +			    (YaTeX-re-search-active-forward
  12.537 +			     "\\\\\\\\" percent nil 1)
  12.538 +			    (setq x (point)))
  12.539 +			   (t
  12.540 +			    (if (YaTeX-re-search-active-backward
  12.541 +				 YaTeX::ref-labeling-regexp
  12.542 +				 percent x t)
  12.543 +				;; if \label{x} in math-expression, display it
  12.544 +				;; because formula source is hard to recognize
  12.545 +				(progn
  12.546 +				  (goto-char (match-end 0))
  12.547 +				  (setq l2 (format "\"label:%s\""
  12.548 +						   (buffer-substring
  12.549 +						    (1- (point))
  12.550 +						    (progn (forward-sexp -1)
  12.551 +							   (1+ (point))))))
  12.552 +				  (setq label
  12.553 +					(if (< (YaTeX-string-width l2) ln)
  12.554 +					    (concat
  12.555 +					     l2
  12.556 +					     (substring
  12.557 +					      label
  12.558 +					      0 (- ln (YaTeX-string-width l2))))
  12.559 +					  l2))
  12.560 +				  (goto-char e)))
  12.561 +			    (funcall output
  12.562 +				     (concat
  12.563 +				      label " "
  12.564 +				      (buffer-substring x m0))
  12.565 +				     x)
  12.566 +			    (cond
  12.567 +			     ((YaTeX-quick-in-environment-p
  12.568 +			       YaTeX-math-gathering-list)
  12.569 +			      ;; if here is inner split/cases/gathered env.,
  12.570 +			      ;; counter for here is only one.
  12.571 +			      ;; Go out this environment and,
  12.572 +			      (YaTeX-end-of-environment)
  12.573 +			      ;; search next expression unit boundary.
  12.574 +			      (YaTeX-re-search-active-forward
  12.575 +			       (concat endrx "\\|\\\\begin{")
  12.576 +			       percent nil 1)
  12.577 +			      (end-of-line)))
  12.578 +			    (if quit (throw 'scan t)))))
  12.579 +			(setq x (point)))))
  12.580  		  (setq e0 (point)))
  12.581  		 ((string-match enums cmd)
  12.582  		  ;(skip-chars-forward "} \t\n")
  12.583 @@ -715,15 +970,51 @@
  12.584  		      (setq x (match-beginning 0))
  12.585  		      (funcall
  12.586  		       output
  12.587 -		       (buffer-substring
  12.588 -			(match-beginning 0)
  12.589 -			(if (re-search-forward itemsep nil t)
  12.590 -			    (progn (goto-char (match-beginning 0))
  12.591 -				   (skip-chars-backward " \t")
  12.592 -				   (1- (point)))
  12.593 -			  (point-end-of-line)))
  12.594 +		       (concat
  12.595 +			existlabel
  12.596 +			(buffer-substring
  12.597 +			 (match-beginning 0)
  12.598 +			 (if (re-search-forward itemsep nil t)
  12.599 +			     (progn (goto-char (match-beginning 0))
  12.600 +				    (skip-chars-backward " \t")
  12.601 +				    (1- (point)))
  12.602 +			   (point-end-of-line))))
  12.603  		       x))
  12.604  		    (setq e0 (point-max))))
  12.605 +		 ((string-match "bibitem" cmd) ;maybe generated by myself
  12.606 +		  (setq label "")
  12.607 +		  (skip-chars-forward " \t")
  12.608 +		  (if (looking-at "{")	;sure to be true!!
  12.609 +		      (forward-list 1))
  12.610 +		  (let ((list '(30 10 65))
  12.611 +			(delim ";") q lim len l str)
  12.612 +		    (save-excursion
  12.613 +		      (setq lim (if (re-search-forward itemsep nil 1)
  12.614 +				    (match-beginning 0) (point))))
  12.615 +		    (while list
  12.616 +		      (skip-chars-forward " \t\n\\")
  12.617 +		      (setq q (looking-at "[\"'{]")
  12.618 +			    len (car list)
  12.619 +			    str
  12.620 +			    (buffer-substring
  12.621 +			     (point)
  12.622 +			     (progn
  12.623 +			       (if q (forward-sexp 1)
  12.624 +				 (search-forward delim lim 1)
  12.625 +				 (forward-char -1))
  12.626 +			       (point))))
  12.627 +		      (if (> (setq l (YaTeX-string-width str)) len)
  12.628 +			  (setq str (concat
  12.629 +				     (YaTeX-truncate-string-width
  12.630 +				      str (- len (if q 5 4)))
  12.631 +				     "... "
  12.632 +				     (if q (substring str -1)))))
  12.633 +		      (if (< (setq l (YaTeX-string-width str)) len)
  12.634 +			  (setq str (concat str (make-string (- len l) ? ))))
  12.635 +		      (if (looking-at delim) (goto-char (match-end 0)))
  12.636 +		      (setq label (concat label " " str)
  12.637 +			    list (cdr list)))
  12.638 +		    (funcall output label match-point)))
  12.639  		 ;;else, simple section-type counter
  12.640  		 ((= (char-after (1- (point))) ?{)
  12.641  		  (setq label (buffer-substring
  12.642 @@ -733,6 +1024,8 @@
  12.643  				      (point))))
  12.644  		  (funcall output label match-point)
  12.645  		  ;; Skip preceding label if exists
  12.646 +		  (if (YaTeX::ref-getset-label (current-buffer) match-point t)
  12.647 +		      (goto-char (get 'YaTeX::ref-getset-label 'foundpoint)))
  12.648  		  (if (save-excursion
  12.649  			(skip-chars-forward "\t \n")
  12.650  			(looking-at YaTeX::ref-labeling-regexp))
  12.651 @@ -819,14 +1112,45 @@
  12.652  	label)))))
  12.653  
  12.654  (fset 'YaTeX::pageref 'YaTeX::ref)
  12.655 +(defun YaTeX::tabref (argp)	    ; For the style file of IPSJ journal
  12.656 +  (YaTeX::ref
  12.657 +   argp nil nil
  12.658 +   (function
  12.659 +    (lambda ()
  12.660 +      (YaTeX-quick-in-environment-p "table")))))
  12.661 +(defun YaTeX::figref (argp)	    ; For the style file of IPSJ journal
  12.662 +  (YaTeX::ref
  12.663 +   argp nil nil
  12.664 +   (function
  12.665 +    (lambda ()
  12.666 +      (YaTeX-quick-in-environment-p "figure")))))
  12.667  
  12.668 -(defun YaTeX::cite-collect-bibs-external (&rest files)
  12.669 -  "Collect bibentry from FILES(variable length argument);
  12.670 +(defun YaTeX::cite-collect-bibs-external (bibptn &rest files)
  12.671 +  "Collect bibentry from FILES(variable length argument) ;
  12.672  and print them to standard output."
  12.673    ;;Thanks; http://icarus.ilcs.hokudai.ac.jp/comp/biblio.html
  12.674 -  (let ((tb (get-buffer-create " *bibtmp*")))
  12.675 +  (let*((tb (get-buffer-create " *bibtmp*"))
  12.676 +	(bibitemsep "^\\s *@[A-Za-z]")
  12.677 +	(target (if (string< "" bibptn) bibptn bibitemsep))
  12.678 +	(checkrx (concat "\\(" bibptn "\\)\\|" bibitemsep))
  12.679 +	beg
  12.680 +	(searchnext
  12.681 +	 (if (string< "" bibptn)
  12.682 +	     (function
  12.683 +	      (lambda()
  12.684 +		(setq beg (point))
  12.685 +		(and
  12.686 +		 (prog1
  12.687 +		     (re-search-forward target nil t)
  12.688 +		   (end-of-line))
  12.689 +		 (re-search-backward bibitemsep beg t))))
  12.690 +	   (function
  12.691 +	    (lambda()
  12.692 +	      (re-search-forward target nil t)))))
  12.693 +	)
  12.694      (save-excursion
  12.695        (set-buffer tb)
  12.696 +      (princ (format "%sbegin{thebibliography}\n" YaTeX-ec))
  12.697        (while files
  12.698  	(erase-buffer)
  12.699  	(cond
  12.700 @@ -836,8 +1160,9 @@
  12.701  	  (insert-file-contents (concat (car files) ".bib"))))
  12.702  	(save-excursion
  12.703  	  (goto-char (point-min))
  12.704 -	  (while (re-search-forward "^\\s *@[A-Za-z]" nil t)
  12.705 +	  (while (funcall searchnext)
  12.706  	    (skip-chars-forward "^{,")
  12.707 +	    (setq beg (point))
  12.708  	    (if (= (char-after (point)) ?{)
  12.709  		(princ (format "%sbibitem{%s}%s\n"
  12.710  			       YaTeX-ec
  12.711 @@ -845,39 +1170,64 @@
  12.712  				(1+ (point))
  12.713  				(progn (skip-chars-forward "^,\n")
  12.714  				       (point)))
  12.715 -			       (if (re-search-forward "title\\s *=" nil t)
  12.716 -				   (buffer-substring
  12.717 -				    (progn
  12.718 -				      (goto-char (match-end 0))
  12.719 -				      (skip-chars-forward " \t\n")
  12.720 -				      (point))
  12.721 -				    (progn
  12.722 -				      (if (looking-at "[{\"]")
  12.723 -					  (forward-sexp 1)
  12.724 -					(forward-char 1)
  12.725 -					(skip-chars-forward "^,"))
  12.726 -				      (point)))))))))
  12.727 -	(setq files (cdr files))))))
  12.728 +			       (mapconcat
  12.729 +				(function
  12.730 +				 (lambda (kwd)
  12.731 +				   (goto-char beg)
  12.732 +				   (if (re-search-forward
  12.733 +					(concat kwd "\\s *=") nil t)
  12.734 +				       (buffer-substring
  12.735 +					(progn
  12.736 +					  (goto-char (match-end 0))
  12.737 +					  (skip-chars-forward " \t\n")
  12.738 +					  (point))
  12.739 +					(progn
  12.740 +					  (if (looking-at "[{\"]")
  12.741 +					      (forward-sexp 1)
  12.742 +					    (forward-char 1)
  12.743 +					    (skip-chars-forward "^,}"))
  12.744 +					  (point))))))
  12.745 +				'("author" "year" "title" )
  12.746 +				";"))))
  12.747 +	    (and (re-search-forward bibitemsep nil t)
  12.748 +		 (forward-line -1))))
  12.749 +	(setq files (cdr files)))
  12.750 +      (princ (format "%sbegin{thebibliography}\n" YaTeX-ec)))))
  12.751  
  12.752  (defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem"
  12.753    "*Regexp of macro name of bibitem definition")
  12.754  
  12.755 -(defun YaTeX::cite-collect-bibs-internal ()
  12.756 +(defun YaTeX::cite-collect-bibs-internal (bibptn)
  12.757    "Collect bibentry in the current buffer and print them to standard output."
  12.758    (let ((ptn (concat YaTeX-ec-regexp
  12.759  		     "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b"))
  12.760 +	(lim (concat YaTeX-ec-regexp
  12.761 +		     "\\(" YaTeX::cite-bibitem-macro-regexp "\\b\\)"
  12.762 +		     "\\|\\(end{\\)"))
  12.763  	(pcnt (regexp-quote YaTeX-comment-prefix)))
  12.764 +    ;; Using bibptn not yet implemented.
  12.765 +    ;; Do you need it?? 2005/11/22
  12.766      (save-excursion
  12.767        (while (YaTeX-re-search-active-forward ptn pcnt nil t)
  12.768  	(skip-chars-forward "^{\n")
  12.769  	(or (eolp)
  12.770 -	    (princ (format "%sbibitem{%s}\n"
  12.771 +	    (princ (format "%sbibitem%s %s\n"
  12.772  			   YaTeX-ec
  12.773  			   (buffer-substring
  12.774 -			    (1+ (point))
  12.775 -			    (progn (forward-sexp 1) (point))))))))))
  12.776 +			    (point)
  12.777 +			    (progn (forward-sexp 1) (point)))
  12.778 +			   (buffer-substring
  12.779 +			    (progn (skip-chars-forward "\n \t") (point))
  12.780 +			    (save-excursion
  12.781 +			      (if (YaTeX-re-search-active-forward
  12.782 +				   lim pcnt nil t)
  12.783 +				  (progn
  12.784 +				    (goto-char (match-beginning 0))
  12.785 +				    (skip-chars-backward "\n \t")
  12.786 +				    (point))
  12.787 +				(point-end-of-line)))))))))))
  12.788  
  12.789 -(defun YaTeX::cite (argp)
  12.790 +(defun YaTeX::cite (argp &rest dummy)
  12.791    (cond
  12.792     ((eq argp 1)
  12.793      (let* ((cb (current-buffer))
  12.794 @@ -886,8 +1236,10 @@
  12.795  	   (hilit-auto-highlight nil)
  12.796  	   (pcnt (regexp-quote YaTeX-comment-prefix))
  12.797  	   (bibrx (concat YaTeX-ec-regexp "bibliography{\\([^}]+\\)}"))
  12.798 +	   (bibptn (read-string "Pattern: "))
  12.799  	   (bbuf (get-buffer-create " *bibitems*"))
  12.800  	   (standard-output bbuf)
  12.801 +	   (me 'YaTeX::cite)		;shuld set this for using YaTeX::ref
  12.802  	   bibs files)
  12.803        (set-buffer bbuf)(erase-buffer)(set-buffer cb)
  12.804        (save-excursion
  12.805 @@ -895,10 +1247,11 @@
  12.806  	;;(1)search external bibdata
  12.807  	(while (YaTeX-re-search-active-forward bibrx pcnt nil t)
  12.808  	  (apply 'YaTeX::cite-collect-bibs-external
  12.809 +		 bibptn
  12.810  		 (YaTeX-split-string
  12.811  		  (YaTeX-match-string 1) ",")))
  12.812  	;;(2)search direct \bibitem usage
  12.813 -	(YaTeX::cite-collect-bibs-internal)
  12.814 +	(YaTeX::cite-collect-bibs-internal bibptn)
  12.815  	(if (progn
  12.816  	      (YaTeX-visit-main t)
  12.817  	      (not (eq (current-buffer) cb)))
  12.818 @@ -907,12 +1260,15 @@
  12.819  	      ;;(1)search external bibdata
  12.820  	      (while (YaTeX-re-search-active-forward bibrx pcnt nil t)
  12.821  		(apply 'YaTeX::cite-collect-bibs-external
  12.822 +		       bibptn
  12.823  		       (YaTeX-split-string
  12.824  			(YaTeX-match-string 1) ",")))
  12.825  	      ;;(2)search internal
  12.826 -	      (YaTeX::cite-collect-bibs-internal)))
  12.827 +	      (YaTeX::cite-collect-bibs-internal bibptn)))
  12.828  	;;Now bbuf holds the list of bibitem
  12.829  	(set-buffer bbuf)
  12.830 +	;;;(switch-to-buffer bbuf)
  12.831 +	(if (fboundp 'font-lock-fontify-buffer) (font-lock-fontify-buffer))
  12.832  	(YaTeX::ref
  12.833  	 argp 
  12.834  	 (concat "\\\\\\("
  12.835 @@ -929,6 +1285,8 @@
  12.836  (fset 'YaTeX::possessivecite 'YaTeX::cite)
  12.837  (fset 'YaTeX::citeyear 'YaTeX::cite)
  12.838  (fset 'YaTeX::citename 'YaTeX::cite)
  12.839 +(fset 'YaTeX::citep 'YaTeX::cite)
  12.840 +(fset 'YaTeX::citet 'YaTeX::cite)
  12.841  
  12.842  (defun YaTeX-yatex-buffer-list ()
  12.843    (save-excursion
  12.844 @@ -982,7 +1340,7 @@
  12.845       ((null rv) "")
  12.846       (t
  12.847        (set-buffer rv)
  12.848 -      (YaTeX::ref argp labelcmd refcmd)))))
  12.849 +      (funcall me argp labelcmd refcmd)))))
  12.850  
  12.851  ;;
  12.852  ; completion for the arguments of \newcommand
  12.853 @@ -1020,6 +1378,12 @@
  12.854        ))
  12.855     (t "")))
  12.856  
  12.857 +(defun YaTeX::newcounter (&optional argp)
  12.858 +  (cond
  12.859 +   ((= argp 1)
  12.860 +    (read-string "New counter name: "))
  12.861 +   (t "")))
  12.862 +
  12.863  ;;
  12.864  ; completion for the arguments of \pagestyle
  12.865  ;;
  12.866 @@ -1159,16 +1523,6 @@
  12.867  (defvar YaTeX:documentstyle-options-local nil
  12.868    "List of LaTeX local documentstyle options.")
  12.869  
  12.870 -(defvar YaTeX-minibuffer-completion-map nil
  12.871 -  "Minibuffer completion key map that allows comma completion.")
  12.872 -(if YaTeX-minibuffer-completion-map nil
  12.873 -  (setq YaTeX-minibuffer-completion-map
  12.874 -	(copy-keymap minibuffer-local-completion-map))
  12.875 -  (define-key YaTeX-minibuffer-completion-map " "
  12.876 -    'YaTeX-minibuffer-complete)
  12.877 -  (define-key YaTeX-minibuffer-completion-map "\t"
  12.878 -    'YaTeX-minibuffer-complete))
  12.879 -
  12.880  (defun YaTeX:documentstyle ()
  12.881    (let*((delim ",")
  12.882  	(dt (append YaTeX:documentstyle-options-local
  12.883 @@ -1210,6 +1564,16 @@
  12.884        (if (string= "" sname) (setq sname YaTeX-default-document-style))
  12.885        (setq YaTeX-default-document-style sname)))))
  12.886  
  12.887 +(defun YaTeX::include (argp &optional prompt)
  12.888 +  (cond
  12.889 +   ((= argp 1)
  12.890 +    (let*((insert-default-directory)
  12.891 +	  (file (read-file-name (or prompt "Input file: ") "")))
  12.892 +      (setq file (substring file 0 (string-match "\\.tex$" file)))))))
  12.893 +
  12.894 +(fset 'YaTeX::input 'YaTeX::include)
  12.895 +
  12.896 +
  12.897  ;;; -------------------- LaTeX2e stuff --------------------
  12.898  (defvar YaTeX:documentclass-options-default
  12.899    '(("a4paper") ("a5paper") ("b4paper") ("b5paper") ("10pt") ("11pt") ("12pt")
  12.900 @@ -1325,6 +1689,8 @@
  12.901  (fset 'YaTeX:colorbox 'YaTeX:textcolor)
  12.902  (fset 'YaTeX::colorbox 'YaTeX::textcolor)
  12.903  (fset 'YaTeX:fcolorbox 'YaTeX:textcolor)
  12.904 +(fset 'YaTeX:pagecolor 'YaTeX:textcolor)
  12.905 +(fset 'YaTeX::pagecolor 'YaTeX::textcolor)
  12.906  
  12.907  (defun YaTeX::fcolorbox (argp)
  12.908    (cond
  12.909 @@ -1333,14 +1699,46 @@
  12.910     ((= argp 3) (read-string "Colored string: "))))
  12.911  
  12.912  (defun YaTeX:scalebox ()
  12.913 -  "Add-in for \\rotatebox"
  12.914 -  (let ((vmag (read-string (if YaTeX-japan "倍率: " "Magnification: ")))
  12.915 -	(hmag (read-string (if YaTeX-japan "横倍率(省略可): "
  12.916 -			     "Horizontal magnification(Optional): "))))
  12.917 +  "Add-in for \\scalebox"
  12.918 +  (let ((vmag (read-string
  12.919 +	       (if YaTeX-japan "倍率(負で反転): "
  12.920 +		 "Magnification(Negative for flipped): ")))
  12.921 +	(hmag (read-string (if YaTeX-japan "縦倍率(省略可): "
  12.922 +			     "Vertical magnification(Optional): "))))
  12.923      (if (and hmag (string< "" hmag))
  12.924  	(format "{%s}[%s]" vmag hmag)
  12.925        (format "{%s}" vmag))))
  12.926  
  12.927 +(defun YaTeX:rotatebox ()
  12.928 +  "Optional argument add-in for \\rotatebox"
  12.929 +  (message "Rotate origin? (N)one (O)rigin (X)-Y: ")
  12.930 +  (let ((c (read-char)) r (defx "x=mm") x (defy "y=mm") y something)
  12.931 +    (cond
  12.932 +     ((memq c '(?O ?o))
  12.933 +      (if (string< "" (setq r (YaTeX:read-oneof "htbpB")))
  12.934 +	  (concat "[origin=" r "]")))
  12.935 +     ((memq c '(?X ?x ?Y ?y))
  12.936 +      (setq r (read-string "" (if YaTeX-emacs-19 (cons defx 3) defx))
  12.937 +	    x (if (string< "x=" r) r)
  12.938 +	    r (read-string "" (if YaTeX-emacs-19 (cons defy 3) defy))
  12.939 +	    y (if (string< "y=" r) r)
  12.940 +	    something (or x y))
  12.941 +      (format "%s%s%s%s%s"
  12.942 +	      (if something "[" "")
  12.943 +	      (if x x "")
  12.944 +	      (if (and x y) "," "")
  12.945 +	      (if y y "")
  12.946 +	      (if something "]" ""))))))
  12.947 +
  12.948 +(defun YaTeX::rotatebox (argp)
  12.949 +  "Argument add-in for \\rotatebox"
  12.950 +  (cond
  12.951 +   ((= argp 1)
  12.952 +    (read-string (if YaTeX-japan "回転角(度; 左回り): "
  12.953 +		   "Angle in degree(unclockwise): ")))
  12.954 +   ((= argp 2)
  12.955 +	(read-string (if YaTeX-japan "テキスト: " "Text: ")))))
  12.956 +
  12.957  (defun YaTeX:includegraphics ()
  12.958    "Add-in for \\includegraphics's option"
  12.959    (let (width height (scale "") angle str)
  12.960 @@ -1364,21 +1762,21 @@
  12.961  
  12.962  (defun YaTeX::includegraphics (argp)
  12.963    "Add-in for \\includegraphics"
  12.964 -  (cond
  12.965 -   ((= argp 1)
  12.966 -    (read-file-name "EPS File: " ""))))
  12.967 +  (YaTeX::include argp "Image File: "))
  12.968   
  12.969  (defun YaTeX:caption ()
  12.970    (setq YaTeX-section-name "label")
  12.971    nil)
  12.972  
  12.973 +
  12.974  (defvar YaTeX::usepackage-alist-default
  12.975    '(("version") ("plext") ("url") ("fancybox") ("pifont") ("longtable")
  12.976      ("ascmac") ("bm") ("graphics") ("graphicx") ("alltt") ("misc") ("eclbkbox")
  12.977      ("amsmath") ("amssymb") ("xymtex") ("chemist")
  12.978      ("a4j") ("array") ("epsf") ("color") ("epsfig") ("floatfig")
  12.979 -    ("landscape") ("path") ("supertabular") ("twocolumn"))
  12.980 -  "Default completion table for arguments of \usepackage")
  12.981 +    ("landscape") ("path") ("supertabular") ("twocolumn")
  12.982 +    ("latexsym") ("times") ("makeidx"))
  12.983 +  "Default completion table for arguments of \\usepackage")
  12.984  
  12.985  (defvar YaTeX::usepackage-alist-private nil
  12.986    "*Private completion list of the argument for usepackage")
  12.987 @@ -1390,11 +1788,14 @@
  12.988    (cond
  12.989     ((equal argp 1)
  12.990      (setq YaTeX-env-name "document")
  12.991 -    (YaTeX-cplread-with-learning
  12.992 -     "Use package: "
  12.993 -     'YaTeX::usepackage-alist-default
  12.994 -     'YaTeX::usepackage-alist-private
  12.995 -     'YaTeX::usepackage-alist-local))))
  12.996 +    (let ((minibuffer-local-completion-map YaTeX-minibuffer-completion-map)
  12.997 +	  (delim ","))
  12.998 +      (YaTeX-cplread-with-learning
  12.999 +       (if YaTeX-japan "Use package(カンマで区切ってOK): "
 12.1000 +	 "Use package(delimitable by comma): ")
 12.1001 +       'YaTeX::usepackage-alist-default
 12.1002 +       'YaTeX::usepackage-alist-private
 12.1003 +       'YaTeX::usepackage-alist-local)))))
 12.1004  
 12.1005  (defun YaTeX::mask (argp)
 12.1006    (cond
 12.1007 @@ -1422,8 +1823,20 @@
 12.1008     ((equal argp 4)
 12.1009      (YaTeX:read-oneof "lcr" 'quick))
 12.1010     ((equal argp 5)
 12.1011 -    (read-string "String: "))
 12.1012 -))
 12.1013 +    (read-string "String: "))))
 12.1014 +
 12.1015 +(defun YaTeX::textcircled (argp)
 12.1016 +  (cond
 12.1017 +   ((equal argp 1)
 12.1018 +    (let ((char (read-string "Circled char: "))
 12.1019 +	  (left "") (right "") c)
 12.1020 +      (setq c (read-char
 12.1021 +	       "Enclose also with (s)mall (t)iny s(C)riptsize (N)one:"))
 12.1022 +      (cond
 12.1023 +       ((memq c '(?s ?S)) (setq left "{\\small " right "}"))
 12.1024 +       ((memq c '(?t ?T)) (setq left "{\\tiny " right "}"))
 12.1025 +       ((memq c '(?c ?C)) (setq left "{\\scriptsize " right "}")))
 12.1026 +      (format "%s%s%s" left char right)))))
 12.1027  
 12.1028  ;;; -------------------- math-mode stuff --------------------
 12.1029  (defun YaTeX::tilde (&optional pos)
 12.1030 @@ -1509,6 +1922,11 @@
 12.1031  		(YaTeX-kill-paren nil))))))
 12.1032    (message ""))
 12.1033  
 12.1034 +(defun YaTeX::DeclareMathOperator (argp)
 12.1035 +  (cond
 12.1036 +   ((equal argp 1)
 12.1037 +    (read-string "Operator: " "\\"))))
 12.1038 +
 12.1039  ;;;
 12.1040  ;; Add-in functions for large-type command.
 12.1041  ;;;
 12.1042 @@ -1524,5 +1942,5 @@
 12.1043  ; fill-prefix: ";;; "
 12.1044  ; paragraph-start: "^$\\|\\|;;;$"
 12.1045  ; paragraph-separate: "^$\\|\\|;;;$"
 12.1046 -; buffer-file-coding-system: sjis
 12.1047 +; coding: sjis
 12.1048  ; End:
    13.1 --- a/yatexenv.el	Thu Dec 25 04:10:32 2003 +0000
    13.2 +++ b/yatexenv.el	Sun Dec 24 06:16:52 2006 +0000
    13.3 @@ -1,8 +1,8 @@
    13.4  ;;; -*- Emacs-Lisp -*-
    13.5  ;;; YaTeX environment-specific functions.
    13.6  ;;; yatexenv.el
    13.7 -;;; (c) 1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
    13.8 -;;; Last modified Fri Jun 27 12:09:30 2003 on firestorm
    13.9 +;;; (c) 1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
   13.10 +;;; Last modified Sat Jun 24 08:14:11 2006 on firestorm
   13.11  ;;; $Id$
   13.12  
   13.13  ;;;
   13.14 @@ -10,8 +10,8 @@
   13.15  ;;;
   13.16  
   13.17  ;; Showing the matching column of tabular environment.
   13.18 -(defun YaTeX-array-what-column ()
   13.19 -  "Show matching columne title of array environment.
   13.20 +(defun YaTeX-array-what-column-internal ()
   13.21 +  "Return the cons of matching column and its title of array environment.
   13.22  When calling from a program, make sure to be in array/tabular environment."
   13.23    (let ((p (point)) beg eot bor (nlptn "\\\\\\\\") (andptn "[^\\]&")
   13.24  	(n 0) j
   13.25 @@ -54,18 +54,23 @@
   13.26  	    (error "This column exceeds the limit."))
   13.27  	(setq j (1- j)))
   13.28        (skip-chars-forward "\\s ")
   13.29 -      (message
   13.30 -       "This is the column(#%d) of: %s" n
   13.31 -       (buffer-substring
   13.32 -	(point)
   13.33 -	(progn
   13.34 -	  (re-search-forward (concat andptn "\\|" nlptn) eot)
   13.35 -	  (goto-char (match-beginning 0))
   13.36 -	  (if (looking-at andptn)
   13.37 -	      (forward-char 1))
   13.38 -	  (skip-chars-backward "\\s ")
   13.39 -	  (point))))))
   13.40 -)
   13.41 +      (list n
   13.42 +	    (buffer-substring
   13.43 +	     (point)
   13.44 +	     (progn
   13.45 +	       (re-search-forward (concat andptn "\\|" nlptn) eot)
   13.46 +	       (goto-char (match-beginning 0))
   13.47 +	       (if (looking-at andptn)
   13.48 +		   (forward-char 1))
   13.49 +	       (skip-chars-backward "\\s ")
   13.50 +	       (point)))))))
   13.51 +
   13.52 +(defun YaTeX-array-what-column ()
   13.53 +  "Show matching column title of array environment.
   13.54 +When calling from a program, make sure to be in array/tabular environment."
   13.55 +  (apply 'message
   13.56 +	 "This is the column(#%d) of: %s"
   13.57 +	 (YaTeX-array-what-column-internal)))
   13.58  
   13.59  ;;;###autoload
   13.60  (defun YaTeX-what-column ()
   13.61 @@ -74,28 +79,12 @@
   13.62    (cond
   13.63     ((YaTeX-quick-in-environment-p '("tabular" "tabular*" "array" "array*"))
   13.64      (YaTeX-array-what-column))
   13.65 -   (t (message "Not in array/tabular environment.")))
   13.66 -)
   13.67 +   (t (message "Not in array/tabular environment."))))
   13.68  
   13.69 -(defun YaTeX-tabular-parse-format (&optional tabular*)
   13.70 -  "Parse `tabular' format.
   13.71 -Return the list of (No.ofCols PointEndofFormat)"
   13.72 -  (let ((p (point)) elt boform eoform (cols 0))
   13.73 -    (save-excursion
   13.74 -      (if (null (YaTeX-beginning-of-environment t))
   13.75 -	  (error "Beginning of tabular not found."))
   13.76 -      (skip-chars-forward "^{")
   13.77 -      (forward-list 1)
   13.78 -      (if tabular*
   13.79 -	  (progn (skip-chars-forward "^{")
   13.80 -		 (forward-list 1)))
   13.81 -      (skip-chars-forward "^{" p)
   13.82 -      (if (/= (following-char) ?\{) (error "Tabular format not found."))
   13.83 -      (setq boform (1+ (point))
   13.84 -	    eoform (progn (forward-list 1) (1- (point))))
   13.85 -      (if (> eoform p) (error "Non-terminated tabular format."))
   13.86 -      (goto-char boform)
   13.87 -      (while (< (point) eoform)
   13.88 +(defun YaTeX-tabular-parse-format-count-cols (beg end)
   13.89 +  (goto-char beg)
   13.90 +  (let (elt (cols 0))
   13.91 +    (while (< (point) end)
   13.92  	(setq elt (following-char))
   13.93  	(cond
   13.94  	 ((string-match (char-to-string elt) "clr") ;normal indicators.
   13.95 @@ -105,16 +94,60 @@
   13.96  	  (forward-char 1))
   13.97  	 ((string-match (char-to-string elt) "p@") ;p or @ expression
   13.98  	  (setq cols (+ (if (eq elt ?p) 1 0) cols))
   13.99 -	  (skip-chars-forward "^{" p)
  13.100 +	  ;;(skip-chars-forward "^{" p)
  13.101 +	  (skip-chars-forward "^{" end)
  13.102  	  (forward-list 1))
  13.103 +	 ((equal elt ?*)		;*{N}{EXP} -> Repeat EXP N times
  13.104 +	  (skip-chars-forward "^{" end)
  13.105 +	  (setq cols (* (string-to-int
  13.106 +			 (buffer-substring
  13.107 +			  (1+ (point))
  13.108 +			  (progn (forward-list 1) (1- (point)))))
  13.109 +			(YaTeX-tabular-parse-format-count-cols
  13.110 +			 (progn (skip-chars-forward "^{" end) (1+ (point)))
  13.111 +			 (progn (forward-list 1) (1- (point)))))))
  13.112  	 (t (forward-char 1))		;unknown char
  13.113  	 ))
  13.114 -      (list cols (1+ eoform))))
  13.115 -)
  13.116 +    cols))
  13.117 +
  13.118 +(defun YaTeX-tabular-parse-format (&optional type)
  13.119 +  "Parse `tabular' format.
  13.120 +Return the list of (No.ofCols PointEndofFormat)"
  13.121 +  (let ((p (point)) boform eoform (cols 0))
  13.122 +    (save-excursion
  13.123 +      (if (null (YaTeX-beginning-of-environment t))
  13.124 +	  (error "Beginning of tabular not found."))
  13.125 +      (skip-chars-forward "^{")
  13.126 +      (forward-list 1)
  13.127 +      (cond
  13.128 +       ((eq type 'tabular*)
  13.129 +	(skip-chars-forward "^{")
  13.130 +	(forward-list 1)))
  13.131 +      (skip-chars-forward "^{" p)
  13.132 +      (if (/= (following-char) ?\{) (error "Tabular format not found."))
  13.133 +      (setq boform (1+ (point))
  13.134 +	    eoform (progn (forward-list 1) (1- (point))))
  13.135 +      (if (> eoform p) (error "Non-terminated tabular format."))
  13.136 +      (goto-char boform)
  13.137 +      (setq cols
  13.138 +	    (cond
  13.139 +	     ((eq type 'alignat)
  13.140 +	      (max
  13.141 +	       1
  13.142 +	       (1-
  13.143 +		(* 2
  13.144 +		   (string-to-int
  13.145 +		    (buffer-substring
  13.146 +		     (point)
  13.147 +		     (progn (up-list -1) (forward-list 1) (1- (point)))))))))
  13.148 +	     (t
  13.149 +	      (YaTeX-tabular-parse-format-count-cols (point) eoform))))
  13.150 +      (list cols (1+ eoform)))))
  13.151 +
  13.152  ;; Insert &
  13.153 -(defun YaTeX-intelligent-newline-tabular (&optional tabular*)
  13.154 +(defun YaTeX-intelligent-newline-tabular (&optional type)
  13.155    "Parse current tabular format and insert that many `&'s."
  13.156 -  (let*((p (point)) (format (YaTeX-tabular-parse-format tabular*))
  13.157 +  (let*((p (point)) (format (YaTeX-tabular-parse-format type))
  13.158  	(cols (car format)) (beg (car (cdr format)))
  13.159  	space hline)
  13.160      (cond
  13.161 @@ -132,16 +165,43 @@
  13.162      (insert "\\\\")
  13.163      (if hline (insert " \\hline"))
  13.164      (goto-char p)
  13.165 -    (YaTeX-indent-line)
  13.166 -)
  13.167 -)
  13.168 +    (YaTeX-indent-line)))
  13.169  
  13.170  (defun YaTeX-intelligent-newline-tabular* ()
  13.171    "Parse current tabular* format and insert that many `&'s."
  13.172 -  (YaTeX-intelligent-newline-tabular t)
  13.173 -)
  13.174 +  (YaTeX-intelligent-newline-tabular 'tabular*))
  13.175  
  13.176  (fset 'YaTeX-intelligent-newline-array 'YaTeX-intelligent-newline-tabular)
  13.177 +(fset 'YaTeX-intelligent-newline-supertabular 'YaTeX-intelligent-newline-tabular)
  13.178 +
  13.179 +(defun YaTeX-intelligent-newline-alignat ()
  13.180 +  (YaTeX-intelligent-newline-tabular 'alignat))
  13.181 +(fset 'YaTeX-intelligent-newline-alignat* 'YaTeX-intelligent-newline-alignat)
  13.182 +
  13.183 +(defun YaTeX-intelligent-newline-align ()
  13.184 +  "Intelligent newline function for align.
  13.185 +Count the number of & in the first align line and insert that many &s."
  13.186 +  (let*((p (point)) (cols 0))
  13.187 +    (save-excursion
  13.188 +      (YaTeX-beginning-of-environment)
  13.189 +      (catch 'done
  13.190 +	(while (YaTeX-re-search-active-forward
  13.191 +		"\\(&\\)\\|\\(\\\\\\\\\\)" YaTeX-comment-prefix p t)
  13.192 +	  (if (match-beginning 1) (setq cols (1+ cols)) (throw 'done t)))))
  13.193 +    (save-excursion
  13.194 +      (if (= cols 0)
  13.195 +	  (insert "&")
  13.196 +	(while (>= (setq cols (1- cols)) 0)
  13.197 +	  (insert "& "))))
  13.198 +    (YaTeX-indent-line)))
  13.199 +
  13.200 +(mapcar
  13.201 + '(lambda (s)
  13.202 +    (fset (intern (concat  "YaTeX-intelligent-newline-"
  13.203 +			   (symbol-name s)))
  13.204 +	  'YaTeX-intelligent-newline-align))
  13.205 + '(align* flalign  flalign* matrix pmatrix bmatrix Bmatrix vmatrix Vmatrix
  13.206 +   cases))
  13.207  
  13.208  ;;;
  13.209  ;; Functions for tabbing environment
  13.210 @@ -214,8 +274,7 @@
  13.211      (newline)
  13.212      (undo-boundary)
  13.213      (if (and env func (fboundp func))
  13.214 -	(funcall func)))
  13.215 -)
  13.216 +	(funcall func))))
  13.217  
  13.218  ;;;
  13.219  ;; Environment-specific line indenting functions
    14.1 --- a/yatexhks.el	Thu Dec 25 04:10:32 2003 +0000
    14.2 +++ b/yatexhks.el	Sun Dec 24 06:16:52 2006 +0000
    14.3 @@ -41,6 +41,13 @@
    14.4    '(lambda () (interactive) (YaTeX-make-section nil nil nil "setlength")))
    14.5  (define-key YaTeX-user-extensional-map "b"
    14.6    '(lambda () (interactive) (YaTeX-make-fontsize nil "bf")))
    14.7 +(define-key YaTeX-user-extensional-map "I" 'YaTeX-browse-info)
    14.8 +
    14.9 +(defun YaTeX-browse-info ()
   14.10 +  "Browse YaTeX's info"
   14.11 +  (interactive)
   14.12 +  (require 'info)
   14.13 +  (Info-goto-node (if YaTeX-japan "(yatexj)Top" "(yatexe)Top")))
   14.14  
   14.15  
   14.16  ;
    15.1 --- a/yatexhlp.el	Thu Dec 25 04:10:32 2003 +0000
    15.2 +++ b/yatexhlp.el	Sun Dec 24 06:16:52 2006 +0000
    15.3 @@ -1,8 +1,8 @@
    15.4  ;;; -*- Emacs-Lisp -*-
    15.5  ;;; YaTeX helper with LaTeX commands and macros.
    15.6  ;;; yatexhlp.el
    15.7 -;;; (c)1994,1998 by HIROSE Yuuji.[yuuji@yatex.org]
    15.8 -;;; Last modified Fri Jun 27 12:09:58 2003 on firestorm
    15.9 +;;; (c)1994,1998,2004 by HIROSE Yuuji.[yuuji@yatex.org]
   15.10 +;;; Last modified Tue Oct 19 01:13:21 2004 on firestorm
   15.11  ;;; $Id$
   15.12  
   15.13  (let ((help-file (concat "YATEXHLP."
   15.14 @@ -11,6 +11,8 @@
   15.15        (help-dir
   15.16         (cond
   15.17  	((and (boundp 'site-directory) site-directory) site-directory)
   15.18 +	((string-match "\\.app/" doc-directory)	;For Emacs.app(Darwin)
   15.19 +	 (expand-file-name "../site-lisp" doc-directory))
   15.20  	(YaTeX-emacs-19 (expand-file-name "../../site-lisp" doc-directory))
   15.21  	(t exec-directory))))
   15.22    (defvar YaTeX-help-file
   15.23 @@ -38,6 +40,29 @@
   15.24  	(t "[[ Description ]]"))
   15.25    "Section header of description.")
   15.26  
   15.27 +(defvar YaTeX-help-mode-map nil "Keymap used in YaTeX-help buffer")
   15.28 +(if YaTeX-help-mode-map nil
   15.29 +  (setq YaTeX-help-mode-map (make-sparse-keymap))
   15.30 +  (let ((map YaTeX-help-mode-map))
   15.31 +    (suppress-keymap map)
   15.32 +    (define-key map "j" '(lambda () (interactive) (scroll-up 1)))
   15.33 +    (define-key map "k" '(lambda () (interactive) (scroll-up -1)))
   15.34 +    (define-key map "n" 'next-line)
   15.35 +    (define-key map "p" 'previous-line)
   15.36 +    (define-key map " " 'scroll-up)
   15.37 +    (define-key map "\C-?" 'scroll-down)
   15.38 +    (define-key map "o" 'other-window)
   15.39 +    (define-key map "h" 'describe-bindings)
   15.40 +    (define-key map "q" 'YaTeX-help-quit)
   15.41 +    (define-key map "<" 'beginning-of-buffer)
   15.42 +    (define-key map ">" 'end-of-buffer)))
   15.43 +
   15.44 +(defun YaTeX-help-quit ()
   15.45 +  "Close help and return to privious buffer"
   15.46 +  (interactive)
   15.47 +  (bury-buffer (current-buffer))
   15.48 +  (set-window-configuration YaTeX-help-saved-config))
   15.49 +
   15.50  (defvar YaTeX-help-reference-regexp "<refer\\s +\\([^>]+\\)>"
   15.51    "Regexp of reference format of YaTeX-help file.")
   15.52  (defvar YaTeX-help-buffer "** YaTeX HELP **" "Help buffer name for yatexhlp")
   15.53 @@ -62,10 +87,11 @@
   15.54  		    (or (assoc entry entries)
   15.55  			(setq entries (cons (list entry) entries)))))))))
   15.56         (list YaTeX-help-file YaTeX-help-file-private)))
   15.57 -    entries)
   15.58 -)
   15.59 +    entries))
   15.60  
   15.61 -(defvar YaTeX-help-entries (YaTeX-help-entries))
   15.62 +(defvar YaTeX-help-entries nil
   15.63 +  "Helo entries alist.")
   15.64 +(setq YaTeX-help-entries (YaTeX-help-entries))
   15.65  
   15.66  (defun YaTeX-help-resolve-reference (buffer1 buffer2 &optional done-list)
   15.67    "Replace reference format in buffer1 with refered contents in buffer2."
   15.68 @@ -100,9 +126,7 @@
   15.69  		  (insert-buffer-substring buffer2 beg end))))
   15.70  	  (switch-to-buffer buffer1)))
   15.71        (if beg (YaTeX-help-resolve-reference
   15.72 -	       buffer1 buffer2 (append done-list ref-list))))
   15.73 -    )
   15.74 -)
   15.75 +	       buffer1 buffer2 (append done-list ref-list))))))
   15.76  
   15.77  (defun YaTeX-refer-help (command help-file &optional append)
   15.78    "Refer the COMMAND's help into HELP-FILE.
   15.79 @@ -137,6 +161,7 @@
   15.80        (YaTeX-showup-buffer
   15.81         hbuf (function (lambda (x) (nth 3 (window-edges x)))) t)
   15.82        (set-buffer hbuf)
   15.83 +      (setq buffer-read-only nil)
   15.84        (if append (goto-char (point-max)) (erase-buffer))
   15.85        (insert YaTeX-help-synopsis "\n")
   15.86        (insert-buffer-substring hfbuf sb se)
   15.87 @@ -144,9 +169,18 @@
   15.88        (insert-buffer-substring hfbuf db de)
   15.89        (YaTeX-help-resolve-reference hbuf hfbuf (list (list command)))
   15.90        (goto-char (point-min))
   15.91 +      (setq buffer-read-only t)
   15.92 +      (set-buffer-modified-p nil)
   15.93 +      (YaTeX-help-mode)
   15.94        (select-window curwin)
   15.95 -      t))
   15.96 -)
   15.97 +      t)))
   15.98 +
   15.99 +(defun YaTeX-help-mode ()
  15.100 +  (interactive)
  15.101 +  (use-local-map YaTeX-help-mode-map)
  15.102 +  (setq major-mode 'yatex-help-mode
  15.103 +	mode-name "YaTeX-HELP"))
  15.104 +
  15.105  (defun YaTeX-help-newline (&optional arg)
  15.106    (interactive "P")
  15.107    (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp))
  15.108 @@ -158,8 +192,8 @@
  15.109  	   YaTeX-help-command-current YaTeX-help-file-current))
  15.110  	(set-window-configuration YaTeX-help-saved-config)
  15.111  	(bury-buffer cbuf))
  15.112 -    (newline arg))
  15.113 -)
  15.114 +    (newline arg)))
  15.115 +
  15.116  (defun YaTeX-help-add-entry (command help-file)
  15.117    (let ((hfbuf (find-file-noselect help-file))
  15.118  	(dbuf (current-buffer)) beg end)
  15.119 @@ -185,8 +219,8 @@
  15.120      (let ((make-backup-files t))
  15.121        (basic-save-buffer))
  15.122      (bury-buffer hfbuf)
  15.123 -    (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries)))
  15.124 -)
  15.125 +    (setq YaTeX-help-entries (cons (list command) YaTeX-help-entries))))
  15.126 +
  15.127  (defun YaTeX-help-prepare-entry (command help-file)
  15.128    "Read help description on COMMAND and add it to HELP-FILE."
  15.129    (let ((buf (get-buffer-create "**Description**"))
  15.130 @@ -207,16 +241,15 @@
  15.131      (use-local-map YaTeX-help-entry-map)
  15.132      (message
  15.133       (cond (YaTeX-japan "入力を終えたら . のみ入力してRET")
  15.134 -	   (t "Type only `.' and RET to exit."))))
  15.135 -)
  15.136 +	   (t "Type only `.' and RET to exit.")))))
  15.137 +
  15.138  (defun YaTeX-enrich-help (command)
  15.139    "Add the COMMAND's help to help file."
  15.140    (if (y-or-n-p (format "No help on `%s'. Create help?" command))
  15.141        (YaTeX-help-prepare-entry
  15.142         command
  15.143         (if (y-or-n-p "Add help to global documentation?")
  15.144 -	   YaTeX-help-file YaTeX-help-file-private)))
  15.145 -)
  15.146 +	   YaTeX-help-file YaTeX-help-file-private))))
  15.147  
  15.148  (defun YaTeX-help-sort (&optional help-file)
  15.149    "Sort help file HELP-FILE.
  15.150 @@ -225,8 +258,7 @@
  15.151    (interactive)
  15.152    (if help-file (set-buffer (find-file-noselect help-file)))
  15.153    (sort-regexp-fields
  15.154 -   nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max))
  15.155 -)
  15.156 +   nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max)))
  15.157  
  15.158  (defun YaTeX-apropos-file (keyword help-file &optional append)
  15.159    (let ((hb (find-file-noselect help-file))
  15.160 @@ -238,6 +270,7 @@
  15.161       ab (function (lambda (x) (nth 3 (window-edges x)))))
  15.162      (select-window (get-buffer-window ab))
  15.163      (set-buffer ab)			;assertion
  15.164 +    (setq buffer-read-only nil)
  15.165      (or append (erase-buffer))
  15.166      (set-buffer hb)
  15.167      (goto-char (point-min))
  15.168 @@ -250,22 +283,23 @@
  15.169        (insert-char ?- (1- (window-width)))
  15.170        (insert (format "\n<<%s>>\n" command))
  15.171        (YaTeX-refer-help command help-file t) ;append mode
  15.172 +      (setq buffer-read-only nil)
  15.173        (set-buffer hb)
  15.174        (goto-char pt)
  15.175        (if (re-search-forward head nil 1)
  15.176  	  (goto-char (1- (match-beginning 0)))))
  15.177 +    (setq buffer-read-only t)
  15.178      (select-window sw)
  15.179 -    pt)
  15.180 -)
  15.181 +    pt))
  15.182  
  15.183  ;;;###autoload
  15.184  (defun YaTeX-apropos (key)
  15.185    (interactive "sLaTeX apropos (regexp): ")
  15.186    (if (string= "" key) (error "Nothing to show"))
  15.187 +  (setq YaTeX-help-saved-config (current-window-configuration))
  15.188    (or (YaTeX-apropos-file key YaTeX-help-file)
  15.189        (YaTeX-apropos-file key YaTeX-help-file-private t)
  15.190 -      (message "No matches found."))
  15.191 -)
  15.192 +      (message "No matches found.")))
  15.193  
  15.194  ;;;###autoload
  15.195  (defun YaTeX-help ()
  15.196 @@ -301,7 +335,7 @@
  15.197  	     "Describe (La)TeX command: "
  15.198  	     YaTeX-help-entries nil nil command))
  15.199        );end excursion
  15.200 +    (setq YaTeX-help-saved-config (current-window-configuration))
  15.201      (or (YaTeX-refer-help command YaTeX-help-file)
  15.202  	(YaTeX-refer-help command YaTeX-help-file-private)
  15.203 -	(YaTeX-enrich-help command)))
  15.204 -)
  15.205 +	(YaTeX-enrich-help command))))
    16.1 --- a/yatexlib.el	Thu Dec 25 04:10:32 2003 +0000
    16.2 +++ b/yatexlib.el	Sun Dec 24 06:16:52 2006 +0000
    16.3 @@ -1,8 +1,8 @@
    16.4  ;;; -*- Emacs-Lisp -*-
    16.5  ;;; YaTeX and yahtml common libraries, general functions and definitions
    16.6  ;;; yatexlib.el
    16.7 -;;; (c)1994-2002 by HIROSE Yuuji.[yuuji@yatex.org]
    16.8 -;;; Last modified Tue Aug 19 22:20:40 2003 on firestorm
    16.9 +;;; (c)1994-2006 by HIROSE Yuuji.[yuuji@yatex.org]
   16.10 +;;; Last modified Sun Dec 24 15:12:20 2006 on firestorm
   16.11  ;;; $Id$
   16.12  
   16.13  ;; General variables
   16.14 @@ -32,6 +32,10 @@
   16.15  ;; autoload from yahtml.el
   16.16  (autoload 'yahtml-inner-environment-but "yahtml" "yahtml internal func." t)
   16.17  
   16.18 +(defvar latex-message-kanji-code 2
   16.19 +  "*Kanji coding system latex command types out.
   16.20 +1 = Shift JIS, 2 = JIS, 3 = EUC. 4 = UTF-8")
   16.21 +
   16.22  (defvar YaTeX-kanji-code-alist
   16.23    (cond
   16.24     ((boundp '*junet*)
   16.25 @@ -43,7 +47,7 @@
   16.26  	    (YaTeX-macos (if (boundp '*sjis-mac*) *sjis-mac* *sjis*mac))
   16.27  	    (t *sjis*)))
   16.28  	  '(2 . *junet*) '(3 . *euc-japan*)))
   16.29 -   (YaTeX-emacs-20
   16.30 +   ((and YaTeX-emacs-20 (featurep 'mule))
   16.31      ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
   16.32      (list '(0 . no-conversion)
   16.33  	  (cons
   16.34 @@ -52,7 +56,8 @@
   16.35  		   ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
   16.36  		   (t 'sjis)))
   16.37  	  '(2 . iso-2022-jp-unix)
   16.38 -	  '(3 . euc-jp-unix))))
   16.39 +	  '(3 . euc-jp-unix)
   16.40 +	  '(4 . utf-8))))
   16.41    "Kanji-code expression translation table.")
   16.42  (defvar YaTeX-inhibit-prefix-letter nil
   16.43    "*T for changing key definitions from [prefix] Letter to [prefix] C-Letter.")
   16.44 @@ -79,6 +84,16 @@
   16.45  \it, \bf 内部での日本語が□になってしまう場合はこれをnilにして下さい。")
   16.46  
   16.47  ;----------- work variables ----------------------------------------
   16.48 +(defvar YaTeX-minibuffer-completion-map nil
   16.49 +  "Minibuffer completion key map that allows comma completion.")
   16.50 +(if YaTeX-minibuffer-completion-map nil
   16.51 +  (setq YaTeX-minibuffer-completion-map
   16.52 +	(copy-keymap minibuffer-local-completion-map))
   16.53 +  (define-key YaTeX-minibuffer-completion-map " "
   16.54 +    'YaTeX-minibuffer-complete)
   16.55 +  (define-key YaTeX-minibuffer-completion-map "\t"
   16.56 +    'YaTeX-minibuffer-complete))
   16.57 +
   16.58  (defvar YaTeX-typesetting-mode-map nil
   16.59    "Keymap used in YaTeX typesetting buffer")
   16.60  
   16.61 @@ -127,6 +142,7 @@
   16.62  ;;;###autoload
   16.63  (defun YaTeX-read-user-completion-table (&optional forcetoread)
   16.64    "Append user completion table of LaTeX macros"
   16.65 +  (interactive)
   16.66    (let*((user-table (expand-file-name YaTeX-user-completion-table))
   16.67  	(local-table (expand-file-name (file-name-nondirectory user-table)))
   16.68  	var localvar localbuf (curbuf (current-buffer)) sexp)
   16.69 @@ -140,7 +156,7 @@
   16.70        (set-buffer (setq localbuf (find-file-noselect local-table)))
   16.71        (widen)
   16.72        (goto-char (point-min))
   16.73 -      (while (re-search-forward "(setq \\([^ ]+\\)" nil t)
   16.74 +      (while (re-search-forward "(setq \\([^ \t\n]+\\)" nil t)
   16.75  	(setq var (intern (buffer-substring
   16.76  			   (match-beginning 1) (match-end 1)))
   16.77  	      localvar (YaTeX-local-table-symbol var))
   16.78 @@ -340,6 +356,13 @@
   16.79    (YaTeX-search-active-forward
   16.80     regexp cmntrx bound err cnt 're-search-backward))
   16.81  
   16.82 +(defun YaTeX-relative-path-p (path)
   16.83 +  "Return non-nil if PATH is not absolute one."
   16.84 +  (let ((md (match-data)))
   16.85 +    (unwind-protect
   16.86 +	(not (string-match "^\\(/\\|[a-z]:\\|\\\\\\).*/" file))
   16.87 +      (store-match-data md))))
   16.88 +
   16.89  ;;;###autoload
   16.90  (defun YaTeX-switch-to-buffer (file &optional setbuf)
   16.91    "Switch to buffer if buffer exists, find file if not.
   16.92 @@ -347,7 +370,7 @@
   16.93    (interactive "Fswitch to file: ")
   16.94    (if (bufferp file)
   16.95        (setq file (buffer-file-name file))
   16.96 -    (and (string-match "^[^/].*/" file)
   16.97 +    (and (YaTeX-relative-path-p file)
   16.98  	 (eq major-mode 'yatex-mode)
   16.99  	 YaTeX-search-file-from-top-directory
  16.100  	 (save-excursion
  16.101 @@ -373,7 +396,7 @@
  16.102    (interactive "Fswitch to file: ")
  16.103    (and (eq major-mode 'yatex-mode)
  16.104         (stringp file)
  16.105 -       (string-match "^[^/].*/" file)
  16.106 +       (YaTeX-relative-path-p file)
  16.107         YaTeX-search-file-from-top-directory
  16.108         (save-excursion
  16.109  	 (YaTeX-visit-main t)
  16.110 @@ -412,7 +435,7 @@
  16.111  (defun YaTeX-replace-format (string format repl)
  16.112    "In STRING, replace first appearance of FORMAT to REPL as if
  16.113  function `format' does.  FORMAT does not contain `%'"
  16.114 -  (let ((ans string))
  16.115 +  (let ((ans string) (case-fold-search nil))
  16.116      (while (not (string=
  16.117  		 ans (setq string (YaTeX-replace-format-sub ans format repl))))
  16.118        (setq ans string))
  16.119 @@ -569,7 +592,7 @@
  16.120  (defun YaTeX-match-string (n &optional m)
  16.121    "Return (buffer-substring (match-beginning n) (match-beginning m))."
  16.122    (if (match-beginning n)
  16.123 -      (buffer-substring (match-beginning n)
  16.124 +      (YaTeX-buffer-substring (match-beginning n)
  16.125  			(match-end (or m n)))))
  16.126  
  16.127  ;;;###autoload
  16.128 @@ -979,7 +1002,7 @@
  16.129  	  (goto-char (get 'YaTeX-inner-environment 'point))
  16.130  	  (and end (YaTeX-goto-corresponding-environment))
  16.131  	  (if (interactive-p) (push-mark op))
  16.132 -	  t))))
  16.133 +	  (point)))))
  16.134  
  16.135  (defun YaTeX-end-of-environment (&optional limit-search-bound)
  16.136    "Goto the end of the current environment.
  16.137 @@ -993,8 +1016,10 @@
  16.138    (interactive)
  16.139    (let ((curp (point)))
  16.140      (if (and (YaTeX-on-begin-end-p) (match-beginning 1)) ;if on \\begin
  16.141 -	(forward-line 1)
  16.142 -      (beginning-of-line))
  16.143 +	(progn (goto-char (match-end 0)))
  16.144 +      (if (= (char-after (point)) ?\\) nil	;if on \\end
  16.145 +	(skip-chars-backward "^\n\\\\")
  16.146 +	(or (bolp) (forward-char -1))))
  16.147      (if (not (YaTeX-end-of-environment))   ;arg1 turns to match-beginning 1
  16.148  	(progn
  16.149  	  (goto-char curp)
  16.150 @@ -1033,6 +1058,17 @@
  16.151      (insert (YaTeX-replace-format-args YaTeX-struct-end env)))
  16.152     (t nil)))
  16.153  
  16.154 +(defun YaTeX-string-width (str)
  16.155 +  "Return the display width of string."
  16.156 +  (if (fboundp 'string-width)
  16.157 +      (string-width str)
  16.158 +    (length str)))
  16.159 +(defun YaTeX-truncate-string-width (str width)
  16.160 +  (cond
  16.161 +   ((fboundp 'truncate-string-to-width) (truncate-string-to-width str width))
  16.162 +   ((fboundp 'truncate-string) (truncate-string str width))
  16.163 +   (t (substring str 0 width))))
  16.164 +
  16.165  ;;; Function for menu support
  16.166  (defun YaTeX-define-menu (keymap bindlist)
  16.167    "Define KEYMAP(symbol)'s menu-bindings according to BINDLIST.
  16.168 @@ -1093,9 +1129,17 @@
  16.169    (if (eq (selected-window) (minibuffer-window))
  16.170        (if (fboundp 'delete-field) (delete-field) (erase-buffer))))
  16.171  
  16.172 +(fset 'YaTeX-buffer-substring
  16.173 +      (if (fboundp 'buffer-substring-no-properties)
  16.174 +	  'buffer-substring-no-properties
  16.175 +	'buffer-substring))
  16.176 +
  16.177  ;;;
  16.178  ;; hilit19 vs. font-lock
  16.179  ;;;
  16.180 +(defvar YaTeX-19-functions-font-lock-direct
  16.181 +  '(YaTeX-19-re-search-in-env))
  16.182 +
  16.183  (defun YaTeX-convert-pattern-hilit2fontlock (h19pa)
  16.184    "Convert hilit19's H19PA patterns alist to font-lock's one.
  16.185  This function is a makeshift for YaTeX and yahtml."
  16.186 @@ -1113,6 +1157,7 @@
  16.187  	   (crossref . YaTeX-font-lock-crossref-face)
  16.188  	   (include . YaTeX-font-lock-include-face)
  16.189  	   (formula . YaTeX-font-lock-formula-face)
  16.190 +	   (delimiter . YaTeX-font-lock-delimiter-face)
  16.191  	   (string . ignore) (comment . ignore)
  16.192  	   )))
  16.193      (while (setq i (car palist))
  16.194 @@ -1138,33 +1183,45 @@
  16.195  		  0 (list 'quote newface) nil)) ;;'keep))
  16.196  	       flpa)))
  16.197         ((and (symbolp (car i)) (fboundp (car i)))
  16.198 -	(setq flpa
  16.199 -	      (cons
  16.200 -	       (list (car (cdr i))	;regexp
  16.201 -		     (list
  16.202 -		      (list
  16.203 -		       'lambda (list 'dummy)
  16.204 -		       '(goto-char (match-beginning 0))
  16.205 -		       '(remove-text-properties
  16.206 -			 (point) (min (point-max) (1+ (point)))
  16.207 -			 '(face nil font-lock-multiline nil))
  16.208 +	(if (memq (car i) YaTeX-19-functions-font-lock-direct)
  16.209 +	    ;; Put direct function call for it.
  16.210 +	    ;; When calling this function, fontify entire matched string.
  16.211 +	    (setq flpa
  16.212 +		  (cons
  16.213 +		   (list
  16.214 +		    (list 'lambda (list 'dummy) ;dummy should be boundary
  16.215 +			  (list (car i) (list 'quote (car (cdr i)))))
  16.216 +		    (list 0 newface))
  16.217 +		   flpa))
  16.218 +	  (setq flpa
  16.219 +		(cons
  16.220 +		 (list (car (cdr i))	;regexp
  16.221  		       (list
  16.222 -			'let (list '(e (match-end 0))
  16.223 -				   (list 'm (list (car i) (car (cdr i)))))
  16.224  			(list
  16.225 -			 'if 'm
  16.226 +			 'lambda (list 'dummy)
  16.227 +			 '(goto-char (match-beginning 0))
  16.228 +			 (if (eq (nth 3 i) 'overwrite)
  16.229 +			     nil
  16.230 +			   '(remove-text-properties
  16.231 +			     (point) (min (point-max) (1+ (point)))
  16.232 +			     '(face nil font-lock-multiline nil)))
  16.233  			 (list
  16.234 -			  'YaTeX-font-lock-fillin
  16.235 -			  (list 'car 'm)
  16.236 -			  (list 'cdr 'm)
  16.237 -			  (list 'quote 'face)
  16.238 -			  (list 'quote 'font-lock)
  16.239 -			  (list 'quote newface))
  16.240 -			 '(goto-char e)
  16.241 -			 ))
  16.242 -		       nil)		;retun nil to cheat font-lock
  16.243 -		      nil nil))		;pre-match, post-match both nil
  16.244 -	       flpa))))
  16.245 +			  'let (list '(e (match-end 0))
  16.246 +				     (list 'm (list (car i) (car (cdr i)))))
  16.247 +			  (list
  16.248 +			   'if 'm
  16.249 +			   (list
  16.250 +			    'YaTeX-font-lock-fillin
  16.251 +			    (list 'car 'm)
  16.252 +			    (list 'cdr 'm)
  16.253 +			    (list 'quote 'face)
  16.254 +			    (list 'quote 'font-lock)
  16.255 +			    (list 'quote newface))
  16.256 +			   '(goto-char e)
  16.257 +			   ))
  16.258 +			 nil)		;retun nil to cheat font-lock
  16.259 +			nil nil))	;pre-match, post-match both nil
  16.260 +		 flpa)))))
  16.261        (setq palist (cdr palist)));while
  16.262      (if (featurep 'xemacsp)
  16.263  	(nreverse flpa)
  16.264 @@ -1214,11 +1271,46 @@
  16.265      :group 'font-lock-faces)
  16.266    (defvar YaTeX-font-lock-formula-face 'YaTeX-font-lock-formula-face)
  16.267  
  16.268 +  (defface YaTeX-font-lock-delimiter-face
  16.269 +    '((((class static-color)) (:bold t))
  16.270 +      (((type tty)) (:bold t))
  16.271 +      (((class color) (background dark))
  16.272 +       (:foreground "saddlebrown" :background "ivory" :bold t))
  16.273 +      (((class color) (background light)) (:foreground "red"))
  16.274 +      (t (:bold t :underline t)))
  16.275 +    "Font Lock mode face used to highlight delimiters."
  16.276 +    :group 'font-lock-faces)
  16.277 +  (defvar YaTeX-font-lock-delimiter-face 'YaTeX-font-lock-delimiter-face)
  16.278 +
  16.279 +  (defface YaTeX-font-lock-math-sub-face
  16.280 +    '((((class static-color)) (:bold t))
  16.281 +      (((type tty)) (:bold t))
  16.282 +      (((class color) (background dark))
  16.283 +       (:foreground "khaki" :bold t :underline t))
  16.284 +      (((class color) (background light))
  16.285 +       (:foreground "Goldenrod" :underline t))
  16.286 +      (t (:bold t :underline t)))
  16.287 +    "Font Lock mode face used to highlight subscripts in formula."
  16.288 +    :group 'font-lock-faces)
  16.289 +  (defvar YaTeX-font-lock-math-sub-face 'YaTeX-font-lock-math-sub-face)
  16.290 +
  16.291 +  (defface YaTeX-font-lock-math-sup-face
  16.292 +    '((((class static-color)) (:bold t))
  16.293 +      (((type tty)) (:bold t))
  16.294 +      (((class color) (background dark))
  16.295 +       (:bold nil :foreground "ivory" :background "lightyellow4"))
  16.296 +      (((class color) (background light))
  16.297 +       (:underline t :foreground "gold"))
  16.298 +      (t (:bold t :underline t)))
  16.299 +    "Font Lock mode face used to highlight superscripts in formula."
  16.300 +    :group 'font-lock-faces)
  16.301 +  (defvar YaTeX-font-lock-math-sup-face 'YaTeX-font-lock-math-sup-face)
  16.302 +
  16.303    (defface YaTeX-font-lock-crossref-face
  16.304      '((((class color) (background dark)) (:foreground "lightgoldenrod"))
  16.305        (((class color) (background light)) (:foreground "DarkGoldenrod"))
  16.306        (t (:bold t :underline t)))
  16.307 -    "Font Lock mode face used to highlight cress references."
  16.308 +    "Font Lock mode face used to highlight cross references."
  16.309      :group 'font-lock-faces)
  16.310    (defvar YaTeX-font-lock-crossref-face 'YaTeX-font-lock-crossref-face)
  16.311  
  16.312 @@ -1300,6 +1392,17 @@
  16.313        (select-window sw)))
  16.314    ))
  16.315  
  16.316 +(defun YaTeX-assoc-regexp (elt alist)
  16.317 +  "Like assoc, return a list of whose car match with ELT.  Search from ALIST.
  16.318 +Note that each car of cons-cell is regexp.  ELT is a plain text to be
  16.319 +compared by regexp."
  16.320 +  (let (x)
  16.321 +    (catch 'found
  16.322 +      (while alist
  16.323 +	(setq x (car (car alist)))
  16.324 +	(if (string-match x elt)
  16.325 +	    (throw 'found (car alist)))
  16.326 +	(setq alist (cdr alist))))))
  16.327  
  16.328  ;;;
  16.329  ;; Functions for the Installation time
  16.330 @@ -1315,10 +1418,25 @@
  16.331  	(mapcar 'byte-compile-file command-line-args-left)
  16.332  	(kill-emacs))))
  16.333  
  16.334 +(defun tfb-and-exit ()
  16.335 +  "Texinfo-format-buffer and kill-emacs."
  16.336 +  (if command-line-args-left
  16.337 +      (let ((load-path (cons ".." load-path)))
  16.338 +	(and (fboundp 'set-language-environment)
  16.339 +	     (featurep 'mule)
  16.340 +	     (set-language-environment "Japanese"))
  16.341 +	(mapcar (function
  16.342 +		 (lambda (arg)
  16.343 +		   (find-file arg)
  16.344 +		   (texinfo-format-buffer)
  16.345 +		   (basic-save-buffer)))
  16.346 +		command-line-args-left)
  16.347 +	(kill-emacs))))
  16.348 +
  16.349  (provide 'yatexlib)
  16.350  ; Local variables:
  16.351  ; fill-prefix: ";;; "
  16.352  ; paragraph-start: "^$\\|\\|;;;$"
  16.353  ; paragraph-separate: "^$\\|\\|;;;$"
  16.354 -; buffer-file-coding-system: sjis
  16.355 +; coding: sjis
  16.356  ; End:
    17.1 --- a/yatexmth.el	Thu Dec 25 04:10:32 2003 +0000
    17.2 +++ b/yatexmth.el	Sun Dec 24 06:16:52 2006 +0000
    17.3 @@ -1,8 +1,8 @@
    17.4  ;;; -*- Emacs-Lisp -*-
    17.5  ;;; YaTeX math-mode-specific functions.
    17.6  ;;; yatexmth.el
    17.7 -;;; (c)1993-2003 by HIROSE Yuuji [yuuji@yatex.org]
    17.8 -;;; Last modified Sun Mar 30 19:56:00 2003 on firestorm
    17.9 +;;; (c)1993-2006 by HIROSE Yuuji [yuuji@yatex.org]
   17.10 +;;; Last modified Sun Dec 24 15:13:15 2006 on firestorm
   17.11  ;;; $Id$
   17.12  
   17.13  ;;; [Customization guide]
   17.14 @@ -107,6 +107,11 @@
   17.15  (YaTeX-setq-math-sym YaTeX-image-neg		"イ"		"¬")
   17.16  (YaTeX-setq-math-sym YaTeX-image-flat		"b"		"♭")
   17.17  (YaTeX-setq-math-sym YaTeX-image-sqrt		""		"√")
   17.18 +(defvar YaTeX-image-nearrow '("__\n /|\n/" "  _\n  /|\n/" ))
   17.19 +(defvar YaTeX-image-nwarrow '(" __\n|\\\n  \\" " _\n|\\n   \"))
   17.20 +(defvar YaTeX-image-searrow '("\\\n \\|\n--`" "\\n  \|\n   ̄"))
   17.21 +(defvar YaTeX-image-swarrow '("  /\n|/\n'~~" "   /\n|/\n  ̄"))
   17.22 +
   17.23  
   17.24  (defvar
   17.25   YaTeX-math-sign-alist-default
   17.26 @@ -202,6 +207,7 @@
   17.27     ("-<"	"prec"		("-<"		"く"))
   17.28     ("-<="	"preceq"	("-<\n-"	"く\n="))
   17.29     ("<<"	"ll"		("<<"		"《"))
   17.30 +   (">>"	"gg"		(">>"		"》"))
   17.31     ;	:
   17.32     ;;arrows
   17.33     ("<-"	"leftarrow"	("<-"		"←"))
   17.34 @@ -224,6 +230,18 @@
   17.35     ("\C-n"	"downarrow"	("|\nv" "↓"))
   17.36     ("v|"	"downarrow"	("|\nv" "↓"))
   17.37     ("v||"	"Downarrow"	"||\n\\/")
   17.38 +   ("\C-p\C-f"	"nearrow"	YaTeX-image-nearrow)
   17.39 +   ("\C-f\C-p"	"nearrow"	YaTeX-image-nearrow)
   17.40 +   ("ne"	"nearrow"	YaTeX-image-nearrow)
   17.41 +   ("\C-p\C-b"	"nwarrow"	YaTeX-image-nwarrow)
   17.42 +   ("\C-b\C-p"	"nwarrow"	YaTeX-image-nwarrow)
   17.43 +   ("nw"	"nwarrow"	YaTeX-image-nwarrow)
   17.44 +   ("\C-n\C-f"	"searrow"	YaTeX-image-searrow)
   17.45 +   ("\C-f\C-n"	"searrow"	YaTeX-image-searrow)
   17.46 +   ("se"	"searrow"	YaTeX-image-searrow)
   17.47 +   ("\C-n\C-b"	"swarrow"       YaTeX-image-swarrow)
   17.48 +   ("\C-b\C-n"	"swarrow"	YaTeX-image-swarrow)
   17.49 +   ("sw"	"swarrow"	YaTeX-image-swarrow)
   17.50     ("|->"	"mapsto"	("|->"		"|→"))
   17.51     ("<-)"	"hookleftarrow"	("   ,\n<--+"	"   ヽ\n<--/"))
   17.52     ("(->"	"hookrightarrow" ("`\n+-->"	"/\n\-->"))
   17.53 @@ -259,6 +277,8 @@
   17.54     ("O+"	"bigoplus"	"/~~~\\\n| + |\n\\___/")
   17.55     ("Ox"	"bigotimes"	"/~~~\\\n| X |\n\\___/")
   17.56     ;;other marks
   17.57 +   ("angle"	"angle"		("/\n~" "∠"))
   17.58 +   ("/_"	"angle"		("/\n~" "∠"))
   17.59     ("Z"		"aleph"		"|\\|")
   17.60     ("|\\|"	"aleph"		"|\\|")
   17.61     ("h-"	"hbar"		"_\nh")
   17.62 @@ -282,6 +302,8 @@
   17.63     ("partial"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
   17.64     ("round"	"partial"	(" -+\n+-+\n+-+" YaTeX-image-partial))
   17.65     ("[]"	"Box"		"[]")
   17.66 +   ("no"	"notag"		"\\notag")
   17.67 +   (":"		"colon"		":")
   17.68     ("Diamond"	"Diamond"	"/\\\n\\/")
   17.69     ("3"		"triangle"	"/\\\n~~")
   17.70     ("C"		"clubsuit"	" o\no+o\n |")
   17.71 @@ -380,8 +402,8 @@
   17.72  (defvar YaTeX-math-display-width
   17.73    (* 8 (1+ (/ YaTeX-math-sign-width 8))))
   17.74  (defvar YaTeX-math-menu-map nil
   17.75 -  "Keymap used in YaTeX mathematical sign menu mode."
   17.76 -)
   17.77 +  "Keymap used in YaTeX mathematical sign menu mode.")
   17.78 +
   17.79  (if YaTeX-math-menu-map nil
   17.80    (setq YaTeX-math-menu-map (make-sparse-keymap))
   17.81    (define-key YaTeX-math-menu-map "n"	'next-line)
   17.82 @@ -400,8 +422,7 @@
   17.83    (define-key YaTeX-math-menu-map "q"	'abort-recursive-edit))
   17.84  
   17.85  (defvar YaTeX-math-exit-key "\e"
   17.86 -  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode."
   17.87 -)
   17.88 +  "*Key sequence after prefix key of YaTeX-math-mode to exit from math-mode.")
   17.89  
   17.90  (defmacro YaTeX-math-japanese-sign (list)
   17.91    (list 'nth 1 list))
   17.92 @@ -438,8 +459,7 @@
   17.93  		   " $'")))
   17.94        (setq YaTeX-math-mode nil)
   17.95        (message "Exit from math mode."))
   17.96 -    (set-buffer-modified-p (buffer-modified-p)))
   17.97 -)
   17.98 +    (set-buffer-modified-p (buffer-modified-p))))
   17.99  
  17.100  (defun YaTeX-math-forward (arg)
  17.101    (interactive "p")
  17.102 @@ -460,77 +480,81 @@
  17.103      (YaTeX-math-gets sign))
  17.104     ((symbolp sign)
  17.105      (YaTeX-math-gets (symbol-value sign)))
  17.106 -   (t sign))
  17.107 -)
  17.108 +   (t sign)))
  17.109  
  17.110  (defun YaTeX-math-get-sign (list)
  17.111 -  (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
  17.112 -)
  17.113 +  (YaTeX-math-gets (car (cdr-safe (cdr-safe list)))))
  17.114 +
  17.115  (defvar YaTeX-math-section-type-regexp
  17.116    "eqn\\\\\\sw+\\b"
  17.117    "*Regexp of section-type math-mode macro")
  17.118  
  17.119  (defun YaTeX-in-math-mode-p ()
  17.120 -  "If current position is supposed to be in LaTeX-math-mode, return t."
  17.121 -  (or (YaTeX-quick-in-environment-p
  17.122 -       (append
  17.123 -	'("math" "eqnarray" "equation" "eqnarray*" "displaymath");LaTeX
  17.124 -	(if YaTeX-use-AMS-LaTeX
  17.125 -	    ;; And math modes of AMS-LaTeX
  17.126 -	    '("align" "align*" "split" "multline" "multline*" "gather"
  17.127 -	      "gather*" "aligned*" "gathered" "gathered*" "alignat"
  17.128 -	      "equation*" "cases" 
  17.129 -	      "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"))))
  17.130 -      (let*((p (point)) (nest 0) me0 r
  17.131 -	    (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
  17.132 -	    (boundary
  17.133 -	     (save-excursion
  17.134 -	       (if (looking-at delim)
  17.135 -		   (goto-char (max (point-min) (1- (point)))))
  17.136 -	       (re-search-backward delim nil 1)
  17.137 -	       (point))))
  17.138 -	(save-excursion
  17.139 -	  (cond
  17.140 -	   ((catch 'open
  17.141 -	      (save-excursion
  17.142 -		(while (and (>= nest 0)
  17.143 -			    (re-search-backward
  17.144 -			     (concat YaTeX-ec-regexp	;\
  17.145 -				     "\\([()]\\|[][]\\)") boundary t))
  17.146 -		  (setq me0 (match-end 0))
  17.147 -		  (if (or (YaTeX-on-comment-p)
  17.148 -			  (YaTeX-literal-p)) nil
  17.149 -		    (if (or (= (char-after (1- me0)) ?\))
  17.150 -			    (= (char-after (1- me0)) ?\]))
  17.151 -			(setq nest (1+ nest))
  17.152 -		      (if (= (preceding-char) ?\\ ) nil;;\\[5pt]
  17.153 -			(setq nest (1- nest))))))
  17.154 -		(if (< nest 0) (throw 'open t))))
  17.155 -	    t)
  17.156 -	   ((and (setq r (YaTeX-on-section-command-p
  17.157 -			  YaTeX-math-section-type-regexp))
  17.158 -		 (numberp r)
  17.159 -		 (> r 0))
  17.160 -	    t)
  17.161 -	   (t (catch 'dollar
  17.162 -		(while ;(search-backward "$" boundary t);little bit fast.
  17.163 -		    (YaTeX-re-search-active-backward ;;;;;; Too slow???
  17.164 -		     "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
  17.165 -		  (cond
  17.166 -		   ((equal (char-after (1- (point))) ?$) ; $$ equation $$
  17.167 -		    (backward-char 1)
  17.168 -		    (setq nest (1+ nest)))
  17.169 -		   ((let ((YaTeX-verbatim-environments
  17.170 -			   (append YaTeX-math-verbatim-environments
  17.171 -				   YaTeX-verbatim-environments)))
  17.172 -		      (YaTeX-literal-p))
  17.173 -		    nil)
  17.174 -		   ((and (equal (char-after (1- (point))) ?\\ )
  17.175 -			 (not (equal (char-after (- (point) 3)) ?\\ )))
  17.176 -		    nil)		;\$
  17.177 -		   (t (setq nest (1+ nest)))))
  17.178 -		(if (= (% nest 2) 1) (throw 'dollar t))))))))
  17.179 -)
  17.180 +  "If current position is supposed to be in LaTeX-math-mode, return t.
  17.181 +This function refers a local variable `source-window' in YaTeX-make-section."
  17.182 +  (save-excursion
  17.183 +    (and (boundp 'source-window) source-window
  17.184 +	 (set-buffer (window-buffer source-window)))
  17.185 +    (or (YaTeX-quick-in-environment-p
  17.186 +	 (append
  17.187 +	  '("math" "eqnarray" "equation" "eqnarray*" "displaymath") ;LaTeX
  17.188 +	  (if YaTeX-use-AMS-LaTeX
  17.189 +	      ;; And math modes of AMS-LaTeX
  17.190 +	      ;;'("align" "align*" "split" "multline" "multline*" "gather"
  17.191 +	      ;;  "gather*" "aligned*" "gathered" "gathered*" "alignat"
  17.192 +	      ;;  "equation*" "cases" "flalign" "flalign*"
  17.193 +	      ;;  "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"
  17.194 +	      YaTeX-math-begin-list
  17.195 +	    )))
  17.196 +	(let*((p (point)) (nest 0) me0 r
  17.197 +	      (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
  17.198 +	      (boundary
  17.199 +	       (save-excursion
  17.200 +		 (if (looking-at delim)
  17.201 +		     (goto-char (max (point-min) (1- (point)))))
  17.202 +		 (re-search-backward delim nil 1)
  17.203 +		 (point))))
  17.204 +	  (save-excursion
  17.205 +	    (cond
  17.206 +	     ((catch 'open
  17.207 +		(save-excursion
  17.208 +		  (while (and (>= nest 0)
  17.209 +			      (re-search-backward
  17.210 +			       (concat YaTeX-ec-regexp ;\
  17.211 +				       "\\([()]\\|[][]\\)") boundary t))
  17.212 +		    (setq me0 (match-end 0))
  17.213 +		    (if (or (YaTeX-on-comment-p)
  17.214 +			    (YaTeX-literal-p)) nil
  17.215 +		      (if (or (= (char-after (1- me0)) ?\))
  17.216 +			      (= (char-after (1- me0)) ?\]))
  17.217 +			  (setq nest (1+ nest))
  17.218 +			(if (= (preceding-char) ?\\ ) nil ;;\\[5pt]
  17.219 +			  (setq nest (1- nest))))))
  17.220 +		  (if (< nest 0) (throw 'open t))))
  17.221 +	      t)
  17.222 +	     ((and (setq r (YaTeX-on-section-command-p
  17.223 +			    YaTeX-math-section-type-regexp))
  17.224 +		   (numberp r)
  17.225 +		   (> r 0))
  17.226 +	      t)
  17.227 +	     (t (catch 'dollar
  17.228 +		  (while ;(search-backward "$" boundary t);little bit fast.
  17.229 +		      (YaTeX-re-search-active-backward ;;;;;; Too slow???
  17.230 +		       "\\$" (concat "[^\\\\]" YaTeX-comment-prefix) boundary t)
  17.231 +		    (cond
  17.232 +		     ((equal (char-after (1- (point))) ?$) ; $$ equation $$
  17.233 +		      (backward-char 1)
  17.234 +		      (setq nest (1+ nest)))
  17.235 +		     ((let ((YaTeX-verbatim-environments
  17.236 +			     (append YaTeX-math-verbatim-environments
  17.237 +				     YaTeX-verbatim-environments)))
  17.238 +			(YaTeX-literal-p))
  17.239 +		      nil)
  17.240 +		     ((and (equal (char-after (1- (point))) ?\\ )
  17.241 +			   (not (equal (char-after (- (point) 3)) ?\\ )))
  17.242 +		      nil)		;\$
  17.243 +		     (t (setq nest (1+ nest)))))
  17.244 +		  (if (= (% nest 2) 1) (throw 'dollar t))))))))))
  17.245  
  17.246  (defun YaTeX-math-display-list (list cols)
  17.247    (goto-char (point-max))
  17.248 @@ -589,8 +613,7 @@
  17.249  		   (prog2 (skip-chars-forward "^ \t\n") (point)))
  17.250  		nil))
  17.251  	(kill-buffer YaTeX-math-menu-buffer))
  17.252 -      command))
  17.253 -)
  17.254 +      command)))
  17.255  
  17.256  ;
  17.257  (defun YaTeX-math-show-image (image &optional exit-char)
  17.258 @@ -702,8 +725,8 @@
  17.259  
  17.260  	      (if match
  17.261  		  (progn (delete-region beg (point))
  17.262 -			 (setq single-command (car (cdr match)))
  17.263 -			 (insert YaTeX-ec single-command)
  17.264 +			 (setq YaTeX-single-command (car (cdr match)))
  17.265 +			 (insert YaTeX-ec YaTeX-single-command)
  17.266  			 (if (and YaTeX-math-need-image
  17.267  				  (setq sign (YaTeX-math-get-sign match)))
  17.268  			     (YaTeX-math-show-image (concat sign "\n")))
  17.269 @@ -716,14 +739,14 @@
  17.270        (if (eq result t)
  17.271  	  (setq unread-command-char last-char)
  17.272  	(message "Done."))
  17.273 -      (if (assoc single-command section-table)
  17.274 -	  (YaTeX-make-section nil nil nil single-command)
  17.275 +      (if (assoc YaTeX-single-command section-table)
  17.276 +	  (YaTeX-make-section nil nil nil YaTeX-single-command)
  17.277  	(setq YaTeX-current-completion-type 'maketitle)
  17.278 -	(YaTeX-make-singlecmd single-command)))
  17.279 +	(YaTeX-make-singlecmd YaTeX-single-command)))
  17.280       ((eq result 'abort)
  17.281        (message "Abort."))
  17.282       ((eq result 'escape)
  17.283 -      (call-interactively (global-key-binding this-key)))
  17.284 +      (call-interactively (lookup-key global-map this-key)))
  17.285       ((eq result 'exit)
  17.286        (YaTeX-toggle-math-mode))
  17.287       ((eq result 'menu)
  17.288 @@ -782,7 +805,7 @@
  17.289  				       (+ (point) 3 longest) t))
  17.290  	  (progn
  17.291  	    (setq move (- (point) point))
  17.292 -	    (setq paren (match-string 0))
  17.293 +	    (setq paren (YaTeX-match-string 0))
  17.294  	    (setq list YaTeX-ams-paren-modifier)
  17.295  	    ;; criterion for whether on [] () \{\} or not.
  17.296  	    (if (string-match YaTeX-left-paren paren)
  17.297 @@ -830,8 +853,8 @@
  17.298  						 paren-regexp "\\)")))
  17.299  			(setq flag nil)))
  17.300  		  (setq list (cdr list)))))
  17.301 -	    (if (<= move (length (match-string 0)))
  17.302 -		(match-string 0)))))))
  17.303 +	    (if (<= move (length (YaTeX-match-string 0)))
  17.304 +		(YaTeX-match-string 0)))))))
  17.305  
  17.306  (defun YaTeX-goto-open-paren (&optional jumpto-co)
  17.307    "Jump to the exact position of open parenthesis.
  17.308 @@ -872,8 +895,8 @@
  17.309    (interactive)
  17.310    (if (not (and YaTeX-use-AMS-LaTeX (YaTeX-on-parenthesis-p)))
  17.311        nil
  17.312 -    (let* ((mod (match-string 1)) ;; modifier
  17.313 -	   (paren (if mod (match-string 2) (match-string 0))) ;; paren
  17.314 +    (let* ((mod (YaTeX-match-string 1)) ;; modifier
  17.315 +	   (paren (if mod (YaTeX-match-string 2) (YaTeX-match-string 0))) ;; paren
  17.316  	   (mod-length (if (or (string= mod "\\left") (string= mod "\\right"))
  17.317  			   5            ;; 5 in case left or right
  17.318  			 (length mod))) ;; length of modifier
    18.1 --- a/yatexpkg.el	Thu Dec 25 04:10:32 2003 +0000
    18.2 +++ b/yatexpkg.el	Sun Dec 24 06:16:52 2006 +0000
    18.3 @@ -1,10 +1,13 @@
    18.4  ;;; -*- Emacs-Lisp -*-
    18.5  ;;; YaTeX package manager
    18.6  ;;; yatexpkg.el
    18.7 -;;; (c)2003 by HIROSE, Yuuji [yuuji@yatex.org]
    18.8 -;;; Last modified Thu Aug 28 18:24:33 2003 on firestorm
    18.9 +;;; (c)2003-2006 by HIROSE, Yuuji [yuuji@yatex.org]
   18.10 +;;; Last modified Sun Dec 24 15:13:29 2006 on firestorm
   18.11  ;;; $Id$
   18.12  
   18.13 +(defvar YaTeX-package-ams-envs
   18.14 +  (mapcar 'car YaTeX-ams-env-table))
   18.15 +
   18.16  (defvar YaTeX-package-alist-default
   18.17    '(("version"	(env "comment")		;by tsuchiya@pine.kuee.kyoto-u.ac.jp
   18.18       		(section "includeversion" "excludeversion"))
   18.19 @@ -14,6 +17,7 @@
   18.20      ("url"	(section "url"))	;by fujieda@jaist.ac.jp
   18.21  
   18.22      ("fancybox"	(section "shadowbox" "doublebox" "ovalbox" "Ovalbox"))
   18.23 +    ("slashbox"	(section "slashbox" "backslashbox"))
   18.24      ("pifont"	(section "ding"))
   18.25      ("longtable" (env "longtable"))
   18.26      ("ascmac"	(env "screen" "boxnote" "shadebox" "itembox")
   18.27 @@ -21,10 +25,20 @@
   18.28       		(section "keytop") ("mask") ("maskbox"))
   18.29      ("bm"	(section "bm"))		;by aoyama@le.chiba-u.ac.jp
   18.30  
   18.31 -    ("graphicx"	(section "includegraphics"))
   18.32      ("alltt"	(env "alltt"))
   18.33      ("misc"	(section "verbfile" "listing"))
   18.34 -    ("eclbkbox"	(env "breakbox")))
   18.35 +    ("eclbkbox"	(env "breakbox"))
   18.36 +    ("supertabular" (env "supertabular"))
   18.37 +    ("amsmath"	(env . YaTeX-package-ams-envs)
   18.38 +     		(section "tag" "tag*"))
   18.39 +    ("graphicx" (section "includegraphics"
   18.40 +			 "rotatebox" "scalebox" "resizebox" "reflectbox")
   18.41 +     		(option . YaTeX-package-graphics-driver-alist))
   18.42 +    ("color"	(section "textcolor" "colorbox" "pagecolor" "color")
   18.43 +     		(option . YaTeX-package-graphics-driver-alist))
   18.44 +    ("ulem"	(section "uline" "uuline" "uwave")
   18.45 +		(option ("normalem")))
   18.46 +    ("multicol"	(env "multicols")))
   18.47    "Default package vs. macro list.
   18.48  Alists contains '(PACKAGENAME . MACROLIST)
   18.49  PACKAGENAME     Basename of package(String).
   18.50 @@ -32,8 +46,21 @@
   18.51  TYPE	One of 'env, 'section or 'maketitle according to completion-type
   18.52  MACROS	List of macros
   18.53  
   18.54 +If TYPE is 'option, its cdr is alist of completion candidates for that
   18.55 +package.  Its cdr can be a symbol whose value is alist.
   18.56 +
   18.57  An good example is the value of YaTeX-package-alist-default.")
   18.58  
   18.59 +(defvar YaTeX-package-graphics-driver-alist
   18.60 +  '(("dvips") ("xdvi") ("dvipdf") ("pdftex") ("dvipsone") ("dviwindo")
   18.61 +    ("emtex") ("dviwin") ("oztex") ("textures") ("pctexps") ("pctexwin")
   18.62 +    ("pctexhp") ("pctex32") ("truetex") ("tcidvi") ("vtex"))
   18.63 +  "Drivers alist of graphics/color stylefile's supporting deveces.
   18.64 +This list is taken from
   18.65 +%% graphics.dtx Copyright (C) 1994      David Carlisle Sebastian Rahtz
   18.66 +%%              Copyright (C) 1995 1996 1997 1998 David Carlisle
   18.67 +as of 2004/1/19.  Thanks.")
   18.68 +
   18.69  (defvar YaTeX-package-alist-private nil
   18.70    "*User defined package vs. macro list. See also YaTeX-package-alist-default")
   18.71  
   18.72 @@ -42,23 +69,33 @@
   18.73  Optional second argument TYPE limits the macro type.
   18.74  TYPE is a symbol, one of 'env, 'section, 'maketitle."
   18.75    (let ((list (append YaTeX-package-alist-private YaTeX-package-alist-default))
   18.76 -	element x pkg pkglist r)
   18.77 +	element x val pkg pkglist r)
   18.78      (while list
   18.79        (setq element (car list)
   18.80  	    pkg (car element)
   18.81  	    element (cdr element))
   18.82        (if (setq r (catch 'found
   18.83  		    (while element
   18.84 -		      (setq x (car element))
   18.85 -		      (and (YaTeX-member macro (cdr x))
   18.86 -			   (or (null type)
   18.87 +		      (setq x (car element)
   18.88 +			    val (cdr x))
   18.89 +		      (if (symbolp val) (setq val (symbol-value val)))
   18.90 +		      (and (or (null type)
   18.91  			       (eq type (car x)))
   18.92 +			   (YaTeX-member macro val)
   18.93  			   (throw 'found (car x)))	;car x is type
   18.94  		      (setq element (cdr element)))))
   18.95  	  (setq pkglist (cons (cons pkg r) pkglist)))
   18.96        (setq list (cdr list)))
   18.97      pkglist))
   18.98  
   18.99 +(defun YaTeX-package-option-lookup (pkg)
  18.100 +  "Look up options for specified pkg and returne them in alist form.
  18.101 +Just only accocing against the alist of YaTeX-package-alist-*"
  18.102 +  (let ((l (cdr (assq 'option
  18.103 +		      (assoc pkg (append YaTeX-package-alist-private
  18.104 +					 YaTeX-package-alist-default))))))
  18.105 +    (if (symbolp l) (symbol-value l) l)))
  18.106 +
  18.107  (defvar YaTeX-package-resolved-list nil
  18.108    "List of macros whose package is confirmed to be loaded.")
  18.109  
  18.110 @@ -68,7 +105,7 @@
  18.111    (let ((cb (current-buffer))
  18.112  	(wc (current-window-configuration))
  18.113  	(usepackage (concat YaTeX-ec "usepackage"))
  18.114 -	(pkglist (YaTeX-package-lookup macro))
  18.115 +	(pkglist (YaTeX-package-lookup macro type))
  18.116  	(usepkgrx (concat
  18.117  		   YaTeX-ec-regexp
  18.118  		   "\\(usepackage\\|include\\)\\b"))
  18.119 @@ -76,7 +113,7 @@
  18.120  		     (set (make-local-variable 'YaTeX-package-resolved-list)
  18.121  			  (cons macro YaTeX-package-resolved-list))))
  18.122  	(begdoc (concat YaTeX-ec "begin{document}"))
  18.123 -	pb pkg mb0)
  18.124 +	pb pkg optlist (option "") mb0 uspkgargs)
  18.125      (if (or (YaTeX-member macro YaTeX-package-resolved-list)
  18.126  	    (null pkglist))
  18.127  	nil				;nothing to do
  18.128 @@ -89,14 +126,25 @@
  18.129  		(goto-char (point-min))
  18.130  		(YaTeX-search-active-forward	;if search fails, goto eob
  18.131  		 begdoc YaTeX-comment-prefix nil 1)
  18.132 -		(while (YaTeX-re-search-active-backward
  18.133 -			usepkgrx YaTeX-comment-prefix nil t)
  18.134 +		(while ;(YaTeX-re-search-active-backward
  18.135 +			;usepkgrx YaTeX-comment-prefix nil t)
  18.136 +		    ;;allow commented out \usepackages 2004/3/16
  18.137 +		    (re-search-backward usepkgrx nil t)
  18.138  		  (setq mb0 (match-beginning 0))
  18.139  		  (skip-chars-forward "^{")
  18.140 -		  (forward-char 1)
  18.141 +		  (setq uspkgargs (YaTeX-buffer-substring
  18.142 +				   (point)
  18.143 +				   (progn
  18.144 +				     ;;(forward-list 1) is more precise,
  18.145 +				     ;; but higher risk.
  18.146 +				     (skip-chars-forward "^}\n")(point))))
  18.147  		  (let ((pl pkglist))
  18.148  		    (while pl		;(car pl)'s car is package, cdr is type
  18.149 -		      (if (looking-at (regexp-quote (car (car pl))))
  18.150 +		      (if (string-match
  18.151 +			   (concat "[{,]\\s *"
  18.152 +				   (regexp-quote (car (car pl)))
  18.153 +				   "\\>")
  18.154 +			   uspkgargs)
  18.155  			  (throw 'found t))
  18.156  		      (setq pl (cdr pl)))
  18.157  		    (goto-char mb0))))
  18.158 @@ -106,6 +154,7 @@
  18.159  	    (if (y-or-n-p
  18.160  		 (format "`%s' requires package. Put \\usepackage now?" macro))
  18.161  		(progn
  18.162 +		  (require 'yatexadd)
  18.163  		  (setq pkg
  18.164  			(completing-read
  18.165  			 "Load which package?(TAB for list): "
  18.166 @@ -113,7 +162,21 @@
  18.167  			 ;;initial input
  18.168  			 (if (= (length pkglist) 1)
  18.169  			     (let ((w (car (car pkglist))))
  18.170 -			       (if YaTeX-emacs-19 (cons w 0) w)))))
  18.171 +			       (if YaTeX-emacs-19 (cons w 0) w))))
  18.172 +			optlist
  18.173 +			(YaTeX-package-option-lookup pkg))
  18.174 +		  (if optlist
  18.175 +		      (let ((minibuffer-completion-table optlist)
  18.176 +			    (delim ",") (w (car (car optlist))))
  18.177 +			(setq option
  18.178 +			      (read-from-minibuffer
  18.179 +			       (format "Any option for {%s}?: " pkg)
  18.180 +			       (if (= (length optlist) 1)
  18.181 +				   (if YaTeX-emacs-19 (cons w 0) w))
  18.182 +			       YaTeX-minibuffer-completion-map)
  18.183 +			      option (if (string< "" option)
  18.184 +					 (concat "[" option "]")
  18.185 +				       ""))))
  18.186  		  (set-buffer pb)
  18.187  		  (goto-char (point-min))
  18.188  		  (if (YaTeX-re-search-active-forward
  18.189 @@ -126,8 +189,8 @@
  18.190  		      (goto-char (match-beginning 0)))
  18.191  		  (insert
  18.192  		   usepackage
  18.193 -		   (format "{%s}\t%% required for `\\%s' (yatex added)\n"
  18.194 -			   pkg macro))
  18.195 +		   (format "%s{%s}\t%% required for `\\%s' (yatex added)\n"
  18.196 +			   option pkg macro))
  18.197  		  (funcall register))
  18.198  	      (message "Don't forget to put \\usepackage{%s} yourself later"
  18.199  		       (car (car pkglist)))) ;doing car car is negligence...
    19.1 --- a/yatexprc.el	Thu Dec 25 04:10:32 2003 +0000
    19.2 +++ b/yatexprc.el	Sun Dec 24 06:16:52 2006 +0000
    19.3 @@ -1,8 +1,8 @@
    19.4  ;;; -*- Emacs-Lisp -*-
    19.5  ;;; YaTeX process handler.
    19.6  ;;; yatexprc.el
    19.7 -;;; (c)1993-2003 by HIROSE Yuuji.[yuuji@yatex.org]
    19.8 -;;; Last modified Sun Nov  2 08:09:44 2003 on firestorm
    19.9 +;;; (c)1993-2006 by HIROSE Yuuji.[yuuji@yatex.org]
   19.10 +;;; Last modified Sun Dec 24 15:12:50 2006 on firestorm
   19.11  ;;; $Id$
   19.12  
   19.13  ;(require 'yatex)
   19.14 @@ -37,6 +37,7 @@
   19.15  ;;    ((boundp 'NEMACS)
   19.16  ;;     (cdr (assq (if YaTeX-dos 1 2) YaTeX-kanji-code-alist))))
   19.17    (cond
   19.18 +   (YaTeX-dos (cdr (assq 1 YaTeX-kanji-code-alist)))
   19.19     (YaTeX-emacs-20
   19.20      (cdr (assoc latex-message-kanji-code YaTeX-kanji-code-alist)))
   19.21     ((boundp 'MULE)
   19.22 @@ -317,7 +318,11 @@
   19.23    (YaTeX-typeset
   19.24     (read-string-with-history
   19.25      "Call command: "
   19.26 -    (concat base-cmd " " (YaTeX-get-preview-file-name))
   19.27 +    (concat base-cmd " "
   19.28 +	    (let ((me (file-name-nondirectory buffer-file-name)))
   19.29 +	      (if (string-match "\\.tex" me)
   19.30 +		  (substring me 0 (match-beginning 0))
   19.31 +		me)))
   19.32      'YaTeX-call-command-history)
   19.33     buffer))
   19.34  
   19.35 @@ -429,12 +434,13 @@
   19.36  		  (YaTeX-get-paper-type)))
   19.37       'YaTeX-preview-command-history)
   19.38      (read-string-with-history
   19.39 -     "Preview file[.dvi]: "
   19.40 +     "Preview file: "
   19.41       (if (get 'dvi2-command 'region)
   19.42  	 (substring YaTeX-texput-file
   19.43  		    0 (rindex YaTeX-texput-file ?.))
   19.44         (YaTeX-get-preview-file-name))
   19.45       'YaTeX-preview-file-history)))
   19.46 +  (if YaTeX-dos (setq preview-file (expand-file-name preview-file)))
   19.47    (setq dvi2-command preview-command)	;`dvi2command' is buffer local
   19.48    (save-excursion
   19.49      (YaTeX-visit-main t)
   19.50 @@ -511,7 +517,7 @@
   19.51  error or warning lines in reverse order."
   19.52    (interactive)
   19.53    (let ((cur-buf (buffer-name)) (cur-win (selected-window))
   19.54 -	error-line typeset-win error-buffer error-win)
   19.55 +	b0 errorp error-line typeset-win error-buffer error-win)
   19.56      (if (null (get-buffer YaTeX-typeset-buffer))
   19.57  	(error "There is no typesetting buffer."))
   19.58      (YaTeX-showup-buffer YaTeX-typeset-buffer nil t)
   19.59 @@ -520,10 +526,10 @@
   19.60  	 (concat "\\(" latex-error-regexp "\\)\\|\\("
   19.61  		 latex-warning-regexp "\\)")
   19.62  	 nil t)
   19.63 -	nil
   19.64 +	(setq errorp (match-beginning 1))
   19.65        (select-window cur-win)
   19.66        (error "No more errors on %s" cur-buf))
   19.67 -    (goto-char (match-beginning 0))
   19.68 +    (goto-char (setq b0 (match-beginning 0)))
   19.69      (skip-chars-forward "^0-9" (match-end 0))
   19.70      (setq error-line
   19.71  	  (string-to-int
   19.72 @@ -545,13 +551,13 @@
   19.73      (setq error-win (selected-window))
   19.74      (goto-line error-line)
   19.75      (message "LaTeX %s in `%s' on line: %d."
   19.76 -	     (if (match-beginning 1) "error" "warning")
   19.77 +	     (if errorp "error" "warning")
   19.78  	     error-buffer error-line)
   19.79      (select-window typeset-win)
   19.80      (skip-chars-backward "0-9")
   19.81      (recenter (/ (window-height) 2))
   19.82      (sit-for 1)
   19.83 -    (goto-char (match-beginning 0))
   19.84 +    (goto-char b0)
   19.85      (select-window error-win)))
   19.86  
   19.87  (defun YaTeX-jump-error-line ()
   19.88 @@ -653,18 +659,27 @@
   19.89  	(delete-matching-lines "^\\\\nonstopmode\\{\\}%_YaTeX_%$")
   19.90  	(widen))))
   19.91  
   19.92 +(defvar YaTeX-dvi2-command-ext-alist
   19.93 + '(("[agx]dvi\\|dviout" . ".dvi")
   19.94 +   ("ghostview\\|gv" . ".ps")
   19.95 +   ("acroread\\|pdf\\|Preview\\|TeXShop" . ".pdf")))
   19.96 +
   19.97  (defun YaTeX-get-preview-file-name ()
   19.98    "Get file name to preview by inquiring YaTeX-get-latex-command"
   19.99    (let* ((latex-cmd (YaTeX-get-latex-command t))
  19.100  	 (rin (rindex latex-cmd ? ))
  19.101  	 (fname (if (> rin -1) (substring latex-cmd (1+ rin)) ""))
  19.102 +	 (r (YaTeX-assoc-regexp dvi2-command YaTeX-dvi2-command-ext-alist))
  19.103 +	 (ext (if r (cdr r) ""))
  19.104  	 (period))
  19.105 -    (if (string= fname "")
  19.106 +    (concat
  19.107 +     (if (string= fname "")
  19.108  	(setq fname (substring (file-name-nondirectory
  19.109  				(buffer-file-name))
  19.110  			       0 -4))
  19.111        (setq period (rindex fname ?.))
  19.112 -      (setq fname (substring fname 0 (if (eq -1 period) nil period))))))
  19.113 +      (setq fname (substring fname 0 (if (eq -1 period) nil period))))
  19.114 +     ext)))
  19.115  
  19.116  (defun YaTeX-get-latex-command (&optional switch)
  19.117    "Specify the latex-command name and its argument.
  19.118 @@ -680,21 +695,27 @@
  19.119  	\"jlatex main.tex\"
  19.120  
  19.121  will be given to the shell."
  19.122 -  (let (magic command target)
  19.123 +  (let (parent tparent magic)
  19.124      (setq parent
  19.125  	  (cond
  19.126 -	   (YaTeX-parent-file YaTeX-parent-file)
  19.127 +	   (YaTeX-parent-file
  19.128 +	    (if YaTeX-dos (expand-file-name YaTeX-parent-file)
  19.129 +	      YaTeX-parent-file))
  19.130  	   (t (save-excursion
  19.131  		(YaTeX-visit-main t)
  19.132  		(file-name-nondirectory (buffer-file-name)))))
  19.133 -	  magic (YaTeX-get-builtin "!"))
  19.134 -    (cond
  19.135 -     (magic
  19.136 -      (cond
  19.137 -       (switch (if (string-match "\\s " magic) magic
  19.138 -		 (concat magic " " parent)))
  19.139 -       (t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
  19.140 -     (t (concat tex-command " " (if switch parent))))))
  19.141 +	  magic (YaTeX-get-builtin "!")
  19.142 +	  tparent (file-name-nondirectory parent))
  19.143 +    (YaTeX-replace-formats
  19.144 +     (cond
  19.145 +      (magic
  19.146 +       (cond
  19.147 +	(switch (if (string-match "\\s " magic) magic
  19.148 +		  (concat magic " " parent)))
  19.149 +	(t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
  19.150 +      (t (concat tex-command " " (if switch parent))))
  19.151 +     (list (cons "f" tparent)
  19.152 +	   (cons "r" (substring tparent 0 (rindex tparent ?.)))))))
  19.153  
  19.154  (defvar YaTeX-lpr-command-history nil
  19.155    "Holds command line history of YaTeX-lpr.")
  19.156 @@ -813,8 +834,9 @@
  19.157         ;;((and main-file (YaTeX-switch-to-buffer main-file setbuf)))
  19.158         ((and main-file
  19.159  	     (file-exists-p (setq main-file (concat "../" main-file)))
  19.160 -	     (y-or-n-p (concat (expand-file-name main-file)
  19.161 -			       " is main file?:")))
  19.162 +	     (or b-in
  19.163 +		 (y-or-n-p (concat (expand-file-name main-file)
  19.164 +				   " is main file?:"))))
  19.165  	(setq YaTeX-parent-file main-file)
  19.166  	;(YaTeX-switch-to-buffer main-file setbuf)
  19.167  	(funcall ff main-file)
  19.168 @@ -851,7 +873,7 @@
  19.169      (if (and (re-search-forward
  19.170  	      (concat "^" (regexp-quote (concat "%#" key))) nil t)
  19.171  	     (not (eolp)))
  19.172 -	(buffer-substring
  19.173 +	(YaTeX-buffer-substring
  19.174  	 (progn (skip-chars-forward " 	" (point-end-of-line))(point))
  19.175  	 (point-end-of-line))
  19.176        nil)))