yatex

changeset 16:cb9afa9c1213

Auto-indentation at begin-type completion works correctly. Hack for gmhist&gmhist-mh. Fix the bug on \ref-completion. YaTeX-help is now available.
author yuuji
date Fri, 06 May 1994 21:14:11 +0000
parents cd762e854337
children 919153366b35
files docs/yatex.ref docs/yatexadd.doc yahtml.el yatex.el yatex.new yatexadd.el yatexhlp.el yatexm-o.el yatexprc.el
diffstat 9 files changed, 308 insertions(+), 50 deletions(-) [+]
line diff
     1.1 --- a/docs/yatex.ref	Mon Apr 25 03:18:12 1994 +0000
     1.2 +++ b/docs/yatex.ref	Fri May 06 21:14:11 1994 +0000
     1.3 @@ -114,6 +114,7 @@
     1.4  	  新規作成/更新モード、数式モードの切り替えメニューが出ます。
     1.5  
     1.6  	◆%# 記法の編集			[prefix] %
     1.7 +	◆オンラインヘルプ		[prefix] ?
     1.8  
     1.9  							       広瀬雄二
    1.10  						    yuuji@ae.keio.ac.jp
     2.1 --- a/docs/yatexadd.doc	Mon Apr 25 03:18:12 1994 +0000
     2.2 +++ b/docs/yatexadd.doc	Fri May 06 21:14:11 1994 +0000
     2.3 @@ -32,10 +32,10 @@
     2.4  	  さすがに、関数を書くだけでは使えません:-)。yatex-mode 起動時には、
     2.5  	その関数を定義したファイルがロードされていなくてはなりません。関数
     2.6  	を定義するファイル名を yatexadd.el(またはバイトコンパイルした形式
     2.7 -	のyatexadd.elc)にし、そのファイルを load-path 中に置いておけば、 
     2.8 +	の yatexadd.elc)にし、そのファイルを load-path 中に置いておけば、 
     2.9  	野鳥が自動的にロードします。それ以外のファイル名にする場合は、
    2.10 -	yatex-mode-hook に付加関数を定義する Emacs-Lisp ファイルをロードす
    2.11 -	るような仕掛けを書いておくのがよいでしょう。
    2.12 +	yatex-mode-load-hook に付加関数を定義する Emacs-Lisp ファイルをロー
    2.13 +	ドするような仕掛けを書いておくのがよいでしょう。
    2.14  
    2.15  
    2.16  【関数定義】
    2.17 @@ -66,10 +66,10 @@
    2.18  			    ~~~~  ~~~
    2.19  
    2.20  	引数型付加関数は『LaTeXコマンド名の前に YaTeX:: をつけた名前』で定
    2.21 -	義します。また引数型付加関数が呼ばれる時には何番目の引数を入力して
    2.22 -	いるのかが引数として渡されます。したがって、引数型付加関数は整数の
    2.23 -	引数を一つ取るものとして定義し、その引数の値により処理を決定するこ
    2.24 -	とになります。
    2.25 +	義します。また引数型付加関数が呼ばれる時にはsection型コマンドの何
    2.26 +	番目の引数を入力しているのかが関数への引数として渡されます。したがっ
    2.27 +	て、引数型付加関数は整数の引数を一つ取るものとして定義し、その引数
    2.28 +	の値により処理を決定することになります。
    2.29  
    2.30  
    2.31  【定義例】
    2.32 @@ -106,8 +106,8 @@
    2.33  		(defun YaTeX::newcommand (n)	;nは引数の位置
    2.34  		  (cond
    2.35  		   ((= n 1)			;第一引数ならコマンド名
    2.36 -		    (concat "\\" (read-string "Command: ")))
    2.37 -		   ((= n 2) "")			;第二引数なら何も入れない
    2.38 +		    (read-string "Command: " "\\")) ;\を初期入力とする
    2.39 +		   ((= n 2) "")			;第二引数なら何もしない
    2.40  		   (t nil)))
    2.41  
    2.42  	なお、引数型付加関数が nil を返した場合は、通常の引数入力関数が呼
     3.1 --- a/yahtml.el	Mon Apr 25 03:18:12 1994 +0000
     3.2 +++ b/yahtml.el	Fri May 06 21:14:11 1994 +0000
     3.3 @@ -1,6 +1,6 @@
     3.4  ;;; -*- Emacs-Lisp -*-
     3.5 -;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp, pcs39334@asciinet.or.jp]
     3.6 -;;; Last modified Sat Apr 23 02:27:54 1994 on pajero
     3.7 +;;; (c ) 1994 by HIROSE Yuuji [yuuji@ae.keio.ac.jp, pcs39334@ascii-net.or.jp]
     3.8 +;;; Last modified Wed May  4 05:31:29 1994 on 98fa
     3.9  ;;; This is sample hack definition for HTML.
    3.10  ;;;
    3.11  ;;; [Purely tentative version]
     4.1 Binary file yatex.el has changed
     5.1 --- a/yatex.new	Mon Apr 25 03:18:12 1994 +0000
     5.2 +++ b/yatex.new	Fri May 06 21:14:11 1994 +0000
     5.3 @@ -1,7 +1,14 @@
     5.4 -
     5.5  	Yet Another tex-mode for Emacs
     5.6  	yatex.el 各バージョンの変更点について。
     5.7  
     5.8 +1.48	[prefix] ? の YaTeX-help でカーソル位置の LaTeX コマンドのヘルプ
     5.9 +	が出るようにした(ヘルプ内容は未完成)。
    5.10 +	begin 型補完全般でのインデント調整処理の改善。
    5.11 +	gmhistとの連携により Preview, Lpr, call-command それぞれのヒスト
    5.12 +	リを他のヒストリとは分離させた。
    5.13 +	\ref 補完でカレントバッファのラベルが出なくなっていたバグを修正。
    5.14 +	outline-minor-mode との連携がうまくいかなかったのを修正。
    5.15 +
    5.16  1.47	YaTeX-quick-in-environment-p と YaTeX-get-latex-command の
    5.17  	バグフィクス。
    5.18  
    5.19 @@ -10,6 +17,8 @@
    5.20  	エラー行ジャンプの適正化。
    5.21  	再帰的 section 型補完時のバグフィクス。
    5.22  	親ファイルを手入力した時に二度目以降もそのファイルを親とみなす。
    5.23 +	[prefix] g でファイル間ジャンプをする時に、既にそのファイルがど
    5.24 +	こかのウィンドウに出ていれば、そのウィンドウに移るようにした。
    5.25  	\verbのアドイン関数追加。
    5.26  
    5.27  1.45:	comment-region を begin/end 行で起動した時にメッセージを出す。
    5.28 @@ -122,3 +131,7 @@
    5.29  	fill-prefix を null にした。
    5.30  
    5.31  1.27:	最初の正式リリース版
    5.32 +
    5.33 +Local Variables:
    5.34 +mode: indented-text
    5.35 +End:
     6.1 --- a/yatexadd.el	Mon Apr 25 03:18:12 1994 +0000
     6.2 +++ b/yatexadd.el	Fri May 06 21:14:11 1994 +0000
     6.3 @@ -1,8 +1,8 @@
     6.4  ;;; -*- Emacs-Lisp -*-
     6.5  ;;; YaTeX add-in functions.
     6.6 -;;; yatexadd.el rev.7
     6.7 +;;; yatexadd.el rev.8
     6.8  ;;; (c )1991-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
     6.9 -;;; Last modified Sat Apr 23 02:26:47 1994 on pajero
    6.10 +;;; Last modified Sat May  7 06:09:39 1994 on pajero
    6.11  ;;; $Id$
    6.12  
    6.13  (provide 'yatexadd)
    6.14 @@ -80,6 +80,10 @@
    6.15  (fset 'YaTeX:eqnarray 'YaTeX:equation)
    6.16  (fset 'YaTeX:displaymath 'YaTeX:equation)
    6.17  
    6.18 +(defun YaTeX:list ()
    6.19 +  "%\n{} %default label\n{} %formatting parameter"
    6.20 +)
    6.21 +
    6.22  ;;;
    6.23  ;;Sample functions for section-type command.
    6.24  ;;;
    6.25 @@ -292,6 +296,7 @@
    6.26  	))
    6.27      ))
    6.28  )
    6.29 +(fset 'YaTeX::pageref 'YaTeX::ref)
    6.30  
    6.31  (defun YaTeX-label-other ()
    6.32    (let ((lbuf "*YaTeX mode buffers*") (blist (buffer-list)) (lnum -1) buf rv
    6.33 @@ -360,6 +365,24 @@
    6.34     (t ""))
    6.35  )
    6.36  
    6.37 +;;
    6.38 +; completion for the arguments of \pagestyle
    6.39 +;;
    6.40 +(defun YaTeX::pagestyle (&optional argp)
    6.41 +  "Read the pagestyle with completion."
    6.42 +  (completing-read
    6.43 +   "Page style: "
    6.44 +   '(("plain") ("empty") ("headings") ("myheadings") ("normal") nil))
    6.45 +)
    6.46 +;;
    6.47 +; completion for the arguments of \pagenumbering
    6.48 +;;
    6.49 +(defun YaTeX::pagenumbering (&optional argp)
    6.50 +  "Read the numbering style."
    6.51 +  (completing-read
    6.52 +   "Page numbering style: "
    6.53 +   '(("arabic") ("Alpha") ("alpha") ("Roman") ("roman")))
    6.54 +)
    6.55  
    6.56  ;;;
    6.57  ;; global subroutines
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/yatexhlp.el	Fri May 06 21:14:11 1994 +0000
     7.3 @@ -0,0 +1,198 @@
     7.4 +;;; -*- Emacs-Lisp -*-
     7.5 +;;; YaTeX helper with LaTeX commands and macros.
     7.6 +;;; yatexhlp.el
     7.7 +;;; (c )1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
     7.8 +;;; Last modified Thu May  5 16:09:42 1994 on 98fa
     7.9 +;;; $Id$
    7.10 +
    7.11 +(let ((help-file
    7.12 +       (concat "YATEXHLP."
    7.13 +	       (cond (YaTeX-japan "jp")
    7.14 +		     (t "eng")))))
    7.15 +  (defvar YaTeX-help-file
    7.16 +    (expand-file-name help-file exec-directory)
    7.17 +    "*Help file of LaTeX/TeX commands or macros.")
    7.18 +  (defvar YaTeX-help-file-private
    7.19 +    (expand-file-name (concat "~/" help-file))
    7.20 +    "*Private help file of LaTeX/TeX macros.")
    7.21 +)
    7.22 +(defvar YaTeX-help-delimiter "\C-_" "Delimiter of each help entry.")
    7.23 +(defvar YaTeX-help-entry-map (copy-keymap YaTeX-mode-map)
    7.24 +  "Key map used in help entry.")
    7.25 +(defvar YaTeX-help-file-current nil
    7.26 +  "Holds help file name to which the description in current buffer should go.")
    7.27 +(defvar YaTeX-help-command-current nil
    7.28 +  "Holds command name on which the user currently write description.")
    7.29 +(defvar YaTeX-help-saved-config nil
    7.30 +  "Holds window configruation before the editing of manual.")
    7.31 +(defvar YaTeX-help-synopsis
    7.32 +  (cond (YaTeX-japan "【書式】")
    7.33 +	(t "[[ Synopsis ]]"))
    7.34 +  "Section header of synopsis.")
    7.35 +(defvar YaTeX-help-description
    7.36 +  (cond (YaTeX-japan "【説明】")
    7.37 +	(t "[[ Description ]]"))
    7.38 +  "Section header of description.")
    7.39 +
    7.40 +(defun YaTeX-refer-help (command help-file)
    7.41 +  "Refer the COMMAND's help into HELP-FILE.
    7.42 +\[Help-file format\]
    7.43 +<DELIM><LaTeX/TeX command without escape character(\\)><NL>
    7.44 +<Synopsis><NL>
    7.45 +<Documentation><TERM>
    7.46 +Where:	<DELIM> is the value of YaTeX-help-delimiter.
    7.47 +	<NL> is newline.
    7.48 +	<TERM> is newline or end of buffer."
    7.49 +  (let ((hfbuf (find-file-noselect help-file))
    7.50 +	(hbuf (get-buffer-create "** YaTeX HELP **"))
    7.51 +	(curwin (selected-window))
    7.52 +	sb se db de)
    7.53 +    (set-buffer hfbuf)
    7.54 +    (goto-char (point-min))
    7.55 +    (if (null
    7.56 +	 (re-search-forward
    7.57 +	  (concat (regexp-quote YaTeX-help-delimiter)
    7.58 +		  (regexp-quote command)
    7.59 +		  "$") nil t))
    7.60 +	nil				;if not found, return nil
    7.61 +      (forward-line 1)
    7.62 +      (setq sb (point)
    7.63 +	    se (progn (forward-line 1) (point))
    7.64 +	    db (point)
    7.65 +	    de (progn
    7.66 +		 (re-search-forward (regexp-quote YaTeX-help-delimiter) nil 1)
    7.67 +		 (1- (match-beginning 0))))
    7.68 +      (YaTeX-showup-buffer hbuf)
    7.69 +      (pop-to-buffer hbuf)
    7.70 +      (erase-buffer)
    7.71 +      (insert YaTeX-help-synopsis "\n")
    7.72 +      (insert-buffer-substring hfbuf sb se)
    7.73 +      (insert "\n" YaTeX-help-description "\n")
    7.74 +      (insert-buffer-substring hfbuf db de)
    7.75 +      (goto-char (point-min))
    7.76 +      (select-window curwin)
    7.77 +      t))
    7.78 +)
    7.79 +(defun YaTeX-help-newline (&optional arg)
    7.80 +  (interactive "P")
    7.81 +  (if (and (= (current-column) 1) (= (preceding-char) ?.) (eolp))
    7.82 +      (let ((cbuf (current-buffer)))
    7.83 +	(beginning-of-line)
    7.84 +	(kill-line 1)
    7.85 +	(save-excursion
    7.86 +	  (YaTeX-help-add-entry
    7.87 +	   YaTeX-help-command-current YaTeX-help-file-current))
    7.88 +	(set-window-configuration YaTeX-help-saved-config)
    7.89 +	(bury-buffer cbuf))
    7.90 +    (newline arg))
    7.91 +)
    7.92 +(defun YaTeX-help-add-entry (command help-file)
    7.93 +  (let ((hfbuf (find-file-noselect help-file))
    7.94 +	(dbuf (current-buffer)) beg end)
    7.95 +    (goto-char (point-min))
    7.96 +    (re-search-forward (concat "^" (regexp-quote YaTeX-help-synopsis)))
    7.97 +    (forward-line 1)	(setq beg (point))
    7.98 +    (end-of-line)	(setq end (point))
    7.99 +    (set-buffer hfbuf)
   7.100 +    (goto-char (point-min))
   7.101 +    (insert YaTeX-help-delimiter command "\n")
   7.102 +    (insert-buffer-substring dbuf beg end)
   7.103 +    (insert "\n")
   7.104 +    (set-buffer dbuf)
   7.105 +    (re-search-forward (concat "^" (regexp-quote YaTeX-help-description)))
   7.106 +    (forward-line 1)
   7.107 +    (setq beg (point))
   7.108 +    (setq end (point-max))
   7.109 +    (set-buffer hfbuf)
   7.110 +    (insert-buffer-substring dbuf beg end)
   7.111 +    (insert "\n\n")
   7.112 +    (forward-line -1)
   7.113 +    (delete-blank-lines)
   7.114 +    (let ((make-backup-files t))
   7.115 +      (basic-save-buffer))
   7.116 +    (bury-buffer hfbuf))
   7.117 +)
   7.118 +(defun YaTeX-help-prepare-entry (command help-file)
   7.119 +  "Read help description on COMMAND and add it to HELP-FILE."
   7.120 +  (let ((buf (get-buffer-create "**Description**"))
   7.121 +	(conf (current-window-configuration)))
   7.122 +    (YaTeX-showup-buffer buf)
   7.123 +    (pop-to-buffer buf)
   7.124 +    (make-local-variable 'YaTeX-help-file-current)
   7.125 +    (make-local-variable 'YaTeX-help-command-current)
   7.126 +    (make-local-variable 'YaTeX-help-saved-config)
   7.127 +    (setq YaTeX-help-file-current help-file
   7.128 +	  YaTeX-help-command-current command
   7.129 +	  YaTeX-help-saved-config conf
   7.130 +	  mode-name "Text"
   7.131 +	  major-mode 'text)
   7.132 +    (erase-buffer)
   7.133 +    (insert YaTeX-help-synopsis "\n\n" YaTeX-help-description "\n\n")
   7.134 +    (define-key YaTeX-help-entry-map "\r" 'YaTeX-help-newline)
   7.135 +    (use-local-map YaTeX-help-entry-map)
   7.136 +    (message
   7.137 +     (cond (YaTeX-japan "入力を終えたら . のみ入力してRET")
   7.138 +	   (t "Type only `.' and RET to exit."))))
   7.139 +)
   7.140 +(defun YaTeX-enrich-help (command)
   7.141 +  "Add the COMMAND's help to help file."
   7.142 +  (if (y-or-n-p (format "No help on `%s'. Create help?" command))
   7.143 +      (YaTeX-help-prepare-entry
   7.144 +       command
   7.145 +       (if (y-or-n-p "Add help to global documentation?")
   7.146 +	   YaTeX-help-file YaTeX-help-file-private)))
   7.147 +)
   7.148 +
   7.149 +(defun YaTeX-help-sort (&optional help-file)
   7.150 +  "Sort help file HELP-FILE.
   7.151 +If HELP-FILE is nil or called interactively, sort current buffer
   7.152 +as a help file."
   7.153 +  (interactive)
   7.154 +  (if help-file (set-buffer (find-file-noselect help-file)))
   7.155 +  (sort-regexp-fields
   7.156 +   nil "\\(\\sw+\\)\\([^]+\\|\\s'\\)" "\\1" (point-min) (point-max))
   7.157 +)
   7.158 +
   7.159 +;;;###autoload
   7.160 +(defun YaTeX-help ()
   7.161 +  "Show help buffer of LaTeX/TeX commands or macros."
   7.162 +  (interactive)
   7.163 +  (let (p beg end command)
   7.164 +    (save-excursion
   7.165 +      (if (looking-at YaTeX-ec-regexp)
   7.166 +	  (goto-char (match-end 0)))
   7.167 +      (setq p (point))			;remember current position.
   7.168 +      (cond
   7.169 +       ((YaTeX-on-begin-end-p)
   7.170 +	;;if on \begin or \end, extract its environment.
   7.171 +	(setq command
   7.172 +	      (cond ((match-beginning 1)
   7.173 +		     (buffer-substring (match-beginning 1) (match-end 1)))
   7.174 +		    ((match-beginning 2)
   7.175 +		     (buffer-substring (match-beginning 2) (match-end 2))))))
   7.176 +       ((search-backward YaTeX-ec (point-beginning-of-line) t)
   7.177 +	(goto-char (setq beg (match-end 0)))
   7.178 +	(re-search-forward "\\sw+")
   7.179 +	(setq end (point))
   7.180 +	(if (and (<= beg p) (<= p end))
   7.181 +	    (setq command (buffer-substring beg end)))))
   7.182 +      (if (or (string= command "begin") (string= command "end"))
   7.183 +	  (progn
   7.184 +	    (search-forward "{" (point-end-of-line))
   7.185 +	    (setq beg (point))
   7.186 +	    (search-forward "}" (point-end-of-line))
   7.187 +	    (setq command (buffer-substring beg (match-beginning 0)))))
   7.188 +      (setq command
   7.189 +	    (completing-read
   7.190 +	     "Describe (La)TeX command: "
   7.191 +	     (append
   7.192 +	      section-table user-section-table tmp-section-table
   7.193 +	      article-table user-article-table
   7.194 +	      env-table     user-env-table     tmp-env-table
   7.195 +	      singlecmd-table user-singlecmd-table tmp-singlecmd-table)
   7.196 +	     nil nil command))	;no-predicate, not require match
   7.197 +      );end excursion
   7.198 +    (or (YaTeX-refer-help command YaTeX-help-file)
   7.199 +	(YaTeX-refer-help command YaTeX-help-file-private)
   7.200 +	(YaTeX-enrich-help command)))
   7.201 +)
     8.1 --- a/yatexm-o.el	Mon Apr 25 03:18:12 1994 +0000
     8.2 +++ b/yatexm-o.el	Fri May 06 21:14:11 1994 +0000
     8.3 @@ -1,7 +1,7 @@
     8.4  ;;; -*- Emacs-Lisp -*-
     8.5  ;;; Sample startup file to invoke yatex-mode with outline-minor mode.
     8.6  ;;; (c )1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
     8.7 -;;; Last modified Sat Jan 29 16:55:05 1994 on gloria
     8.8 +;;; Last modified Wed May  4 19:44:53 1994 on 98fa
     8.9  
    8.10  ;;;
    8.11  ;; outline-minor-mode(使用しない場合は不要です)
    8.12 @@ -26,11 +26,12 @@
    8.13  (defvar yatex-mode-hook
    8.14    '(lambda ()
    8.15       (setq outline-regexp LaTeX-outline-regexp)			    ;;@
    8.16 -     (outline-minor-mode)					    ;;@
    8.17 -     (YaTeX-define-begend-key "ba" "abstract")))
    8.18 +     (outline-minor-mode 1)					    ;;@
    8.19 +     ))
    8.20  (defvar yatex-mode-load-hook
    8.21    '(lambda ()
    8.22       (setq-default outline-prefix-char (concat YaTeX-prefix "\C-o"));;@
    8.23       (require 'min-out)						    ;;@
    8.24       (define-key outline-minor-keymap "\C-?" 'hide-subtree)	    ;;@
    8.25 +     (YaTeX-define-begend-key "ba" "abstract")
    8.26       ))
     9.1 --- a/yatexprc.el	Mon Apr 25 03:18:12 1994 +0000
     9.2 +++ b/yatexprc.el	Fri May 06 21:14:11 1994 +0000
     9.3 @@ -2,7 +2,7 @@
     9.4  ;;; YaTeX process handler.
     9.5  ;;; yatexprc.el
     9.6  ;;; (c )1993-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
     9.7 -;;; Last modified Mon Apr 25 12:13:17 1994 on alto
     9.8 +;;; Last modified Thu May  5 17:33:04 1994 on 98fa
     9.9  ;;; $Id$
    9.10  
    9.11  (require 'yatex)
    9.12 @@ -132,21 +132,21 @@
    9.13      (let*
    9.14  	((end "") typeout ;Type out message that tells the method of cutting.
    9.15  	 (cmd (concat (YaTeX-get-latex-command nil) " " YaTeX-texput-file))
    9.16 -	 (buffer (current-buffer)) opoint preamble
    9.17 -	 (region
    9.18 -	  (if (re-search-backward
    9.19 -	       "%#BEGIN" nil t)
    9.20 -	      (progn
    9.21 -		(setq typeout "--- Region from BEGIN to " end "END ---")
    9.22 -		(buffer-substring
    9.23 -		 (match-end 0)
    9.24 -		 (if (re-search-forward "%#END" nil t)
    9.25 -		     (match-beginning 0)
    9.26 -		   (setq end "end of buffer ---")
    9.27 -		   (point-max))))
    9.28 -	    (setq typeout "=== Region from (point) to (mark) ===")
    9.29 -	    (buffer-substring (point) (mark)))))
    9.30 +	 (buffer (current-buffer)) opoint preamble main
    9.31 +	 reg-begin reg-end)
    9.32 +      
    9.33 +      (if (re-search-backward "%#BEGIN" nil t)
    9.34 +	  (progn
    9.35 +	    (setq typeout "--- Region from BEGIN to " end "END ---"
    9.36 +		  reg-begin (match-end 0))
    9.37 +	    (if (re-search-forward "%#END" nil t)
    9.38 +		(setq reg-end (match-beginning 0)
    9.39 +		      end "end of buffer ---")
    9.40 +	      (setq reg-end (point-max))))
    9.41 +	(setq typeout "=== Region from (point) to (mark) ===")
    9.42 +	(setq reg-begin (point) reg-end (mark)))
    9.43        (YaTeX-visit-main t)
    9.44 +      (setq main (current-buffer))
    9.45        (setq opoint (point))
    9.46        (goto-char (point-min))
    9.47        (setq
    9.48 @@ -157,17 +157,18 @@
    9.49  		 "\\begin{document}")))
    9.50        (goto-char opoint)
    9.51        ;;(set-buffer buffer)		;for clarity
    9.52 -      (find-file YaTeX-texput-file)
    9.53 +      (set-buffer (find-file-noselect YaTeX-texput-file))
    9.54 +      ;;(find-file YaTeX-texput-file)
    9.55        (erase-buffer)
    9.56        (if YaTeX-need-nonstop
    9.57  	  (insert "\\nonstopmode{}\n"))
    9.58        (insert preamble "\n")
    9.59 -      (insert region)
    9.60 +      (insert-buffer-substring buffer reg-begin reg-end)
    9.61        (insert "\\typeout{" typeout end "}\n") ;Notice the selected method.
    9.62        (insert "\n\\end{document}\n")
    9.63        (basic-save-buffer)
    9.64        (kill-buffer (current-buffer))
    9.65 -      (YaTeX-visit-main t)
    9.66 +      (set-buffer main)		;return to parent file or itself.
    9.67        (YaTeX-typeset cmd YaTeX-typeset-buffer)
    9.68        (put 'dvi2-command 'region t)))
    9.69  )
    9.70 @@ -226,11 +227,15 @@
    9.71      (put 'dvi2-command 'region nil))
    9.72  )
    9.73  
    9.74 +(defvar YaTeX-call-command-history nil
    9.75 +  "Holds history list of YaTeX-call-command-on-file.")
    9.76 +(put 'YaTeX-call-command-history 'no-default t)
    9.77  (defun YaTeX-call-command-on-file (base-cmd buffer)
    9.78    (YaTeX-save-buffers)
    9.79    (YaTeX-typeset
    9.80 -   (read-string "Call command: "
    9.81 -		(concat base-cmd " " (YaTeX-get-preview-file-name)))
    9.82 +   (let ((minibufer-history-symbol 'YaTeX-call-command-history))
    9.83 +     (read-string "Call command: "
    9.84 +		  (concat base-cmd " " (YaTeX-get-preview-file-name))))
    9.85     buffer)
    9.86  )
    9.87  
    9.88 @@ -262,16 +267,25 @@
    9.89  	(start-process "system" buffer shell-file-name "-c" command))))
    9.90  )
    9.91  
    9.92 +(defvar YaTeX-preview-command-history nil
    9.93 +  "Holds minibuffer history of preview command.")
    9.94 +(put 'YaTeX-preview-command-history 'no-default t)
    9.95 +(defvar YaTeX-preview-file-history nil
    9.96 +  "Holds minibuffer history of file to preview.")
    9.97 +(put 'YaTeX-preview-file-history 'no-default t)
    9.98  (defun YaTeX-preview (preview-command preview-file)
    9.99    "Execute xdvi (or other) to tex-preview."
   9.100    (interactive
   9.101 -   (list (read-string "Preview command: " dvi2-command)
   9.102 -	 (read-string "Preview file[.dvi]: "
   9.103 -		      (if (get 'dvi2-command 'region)
   9.104 -			  (substring YaTeX-texput-file
   9.105 -				     0 (rindex YaTeX-texput-file ?.))
   9.106 -			(YaTeX-get-preview-file-name))
   9.107 -		      )))
   9.108 +   (list
   9.109 +    (let ((minibuffer-history-symbol 'YaTeX-preview-command-history))
   9.110 +      (read-string "Preview command: " dvi2-command))
   9.111 +    (let ((minibuffer-history-symbol 'YaTeX-preview-file-history))
   9.112 +      (read-string "Preview file[.dvi]: "
   9.113 +		   (if (get 'dvi2-command 'region)
   9.114 +		       (substring YaTeX-texput-file
   9.115 +				  0 (rindex YaTeX-texput-file ?.))
   9.116 +		     (YaTeX-get-preview-file-name))
   9.117 +		   ))))
   9.118    (setq dvi2-command preview-command)
   9.119    (save-excursion
   9.120      (YaTeX-visit-main t)
   9.121 @@ -480,9 +494,12 @@
   9.122         (switch (if (string-match "\\s " magic) magic
   9.123  		 (concat magic " " parent)))
   9.124         (t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
   9.125 -     (t (concat tex-command " " parent))))
   9.126 +     (t (concat tex-command " " (if switch parent)))))
   9.127  )
   9.128  
   9.129 +(defvar YaTeX-lpr-command-history nil
   9.130 +  "Holds command line history of YaTeX-lpr.")
   9.131 +(put 'YaTeX-lpr-command-history 'no-default t)
   9.132  (defun YaTeX-lpr (arg)
   9.133    "Print out.  If prefix arg ARG is non nil, call print driver without
   9.134  page range description."
   9.135 @@ -511,8 +528,10 @@
   9.136  	  ""
   9.137  	(YaTeX-replace-format dviprint-to-format "e" to)))
   9.138       )
   9.139 -    (setq cmd (read-string "Edit command line: "
   9.140 -			   (format cmd (YaTeX-get-preview-file-name))))
   9.141 +    (setq cmd
   9.142 +	  (let ((minibuffer-history-symbol 'YaTeX-lpr-command-history))
   9.143 +	    (read-string "Edit command line: "
   9.144 +			 (format cmd (YaTeX-get-preview-file-name)))))
   9.145      (save-excursion
   9.146        (YaTeX-visit-main t) ;;change execution directory
   9.147        (with-output-to-temp-buffer "*dvi-printing*"
   9.148 @@ -625,7 +644,8 @@
   9.149  of its window object.  Non-nil for optional third argument SELECT selects
   9.150  that window."
   9.151    (or (and (get-buffer-window buffer)
   9.152 -	   (progn (if select (select-window (get-buffer-window buffer))) t))
   9.153 +	   (progn (if select (select-window (get-buffer-window buffer)))
   9.154 +		  t))
   9.155        (cond
   9.156         ((> (length (YaTeX-window-list)) 2)
   9.157  	(let ((window (selected-window))
   9.158 @@ -642,8 +662,10 @@
   9.159  	  (switch-to-buffer buffer)
   9.160  	  (or select (select-window window))))
   9.161         ((= (length (YaTeX-window-list)) 2)
   9.162 -	(other-window 1)
   9.163 -	(switch-to-buffer buffer))
   9.164 +	(let ((window (selected-window)))
   9.165 +	  (other-window 1)
   9.166 +	  (switch-to-buffer buffer)
   9.167 +	  (or select (select-window window))))
   9.168         (t nil)))
   9.169  )
   9.170