changeset 48:a0640ff3f72f

Inter-file ref/label, cite/bibitem jump.
author yuuji
date Mon, 31 Oct 1994 17:49:43 +0000
parents d7e7b4654058
children eb0512bfcb7f
files docs/yatex.ref docs/yatexe.tex docs/yatexj.tex help/YATEXHLP.jp yatex.el yatex.new yatexadd.el
diffstat 7 files changed, 116 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/docs/yatex.ref	Mon Oct 24 17:26:47 1994 +0000
+++ b/docs/yatex.ref	Mon Oct 31 17:49:43 1994 +0000
@@ -72,7 +72,9 @@
 
 	・\begin{}, \end{}の上		対応する \end{},\begin{} へ
 	・%#BEGIN, %#END の上		対応する %#BEGIN, %#END へ
-	・\include(only), \input の上	対応するファイル
+	・\include(only), \input の上   対応するファイルへ
+	・\ref, \label の上             対応する \label, \ref へ
+	・\cite, \bibitem の上          対応する \bibitem, \cite へ
 
 	◆メインファイルへジャンプ	[prefix] ^
 	◆別ウィンドウで   〃		[prefix] 4^
--- a/docs/yatexe.tex	Mon Oct 24 17:26:47 1994 +0000
+++ b/docs/yatexe.tex	Mon Oct 31 17:49:43 1994 +0000
@@ -906,7 +906,7 @@
 @cindex cursor jump
 @cindex prefix g
 
-  On a @code{\begin},@code{\end} line, the key stroke
+  Typing
 
 @table @kbd
 @item [prefix] g
@@ -914,13 +914,26 @@
 @end table
 
 @noindent
