changeset 77:1b172d26b55e

Fix auto-fill movement on Emacs21. Fix YaTeX:ref. Support jump/change on AMS-LaTeX's parentheses.
author yuuji
date Thu, 01 May 2003 13:38:27 +0000
parents c16a10460ce5
children 5b19f901fa16
files docs/htmlqa docs/qanda help/YATEXHLP.eng help/YATEXHLP.jp yahtml.el yatex.el yatex.new yatex19.el yatexadd.el yatexenv.el yatexlib.el yatexmth.el yatexprc.el yatexsec.el
diffstat 14 files changed, 292 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/docs/htmlqa	Mon Nov 25 09:33:34 2002 +0000
+++ b/docs/htmlqa	Thu May 01 13:38:27 2003 +0000
@@ -104,6 +104,17 @@
 	htmllintを使うとhtmllintに怒られないこと自体が目的となりがちです
 	が、わたしはそれは本末転倒であると思います。
 	
+・<a href="...">の途中で auto-fill されちゃうと悲しい
+	
+	使っているのがMule2(Emacs-19)以降なら auto-fill-inhibit-regexp
+	という変数でコントロールできます。 yahtml-mode-hook を使って以下
+	のように設定しましょう。
+	
+	(add-hook 'yahtml-mode-hook
+	          '(lambda ()
+		     (setq auto-fill-inhibit-regexp
+			   "^[       ]*\\(<a href\\|<img src=\\)")))
+	
 ■どうにかならんかなあ関連
 ・長い文書の下の方だとインデントがめちゃ遅いんだけど。
 	
--- a/docs/qanda	Mon Nov 25 09:33:34 2002 +0000
+++ b/docs/qanda	Thu May 01 13:38:27 2003 +0000
@@ -266,17 +266,6 @@
 	もし、デフォルトとは違う深さでfillしたい場合は、行の最初の非空白
 	文字にカーソルを合わせて M-q してください。
 	
-・<a href="...">の途中で auto-fill されちゃうと悲しい
-	
-	使っているのがMule2(Emacs-19)以降なら auto-fill-inhibit-regexp
-	という変数でコントロールできます。 yatex-mode-hook を使って以下
-	のように設定しましょう。
-	
-	(add-hook 'yahtml-mode-hook
-	          '(lambda ()
-		     (setq auto-fill-inhibit-regexp
-			   "^[       ]*\\(<a href\\|<img src=\\)")))
-	
 ・Win95/WinNTでタイプセッタなど外部プロセスが呼べない
 	
 	shellを変更していないならとりあえず、
@@ -609,7 +598,8 @@
 	のようにメイルを送れば加入できます。手続きは全て自動で行われ、登
 	録が完了すると確認とともに、参加/休止/脱会等の制御コマンドの利用
 	方法が返送されます。是非参加して一緒に野鳥/雷鳥/白鳥/飛鳥を育て
-	てください。
+	てください。なお、自己紹介の文が無い場合一見加入したように見えま
+	すが、自動的に登録解除しますので御注意下さい。
 	
 ・野鳥の最新情報は?
 	
--- a/help/YATEXHLP.eng	Mon Nov 25 09:33:34 2002 +0000
+++ b/help/YATEXHLP.eng	Thu May 01 13:38:27 2003 +0000
@@ -1153,11 +1153,12 @@
 abbrv	omit the first name of author, publishing month, book title
 
 thebibliography
-\begin{thebibliography} \bibitem{ITEM},... \end{thebibliography}
+\begin{thebibliography}{LONGEST-LABEL} \bibitem{ITEM},... \end{thebibliography}
 The thebibliography environment is a list environment.  To save the
 use of an extra counter, it should use  enumiv  as the item counter.
 Instead of using \item, items in the bibliography are produced by the 
 \bibitem command.
+LONGEST-LABEL is a dummy string to notify the maximum width of label.
 ---
 <refer bibitem>
 
--- a/help/YATEXHLP.jp	Mon Nov 25 09:33:34 2002 +0000
+++ b/help/YATEXHLP.jp	Thu May 01 13:38:27 2003 +0000
@@ -1106,7 +1106,7 @@
 abbrv	著者のファーストネーム、発行月、書籍名が省略される
 
 thebibliography
-\begin{thebibliography} \bibitem{アイテム}… \end{thebibliography}
+\begin{thebibliography}{LONGESTLABEL} \bibitem{アイテム}… \end{thebibliography}
 参考文献データの登録環境を開始する。
 データは \bibitem コマンドによって登録する。
 \bibitem コマンドの用法は以下の通り。
@@ -1114,9 +1114,10 @@
 
 bibitem
 \bibitem{NAME}			\bibitem[LABEL]{NAME}
-\bibitem{NAME}の書式では、NAMEで参照され、[1],[2] のような形で引用記号が
+\bibitem{NAME}の書式では、\cite{NAME}で参照され、[1],[2] のような形で引用記号が
 出力される、\bibitem[LABEL]{NAME}の書式では、\cite{NAME}で参照され、
 [LABEL] のような引用記号が出力される。
