changeset 14:b7b023a74293

Region-based section-type completion. Kill section-type command and parens (sometimes with font) with [prefix] k. Rewrite error-jump functions. Fix the bug of recursive section-type completion.
author yuuji
date Fri, 22 Apr 1994 17:35:25 +0000
parents eafae54794a0
children cd762e854337
files docs/yatex.ref docs/yatexadd.doc docs/yatexgen.doc yatex.el yatex.new yatexadd.el yatexgen.el yatexmth.el yatexprc.el
diffstat 9 files changed, 170 insertions(+), 131 deletions(-) [+]
line wrap: on
line diff
--- a/docs/yatex.ref	Sat Jan 29 07:59:59 1994 +0000
+++ b/docs/yatex.ref	Fri Apr 22 17:35:25 1994 +0000
@@ -23,6 +23,7 @@
 	◆large型補完(領域指定)		[prefix] L
 	◆maketitle型補完		[prefix] m
 	◆section型補完			[prefix] s
+	◆section型補完(領域指定)	[prefix] S
 	◆随時補完			[prefix] SPC
 
 	  即時begin型補完の、環境名の頭文字の対応については、yatex.doc を
@@ -101,8 +102,8 @@
 
 	◆コマンド削除			[prefix] k
 
-	  \begin{}, \end{} のペア、または %#BEGIN, %#END のペアを一挙に削
-	除します。
+	  \begin{}, \end{} のペア、%#BEGIN, %#END のペア、括弧のペア、ま
+	たはsection型コマンドを一挙に削除します。
 
 	◆領域を()で括る		[prefix] )
 	◆領域を{}で括る		[prefix] }
@@ -114,10 +115,9 @@
 
 	◆%# 記法の編集			[prefix] %
 
-								   広瀬雄二
-							yuuji@ae.keio.ac.jp
-							pcs39334(ASCII-NET)
-
+							       広瀬雄二
+						    yuuji@ae.keio.ac.jp
+						pcs39334@asciinet.or.jp
 
 Local variables:
 mode: text
--- a/docs/yatexadd.doc	Sat Jan 29 07:59:59 1994 +0000
+++ b/docs/yatexadd.doc	Fri Apr 22 17:35:25 1994 +0000
@@ -161,6 +161,6 @@
 	思います。
 
 
-								   広瀬雄二
-							yuuji@ae.keio.ac.jp
-							pcs39334(ASCII-NET)
+							       広瀬雄二
+						    yuuji@ae.keio.ac.jp
+						pcs39334@asciinet.or.jp
--- a/docs/yatexgen.doc	Sat Jan 29 07:59:59 1994 +0000
+++ b/docs/yatexgen.doc	Fri Apr 22 17:35:25 1994 +0000
@@ -50,7 +50,6 @@
 	ら、幸福感に浸るだけにして、決して筆者まで送ったりしないで下さい。
 	yatexgen が作るんだから、ろくな関数じゃないことは分かってます:-p。
 
-
-								   広瀬雄二
-							yuuji@ae.keio.ac.jp
-							pcs39334(ASCII-NET)
+							       広瀬雄二
+						    yuuji@ae.keio.ac.jp
+						pcs39334@asciinet.or.jp
Binary file yatex.el has changed
--- a/yatex.new	Sat Jan 29 07:59:59 1994 +0000
+++ b/yatex.new	Fri Apr 22 17:35:25 1994 +0000
@@ -2,6 +2,13 @@
 	Yet Another tex-mode for Emacs
 	yatex.el 各バージョンの変更点について。
 
+1.46	リジョン指定つき section 型補完の追加。
+	[prefix] k で section 型コマンドの削除、対応する括弧の削除。
+	エラー行ジャンプの適正化。
+	再帰的 section 型補完時のバグフィクス。
+	親ファイルを手入力した時に二度目以降もそのファイルを親とみなす。
+	\verbのアドイン関数追加。
+
 1.45:	comment-region を begin/end 行で起動した時にメッセージを出す。
 	yatexmth:イメージ補完で複数の補完テーブルが使えるようにし、
 	/で始まるギリシャ文字補完を追加。
--- a/yatexadd.el	Sat Jan 29 07:59:59 1994 +0000
+++ b/yatexadd.el	Fri Apr 22 17:35:25 1994 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX add-in functions.
-;;; yatexadd.el rev.6
-;;; (c )1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Sat Jan 29 16:55:09 1994 on gloria
+;;; yatexadd.el rev.7
+;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
+;;; Last modified Sat Apr 23 02:26:47 1994 on pajero
 ;;; $Id$
 
 (provide 'yatexadd)
@@ -152,6 +152,17 @@
       (concat ULchar "{" bndry "}")))
 )
 