+in a certain place move the cursor to the place corresponding to the
+La@TeX{} command of last place.  YaTeX recognize the followings as pairs
+that have relation each other.
+
+@table
+@item @code{\begin@{@}} <-> @code{\end@{@}}
+@item @code{%#BEGIN} <-> @code{%#END}
+@item @code{\label@{@}} <-> @code{\ref@{@}}
+@item @code{\include(\input)} -> included file
+@item @code{\bibitem@{@}} <-> @code{\cite@{@}}
+@end table
+
+  On a @code{\begin},@code{\end} line, typing @kbd{[prefix] g}
 moves the cursor to the corresponding @code{\end},@code{\begin} line, if
-its partner really exists.  It is also applicable to A @code{%#BEGIN} and
-@code{%#END} pair.
+its partner really exists.  The movement on the line @code{%#BEGIN} and
+@code{%#END} are the same.
 
   If you type @code{[prefix] g} on the line of @code{\include@{chap1@}},
-maybe   in main text, YaTeX switches buffer to @file{chap1.tex}.  On the
-contrary, the key strokes
+typically in the main text, YaTeX switches buffer to @file{chap1.tex}.
+The key strokes below work to the contrary.  Typing
 
 @table @kbd
 @item [prefix] ^
--- a/docs/yatexj.tex	Mon Oct 24 17:26:47 1994 +0000
+++ b/docs/yatexj.tex	Mon Oct 31 17:49:43 1994 +0000
@@ -77,7 +77,8 @@
 @item 野鳥にないガイド付き引数入力関数の自動生成(@file{yatexgen.el})
 @item La@TeX{} コマンドの削除/変更(@kbd{C-c k}, @kbd{C-c c})
 @item ファイル間、@code{\begin}<->@code{\end}間、
-        @code{\ref}<->@code{\label}間ジャンプ(@kbd{C-c g})
+        @code{\ref}<->@code{\label}間、
+        @code{\cite}<->@code{\bibitem}ジャンプ(@kbd{C-c g})
 @item 一括コメントアウト/アンコメントアウト
         (@kbd{C-c >}, @kbd{C-c <}, @kbd{C-c ,}, @kbd{C-c .})
 @item アクセント記号/数式環境用コマンド/ギリシャ文字の入力支援
@@ -978,7 +979,7 @@
 @cindex カーソルジャンプ[かあそるしやんふ]
 @cindex prefix g
 
-  @code{\begin@{@}} や @code{\end@{@}} の行にカーソルを合わせ、
+  文書中のいろいろな場所で
 
 @table @kbd
 @item [prefix] g
@@ -986,9 +987,21 @@
 @end table
 
 @noindent 
+を押すことにより、カーソル位置のLa@TeX{}コマンドに対応する場所にジャンプ
+します。対応関係が存在すると解釈されるコマンドには以下のものがあります。
+
+@table
+@item @code{\begin@{@}}←→@code{\end@{@}}
+@item @code{%#BEGIN}←→@code{%#END}
+@item @code{\label@{@}}←→@code{\ref@{@}}
+@item @code{\include(\input)}→対応するファイル
+@item @code{\bibitem@{@}}←→@code{\cite@{@}}
+@end table
+
+  @code{\begin@{@}} か @code{\end@{@}} の行で@kbd{[prefix] g}
 を押すことにより、対応する@code{end/begin}の行にジャンプします。もちろん対
 応するものがない場合はエラーになります。またこれは、領域固定のための 
-@code{%#BEGIN} と @code{%#END} のペアに対しても使えます。
+@code{%#BEGIN} と @code{%#END} のペアに対しても同様に動作します。
 @xref{%#記法}
 
   メインの .tex ファイルの @code{\include{chap1}} などにカーソルを合わせ、
@@ -1025,6 +1038,8 @@
 上記のコマンドは通常の@kbd{[prefix]}キーではなく@kbd{META}キーをプリフィク
 スとして機能するのでご注意下さい。
 
+  
+
 @node Modifying/Deleting, Filling item, Cursor jump, Top
 @comment  node-name,  next,  previous,  up
 @chapter 変更/削除
--- a/help/YATEXHLP.jp	Mon Oct 24 17:26:47 1994 +0000
+++ b/help/YATEXHLP.jp	Mon Oct 31 17:49:43 1994 +0000
@@ -1054,8 +1054,8 @@
 bibitem
 \bibitem{NAME}			\bibitem[LABEL]{NAME}
 \bibitem{NAME}の書式では、NAMEで参照され、[1],[2] のような形で引用記号が
-出力される、\bibitem[LABEL]{NAME}の書式では、\cite{LABEL}で参照され、
-[Knuth82] のような引用記号が出力される。
+出力される、\bibitem[LABEL]{NAME}の書式では、\cite{NAME}で参照され、
+[LABEL] のような引用記号が出力される。
 
 footnote
 \footnote{NOTE}
Binary file yatex.el has changed
--- a/yatex.new	Mon Oct 24 17:26:47 1994 +0000
+++ b/yatex.new	Mon Oct 31 17:49:43 1994 +0000
@@ -1,6 +1,11 @@
 	Yet Another tex-mode for Emacs
 	yatex.el 各バージョンの変更点について。
 
+1.53	Emacs-19で新単語の更新がうまくいかなかったのを今度こそ直した。
+	ref/labelジャンプで別のバッファのref/labelに飛べるようにした。
+	ref/labelジャンプと同形式でcite/bibitem間で飛べるようにした。
+	cite/bibitemのアドイン関数の追加。
+
 1.52	外部プロセス用テンポラリバッファが別frameにある時には現frameにテ
 	ンポラリバッファをpopupしないようにした。
 	Hilightening に独自のタグを導入し、reverseVideo がON/OFFの時両方
--- a/yatexadd.el	Mon Oct 24 17:26:47 1994 +0000
+++ b/yatexadd.el	Mon Oct 31 17:49:43 1994 +0000
@@ -2,7 +2,7 @@
 ;;; YaTeX add-in functions.
 ;;; yatexadd.el rev.9
 ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Mon Aug 22 14:19:39 1994 on figaro
+;;; Last modified Mon Oct 31 12:55:54 1994 on pajero
 ;;; $Id$
 
 ;;;
@@ -246,6 +246,18 @@
   nil
 )
 
+(defun YaTeX:cite ()
+  (let ((comment (read-string "Comment for citation: ")))
+    (if (string= comment "") ""
+      (concat "[" comment "]")))
+)
+
+(defun YaTeX:bibitem ()
+  (let ((label (read-string "Citation label: ")))
+    (if (string= label "") ""
+      (concat "[" label "]")))
+)
+
 ;;;
 ;;Subroutine
 ;;;
@@ -327,11 +339,12 @@
       (goto-char (match-beginning 0))))
     (message YaTeX-label-guide-msg))
 )
-(defun YaTeX::ref (argp)
+(defun YaTeX::ref (argp &optional labelcmd refcmd)
   (cond
    ((= argp 1)
     (save-excursion
-      (let ((lnum 0) e0 m1 e1 label label-list (buf (current-buffer))
+      (let ((lnum 0) e0 label label-list (buf (current-buffer))
+	    (labelcmd (or labelcmd "label")) (refcmd (or refcmd "ref"))
 	    (p (point)) initl line)
 	(goto-char (point-min))
 	(message "Collecting labels...")
@@ -339,27 +352,31 @@
 	  (YaTeX-showup-buffer
 	   YaTeX-label-buffer (function (lambda (x) (window-width x))))
 	  (with-output-to-temp-buffer YaTeX-label-buffer
-	    (while (re-search-forward "\\label{\\([^}]+\\)}" nil t)
-	      (setq e0 (match-end 0) m1 (match-beginning 1) e1 (match-end 1))
-	      (if (search-backward
-		   YaTeX-comment-prefix (point-beginning-of-line) t) nil
-		(setq label (buffer-substring m1 e1)
-		      label-list (cons label label-list))
-		(or initl
-		    (if (< p (point)) (setq initl lnum)))
-		(beginning-of-line)
-		(skip-chars-forward " \t\n" nil)
-		(princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
-			       (buffer-substring (point) (point-end-of-line))))
-		(setq lnum (1+ lnum))
-		(message "Collecting \\label{}... %d" lnum))
+	    (while (YaTeX-re-search-active-forward
+		    (concat "\\\\" labelcmd)
+		    (regexp-quote YaTeX-comment-prefix) nil t)
+	      (goto-char (match-beginning 0))
+	      (skip-chars-forward "^{")
+	      (setq label
+		    (buffer-substring
+		     (1+ (point))
+		     (prog2 (forward-list 1) (setq e0 (1- (point)))))
+		    label-list (cons label label-list))
+	      (or initl
+		  (if (< p (point)) (setq initl lnum)))
+	      (beginning-of-line)
+	      (skip-chars-forward " \t\n" nil)
+	      (princ (format "%c:{%s}\t<<%s>>\n" (+ (% lnum 26) ?A) label
+			     (buffer-substring (point) (point-end-of-line))))
+	      (setq lnum (1+ lnum))
+	      (message "Collecting \\%s{}... %d" labelcmd lnum)
 	      (goto-char e0))
 	    (princ YaTeX-label-menu-other)
 	    (princ YaTeX-label-menu-repeat)
 	    (princ YaTeX-label-menu-any)
 	    );with
 	  (goto-char p)
-	  (message "Collecting labels...Done")
+	  (message "Collecting %s...Done" labelcmd)
 	  (pop-to-buffer YaTeX-label-buffer)
 	  (YaTeX::label-setup-key-map)
 	  (setq truncate-lines t)
@@ -379,12 +396,12 @@
 		  (save-excursion
 		    (switch-to-buffer buf)
 		    (goto-char p)
-		    (if (re-search-backward "\\\\ref{\\([^}]+\\)}" nil t)
-			(setq label (buffer-substring
-				     (match-beginning 1) (match-end 1)))
+		    (if (re-search-backward
+			 (concat "\\\\" refcmd "{\\([^}]+\\)}") nil t)
+			(setq label (YaTeX-match-string 1))
 		      (setq label ""))))
 		 ((>= line (+ lnum 2))
-		  (setq label (read-string "\\ref{???}: ")))
+		  (setq label (read-string (format "\\%s{???}: " refcmd))))
 		 (t (setq label (nth (- lnum line 1) label-list)))))
 	    (bury-buffer YaTeX-label-buffer)))
 	label
@@ -392,19 +409,33 @@
     ))
 )
 (fset 'YaTeX::pageref 'YaTeX::ref)
+(defun YaTeX::cite (argp)
+  (cond
+   ((eq argp 1)
+    (YaTeX::ref argp "bibitem\\(\\[.*\\]\\)?" "cite"))
+   (t nil)))
 
-(defun YaTeX-label-other ()
-  (let ((lbuf "*YaTeX mode buffers*") (blist (buffer-list)) (lnum -1) buf rv
+(defun YaTeX-yatex-buffer-list ()
+  (save-excursion
+    (delq nil (mapcar (function (lambda (buf)
+				  (set-buffer buf)
+				  (if (eq major-mode 'yatex-mode) buf)))
+		      (buffer-list))))
+)
+
+(defun YaTeX-select-other-yatex-buffer ()
+  "Select buffer from all yatex-mode's buffers interactivelly."
+  (interactive)
+  (let ((lbuf "*YaTeX mode buffers*") (blist (YaTeX-yatex-buffer-list))
+	(lnum -1) buf rv
 	(ff "**find-file**"))
     (YaTeX-showup-buffer
      lbuf (function (lambda (x) 1)))	;;Select next window surely.
     (with-output-to-temp-buffer lbuf
       (while blist
-	(if (and (buffer-file-name (setq buf (car blist)))
-		 (progn (set-buffer buf) (eq major-mode 'yatex-mode)))
-	    (princ
-	     (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
-		     (buffer-name buf))))
+	(princ
+	 (format "%c:{%s}\n" (+ (% (setq lnum (1+ lnum)) 26) ?A)
+		 (buffer-name (car blist))))
 	(setq blist (cdr blist)))
       (princ (format "':{%s}" ff)))
     (pop-to-buffer lbuf)
@@ -421,14 +452,20 @@
 		(if (re-search-forward "{\\([^\\}]+\\)}" (point-end-of-line) t)
 		    (buffer-substring (match-beginning 1) (match-end 1)) nil)))
       (kill-buffer lbuf))
+    (if (string= rv ff)
+	(progn
+	  (call-interactively 'find-file)
+	  (current-buffer))
+      rv))
+)
+
+(defun YaTeX-label-other ()
+  (let ((rv (YaTeX-select-other-yatex-buffer)))
     (cond
      ((null rv) "")
-     ((string= rv ff)
-      (call-interactively 'find-file)
-      (YaTeX::ref argp))
      (t
       (set-buffer rv)
-      (YaTeX::ref argp)))
+      (YaTeX::ref argp labelcmd refcmd)))
     )
 )
 

yatex.org