+LONGESTLABEL は、ラベルの最長を示すためのダミー文字列。
 
 cite
 \cite{NAME}			\cite[LABEL]{NAME}
--- a/yahtml.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yahtml.el	Thu May 01 13:38:27 2003 +0000
@@ -1,6 +1,6 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; (c ) 1994-2002 by HIROSE Yuuji [yuuji@yatex.org]
-;;; Last modified Wed May 22 13:55:01 2002 on firestorm
+;;; Last modified Thu Nov 21 17:55:40 2002 on firestorm
 ;;; $Id$
 
 (defconst yahtml-revision-number "1.70"
@@ -37,6 +37,20 @@
 ;;; 		("/home/staff/yuuji/html" . "http://www.othernet/~yuuji")))
 ;;;      ;UNIXの絶対パスと対応するURLのリストを書いて下さい。
 ;;; 
+;;; HTMLファイル漢字コードが正しく判別されるようにホームディレクトリに
+;;; .htaccess ファイルを作り以下のどれか1行を選んで書いて下さい。
+;;; 
+;;;	AddType "text/html; charset=Shift_JIS"	.html	(SJISの場合)
+;;;	AddType "text/html; charset=iso2022-jp"	.html	(JISの場合)
+;;;	AddType "text/html; charset=EUC-JP"	.html	(EUCの場合)
+;;; 
+;;; .htaccess が作れない場合は
+;;;	(setq yahtml-kanji-code 2)
+;;;	;HTMLファイルの漢字コードを変更する場合は 1=SJIS、2=JIS、3=EUC
+;;;	;で設定して下さい。デフォルトは 2 です。
+;;; 
+;;; を適切に書き換えて ~/.emacs に足して下さい。
+;;; 
 ;;;[Commentary]
 ;;;
 ;;; It is assumed you are already familiar with YaTeX.  The following