+(defun YaTeX:verb ()
+  "Enclose \\verb's contents with the same characters."
+  (let ((quote-char (read-string "Quoting char: " "|"))
+	(contents (read-string "Quoted contents: ")))
+    (concat quote-char contents quote-char))
+)
+
+;;;
+;;Subroutine
+;;;
+
 (defun YaTeX:check-completion-type (type)
   "Check valid completion type."
   (if (not (eq type YaTeX-current-completion-type))
--- a/yatexgen.el	Sat Jan 29 07:59:59 1994 +0000
+++ b/yatexgen.el	Fri Apr 22 17:35:25 1994 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; Generate add-in functions for YaTeX.
 ;;; yatexgen.el rev.1(beta2)
-;;; (c )1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Sat Jan 29 16:55:07 1994 on gloria
+;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
+;;; Last modified Sat Apr 23 02:26:34 1994 on pajero
 ;;; $Id$
 
 (require 'yatex)
--- a/yatexmth.el	Sat Jan 29 07:59:59 1994 +0000
+++ b/yatexmth.el	Fri Apr 22 17:35:25 1994 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX interface for math-mode.
 ;;; yatexmth.el rev.2
-;;; (c )1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
-;;; Last modified Sat Jan 29 16:55:03 1994 on gloria
+;;; (c )1993-1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
+;;; Last modified Sat Apr 23 02:26:57 1994 on pajero
 ;;; $Id$
 
 ;;; [Customization guide]
--- a/yatexprc.el	Sat Jan 29 07:59:59 1994 +0000
+++ b/yatexprc.el	Fri Apr 22 17:35:25 1994 +0000
@@ -1,8 +1,8 @@
 ;;; -*- Emacs-Lisp -*-
 ;;; YaTeX process handler.
 ;;; yatexprc.el
-;;; (c )1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
-;;; Last modified Sat Jan 29 16:54:54 1994 on gloria
+;;; (c )1993-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
+;;; Last modified Sat Apr 23 02:34:07 1994 on pajero
 ;;; $Id$
 
 (require 'yatex)
@@ -16,6 +16,9 @@
 (defvar YaTeX-typeset-buffer-syntax nil
   "*Syntax table for typesetting buffer")
 
+(defvar YaTeX-current-TeX-buffer nil
+  "Keeps the buffer on which recently typeset run.")
+
 (if YaTeX-typeset-buffer-syntax nil
   (setq YaTeX-typeset-buffer-syntax
 	(make-syntax-table (standard-syntax-table)))
@@ -34,7 +37,7 @@
 	;; if tex command is halting.
 	(YaTeX-kill-typeset-process YaTeX-typeset-process))
     (YaTeX-visit-main t);;execution directory
-    ;;Select under-most window if there are more than 2 windows and
+    ;;Select lower-most window if there are more than 2 windows and
     ;;typeset buffer not seen.
     (YaTeX-showup-buffer
      buffer (function (lambda (x) (nth 3 (window-edges x)))))
@@ -50,7 +53,7 @@
 	      (start-process "LaTeX" buffer shell-file-name "-c"
 			     command))
 	(set-process-sentinel YaTeX-typeset-process 'YaTeX-typeset-sentinel)))
-    (setq current-TeX-buffer (buffer-name))
+    (setq YaTeX-current-TeX-buffer (buffer-name))
     (select-window (get-buffer-window buffer))
     (use-local-map YaTeX-typesetting-mode-map)
     (set-syntax-table YaTeX-typeset-buffer-syntax)
@@ -264,7 +267,6 @@
   (interactive
    (list (read-string "Preview command: " dvi2-command)
 	 (read-string "Preview file[.dvi]: "
-		      ;;(substring (buffer-name) 0 -4)
 		      (if (get 'dvi2-command 'region)
 			  (substring YaTeX-texput-file
 				     0 (rindex YaTeX-texput-file ?.))
@@ -287,85 +289,74 @@
 )
 
 (defun YaTeX-prev-error ()
-  "Visit previous error.  The reason why not NEXT-error is to
-avoid making confliction of line numbers by editing."
+  "Visit previous typeset error.
+  To avoid making confliction of line numbers by editing, jump to
+error or warning lines in reverse order."
   (interactive)
   (let ((cur-buf (buffer-name)) (cur-win (selected-window))
-	YaTeX-error-line typeset-win error-buffer error-win)
+	error-line typeset-win error-buffer error-win)
     (if (null (get-buffer YaTeX-typeset-buffer))
-	(message "There is no output buffer of typesetting.")
-      (YaTeX-pop-to-buffer YaTeX-typeset-buffer)
-      (setq typeset-win (selected-window))
-      (if YaTeX-dos
-	  (if (search-backward latex-dos-emergency-message nil t)
-	      (progn (goto-char (point-max))
-		     (setq error-regexp latex-error-regexp))
-	    (beginning-of-line)
-	    (forward-char -1)
-	    (setq error-regexp latex-warning-regexp))
-	(if YaTeX-typeset-process      ; if jlatex on UNIX
-	    (if (eq (process-status YaTeX-typeset-process) 'run)
-		(progn
-		  (goto-char (point-max))
-		  (setq error-regexp latex-error-regexp))
-	      (beginning-of-line)
-	      (setq error-regexp latex-warning-regexp))))
-      (if (re-search-backward error-regexp nil t)
-	  (setq YaTeX-error-line
-		(string-to-int
-		 (buffer-substring
-		  (progn (goto-char (match-beginning 0))
-			 (skip-chars-forward "^0-9")
-			 (point))
-		  (progn (skip-chars-forward "0-9") (point)))))
-	(message "No more errors on %s" cur-buf)
-	(ding))
-      (setq error-buffer (YaTeX-get-error-file cur-buf)); arg. is default buf.
-      (setq error-win (get-buffer-window error-buffer))
+	(error "There is no typesetting buffer."))
+    (YaTeX-pop-to-buffer YaTeX-typeset-buffer)
+    (setq typeset-win (selected-window))
+    (if (re-search-backward
+	 (concat "\\(" latex-error-regexp "\\)\\|\\("
+		 latex-warning-regexp "\\)")
+	 nil t)
+	nil
       (select-window cur-win)
-      (if (or (null YaTeX-error-line) (equal 0 YaTeX-error-line))
-	  nil
-	;; if warning or error found
-	(if error-win (select-window error-win)
-	  (select-window (get-lru-window))
-	  (YaTeX-switch-to-buffer error-buffer)
-	  (setq error-win (selected-window)))
-	(goto-line YaTeX-error-line)
-	(message "latex error or warning in '%s' at line: %d"
-		 error-buffer YaTeX-error-line)
-	(select-window typeset-win)
-	(skip-chars-backward "[0-9]")
-	(recenter (/ (window-height) 2))
-	(sit-for 3)
-	(forward-char -1)
-	(select-window error-win)
-	)))
+      (error "No more erros on %s" cur-buf))
+    (goto-char (match-beginning 0))
+    (skip-chars-forward "^0-9" (match-end 0))
+    (setq error-line
+	  (string-to-int
+	   (buffer-substring
+	    (point)
+	    (progn (skip-chars-forward "0-9" (match-end 0)) (point))))
+	  error-buffer (YaTeX-get-error-file cur-buf)
+	  error-win (get-buffer-window error-buffer))
+    (if (or (null error-line) (equal 0 error-line))
+	(error "Can't detect error position."))
+    (select-window cur-win)
+    (cond
+     (error-win (select-window error-win))
+     ((eq (get-lru-window) typeset-win)
+      (YaTeX-switch-to-buffer error-buffer))
+     (t (select-window (get-lru-window))
+	(YaTeX-switch-to-buffer error-buffer)))
+    (setq error-win (selected-window))
+    (goto-line error-line)
+    (message "LaTeX %s in `%s' on line: %d."
+	     (if (match-beginning 1) "error" "warning")
+	     error-buffer error-line)
+    (select-window typeset-win)
+    (skip-chars-backward "0-9")
+    (recenter (/ (window-height) 2))
+    (sit-for 3)
+    (goto-char (match-beginning 0))
+    (select-window error-win))
 )
 
 (defun YaTeX-jump-error-line ()
   "Jump to corresponding line on latex command's error message."
   (interactive)
-  (let ((p (point))
-	(end (progn (end-of-line) (point)))
-	(begin (progn (beginning-of-line)(point))))
-    (if (null (re-search-forward "l[ ines]*\\.*[1-9][0-9]*" end t))
-	(if (save-excursion (end-of-line) (eobp))
-	    (progn (goto-char p) (insert (this-command-keys)))
-	  (message "No line number expression"))
+  (let (error-line error-file error-buf)
+    (save-excursion
+      (beginning-of-line)
+      (setq error-line (re-search-forward "l[ ines]*\\.\\([1-9][0-9]*\\)"
+					  (point-end-of-line) t)))
+    (if (null error-line)
+	(if (eobp) (insert (this-command-keys))
+	  (error "No line number expression."))
       (goto-char (match-beginning 0))
-      (re-search-forward "[1-9][0-9]*" end t)
-      (save-restriction
-	(let ((error-line
-	       (string-to-int (buffer-substring (match-beginning 0)
-						(match-end 0))))
-	      (error-file (YaTeX-get-error-file current-TeX-buffer)))
-	  ;;(goto-char (match-beginning 0))
-	  (other-window -1)
-	  (message "errors in %s" error-file)
-	  ;(switch-to-buffer current-TeX-buffer)
-	  (if (not (YaTeX-switch-to-buffer error-file))
-	      (error "%s is not found in this directory."))
-	  (goto-line error-line)))))
+      (setq error-line (string-to-int
+			(buffer-substring (match-beginning 1) (match-end 1)))
+	    error-file (YaTeX-get-error-file YaTeX-current-TeX-buffer)
+	    error-buf (YaTeX-switch-to-buffer error-file t))
+      (if (null error-buf)
+	  (error "`%s' is not found in this directory." error-file))
+      (YaTeX-showup-buffer error-buf nil t)
+      (goto-line error-line)))
 )
 
 (defun YaTeX-send-string ()
@@ -425,7 +416,7 @@
       
 (defun YaTeX-put-nonstopmode ()
   (if YaTeX-need-nonstop
-      (if (re-search-backward "\\nonstopmode{}" (point-min) t)
+      (if (re-search-backward "\\\\nonstopmode{}" (point-min) t)
 	  nil                    ;if already written in text then do nothing
 	(save-excursion
 	  (YaTeX-visit-main t)
@@ -453,7 +444,9 @@
 	 (fname (if (> rin -1) (substring latex-cmd (1+ rin)) ""))
 	 (period))
     (if (string= fname "")
-	(setq fname (substring (buffer-name) 0 -4))
+	(setq fname (substring (file-name-nondirectory
+				(buffer-file-name))
+			       0 -4))
       (setq period (rindex fname ?.))
       (setq fname (substring fname 0 (if (eq -1 period) nil period)))
       ))
@@ -461,21 +454,24 @@
 
 (defun YaTeX-get-latex-command (&optional switch)
   "Specify the latex-command name and its argument.
-If there is a line which begins by string: \"%#!\", the following
+If there is a line which begins with string: \"%#!\", the following
 strings are assumed to be the latex-command and arguments.  The
 default value of latex-command is:
-	tex-command (buffer-name)
+	tex-command FileName
 and if you write \"%#!jlatex\" in the beginning of certain line.
-	\"jlatex \" (buffer-name)
+	\"jlatex \" FileName
 will be the latex-command,
 and you write \"%#!jlatex main.tex\" on some line and argument SWITCH
-is t, then
+is non-nil, then
 	\"jlatex main.tex\"
 will be given to the shell."
-  (let*
-      ((default-command
-	 (concat tex-command " "
-		 (if switch (buffer-name) ""))));default value
+  (let*((target (file-name-nondirectory
+		 (or YaTeX-parent-file
+		     (save-excursion
+		       (YaTeX-visit-main t)
+		       (buffer-file-name)))))
+	(default-command
+	  (concat tex-command " " (if switch target ""))));default value
     (save-excursion
       (goto-char (point-min))
       (if (null (re-search-forward "^%#!" (point-max) t))
@@ -486,16 +482,16 @@
 	  (let ((s (point)))
 	    (skip-chars-forward "^ 	" (point-end-of-line)) ;Skip command
 	    (skip-chars-forward " 	" (point-end-of-line))
-	    ;(setq YaTeX-latex-command (buffer-substring s (point)))
 	    (cond
 	     ((null switch)
 	      (buffer-substring s (point)))
 	     ((eolp)			 ;Only return command name
-	      (concat (buffer-substring s (point)) " " (buffer-name)))
+	      (concat (buffer-substring s (point)) " "
+		      (file-name-nondirectory
+		       (or YaTeX-parent-file (buffer-file-name)))))
 	     (t(end-of-line)		   ;Change entire command name
 	       (buffer-substring s (point))) ;including arguments.
-	    ))
-	))))
+	    ))))))
 )
 
 (defun YaTeX-lpr (arg)
@@ -542,26 +538,42 @@
 
 (defun YaTeX-main-file-p ()
   "Return if current buffer is main LaTeX source."
-  (string-match (concat "^" (YaTeX-get-preview-file-name) ".tex")(buffer-name))
+  (cond
+   ((YaTeX-get-builtin "!")
+    (string-match
+     (concat "^" (YaTeX-get-preview-file-name) ".tex")(buffer-name)))
+   (t
+    (save-excursion
+      (let ((latex-main-id (concat "^\\s *" YaTeX-ec-regexp "documentstyle")))
+	(or (re-search-backward latex-main-id nil t)
+	    (re-search-forward latex-main-id nil t))))))
 )
 
 (defun YaTeX-visit-main (&optional setbuf)
   "Switch to buffer main LaTeX source.  Use set-buffer instead of
-switch-to-buffer if optional second argument SETBUF is t(Use it only
+switch-to-buffer if the optional second argument SETBUF is t(Use it only
 in Emacs-Lisp program)."
   (interactive)
-  (let ((main-file (YaTeX-get-preview-file-name)))
-    (if (string-match (concat "^" main-file ".tex") (buffer-name))
+  (let (main-file)
+    (if (YaTeX-get-builtin "!")
+	(setq main-file (concat (YaTeX-get-preview-file-name) ".tex")))
+    (if YaTeX-parent-file
+	(setq main-file YaTeX-parent-file))
+    (if (YaTeX-main-file-p)
 	(if (interactive-p) (message "I think this is main LaTeX source.") nil)
       (cond
-       ((YaTeX-switch-to-buffer (setq main-file (concat main-file ".tex"))
-				setbuf))
-       ((and (file-exists-p (setq main-file (concat "../" main-file)))
+       ((and (interactive-p) main-file (get-buffer-window main-file))
+	(select-window (get-buffer-window main-file)))
+       ((and main-file (YaTeX-switch-to-buffer main-file setbuf)))
+       ((and main-file
+	     (file-exists-p (setq main-file (concat "../" main-file)))
 	     (y-or-n-p (concat (expand-file-name main-file)
 			       " is main file?:")))
 	(YaTeX-switch-to-buffer main-file setbuf))
-       (t (find-file (read-file-name "Enter your main text: " nil nil 1)))
-	)))
+       (t (setq main-file (read-file-name "Enter your main text: " nil nil 1))
+	  (setq YaTeX-parent-file main-file)
+	  (find-file main-file))
+       )))
   nil
 )
 
@@ -605,22 +617,32 @@
     (pop-to-buffer buffer))
 )
 
-(defun YaTeX-showup-buffer (buffer &optional func)
+(defun YaTeX-showup-buffer (buffer &optional func select)
   "Make BUFFER show up in certain window (but current window)
 that gives the maximum value by the FUNC.  FUNC should take an argument
-of its window object"
-  (or (get-buffer-window buffer)
-      (< (length (YaTeX-window-list)) 3)
-      (let ((window (selected-window)) (list (YaTeX-window-list)) win w (x 0))
-	(while list
-	  (setq w (car list))
-	    (if (and (not (eq window w))
-		     (> (funcall func w) x))
-		(setq win w x (funcall func w)))
-	    (setq list (cdr list)))
-	(select-window win)
-	(switch-to-buffer buffer)
-	(select-window window)))
+of its window object.  Non-nil for optional third argument SELECT selects
+that window."
+  (or (and (get-buffer-window buffer)
+	   (progn (if select (select-window (get-buffer-window buffer))) t))
+      (cond
+       ((> (length (YaTeX-window-list)) 2)
+	(let ((window (selected-window))
+	      (list (YaTeX-window-list)) win w (x 0))
+	  (if func
+	      (while list
+		(setq w (car list))
+		(if (and (not (eq window w))
+			 (> (funcall func w) x))
+		    (setq win w x (funcall func w)))
+		(setq list (cdr list)))
+	    (setq win (get-lru-window)))
+	  (select-window win)
+	  (switch-to-buffer buffer)
+	  (or select (select-window window))))
+       ((= (length (YaTeX-window-list)) 2)
+	(other-window 1)
+	(switch-to-buffer buffer))
+       (t nil)))
 )
 
 (defun YaTeX-window-list ()

yatex.org