yatex

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 diff
     1.1 --- a/docs/htmlqa	Mon Nov 25 09:33:34 2002 +0000
     1.2 +++ b/docs/htmlqa	Thu May 01 13:38:27 2003 +0000
     1.3 @@ -104,6 +104,17 @@
     1.4  	htmllintを使うとhtmllintに怒られないこと自体が目的となりがちです
     1.5  	が、わたしはそれは本末転倒であると思います。
     1.6  	
     1.7 +・<a href="...">の途中で auto-fill されちゃうと悲しい
     1.8 +	
     1.9 +	使っているのがMule2(Emacs-19)以降なら auto-fill-inhibit-regexp
    1.10 +	という変数でコントロールできます。 yahtml-mode-hook を使って以下
    1.11 +	のように設定しましょう。
    1.12 +	
    1.13 +	(add-hook 'yahtml-mode-hook
    1.14 +	          '(lambda ()
    1.15 +		     (setq auto-fill-inhibit-regexp
    1.16 +			   "^[       ]*\\(<a href\\|<img src=\\)")))
    1.17 +	
    1.18  ■どうにかならんかなあ関連
    1.19  ・長い文書の下の方だとインデントがめちゃ遅いんだけど。
    1.20  	
     2.1 --- a/docs/qanda	Mon Nov 25 09:33:34 2002 +0000
     2.2 +++ b/docs/qanda	Thu May 01 13:38:27 2003 +0000
     2.3 @@ -266,17 +266,6 @@
     2.4  	もし、デフォルトとは違う深さでfillしたい場合は、行の最初の非空白
     2.5  	文字にカーソルを合わせて M-q してください。
     2.6  	
     2.7 -・<a href="...">の途中で auto-fill されちゃうと悲しい
     2.8 -	
     2.9 -	使っているのがMule2(Emacs-19)以降なら auto-fill-inhibit-regexp
    2.10 -	という変数でコントロールできます。 yatex-mode-hook を使って以下
    2.11 -	のように設定しましょう。
    2.12 -	
    2.13 -	(add-hook 'yahtml-mode-hook
    2.14 -	          '(lambda ()
    2.15 -		     (setq auto-fill-inhibit-regexp
    2.16 -			   "^[       ]*\\(<a href\\|<img src=\\)")))
    2.17 -	
    2.18  ・Win95/WinNTでタイプセッタなど外部プロセスが呼べない
    2.19  	
    2.20  	shellを変更していないならとりあえず、
    2.21 @@ -609,7 +598,8 @@
    2.22  	のようにメイルを送れば加入できます。手続きは全て自動で行われ、登
    2.23  	録が完了すると確認とともに、参加/休止/脱会等の制御コマンドの利用
    2.24  	方法が返送されます。是非参加して一緒に野鳥/雷鳥/白鳥/飛鳥を育て
    2.25 -	てください。
    2.26 +	てください。なお、自己紹介の文が無い場合一見加入したように見えま
    2.27 +	すが、自動的に登録解除しますので御注意下さい。
    2.28  	
    2.29  ・野鳥の最新情報は?
    2.30  	
     3.1 --- a/help/YATEXHLP.eng	Mon Nov 25 09:33:34 2002 +0000
     3.2 +++ b/help/YATEXHLP.eng	Thu May 01 13:38:27 2003 +0000
     3.3 @@ -1153,11 +1153,12 @@
     3.4  abbrv	omit the first name of author, publishing month, book title
     3.5  
     3.6  thebibliography
     3.7 -\begin{thebibliography} \bibitem{ITEM},... \end{thebibliography}
     3.8 +\begin{thebibliography}{LONGEST-LABEL} \bibitem{ITEM},... \end{thebibliography}
     3.9  The thebibliography environment is a list environment.  To save the
    3.10  use of an extra counter, it should use  enumiv  as the item counter.
    3.11  Instead of using \item, items in the bibliography are produced by the 
    3.12  \bibitem command.
    3.13 +LONGEST-LABEL is a dummy string to notify the maximum width of label.
    3.14  ---
    3.15  <refer bibitem>
    3.16  
     4.1 --- a/help/YATEXHLP.jp	Mon Nov 25 09:33:34 2002 +0000
     4.2 +++ b/help/YATEXHLP.jp	Thu May 01 13:38:27 2003 +0000
     4.3 @@ -1106,7 +1106,7 @@
     4.4  abbrv	著者のファーストネーム、発行月、書籍名が省略される
     4.5  
     4.6  thebibliography
     4.7 -\begin{thebibliography} \bibitem{アイテム}… \end{thebibliography}
     4.8 +\begin{thebibliography}{LONGESTLABEL} \bibitem{アイテム}… \end{thebibliography}
     4.9  参考文献データの登録環境を開始する。
    4.10  データは \bibitem コマンドによって登録する。
    4.11  \bibitem コマンドの用法は以下の通り。
    4.12 @@ -1114,9 +1114,10 @@
    4.13  
    4.14  bibitem
    4.15  \bibitem{NAME}			\bibitem[LABEL]{NAME}
    4.16 -\bibitem{NAME}の書式では、NAMEで参照され、[1],[2] のような形で引用記号が
    4.17 +\bibitem{NAME}の書式では、\cite{NAME}で参照され、[1],[2] のような形で引用記号が
    4.18  出力される、\bibitem[LABEL]{NAME}の書式では、\cite{NAME}で参照され、
    4.19  [LABEL] のような引用記号が出力される。
    4.20 +LONGESTLABEL は、ラベルの最長を示すためのダミー文字列。
    4.21  
    4.22  cite
    4.23  \cite{NAME}			\cite[LABEL]{NAME}
     5.1 --- a/yahtml.el	Mon Nov 25 09:33:34 2002 +0000
     5.2 +++ b/yahtml.el	Thu May 01 13:38:27 2003 +0000
     5.3 @@ -1,6 +1,6 @@
     5.4  ;;; -*- Emacs-Lisp -*-
     5.5  ;;; (c ) 1994-2002 by HIROSE Yuuji [yuuji@yatex.org]
     5.6 -;;; Last modified Wed May 22 13:55:01 2002 on firestorm
     5.7 +;;; Last modified Thu Nov 21 17:55:40 2002 on firestorm
     5.8  ;;; $Id$
     5.9  
    5.10  (defconst yahtml-revision-number "1.70"
    5.11 @@ -37,6 +37,20 @@
    5.12  ;;; 		("/home/staff/yuuji/html" . "http://www.othernet/~yuuji")))
    5.13  ;;;      ;UNIXの絶対パスと対応するURLのリストを書いて下さい。
    5.14  ;;; 
    5.15 +;;; HTMLファイル漢字コードが正しく判別されるようにホームディレクトリに
    5.16 +;;; .htaccess ファイルを作り以下のどれか1行を選んで書いて下さい。
    5.17 +;;; 
    5.18 +;;;	AddType "text/html; charset=Shift_JIS"	.html	(SJISの場合)
    5.19 +;;;	AddType "text/html; charset=iso2022-jp"	.html	(JISの場合)
    5.20 +;;;	AddType "text/html; charset=EUC-JP"	.html	(EUCの場合)
    5.21 +;;; 
    5.22 +;;; .htaccess が作れない場合は
    5.23 +;;;	(setq yahtml-kanji-code 2)
    5.24 +;;;	;HTMLファイルの漢字コードを変更する場合は 1=SJIS、2=JIS、3=EUC
    5.25 +;;;	;で設定して下さい。デフォルトは 2 です。
    5.26 +;;; 
    5.27 +;;; を適切に書き換えて ~/.emacs に足して下さい。
    5.28 +;;; 
    5.29  ;;;[Commentary]
    5.30  ;;;
    5.31  ;;; It is assumed you are already familiar with YaTeX.  The following
    5.32 @@ -507,6 +521,7 @@
    5.33    (let*((fn (file-name-nondirectory (or buffer-file-name "")))
    5.34  	(ext (substring fn (or (string-match "\\.[a-z0-9]+$" fn) 0)))
    5.35  	(ptn (format "^\\s *AddType.*charset=\\(.*\\)\\%s$" ext))
    5.36 +	(case-fold-search t)
    5.37  	line
    5.38  	charset)
    5.39      (if (setq line (yahtml-get-user-httpconf-entry ptn))
    5.40 @@ -1506,7 +1521,7 @@
    5.41  (defun yahtml-insert-p (&optional arg)
    5.42    "Convenient function to insert <p></p>"
    5.43    (interactive "P")
    5.44 -  (if arg (yahtml-insert-tag nil "p")
    5.45 +  (if arg (yahtml-insert-tag arg "p")
    5.46      (save-excursion			;insert "/p" first to memorize "p"
    5.47        (yahtml-insert-single "/p"))	;in the last-completion variable
    5.48      (yahtml-insert-single "p")))
     6.1 --- a/yatex.el	Mon Nov 25 09:33:34 2002 +0000
     6.2 +++ b/yatex.el	Thu May 01 13:38:27 2003 +0000
     6.3 @@ -1,8 +1,8 @@
     6.4  ;;; -*- Emacs-Lisp -*-
     6.5  ;;; Yet Another tex-mode for emacs - //野鳥//
     6.6 -;;; yatex.el rev. 1.70
     6.7 -;;; (c )1991-2002 by HIROSE Yuuji.[yuuji@yatex.org]
     6.8 -;;; Last modified Wed May 22 13:54:47 2002 on firestorm
     6.9 +;;; yatex.el rev. 1.71
    6.10 +;;; (c )1991-2003 by HIROSE Yuuji.[yuuji@yatex.org]
    6.11 +;;; Last modified Thu May  1 22:36:40 2003 on firestorm
    6.12  ;;; $Id$
    6.13  ;;; The latest version of this software is always available at;
    6.14  ;;; http://www.yatex.org/
    6.15 @@ -24,7 +24,7 @@
    6.16  
    6.17  (require 'comment)
    6.18  (require 'yatexlib)
    6.19 -(defconst YaTeX-revision-number "1.70"
    6.20 +(defconst YaTeX-revision-number "1.71"
    6.21    "Revision number of running yatex.el")
    6.22  
    6.23  ;---------- Local variables ----------
    6.24 @@ -607,7 +607,7 @@
    6.25  	  '(dvi2-command fill-column fill-prefix
    6.26  	    tmp-env-table tmp-section-table tmp-fontsize-table
    6.27  	    tmp-singlecmd-table paragraph-start paragraph-separate
    6.28 -	    YaTeX-math-mode indent-line-function
    6.29 +	    YaTeX-math-mode indent-line-function comment-line-break-function
    6.30  	    comment-start comment-start-skip
    6.31  	    ))
    6.32    (cond ((boundp 'MULE)
    6.33 @@ -632,8 +632,12 @@
    6.34  	comment-end ""
    6.35  	comment-start-skip "[^\\\\]%+[ \t]*"
    6.36  	local-abbrev-table yatex-mode-abbrev-table)
    6.37 +  (if (fboundp 'comment-indent-new-line) ;for Emacs21
    6.38 +      (setq comment-line-break-function 'YaTeX-comment-line-break))
    6.39 +
    6.40    (if (and YaTeX-use-font-lock (featurep 'font-lock))
    6.41        (progn
    6.42 +	(require 'yatex19)
    6.43  	(YaTeX-font-lock-set-default-keywords)
    6.44  	(or  (featurep 'xemacs)
    6.45  	     (set (make-local-variable 'font-lock-defaults)
    6.46 @@ -698,6 +702,7 @@
    6.47  (autoload 'YaTeX-on-parenthesis-p "yatexmth" "Check if on math-parens" t)
    6.48  (autoload 'YaTeX-goto-open-paren "yatexmth" "Goto opening paren" t)
    6.49  (autoload 'YaTeX-change-parentheses "yatexmth" "Change corresponding parens" t)
    6.50 +(autoload 'YaTeX-goto-corresponding-paren "yatexmth" "\bigl\bigr jumps" t)
    6.51  
    6.52  ;;autoload from yatexhlp.el
    6.53  (autoload 'YaTeX-help "yatexhlp" "YaTeX helper with LaTeX commands." t)
    6.54 @@ -1356,7 +1361,8 @@
    6.55    (if (or (string-match YaTeX-array-env-regexp
    6.56  			(or (YaTeX-inner-environment t) "document"))
    6.57  	  (= (preceding-char) 92)
    6.58 -	  (YaTeX-literal-p))
    6.59 +	  (YaTeX-literal-p)
    6.60 +	  (YaTeX-in-math-mode-p))
    6.61        (insert "&")
    6.62      (insert "\\&")))
    6.63  
    6.64 @@ -1471,7 +1477,8 @@
    6.65        (setq scmd (cdr (assoc (YaTeX-match-string 1)
    6.66  			     '(("label" . "\\(page\\)?ref") ("ref" . "label")
    6.67  			       ("pageref" . "label")
    6.68 -			       ("cite" . "bibitem") ("bibitem" . "cite")))))
    6.69 +			       ("cite" . "bibitem\\(\\[[^]]+\\]\\)?")
    6.70 +			       ("bibitem" . "cite\\(\\[[^]]+\\]\\)?")))))
    6.71        (goto-char (match-end 0))
    6.72        (let ((label (buffer-substring 
    6.73  		    (1- (point)) (progn (backward-list 1) (1+ (point))))))
    6.74 @@ -1702,8 +1709,22 @@
    6.75      (while (setq i (string-match "\\\\(" command i))
    6.76        (setq grouping (1+ grouping) i (+ i 2)))
    6.77      (save-excursion
    6.78 -      (if (looking-at YaTeX-ec-regexp) nil
    6.79 +      (if (looking-at (concat YaTeX-ec-regexp command)) nil
    6.80  	(catch 'found			;caught value has no meaning
    6.81 +	  ;;(1) looking at current position
    6.82 +	  (if (looking-at command)
    6.83 +	      (progn
    6.84 +		(while (and (not (bobp)) (looking-at command))
    6.85 +		  (forward-char -1))
    6.86 +		(throw 'found t)))
    6.87 +	  ;;(2) search command directly
    6.88 +	  (skip-chars-forward "^{}[]")
    6.89 +	  (and (YaTeX-re-search-active-backward
    6.90 +		(concat YaTeX-ec-regexp command) YaTeX-comment-prefix nil t)
    6.91 +	       (>= p (match-beginning 0))
    6.92 +	       (throw 'found (goto-char (match-beginning 0))))
    6.93 +	  ;;(3) search token
    6.94 +	  (goto-char p)
    6.95  	  (while t
    6.96  	    (if (bobp) (throw 'found nil))
    6.97  	    (cond
    6.98 @@ -1756,7 +1777,18 @@
    6.99  
   6.100  (defun YaTeX-on-begin-end-p ()
   6.101    (save-excursion
   6.102 -    (beginning-of-line)
   6.103 +    (if (and (boundp 'in-leftright-p) in-leftright-p)
   6.104 +	;; Dirty workaround for YaTeX-goto-corresponding-leftright 2003/3/28
   6.105 +	(let ((md (match-data)))	; for safety
   6.106 +	  (if (looking-at YaTeX-ec-regexp)
   6.107 +	      nil			; stay here
   6.108 +	    (cond
   6.109 +	     ((looking-at "\\w")		(skip-chars-backward "A-Za-z"))
   6.110 +	     ((looking-at "\\.()\\[\\]|")	(forward-char -1)))
   6.111 +	    (if (equal (char-after (1- (point)))
   6.112 +		       (string-to-char YaTeX-ec))
   6.113 +		(forward-char -1))))
   6.114 +      (beginning-of-line))
   6.115      (re-search-forward
   6.116       ;;"\\\\begin{\\([^}]+\\)}\\|\\\\end{\\([^}]+\\)}"
   6.117       (concat
   6.118 @@ -1798,17 +1830,22 @@
   6.119  (defun YaTeX-goto-corresponding-* (arg)
   6.120    "Parse current line and call suitable function."
   6.121    (interactive "P")
   6.122 -  (cond
   6.123 -   ((YaTeX-goto-corresponding-label arg))
   6.124 -   ((YaTeX-goto-corresponding-environment))
   6.125 -   ((YaTeX-goto-corresponding-file-processor arg))
   6.126 -   ((YaTeX-goto-corresponding-file arg))
   6.127 -   ((YaTeX-goto-corresponding-BEGIN-END))
   6.128 -   ((and (string-match
   6.129 -	  YaTeX-equation-env-regexp	;to delay loading
   6.130 -	  (or (YaTeX-inner-environment t) "document"))
   6.131 -	 (YaTeX-goto-corresponding-leftright)))
   6.132 -   (t (message "I don't know where to go."))))
   6.133 +  (let (mm)
   6.134 +    (cond
   6.135 +     ((YaTeX-goto-corresponding-label arg))
   6.136 +     ((YaTeX-goto-corresponding-environment))
   6.137 +     ((YaTeX-goto-corresponding-file-processor arg))
   6.138 +     ((YaTeX-goto-corresponding-file arg))
   6.139 +     ((YaTeX-goto-corresponding-BEGIN-END))
   6.140 +     ((and (setq mm (YaTeX-in-math-mode-p))
   6.141 +	   (YaTeX-goto-corresponding-leftright)))
   6.142 +     ((and mm YaTeX-use-AMS-LaTeX
   6.143 +	   (YaTeX-goto-corresponding-paren)))
   6.144 +     ;;((and (string-match
   6.145 +     ;;	  YaTeX-equation-env-regexp	;to delay loading
   6.146 +     ;;	  (or (YaTeX-inner-environment t) "document"))
   6.147 +     ;;	 (YaTeX-goto-corresponding-leftright)))
   6.148 +     (t (message "I don't know where to go.")))))
   6.149  
   6.150  (defun YaTeX-goto-corresponding-*-other-window (arg)
   6.151    "Parse current line and call suitable function."
   6.152 @@ -1836,11 +1873,11 @@
   6.153    "Uncomment out region by '%'."
   6.154    (interactive "P")
   6.155    (if (not (YaTeX-on-begin-end-p))
   6.156 -      (uncomment-region
   6.157 +      (uncomment-out-region
   6.158         (if alt-prefix (read-string "Remove prefix: ")
   6.159  	 YaTeX-comment-prefix)
   6.160         (region-beginning) (region-end) YaTeX-uncomment-once)
   6.161 -    (YaTeX-comment-uncomment-env 'uncomment-region)))
   6.162 +    (YaTeX-comment-uncomment-env 'uncomment-out-region)))
   6.163  
   6.164  (defun YaTeX-comment-uncomment-env (func)
   6.165    "Comment or uncomment out one LaTeX environment switching function by FUNC."
   6.166 @@ -1893,7 +1930,7 @@
   6.167  		(paragraph-separate paragraph-start))
   6.168  	    (mark-paragraph)
   6.169  	    (if (not (bobp)) (forward-line 1))
   6.170 -	    (uncomment-region "%" nil nil YaTeX-uncomment-once))
   6.171 +	    (uncomment-out-region "%" nil nil YaTeX-uncomment-once))
   6.172  	(message "This line is not a comment line.")))))
   6.173  
   6.174  (defun YaTeX-remove-prefix (prefix &optional once)
   6.175 @@ -2688,6 +2725,11 @@
   6.176  		  (looking-at "\\sw+")) ;is not japanese string
   6.177  		(insert YaTeX-comment-prefix)))))))
   6.178  
   6.179 +(defun YaTeX-comment-line-break (&optional soft)
   6.180 +  "Call comment-indent-new-line and YaTeX-indent-line"
   6.181 +  (comment-indent-new-line soft)
   6.182 +  (YaTeX-indent-line))
   6.183 +
   6.184  (defun YaTeX-latex2e-p ()
   6.185    (let ((b (current-buffer))
   6.186  	(ptn (concat YaTeX-ec "documentclass")))
     7.1 --- a/yatex.new	Mon Nov 25 09:33:34 2002 +0000
     7.2 +++ b/yatex.new	Thu May 01 13:38:27 2003 +0000
     7.3 @@ -1,6 +1,16 @@
     7.4  	What's new in YaTeX/yahtml
     7.5  	野鳥/yahtml - 各バージョンの変更点について
     7.6  
     7.7 +1.71	=== yatex ===
     7.8 +	fill-prefix を指定している場合、Emacs21で \item の auto-fill が
     7.9 +	\item の深さにかかわらず fill-prefix になってしまうのを回避
    7.10 +	\refのラベル補完で、既にlabel定義してあるものがカウンタと\label
    7.11 +	両方が補完候補に出現していたのを修正。またenumerate環境内では
    7.12 +	\itemとラベルが重複して候補に現れていたのを修正。
    7.13 +	Emacsの背景色の定義がXリソースに全く無いときの不具合修正
    7.14 +	[prefix] c で AMS-LaTeX の大括弧対の種類を変えられるようにした
    7.15 +	[prefix] g で AMS-LaTeX の括弧対間でジャンプできるようにした
    7.16 +
    7.17  1.70	Emacs21でmake-frameがエラーになることがあるのを回避
    7.18  	font-lock での Recenter が効かなくなるのを修正
    7.19  	(他、細かい修正がほとんど)
     8.1 --- a/yatex19.el	Mon Nov 25 09:33:34 2002 +0000
     8.2 +++ b/yatex19.el	Thu May 01 13:38:27 2003 +0000
     8.3 @@ -1,7 +1,7 @@
     8.4  ;;; -*- Emacs-Lisp -*-
     8.5  ;;; YaTeX facilities for Emacs 19
     8.6 -;;; (c )1994-2002 by HIROSE Yuuji.[yuuji@yatex.org]
     8.7 -;;; Last modified Wed May 22 13:55:20 2002 on firestorm
     8.8 +;;; (c )1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
     8.9 +;;; Last modified Fri Feb 21 01:35:19 2003 on firestorm
    8.10  ;;; $Id$
    8.11  
    8.12  ;(require 'yatex)
    8.13 @@ -18,15 +18,15 @@
    8.14     ((boundp 'frame-background-mode) frame-background-mode)
    8.15     ((fboundp 'get-frame-background-mode)
    8.16      (get-frame-background-mode (selected-frame)))
    8.17 -   (if (face-background 'default)
    8.18 -       (if (> (+ 32768 32768 32768)
    8.19 -	      (apply '+
    8.20 -		     (funcall (if (fboundp 'color-rgb-components)
    8.21 -				  'color-rgb-components
    8.22 -				'x-color-values)
    8.23 -			      (face-background 'default))))
    8.24 -	   'dark
    8.25 -	 'light))
    8.26 +   ((face-background 'default)
    8.27 +    (if (> (+ 32768 32768 32768)
    8.28 +	   (apply '+
    8.29 +		  (funcall (if (fboundp 'color-rgb-components)
    8.30 +			       'color-rgb-components
    8.31 +			     'x-color-values)
    8.32 +			   (face-background 'default))))
    8.33 +	'dark
    8.34 +      'light))
    8.35     (t nil)))
    8.36  
    8.37  (defvar YaTeX-mode-menu-map (make-sparse-keymap "YaTeX"))
     9.1 --- a/yatexadd.el	Mon Nov 25 09:33:34 2002 +0000
     9.2 +++ b/yatexadd.el	Thu May 01 13:38:27 2003 +0000
     9.3 @@ -1,8 +1,8 @@
     9.4  ;;; -*- Emacs-Lisp -*-
     9.5  ;;; YaTeX add-in functions.
     9.6 -;;; yatexadd.el rev.14
     9.7 -;;; (c )1991-2000 by HIROSE Yuuji.[yuuji@yatex.org]
     9.8 -;;; Last modified Sat Sep 29 23:17:06 2001 on duke
     9.9 +;;; yatexadd.el rev.15
    9.10 +;;; (c )1991-2003 by HIROSE Yuuji.[yuuji@yatex.org]
    9.11 +;;; Last modified Mon Mar 17 16:46:01 2003 on serow
    9.12  ;;; $Id$
    9.13  
    9.14  ;;;
    9.15 @@ -144,7 +144,7 @@
    9.16  
    9.17  (defun YaTeX:thebibliography ()
    9.18    (setq YaTeX-section-name "bibitem")
    9.19 -  "")
    9.20 +  (concat "{" (read-string "Longest label: ") "}"))
    9.21  
    9.22  ;;;
    9.23  ;;Sample functions for section-type command.
    9.24 @@ -492,9 +492,14 @@
    9.25  	(forward-list 1)
    9.26  	(skip-chars-forward " \t\n")
    9.27  	;(setq boundary "[^\\]")
    9.28 +	(setq inspoint (point))
    9.29  	(setq boundary
    9.30  	      (save-excursion
    9.31 -		(if (YaTeX-re-search-active-forward "[^\\]" r-escape nil 1)
    9.32 +		(if (YaTeX-re-search-active-forward
    9.33 +		     (concat YaTeX-ec-regexp
    9.34 +			     "\\(" YaTeX-sectioning-regexp "\\|"
    9.35 +			     "begin\\|item\\)")
    9.36 +		     r-escape nil 1)
    9.37  		    (match-beginning 0)
    9.38  		  (1- (point))))))
    9.39         ((looking-at "item\\s ")
    9.40 @@ -506,7 +511,8 @@
    9.41  		     (concat YaTeX-ec-regexp "\\(item\\|begin\\|end\\)\\b")
    9.42  		     r-escape nil 1)
    9.43  		    (match-beginning 0)
    9.44 -		  (1- (point))))))
    9.45 +		  (1- (point))))
    9.46 +	      inspoint boundary))
    9.47         ((looking-at "bibitem")
    9.48  	(setq labelholder "bibitem")	; label holder is bibitem itself
    9.49  	(setq boundary
    9.50 @@ -515,7 +521,8 @@
    9.51  		     (concat YaTeX-ec-regexp "\\(bibitem\\|end\\)\\b")
    9.52  		     r-escape nil 1)
    9.53  		    (match-beginning 0)
    9.54 -		  (1- (point))))))
    9.55 +		  (1- (point))))
    9.56 +	      inspoint boundary))
    9.57         ((string-match YaTeX::ref-mathenv-regexp
    9.58  		      (setq env (or (YaTeX-inner-environment t) "document")))
    9.59  	(setq mathp t)
    9.60 @@ -526,7 +533,8 @@
    9.61  		     (concat YaTeX-ec-regexp "\\(\\\\\\|end{" env "}\\)")
    9.62  		     r-escape nil 1)
    9.63  		    (match-beginning 0)
    9.64 -		  (1- (point))))))
    9.65 +		  (1- (point))))
    9.66 +	      inspoint boundary))
    9.67         ((looking-at "footnote\\s *{")
    9.68  	(skip-chars-forward "^{")	;move onto `{'
    9.69  	(setq boundary
    9.70 @@ -535,11 +543,15 @@
    9.71  		    (forward-list 1)
    9.72  		  (error (error "\\\\footnote at point %s's brace not closed"
    9.73  				(point))))
    9.74 -		(1- (point)))))
    9.75 +		(1- (point)))
    9.76 +	      inspoint boundary))
    9.77         ((looking-at "caption\\|\\(begin\\)")
    9.78  	(skip-chars-forward "^{")
    9.79 -	(if (match-beginning 1) (forward-list 1))
    9.80 +	;;;;;;(if (match-beginning 1) (forward-list 1))
    9.81 +	;; caption can be treated as mathenv, is it right??
    9.82 +	(forward-list 1)
    9.83  	;;(setq boundary (concat YaTeX-ec-regexp "\\(begin\\|end\\)\\b"))
    9.84 +	(setq inspoint (point))
    9.85  	(setq boundary
    9.86  	      (save-excursion
    9.87  		(if (YaTeX-re-search-active-forward
    9.88 @@ -566,7 +578,7 @@
    9.89  	     (forward-sexp 1) (1- (point))))
    9.90  	;;else make a label
    9.91  	;(goto-char (match-beginning 0))
    9.92 -	(goto-char boundary)
    9.93 +	(goto-char inspoint)
    9.94  	(skip-chars-backward " \t\n")
    9.95  	(save-excursion (setq newlabel (YaTeX::ref-generate-label)))
    9.96  	(delete-region (point) (progn (skip-chars-backward " \t") (point)))
    9.97 @@ -578,7 +590,7 @@
    9.98  
    9.99  (defvar YaTeX::ref-labeling-regexp-alist
   9.100    '(("\\\\begin{java}{\\([^}]+\\)}" . 1)
   9.101 -    ("\\\\elabel{\\([^}]+\\)}" . 1)))
   9.102 +    ("\\\\label{\\([^}]+\\)}" . 1)))
   9.103  (defvar YaTeX::ref-labeling-regexp
   9.104    (mapconcat 'car YaTeX::ref-labeling-regexp-alist "\\|"))
   9.105  (defvar YaTeX::ref-mathenv-regexp
   9.106 @@ -614,7 +626,7 @@
   9.107  			       (car s))))
   9.108  			YaTeX-sectioning-level))
   9.109  		 "\\|")
   9.110 -		"\\|caption\\|footnote\\){"
   9.111 +		"\\|caption\\(\\[[^]]+\\]\\)?\\|footnote\\){"
   9.112  		"\\|\\(begin{\\(" mathenvs "\\|" enums  "\\)\\)\\)")))
   9.113  	  (regexp (concat "\\(" counter
   9.114  			  "\\)\\|\\(" YaTeX::ref-labeling-regexp "\\)"))
   9.115 @@ -706,15 +718,21 @@
   9.116  				   (skip-chars-backward " \t")
   9.117  				   (1- (point)))
   9.118  			  (point-end-of-line)))
   9.119 -		       x))))
   9.120 -
   9.121 +		       x))
   9.122 +		    (setq e0 (point-max))))
   9.123 +		 ;;else, simple section-type counter
   9.124  		 ((= (char-after (1- (point))) ?{)
   9.125  		  (setq label (buffer-substring
   9.126  			       (match-beginning 0)
   9.127  			       (progn (forward-char -1)
   9.128  				      (forward-list 1)
   9.129  				      (point))))
   9.130 -		  (funcall output label match-point))
   9.131 +		  (funcall output label match-point)
   9.132 +		  ;; Skip preceding label if exists
   9.133 +		  (if (save-excursion
   9.134 +			(skip-chars-forward "\t \n")
   9.135 +			(looking-at YaTeX::ref-labeling-regexp))
   9.136 +		      (setq e0 (match-end 0))))
   9.137  		 (t
   9.138  		  (skip-chars-forward " \t")
   9.139  		  (setq label (buffer-substring
   9.140 @@ -728,7 +746,10 @@
   9.141  				     (1- (point)))
   9.142  				 (point-end-of-line))))
   9.143  		  (funcall output label match-point)
   9.144 -		  ))
   9.145 +		  (if (save-excursion
   9.146 +			(skip-chars-forward "\t \n")
   9.147 +			(looking-at YaTeX::ref-labeling-regexp))
   9.148 +		      (setq e0 (match-end 0)))))
   9.149  		) ;;put label buffer
   9.150  	       ;;
   9.151  	       ;; if user defined label found
   9.152 @@ -834,9 +855,13 @@
   9.153  				      (point)))))))))
   9.154  	(setq files (cdr files))))))
   9.155  
   9.156 +(defvar YaTeX::cite-bibitem-macro-regexp "bibitem\\|harvarditem"
   9.157 +  "*Regexp of macro name of bibitem definition")
   9.158 +
   9.159  (defun YaTeX::cite-collect-bibs-internal ()
   9.160    "Collect bibentry in the current buffer and print them to standard output."
   9.161 -  (let ((ptn (concat YaTeX-ec-regexp "bibitem\\b"))
   9.162 +  (let ((ptn (concat YaTeX-ec-regexp
   9.163 +		     "\\(" YaTeX::cite-bibitem-macro-regexp "\\)\\b"))
   9.164  	(pcnt (regexp-quote YaTeX-comment-prefix)))
   9.165      (save-excursion
   9.166        (while (YaTeX-re-search-active-forward ptn pcnt nil t)
   9.167 @@ -884,11 +909,22 @@
   9.168  	      (YaTeX::cite-collect-bibs-internal)))
   9.169  	;;Now bbuf holds the list of bibitem
   9.170  	(set-buffer bbuf)
   9.171 -	(YaTeX::ref argp "\\\\\\(bibitem\\)\\(\\[.*\\]\\)?" "cite"))))
   9.172 -  
   9.173 +	(YaTeX::ref
   9.174 +	 argp 
   9.175 +	 (concat "\\\\\\("
   9.176 +		 YaTeX::cite-bibitem-macro-regexp
   9.177 +		 "\\)\\(\\[.*\\]\\)?")
   9.178 +	 "cite"))))
   9.179 +
   9.180     (t nil)))
   9.181  
   9.182 +;;; for AMS-LaTeX
   9.183  (and YaTeX-use-AMS-LaTeX (fset 'YaTeX::eqref 'YaTeX::ref))
   9.184 +;;; for Harvard citation style
   9.185 +(fset 'YaTeX::citeasnoun 'YaTeX::cite)
   9.186 +(fset 'YaTeX::possessivecite 'YaTeX::cite)
   9.187 +(fset 'YaTeX::citeyear 'YaTeX::cite)
   9.188 +(fset 'YaTeX::citename 'YaTeX::cite)
   9.189  
   9.190  (defun YaTeX-yatex-buffer-list ()
   9.191    (save-excursion
    10.1 --- a/yatexenv.el	Mon Nov 25 09:33:34 2002 +0000
    10.2 +++ b/yatexenv.el	Thu May 01 13:38:27 2003 +0000
    10.3 @@ -1,8 +1,8 @@
    10.4  ;;; -*- Emacs-Lisp -*-
    10.5  ;;; YaTeX environment-specific functions.
    10.6  ;;; yatexenv.el
    10.7 -;;; (c ) 1994-1997 by HIROSE Yuuji.[yuuji@yatex.org]
    10.8 -;;; Last modified Thu Jan 18 15:21:26 2001 on buell
    10.9 +;;; (c ) 1994-2003 by HIROSE Yuuji.[yuuji@yatex.org]
   10.10 +;;; Last modified Sun Mar 30 19:25:47 2003 on firestorm
   10.11  ;;; $Id$
   10.12  
   10.13  ;;;
   10.14 @@ -280,12 +280,11 @@
   10.15  
   10.16  ;;;###autoload
   10.17  (defun YaTeX-goto-corresponding-leftright ()
   10.18 -  "Go to corresponding \left or \right.
   10.19 -Note that this function assumes the corresponding \left\right
   10.20 -is on another line."
   10.21 +  "Go to corresponding \left or \right."
   10.22    (let ((YaTeX-struct-begin "\\left%1")
   10.23  	(YaTeX-struct-end "\\right%1")
   10.24 -	(YaTeX-struct-name-regexp "[][(){}\\.|]"))
   10.25 +	(YaTeX-struct-name-regexp "[][(){}\\.|]")
   10.26 +	(in-leftright-p t))
   10.27      (YaTeX-goto-corresponding-environment t)))
   10.28  
   10.29  ;;;
    11.1 --- a/yatexlib.el	Mon Nov 25 09:33:34 2002 +0000
    11.2 +++ b/yatexlib.el	Thu May 01 13:38:27 2003 +0000
    11.3 @@ -2,7 +2,7 @@
    11.4  ;;; YaTeX and yahtml common libraries, general functions and definitions
    11.5  ;;; yatexlib.el
    11.6  ;;; (c )1994-2002 by HIROSE Yuuji.[yuuji@yatex.org]
    11.7 -;;; Last modified Wed May 22 13:55:31 2002 on firestorm
    11.8 +;;; Last modified Wed Oct  2 23:35:33 2002 on firestorm
    11.9  ;;; $Id$
   11.10  
   11.11  ;; General variables
   11.12 @@ -30,14 +30,16 @@
   11.13  (defvar YaTeX-kanji-code-alist
   11.14    (cond
   11.15     ((boundp '*junet*)
   11.16 -    (list (cons
   11.17 +    (list '(0 . *noconv*)
   11.18 +	  (cons
   11.19  	   1
   11.20  	   (if YaTeX-dos (if (boundp '*sjis-dos*) *sjis-dos* *sjis*dos)
   11.21  	     *sjis*))
   11.22  	  '(2 . *junet*) '(3 . *euc-japan*)))
   11.23     (YaTeX-emacs-20
   11.24      ;;(cdr-safe(assq 'coding-system (assoc "Japanese" language-info-alist)))
   11.25 -    (list (cons
   11.26 +    (list '(0 . no-conversion)
   11.27 +	  (cons
   11.28  	   1 (cond (YaTeX-dos 'shift_jis-dos)
   11.29  		   ((member 'shift_jis (coding-system-list)) 'shift_jis-unix)
   11.30  		   (t 'sjis)))
   11.31 @@ -724,7 +726,7 @@
   11.32    (cond
   11.33     ((and (string< "19" emacs-version) (not (featurep 'xemacs)))
   11.34      (insert-file-contents file visit beg end))
   11.35 -   ((string-match "unix" (symbol-name system-type))
   11.36 +   ((string-match "unix\\|linux" (symbol-name system-type))
   11.37      (let ((default-process-coding-system
   11.38  	    (and (boundp '*noconv*) (list '*noconv*)))
   11.39  	  (file-coding-system (and (boundp '*noconv*) '*noconv*))
   11.40 @@ -734,7 +736,7 @@
   11.41  		    (or (and (boundp 'shell-command-option)
   11.42  			     shell-command-option)
   11.43  			"-c")
   11.44 -		    (format "head -c %d | tail -c +%d" end beg))))
   11.45 +		    (format "dd bs=1 count=%d | tail -c +%d" end beg))))
   11.46      (t (insert-file-contents file))))
   11.47  
   11.48  (defun YaTeX-split-string (str &optional sep null)
    12.1 --- a/yatexmth.el	Mon Nov 25 09:33:34 2002 +0000
    12.2 +++ b/yatexmth.el	Thu May 01 13:38:27 2003 +0000
    12.3 @@ -1,8 +1,8 @@
    12.4  ;;; -*- Emacs-Lisp -*-
    12.5  ;;; YaTeX math-mode-specific functions.
    12.6  ;;; yatexmth.el
    12.7 -;;; (c)1993-2000 by HIROSE Yuuji [yuuji@yatex.org]
    12.8 -;;; Last modified Tue Dec 19 11:03:51 2000 on buell
    12.9 +;;; (c)1993-2003 by HIROSE Yuuji [yuuji@yatex.org]
   12.10 +;;; Last modified Sun Mar 30 19:56:00 2003 on firestorm
   12.11  ;;; $Id$
   12.12  
   12.13  ;;; [Customization guide]
   12.14 @@ -466,6 +466,10 @@
   12.15  (defun YaTeX-math-get-sign (list)
   12.16    (YaTeX-math-gets (car (cdr-safe (cdr-safe list))))
   12.17  )
   12.18 +(defvar YaTeX-math-section-type-regexp
   12.19 +  "eqn\\\\\\sw+\\b"
   12.20 +  "*Regexp of section-type math-mode macro")
   12.21 +
   12.22  (defun YaTeX-in-math-mode-p ()
   12.23    "If current position is supposed to be in LaTeX-math-mode, return t."
   12.24    (or (YaTeX-quick-in-environment-p
   12.25 @@ -477,7 +481,7 @@
   12.26  	      "gather*" "aligned*" "gathered" "gathered*" "alignat"
   12.27  	      "equation*" "cases" 
   12.28  	      "alignat*" "xalignat" "xalignat*" "xxalignat" "xxalignat*"))))
   12.29 -      (let*((p (point)) (nest 0) me0
   12.30 +      (let*((p (point)) (nest 0) me0 r
   12.31  	    (delim (concat YaTeX-sectioning-regexp "\\|^$\\|^\C-l"))
   12.32  	    (boundary
   12.33  	     (save-excursion
   12.34 @@ -503,6 +507,11 @@
   12.35  			(setq nest (1- nest))))))
   12.36  		(if (< nest 0) (throw 'open t))))
   12.37  	    t)
   12.38 +	   ((and (setq r (YaTeX-on-section-command-p
   12.39 +			  YaTeX-math-section-type-regexp))
   12.40 +		 (numberp r)
   12.41 +		 (> r 0))
   12.42 +	    t)
   12.43  	   (t (catch 'dollar
   12.44  		(while ;(search-backward "$" boundary t);little bit fast.
   12.45  		    (YaTeX-re-search-active-backward ;;;;;; Too slow???
   12.46 @@ -824,8 +833,9 @@
   12.47  	    (if (<= move (length (match-string 0)))
   12.48  		(match-string 0)))))))
   12.49  
   12.50 -(defun YaTeX-goto-open-paren ()
   12.51 -  "Jump to the exact position of open parenthesis"
   12.52 +(defun YaTeX-goto-open-paren (&optional jumpto-co)
   12.53 +  "Jump to the exact position of open parenthesis.
   12.54 +If optional argument JUMPTO-CO is non-nil, goto corresponding parentheses."
   12.55    (interactive)
   12.56    (let ((paren)
   12.57  	(backslash-syntax (char-to-string (char-syntax ?\\))))
   12.58 @@ -833,14 +843,30 @@
   12.59  	(if (string-match "(\\|{\\|\\[" paren (1- (length paren)))
   12.60  	    (progn
   12.61  	      (re-search-forward "(\\|{\\|\\[" (+ (point) (length paren)) t)
   12.62 -	      (backward-char))
   12.63 +	      (backward-char)
   12.64 +	      (if jumpto-co
   12.65 +		  (unwind-protect
   12.66 +		      (progn
   12.67 +			(modify-syntax-entry ?\\ " ")
   12.68 +			(forward-list)
   12.69 +			(backward-char))
   12.70 +		    (modify-syntax-entry ?\\ backslash-syntax)))
   12.71 +	      (point))
   12.72  	  (re-search-forward ")\\|}\\|\\]" (+ (point) (length paren)) t)
   12.73  	  (unwind-protect
   12.74  	      (progn
   12.75  		(modify-syntax-entry ?\\ " ")
   12.76 -		(backward-list))
   12.77 +		(backward-list)
   12.78 +		(point))
   12.79  	    (modify-syntax-entry ?\\ backslash-syntax))))))
   12.80  
   12.81 +;;;###autoload
   12.82 +(defun YaTeX-goto-corresponding-paren ()
   12.83 +  "Go to corresponding mathematical parentheses."
   12.84 +  (if (YaTeX-on-parenthesis-p)
   12.85 +      (YaTeX-goto-open-paren t)
   12.86 +    nil))
   12.87 +
   12.88  (defun YaTeX-change-parentheses ()
   12.89    "Change the size of parentheses, braces, and brackets of AMS-LaTeX."
   12.90    (interactive)
   12.91 @@ -855,6 +881,7 @@
   12.92  	   (length (+ mod-length paren-length)) ;; length of whole string
   12.93  	   (big-p t) ;; flag whether new modifier is "[Bb]ig+" or not.
   12.94  	   size ;; left, big, Big etc.
   12.95 +	   type ;; parentheses type
   12.96  	   lr   ;; "l" or "r".
   12.97  	   char newsize newsize-length
   12.98  	   (backslash-syntax (char-to-string (char-syntax ?\\)))
   12.99 @@ -876,7 +903,7 @@
  12.100        (while (not newsize)
  12.101  	(message (format (concat "Change from %s: "
  12.102  				 "l(big) L(Big) h(bigg) H(Bigg) "
  12.103 -				 "r(left-right) n(NONE) ") size))
  12.104 +				 "r(left-right) n(NONE) ( { [") size))
  12.105  	(setq char (read-char)
  12.106  	      newsize (cond ((char-equal char ?l) "\\big")
  12.107  			    ((char-equal char ?L) "\\Big")
  12.108 @@ -884,28 +911,43 @@
  12.109  			    ((char-equal char ?H) "\\Bigg")
  12.110  			    ((char-equal char ?r)
  12.111  			     (setq big-p nil) "\\left")
  12.112 +			    ((memq char '(?\( ?\)))
  12.113 +			     (setq big-p nil type '("(" . ")")) "")
  12.114 +			    ((memq char '(?\{ ?\}))
  12.115 +			     (setq big-p nil type '("\\{" . "\\}")) "")
  12.116 +			    ((memq char '(?\[ ?\]))
  12.117 +			     (setq big-p nil type '("[" . "]")) "")
  12.118  			    ((char-equal char ?n)
  12.119  			     (setq big-p nil) "")
  12.120  			    (t nil))
  12.121  	      newsize-length (length newsize)))
  12.122        (YaTeX-goto-open-paren)
  12.123        (forward-char)
  12.124 -      (delete-region (- (point) length) (- (point) paren-length))
  12.125 -      (backward-char paren-length)
  12.126 +      (cond
  12.127 +       (type
  12.128 +	(delete-region (point) (- (point) paren-length))
  12.129 +	(save-excursion (insert (car type))))
  12.130 +       (t
  12.131 +	(delete-region (- (point) length) (- (point) paren-length))
  12.132 +	(backward-char paren-length)))
  12.133        (insert-string newsize)
  12.134        (if big-p (insert ?l))
  12.135 -      (forward-char (1- paren-length))
  12.136        (unwind-protect
  12.137  	  (progn
  12.138  	    (modify-syntax-entry ?\\ " ")
  12.139  	    (forward-list)
  12.140  	    (if (string= size "left-right") (setq length (1+ length)))
  12.141  	    (if (eq char ?r) (setq newsize "\\right"))
  12.142 -	    (delete-region (- (point) length) (- (point) paren-length))
  12.143 -	    (backward-char paren-length)
  12.144 -	    (insert-string newsize)
  12.145 -	    (if big-p (insert ?r))
  12.146 -	    (forward-char paren-length)
  12.147 +	    (cond
  12.148 +	     (type
  12.149 +	      (delete-region (point) (- (point) paren-length))
  12.150 +	      (insert (cdr type)))
  12.151 +	     (t
  12.152 +	      (delete-region (- (point) length) (- (point) paren-length))
  12.153 +	      (backward-char paren-length)
  12.154 +	      (insert-string newsize)
  12.155 +	      (if big-p (insert ?r))
  12.156 +	      (forward-char paren-length)))
  12.157  	    (if (string= lr "l") (backward-list)))
  12.158  	(modify-syntax-entry ?\\ backslash-syntax))
  12.159        t)))
    13.1 --- a/yatexprc.el	Mon Nov 25 09:33:34 2002 +0000
    13.2 +++ b/yatexprc.el	Thu May 01 13:38:27 2003 +0000
    13.3 @@ -1,8 +1,8 @@
    13.4  ;;; -*- Emacs-Lisp -*-
    13.5  ;;; YaTeX process handler.
    13.6  ;;; yatexprc.el
    13.7 -;;; (c )1993-2000 by HIROSE Yuuji.[yuuji@yatex.org]
    13.8 -;;; Last modified Sun Dec 31 21:57:44 2000 on firestorm
    13.9 +;;; (c )1993-2003 by HIROSE Yuuji.[yuuji@yatex.org]
   13.10 +;;; Last modified Thu May  1 22:37:31 2003 on firestorm
   13.11  ;;; $Id$
   13.12  
   13.13  ;(require 'yatex)
   13.14 @@ -386,18 +386,20 @@
   13.15  (defun YaTeX-get-paper-type ()
   13.16    "Search options in header and return a paper type, such as \"a4\", \"a4r\", etc."
   13.17    (save-excursion
   13.18 +    (YaTeX-visit-main t)
   13.19      (goto-char (point-min))
   13.20 -    (if (re-search-forward
   13.21 -	 "^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t)
   13.22 -	(let ((opts (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*")))
   13.23 -	  (concat
   13.24 -	   (catch 'found-paper
   13.25 -	     (mapcar (lambda (pair)
   13.26 -		       (if (member (car pair) opts)
   13.27 -			   (throw 'found-paper (cdr pair))))
   13.28 -		     YaTeX-paper-type-alist)
   13.29 -	     YaTeX-default-paper-type)
   13.30 -	   (if (member "landscape" opts) "r" ""))))))
   13.31 +    (let ((opts
   13.32 +	   (if (re-search-forward
   13.33 +		"^[ \t]*\\\\document\\(style\\|class\\)[ \t]*\\[\\([^]]*\\)\\]" nil t)
   13.34 +	       (YaTeX-split-string (YaTeX-match-string 2) "[ \t]*,[ \t]*"))))
   13.35 +      (concat
   13.36 +       (catch 'found-paper
   13.37 +	 (mapcar (lambda (pair)
   13.38 +		   (if (member (car pair) opts)
   13.39 +		       (throw 'found-paper (cdr pair))))
   13.40 +		 YaTeX-paper-type-alist)
   13.41 +	 YaTeX-default-paper-type)
   13.42 +       (if (member "landscape" opts) "r" "")))))
   13.43  
   13.44  (defvar YaTeX-preview-command-history nil
   13.45    "Holds minibuffer history of preview command.")
    14.1 --- a/yatexsec.el	Mon Nov 25 09:33:34 2002 +0000
    14.2 +++ b/yatexsec.el	Thu May 01 13:38:27 2003 +0000
    14.3 @@ -1,8 +1,8 @@
    14.4  ;;; -*- Emacs-Lisp -*-
    14.5  ;;; YaTeX sectioning browser.
    14.6  ;;; yatexsec.el
    14.7 -;;; (c ) 1994,1998,1999 by HIROSE Yuuji [yuuji@yatex.org]
    14.8 -;;; Last modified Mon Dec 25 19:18:36 2000 on firestorm
    14.9 +;;; (c ) 1994,1998,1999,2003 by HIROSE Yuuji [yuuji@yatex.org]
   14.10 +;;; Last modified Wed Mar  5 13:19:11 2003 on firestorm
   14.11  ;;; $Id$
   14.12  
   14.13  (defvar YaTeX-sectioning-level
   14.14 @@ -115,20 +115,35 @@
   14.15  
   14.16  (defvar YaTeX-sectioning-buffer-parent nil)
   14.17  (defun YaTeX-sectioning-buffer-jump-internal (&optional keep)
   14.18 -  (let (ptn (p (point)))		;save-excursion is NG because
   14.19 -    (beginning-of-line)		;this function should switch buffer
   14.20 +  (let ((p (point))		;save-excursion is NG because
   14.21 +	ptn ln)			;this function should switch buffer
   14.22 +    (beginning-of-line)
   14.23      (if (re-search-forward YaTeX-sectioning-regexp)
   14.24 -	(progn (setq ptn (buffer-substring
   14.25 -			  (1- (match-beginning 0))
   14.26 -			  (progn (skip-chars-forward "^}") (1+ (point)))))
   14.27 -	       (goto-char p)
   14.28 -	       (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t)
   14.29 -	       (goto-char (point-max))
   14.30 -	       (search-backward ptn)
   14.31 -	       (if keep (goto-buffer-window YaTeX-sectioning-buffer))
   14.32 -	       (current-buffer))
   14.33 -      nil))
   14.34 -)
   14.35 +	(progn
   14.36 +	  (save-restriction
   14.37 +	    (narrow-to-region (point-beginning-of-line) (point-end-of-line))
   14.38 +	    (setq ptn (buffer-substring
   14.39 +		       (1- (match-beginning 0))
   14.40 +		       (progn (skip-chars-forward "^}") (1+ (point))))
   14.41 +		  ln (buffer-substring
   14.42 +		      (progn (search-forward "line:") (match-end 0))
   14.43 +		      (progn (skip-chars-forward "0-9") (point)))))
   14.44 +	  (goto-char p)
   14.45 +	  (YaTeX-showup-buffer YaTeX-sectioning-buffer-parent nil t)
   14.46 +	  (or
   14.47 +	   (and ln (string< "" ln)
   14.48 +		(progn
   14.49 +		  (goto-line (max 1 (1- (string-to-int ln))))
   14.50 +		  (and
   14.51 +		   (search-forward ptn nil t)
   14.52 +		   (goto-char (match-beginning 0)))))
   14.53 +	   (progn
   14.54 +	     (goto-char (point-max))
   14.55 +	     (search-backward ptn)))
   14.56 +	  (if keep (goto-buffer-window YaTeX-sectioning-buffer))
   14.57 +	  (current-buffer))
   14.58 +      nil)))
   14.59 +
   14.60  (defun YaTeX-sectioning-buffer-jump (&optional keep)
   14.61    "Goto corresponding sectioning unit with current line in the next window.
   14.62  If optional argument KEEP is non-nil, only shows the line."