@@ -507,6 +521,7 @@
   (let*((fn (file-name-nondirectory (or buffer-file-name "")))
 	(ext (substring fn (or (string-match "\\.[a-z0-9]+$" fn) 0)))
 	(ptn (format "^\\s *AddType.*charset=\\(.*\\)\\%s$" ext))
+	(case-fold-search t)
 	line
 	charset)
     (if (setq line (yahtml-get-user-httpconf-entry ptn))
@@ -1506,7 +1521,7 @@
 (defun yahtml-insert-p (&optional arg)
   "Convenient function to insert <p></p>"
   (interactive "P")
-  (if arg (yahtml-insert-tag nil "p")
+  (if arg (yahtml-insert-tag arg "p")
     (save-excursion			;insert "/p" first to memorize "p"
       (yahtml-insert-single "/p"))	;in the last-completion variable
     (yahtml-insert-single "p")))
--- a/yatex.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatex.el	Thu May 01 13:38:27 2003 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; Yet Another tex-mode for emacs - //野鳥//
-;;; yatex.el rev. 1.70
-;;; (c )1991-2002 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Wed May 22 13:54:47 2002 on firestorm
+;;; yatex.el rev. 1.71
+;;; (c )1991-2003 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Thu May  1 22:36:40 2003 on firestorm
 ;;; $Id$
 ;;; The latest version of this software is always available at;
 ;;; http://www.yatex.org/
@@ -24,7 +24,7 @@
 
 (require 'comment)
 (require 'yatexlib)
-(defconst YaTeX-revision-number "1.70"
+(defconst YaTeX-revision-number "1.71"
   "Revision number of running yatex.el")
 
 ;---------- Local variables ----------
@@ -607,7 +607,7 @@
 	  '(dvi2-command fill-column fill-prefix
 	    tmp-env-table tmp-section-table tmp-fontsize-table
 	    tmp-singlecmd-table paragraph-start paragraph-separate
-	    YaTeX-math-mode indent-line-function
+	    YaTeX-math-mode indent-line-function comment-line-break-function
 	    comment-start comment-start-skip
 	    ))
   (cond ((boundp 'MULE)
@@ -632,8 +632,12 @@
 	comment-end ""
 	comment-start-skip "[^\\\\]%+[ \t]*"
 	local-abbrev-table yatex-mode-abbrev-table)
+  (if (fboundp 'comment-indent-new-line) ;for Emacs21
+      (setq comment-line-break-function 'YaTeX-comment-line-break))
+
   (if (and YaTeX-use-font-lock (featurep 'font-lock))
       (progn
+	(require 'yatex19)
 	(YaTeX-font-lock-set-default-keywords)
 	(or  (featurep 'xemacs)
 	     (set (make-local-variable 'font-lock-defaults)
@@ -698,6 +702,7 @@
 (autoload 'YaTeX-on-parenthesis-p "yatexmth" "Check if on math-parens" t)
 (autoload 'YaTeX-goto-open-paren "yatexmth" "Goto opening paren" t)
 (autoload 'YaTeX-change-parentheses "yatexmth" "Change corresponding parens" t)
+(autoload 'YaTeX-goto-corresponding-paren "yatexmth" "\bigl\bigr jumps" t)
 
 ;;autoload from yatexhlp.el
 (autoload 'YaTeX-help "yatexhlp" "YaTeX helper with LaTeX commands." t)
@@ -1356,7 +1361,8 @@
   (if (or (string-match YaTeX-array-env-regexp
 			(or (YaTeX-inner-environment t) "document"))
 	  (= (preceding-char) 92)
-	  (YaTeX-literal-p))
+	  (YaTeX-literal-p)
+	  (YaTeX-in-math-mode-p))
       (insert "&")
     (insert "\\&")))
 
@@ -1471,7 +1477,8 @@
       (setq scmd (cdr (assoc (YaTeX-match-string 1)
 			     '(("label" . "\\(page\\)?ref") ("ref" . "label")
 			       ("pageref" . "label")
-			       ("cite" . "bibitem") ("bibitem" . "cite")))))
+			       ("cite" . "bibitem\\(\\[[^]]+\\]\\)?")
+			       ("bibitem" . "cite\\(\\[[^]]+\\]\\)?")))))
       (goto-char (match-end 0))
       (let ((label (buffer-substring 
 		    (1- (point)) (progn (backward-list 1) (1+ (point))))))
@@ -1702,8 +1709,22 @@
     (while (setq i (string-match "\\\\(" command i))
       (setq grouping (1+ grouping) i (+ i 2)))
     (save-excursion
-      (if (looking-at YaTeX-ec-regexp) nil
+      (if (looking-at (concat YaTeX-ec-regexp command)) nil
 	(catch 'found			;caught value has no meaning
+	  ;;(1) looking at current position
+	  (if (looking-at command)
+	      (progn
+		(while (and (not (bobp)) (looking-at command))
+		  (forward-char -1))
+		(throw 'found t)))
+	  ;;(2) search command directly
+	  (skip-chars-forward "^{}[]")
+	  (and (YaTeX-re-search-active-backward
+		(concat YaTeX-ec-regexp command) YaTeX-comment-prefix nil t)
+	       (>= p (match-beginning 0))
+	       (throw 'found (goto-char (match-beginning 0))))
+	  ;;(3) search token
+	  (goto-char p)
 	  (while t
 	    (if (bobp) (throw 'found nil))
 	    (cond
@@ -1756,7 +1777,18 @@
 
 (defun YaTeX-on-begin-end-p ()
   (save-excursion
-    (beginning-of-line)
+    (if (and (boundp 'in-leftright-p) in-leftright-p)
+	;; Dirty workaround for YaTeX-goto-corresponding-leftright 2003/3/28
+	(let ((md (match-data)))	; for safety
+	  (if (looking-at YaTeX-ec-regexp)
+	      nil			; stay here
+	    (cond
+	     ((looking-at "\\w")		(skip-chars-backward "A-Za-z"))
+	     ((looking-at "\\.()\\[\\]|")	(forward-char -1)))
+	    (if (equal (char-after (1- (point)))
+		       (string-to-char YaTeX-ec))
+		(forward-char -1))))
+      (beginning-of-line))
     (re-search-forward
      ;;"\\\\begin{\\([^}]+\\)}\\|\\\\end{\\([^}]+\\)}"
      (concat
@@ -1798,17 +1830,22 @@
 (defun YaTeX-goto-corresponding-* (arg)
   "Parse current line and call suitable function."
   (interactive "P")
-  (cond
-   ((YaTeX-goto-corresponding-label arg))
-   ((YaTeX-goto-corresponding-environment))
-   ((YaTeX-goto-corresponding-file-processor arg))
-   ((YaTeX-goto-corresponding-file arg))
-   ((YaTeX-goto-corresponding-BEGIN-END))
-   ((and (string-match
-	  YaTeX-equation-env-regexp	;to delay loading
-	  (or (YaTeX-inner-environment t) "document"))
-	 (YaTeX-goto-corresponding-leftright)))
-   (t (message "I don't know where to go."))))
+  (let (mm)
+    (cond
+     ((YaTeX-goto-corresponding-label arg))
+     ((YaTeX-goto-corresponding-environment))
+     ((YaTeX-goto-corresponding-file-processor arg))
+     ((YaTeX-goto-corresponding-file arg))
+     ((YaTeX-goto-corresponding-BEGIN-END))
+     ((and (setq mm (YaTeX-in-math-mode-p))
+	   (YaTeX-goto-corresponding-leftright)))
+     ((and mm YaTeX-use-AMS-LaTeX
+	   (YaTeX-goto-corresponding-paren)))
+     ;;((and (string-match
+     ;;	  YaTeX-equation-env-regexp	;to delay loading
+     ;;	  (or (YaTeX-inner-environment t) "document"))
+     ;;	 (YaTeX-goto-corresponding-leftright)))
+     (t (message "I don't know where to go.")))))
 
 (defun YaTeX-goto-corresponding-*-other-window (arg)
   "Parse current line and call suitable function."
@@ -1836,11 +1873,11 @@
   "Uncomment out region by '%'."
   (interactive "P")
   (if (not (YaTeX-on-begin-end-p))
-      (uncomment-region
+      (uncomment-out-region
        (if alt-prefix (read-string "Remove prefix: ")
 	 YaTeX-comment-prefix)
        (region-beginning) (region-end) YaTeX-uncomment-once)
-    (YaTeX-comment-uncomment-env 'uncomment-region)))
+    (YaTeX-comment-uncomment-env 'uncomment-out-region)))
 
 (defun YaTeX-comment-uncomment-env (func)
   "Comment or uncomment out one LaTeX environment switching function by FUNC."
@@ -1893,7 +1930,7 @@
 		(paragraph-separate paragraph-start))
 	    (mark-paragraph)
 	    (if (not (bobp)) (forward-line 1))
-	    (uncomment-region "%" nil nil YaTeX-uncomment-once))
+	    (uncomment-out-region "%" nil nil YaTeX-uncomment-once))
 	(message "This line is not a comment line.")))))
 
 (defun YaTeX-remove-prefix (prefix &optional once)
@@ -2688,6 +2725,11 @@
 		  (looking-at "\\sw+")) ;is not japanese string
 		(insert YaTeX-comment-prefix)))))))
 
+(defun YaTeX-comment-line-break (&optional soft)
+  "Call comment-indent-new-line and YaTeX-indent-line"
+  (comment-indent-new-line soft)
+  (YaTeX-indent-line))
+
 (defun YaTeX-latex2e-p ()
   (let ((b (current-buffer))
 	(ptn (concat YaTeX-ec "documentclass")))
--- a/yatex.new	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatex.new	Thu May 01 13:38:27 2003 +0000
@@ -1,6 +1,16 @@
 	What's new in YaTeX/yahtml
 	野鳥/yahtml - 各バージョンの変更点について
 
+1.71	=== yatex ===
+	fill-prefix を指定している場合、Emacs21で \item の auto-fill が
+	\item の深さにかかわらず fill-prefix になってしまうのを回避
+	\refのラベル補完で、既にlabel定義してあるものがカウンタと\label
+	両方が補完候補に出現していたのを修正。またenumerate環境内では
+	\itemとラベルが重複して候補に現れていたのを修正。
+	Emacsの背景色の定義がXリソースに全く無いときの不具合修正
+	[prefix] c で AMS-LaTeX の大括弧対の種類を変えられるようにした
+	[prefix] g で AMS-LaTeX の括弧対間でジャンプできるようにした
+
 1.70	Emacs21でmake-frameがエラーになることがあるのを回避
 	font-lock での Recenter が効かなくなるのを修正
 	(他、細かい修正がほとんど)
--- a/yatex19.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatex19.el	Thu May 01 13:38:27 2003 +0000
@@ -1,7 +1,7 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX facilities for Emacs 19
-;;; (c )1994-2002 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Wed May 22 13:55:20 2002 on firestorm
+;;; (c )1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Fri Feb 21 01:35:19 2003 on firestorm
 ;;; $Id$
 
 ;(require 'yatex)
@@ -18,15 +18,15 @@
    ((boundp 'frame-background-mode) frame-background-mode)
    ((fboundp 'get-frame-background-mode)
     (get-frame-background-mode (selected-frame)))
-   (if (face-background 'default)
-       (if (> (+ 32768 32768 32768)
-	      (apply '+
-		     (funcall (if (fboundp 'color-rgb-components)
-				  'color-rgb-components
-				'x-color-values)
-			      (face-background 'default))))
-	   'dark
-	 'light))
+   ((face-background 'default)
+    (if (> (+ 32768 32768 32768)
+	   (apply '+
+		  (funcall (if (fboundp 'color-rgb-components)
+			       'color-rgb-components
+			     'x-color-values)
+			   (face-background 'default))))
+	'dark
+      'light))
    (t nil)))
 
 (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX"))
--- a/yatexadd.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatexadd.el	Thu May 01 13:38:27 2003 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX add-in functions.
-;;; yatexadd.el rev.14
-;;; (c )1991-2000 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Sat Sep 29 23:17:06 2001 on duke
+;;; yatexadd.el rev.15
+;;; (c )1991-2003 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Mon Mar 17 16:46:01 2003 on serow
 ;;; $Id$
 
 ;;;
@@ -144,7 +144,7 @@
 
 (defun YaTeX:thebibliography ()
   (setq YaTeX-section-name "bibitem")
-  "")
+  (concat "{" (read-string "Longest label: ") "}"))
 
 ;;;
 ;;Sample functions for section-type command.
@@ -492,9 +492,14 @@
 	(forward-list 1)
 	(skip-chars-forward " \t\n")
 	;(setq boundary "[^\\]")
+	(setq inspoint (point))
 	(setq boundary
 	      (save-excursion
-		(if (YaTeX-re-search-active-forward "[^\\]" r-escape nil 1)
+		(if (YaTeX-re-search-active-forward
+		     (concat YaTeX-ec-regexp
+			     "\\(" YaTeX-sectioning-regexp "\\|"
+			     "begin\\|item\\)")
+		     r-escape nil 1)
 		    (match-beginning 0)
 		  (1- (point))))))
        ((looking-at "item\\s ")
@@ -506,7 +511,8 @@
 		     (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")
 		     r-escape nil 1)
 		    (match-beginning 0)
-		  (1- (point))))))
+		  (1- (point))))
+	      inspoint boundary))
        ((looking-at "bibitem")
 	(setq labelholder "bibitem")	; label holder is bibitem itself
 	(setq boundary
@@ -515,7 +521,8 @@
 		     (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b")
 		     r-escape nil 1)
 		    (match-beginning 0)
-		  (1- (point))))))
+		  (1- (point))))
+	      inspoint boundary))
        ((string-match YaTeX::ref-mathenv-regexp
 		      (setq env (or (YaTeX-inner-environment t) "document")))
 	(setq mathp t)
@@ -526,7 +533,8 @@
 		     (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")
 		     r-escape nil 1)
 		    (match-beginning 0)
-		  (1- (point))))))
+		  (1- (point))))
+	      inspoint boundary))
        ((looking-at "footnote\\s *{")
 	(skip-chars-forward "^{")	;move onto `{'
 	(setq boundary
@@ -535,11 +543,15 @@
 		    (forward-list 1)
 		  (error (error "\\\\footnote at point %s's brace not closed"
 				(point))))
-		(1- (point)))))
+		(1- (point)))
+	      inspoint boundary))
        ((looking-at "caption\\|\\(begin\\)")
 	(skip-chars-forward "^{")
-	(if (match-beginning 1) (forward-list 1))
+	;;;;;;(if (match-beginning 1) (forward-list 1))
+	;; caption can be treated as mathenv, is it right??
+	(forward-list 1)
 	;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b"))
+	(setq inspoint (point))
 	(setq boundary
 	      (save-excursion
 		(if (YaTeX-re-search-active-forward
@@ -566,7 +578,7 @@
 	     (forward-sexp 1) (1- (point))))
 	;;else make a label
 	;(goto-char (match-beginning 0))
-	(goto-char boundary)
+	(goto-char inspoint)
 	(skip-chars-backward " \t\n")
 	(save-excursion (setq newlabel (YaTeX::ref-generate-label)))
 	(delete-region (point) (progn (skip-chars-backward " \t") (point)))
@@ -578,7 +590,7 @@
 
 (defvar YaTeX::ref-labeling-regexp-alist
   '(("\\\\begin{java}{\\([^}]+\\)}" . 1)
-    ("\\\\elabel{\\([^}]+\\)}" . 1)))
+    ("\\\\label{\\([^}]+\\)}" . 1)))
 (defvar YaTeX::ref-labeling-regexp
   (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|"))
 (defvar YaTeX::ref-mathenv-regexp
@@ -614,7 +626,7 @@
 			       (car s))))
 			YaTeX-sectioning-level))
 		 "\\|")
-		"\\|caption\\|footnote\\){"
+		"\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){"
 		"\\|\\(begin{\\(" mathenvs "\\|" enums  "\\)\\)\\)")))
 	  (regexp (concat "\\(" counter
 			  "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)"))
@@ -706,15 +718,21 @@
 				   (skip-chars-backward " \t")
 				   (1- (point)))
 			  (point-end-of-line)))
-		       x))))
-
+		       x))
+		    (setq e0 (point-max))))
+		 ;;else, simple section-type counter
 		 ((= (char-after (1- (point))) ?{)
 		  (setq label (buffer-substring
 			       (match-beginning 0)
 			       (progn (forward-char -1)
 				      (forward-list 1)
 				      (point))))
-		  (funcall output label match-point))
+		  (funcall output label match-point)
+		  ;; Skip preceding label if exists
+		  (if (save-excursion
+			(skip-chars-forward "\t \n")
+			(looking-at YaTeX::ref-labeling-regexp))
+		      (setq e0 (match-end 0))))
 		 (t
 		  (skip-chars-forward " \t")
 		  (setq label (buffer-substring
@@ -728,7 +746,10 @@
 				     (1- (point)))
 				 (point-end-of-line))))
 		  (funcall output label match-point)
-		  ))
+		  (if (save-excursion
+			(skip-chars-forward "\t \n")
+			(looking-at YaTeX::ref-labeling-regexp))
+		      (setq e0 (match-end 0)))))
 		) ;;put label buffer
 	       ;;
 	       ;; if user defined label found
@@ -834,9 +855,13 @@
 				      (point)))))))))
 	(setq files (cdr files))))))
 
+(defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem"
+  "*Regexp of macro name of bibitem definition")
+
 (defun YaTeX::cite-collect-bibs-internal ()
   "Collect bibentry in the current buffer and print them to standard output."
-  (let ((ptn (concat YaTeX-ec-regexp "bibitem\\b"))
+  (let ((ptn (concat YaTeX-ec-regexp
+		     "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b"))
 	(pcnt (regexp-quote YaTeX-comment-prefix)))
     (save-excursion
       (while (YaTeX-re-search-active-forward ptn pcnt nil t)
@@ -884,11 +909,22 @@
 	      (YaTeX::cite-collect-bibs-internal)))
 	;;Now bbuf holds the list of bibitem
 	(set-buffer bbuf)
-	(YaTeX::ref argp "\\\\\\(bibitem\\)\\(\\[.*\\]\\)?" "cite"))))
-  
+	(YaTeX::ref
+	 argp 
+	 (concat "\\\\\\("
+		 YaTeX::cite-bibitem-macro-regexp
+		 "\\)\\(\\[.*\\]\\)?")
+	 "cite"))))
+
    (t nil)))
 
+;;; for AMS-LaTeX
 (and YaTeX-use-AMS-LaTeX (fset 'YaTeX::eqref 'YaTeX::ref))
+;;; for Harvard citation style
+(fset 'YaTeX::citeasnoun 'YaTeX::cite)
+(fset 'YaTeX::possessivecite 'YaTeX::cite)
+(fset 'YaTeX::citeyear 'YaTeX::cite)
+(fset 'YaTeX::citename 'YaTeX::cite)
 
 (defun YaTeX-yatex-buffer-list ()
   (save-excursion
--- a/yatexenv.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatexenv.el	Thu May 01 13:38:27 2003 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX environment-specific functions.
 ;;; yatexenv.el
-;;; (c ) 1994-1997 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Thu Jan 18 15:21:26 2001 on buell
+;;; (c ) 1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Sun Mar 30 19:25:47 2003 on firestorm
 ;;; $Id$
 
 ;;;
@@ -280,12 +280,11 @@
 
 ;;;###autoload
 (defun YaTeX-goto-corresponding-leftright ()
-  "Go to corresponding \left or \right.
-Note that this function assumes the corresponding \left\right
-is on another line."
+  "Go to corresponding \left or \right."
   (let ((YaTeX-struct-begin "\\left%1")
 	(YaTeX-struct-end "\\right%1")
-	(YaTeX-struct-name-regexp "[][(){}\\.|]"))
+	(YaTeX-struct-name-regexp "[][(){}\\.|]")
+	(in-leftright-p t))
     (YaTeX-goto-corresponding-environment t)))
 
 ;;;
--- a/yatexlib.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatexlib.el	Thu May 01 13:38:27 2003 +0000
@@ -2,7 +2,7 @@
 ;;; YaTeX and yahtml common libraries, general functions and definitions
 ;;; yatexlib.el
 ;;; (c )1994-2002 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Wed May 22 13:55:31 2002 on firestorm
+;;; Last modified Wed Oct  2 23:35:33 2002 on firestorm
 ;;; $Id$
 
 ;; General variables
@@ -30,14 +30,16 @@
 (defvar YaTeX-kanji-code-alist
   (cond
    ((boundp '*junet*)
-    (list (cons
+    (list '(0 . *noconv*)
+	  (cons
 	   1
 	   (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos)
 	     *sjis*))
 	  '(2 . *junet*) '(3 . *euc-japan*)))
    (YaTeX-emacs-20
     ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
-    (list (cons
+    (list '(0 . no-conversion)
+	  (cons
 	   1 (cond (YaTeX-dos 'shift_jis-dos)
 		   ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
 		   (t 'sjis)))
@@ -724,7 +726,7 @@
   (cond
    ((and (string< "19" emacs-version) (not (featurep 'xemacs)))
     (insert-file-contents file visit beg end))
-   ((string-match "unix" (symbol-name system-type))
+   ((string-match "unix\\|linux" (symbol-name system-type))
     (let ((default-process-coding-system
 	    (and (boundp '*noconv*) (list '*noconv*)))
 	  (file-coding-system (and (boundp '*noconv*) '*noconv*))
@@ -734,7 +736,7 @@
 		    (or (and (boundp 'shell-command-option)
 			     shell-command-option)
 			"-c")
-		    (format "head -c %d | tail -c +%d" end beg))))
+		    (format "dd bs=1 count=%d | tail -c +%d" end beg))))
     (t (insert-file-contents file))))
 
 (defun YaTeX-split-string (str &optional sep null)
--- a/yatexmth.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatexmth.el	Thu May 01 13:38:27 2003 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX math-mode-specific functions.
 ;;; yatexmth.el
-;;; (c)1993-2000 by HIROSE Yuuji [yuuji@yatex.org]
-;;; Last modified Tue Dec 19 11:03:51 2000 on buell
+;;; (c)1993-2003 by HIROSE Yuuji [yuuji@yatex.org]
+;;; Last modified Sun Mar 30 19:56:00 2003 on firestorm
 ;;; $Id$
 
 ;;; [Customization guide]
@@ -466,6 +466,10 @@
 (defun YaTeX-math-get-sign (list)
   (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
 )
+(defvar YaTeX-math-section-type-regexp
+  "eqn\\\\\\sw+\\b"
+  "*Regexp of section-type math-mode macro")
+
 (defun YaTeX-in-math-mode-p ()
   "If current position is supposed to be in LaTeX-math-mode, return t."
   (or (YaTeX-quick-in-environment-p
@@ -477,7 +481,7 @@
 	      "gather*" "aligned*" "gathered" "gathered*" "alignat"
 	      "equation*" "cases" 
 	      "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"))))
-      (let*((p (point)) (nest 0) me0
+      (let*((p (point)) (nest 0) me0 r
 	    (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
 	    (boundary
 	     (save-excursion
@@ -503,6 +507,11 @@
 			(setq nest (1- nest))))))
 		(if (< nest 0) (throw 'open t))))
 	    t)
+	   ((and (setq r (YaTeX-on-section-command-p
+			  YaTeX-math-section-type-regexp))
+		 (numberp r)
+		 (> r 0))
+	    t)
 	   (t (catch 'dollar
 		(while ;(search-backward "$" boundary t);little bit fast.
 		    (YaTeX-re-search-active-backward ;;;;;; Too slow???
@@ -824,8 +833,9 @@
 	    (if (<= move (length (match-string 0)))
 		(match-string 0)))))))
 
-(defun YaTeX-goto-open-paren ()
-  "Jump to the exact position of open parenthesis"
+(defun YaTeX-goto-open-paren (&optional jumpto-co)
+  "Jump to the exact position of open parenthesis.
+If optional argument JUMPTO-CO is non-nil, goto corresponding parentheses."
   (interactive)
   (let ((paren)
 	(backslash-syntax (char-to-string (char-syntax ?\\))))
@@ -833,14 +843,30 @@
 	(if (string-match "(\\|{\\|\\[" paren (1- (length paren)))
 	    (progn
 	      (re-search-forward "(\\|{\\|\\[" (+ (point) (length paren)) t)
-	      (backward-char))
+	      (backward-char)
+	      (if jumpto-co
+		  (unwind-protect
+		      (progn
+			(modify-syntax-entry ?\\ " ")
+			(forward-list)
+			(backward-char))
+		    (modify-syntax-entry ?\\ backslash-syntax)))
+	      (point))
 	  (re-search-forward ")\\|}\\|\\]" (+ (point) (length paren)) t)
 	  (unwind-protect
 	      (progn
 		(modify-syntax-entry ?\\ " ")
-		(backward-list))
+		(backward-list)
+		(point))
 	    (modify-syntax-entry ?\\ backslash-syntax))))))
 
+;;;###autoload
+(defun YaTeX-goto-corresponding-paren ()
+  "Go to corresponding mathematical parentheses."
+  (if (YaTeX-on-parenthesis-p)
+      (YaTeX-goto-open-paren t)
+    nil))
+
 (defun YaTeX-change-parentheses ()
   "Change the size of parentheses, braces, and brackets of AMS-LaTeX."
   (interactive)
@@ -855,6 +881,7 @@
 	   (length (+ mod-length paren-length)) ;; length of whole string
 	   (big-p t) ;; flag whether new modifier is "[Bb]ig+" or not.
 	   size ;; left, big, Big etc.
+	   type ;; parentheses type
 	   lr   ;; "l" or "r".
 	   char newsize newsize-length
 	   (backslash-syntax (char-to-string (char-syntax ?\\)))
@@ -876,7 +903,7 @@
       (while (not newsize)
 	(message (format (concat "Change from %s: "
 				 "l(big) L(Big) h(bigg) H(Bigg) "
-				 "r(left-right) n(NONE) ") size))
+				 "r(left-right) n(NONE) ( { [") size))
 	(setq char (read-char)
 	      newsize (cond ((char-equal char ?l) "\\big")
 			    ((char-equal char ?L) "\\Big")
@@ -884,28 +911,43 @@
 			    ((char-equal char ?H) "\\Bigg")
 			    ((char-equal char ?r)
 			     (setq big-p nil) "\\left")
+			    ((memq char '(?\( ?\)))
+			     (setq big-p nil type '("(" . ")")) "")
+			    ((memq char '(?\{ ?\}))
+			     (setq big-p nil type '("\\{" . "\\}")) "")
+			    ((memq char '(?\[ ?\]))
+			     (setq big-p nil type '("[" . "]")) "")
 			    ((char-equal char ?n)
 			     (setq big-p nil) "")
 			    (t nil))
 	      newsize-length (length newsize)))
       (YaTeX-goto-open-paren)
       (forward-char)
-      (delete-region (- (point) length) (- (point) paren-length))
-      (backward-char paren-length)
+      (cond
+       (type
+	(delete-region (point) (- (point) paren-length))
+	(save-excursion (insert (car type))))
+       (t
+	(delete-region (- (point) length) (- (point) paren-length))
+	(backward-char paren-length)))
       (insert-string newsize)
       (if big-p (insert ?l))
-      (forward-char (1- paren-length))
       (unwind-protect
 	  (progn
 	    (modify-syntax-entry ?\\ " ")
 	    (forward-list)
 	    (if (string= size "left-right") (setq length (1+ length)))
 	    (if (eq char ?r) (setq newsize "\\right"))
-	    (delete-region (- (point) length) (- (point) paren-length))
-	    (backward-char paren-length)
-	    (insert-string newsize)
-	    (if big-p (insert ?r))
-	    (forward-char paren-length)
+	    (cond
+	     (type
+	      (delete-region (point) (- (point) paren-length))
+	      (insert (cdr type)))
+	     (t
+	      (delete-region (- (point) length) (- (point) paren-length))
+	      (backward-char paren-length)
+	      (insert-string newsize)
+	      (if big-p (insert ?r))
+	      (forward-char paren-length)))
 	    (if (string= lr "l") (backward-list)))
 	(modify-syntax-entry ?\\ backslash-syntax))
       t)))
--- a/yatexprc.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatexprc.el	Thu May 01 13:38:27 2003 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX process handler.
 ;;; yatexprc.el
-;;; (c )1993-2000 by HIROSE Yuuji.[yuuji@yatex.org]
-;;; Last modified Sun Dec 31 21:57:44 2000 on firestorm
+;;; (c )1993-2003 by HIROSE Yuuji.[yuuji@yatex.org]
+;;; Last modified Thu May  1 22:37:31 2003 on firestorm
 ;;; $Id$
 
 ;(require 'yatex)
@@ -386,18 +386,20 @@
 (defun YaTeX-get-paper-type ()
   "Search options in header and return a paper type, such as \"a4\", \"a4r\", etc."
   (save-excursion
+    (YaTeX-visit-main t)
     (goto-char (point-min))
-    (if (re-search-forward
-	 "^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t)
-	(let ((opts (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*")))
-	  (concat
-	   (catch 'found-paper
-	     (mapcar (lambda (pair)
-		       (if (member (car pair) opts)
-			   (throw 'found-paper (cdr pair))))
-		     YaTeX-paper-type-alist)
-	     YaTeX-default-paper-type)
-	   (if (member "landscape" opts) "r" ""))))))
+    (let ((opts
+	   (if (re-search-forward
+		"^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t)
+	       (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*"))))
+      (concat
+       (catch 'found-paper
+	 (mapcar (lambda (pair)
+		   (if (member (car pair) opts)
+		       (throw 'found-paper (cdr pair))))
+		 YaTeX-paper-type-alist)
+	 YaTeX-default-paper-type)
+       (if (member "landscape" opts) "r" "")))))
 
 (defvar YaTeX-preview-command-history nil
   "Holds minibuffer history of preview command.")
--- a/yatexsec.el	Mon Nov 25 09:33:34 2002 +0000
+++ b/yatexsec.el	Thu May 01 13:38:27 2003 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX sectioning browser.
 ;;; yatexsec.el
-;;; (c ) 1994,1998,1999 by HIROSE Yuuji [yuuji@yatex.org]
-;;; Last modified Mon Dec 25 19:18:36 2000 on firestorm
+;;; (c ) 1994,1998,1999,2003 by HIROSE Yuuji [yuuji@yatex.org]
+;;; Last modified Wed Mar  5 13:19:11 2003 on firestorm
 ;;; $Id$
 
 (defvar YaTeX-sectioning-level
@@ -115,20 +115,35 @@
 
 (defvar YaTeX-sectioning-buffer-parent nil)
 (defun YaTeX-sectioning-buffer-jump-internal (&optional keep)
-  (let (ptn (p (point)))		;save-excursion is NG because
-    (beginning-of-line)		;this function should switch buffer
+  (let ((p (point))		;save-excursion is NG because
+	ptn ln)			;this function should switch buffer
+    (beginning-of-line)
     (if (re-search-forward YaTeX-sectioning-regexp)
-	(progn (setq ptn (buffer-substring
-			  (1- (match-beginning 0))
-			  (progn (skip-chars-forward "^}") (1+ (point)))))
-	       (goto-char p)
-	       (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t)
-	       (goto-char (point-max))
-	       (search-backward ptn)
-	       (if keep (goto-buffer-window YaTeX-sectioning-buffer))
-	       (current-buffer))
-      nil))
-)
+	(progn
+	  (save-restriction
+	    (narrow-to-region (point-beginning-of-line) (point-end-of-line))
+	    (setq ptn (buffer-substring
+		       (1- (match-beginning 0))
+		       (progn (skip-chars-forward "^}") (1+ (point))))
+		  ln (buffer-substring
+		      (progn (search-forward "line:") (match-end 0))
+		      (progn (skip-chars-forward "0-9") (point)))))
+	  (goto-char p)
+	  (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t)
+	  (or
+	   (and ln (string< "" ln)
+		(progn
+		  (goto-line (max 1 (1- (string-to-int ln))))
+		  (and
+		   (search-forward ptn nil t)
+		   (goto-char (match-beginning 0)))))
+	   (progn
+	     (goto-char (point-max))
+	     (search-backward ptn)))
+	  (if keep (goto-buffer-window YaTeX-sectioning-buffer))
+	  (current-buffer))
+      nil)))
+
 (defun YaTeX-sectioning-buffer-jump (&optional keep)
   "Goto corresponding sectioning unit with current line in the next window.
 If optional argument KEEP is non-nil, only shows the line."

yatex.org