yatex

diff yatexprc.el @ 15:cd762e854337

Fix bugs.
author yuuji
date Mon, 25 Apr 1994 03:18:12 +0000
parents b7b023a74293
children cb9afa9c1213
line diff
     1.1 --- a/yatexprc.el	Fri Apr 22 17:35:25 1994 +0000
     1.2 +++ b/yatexprc.el	Mon Apr 25 03:18:12 1994 +0000
     1.3 @@ -2,7 +2,7 @@
     1.4  ;;; YaTeX process handler.
     1.5  ;;; yatexprc.el
     1.6  ;;; (c )1993-1994 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
     1.7 -;;; Last modified Sat Apr 23 02:34:07 1994 on pajero
     1.8 +;;; Last modified Mon Apr 25 12:13:17 1994 on alto
     1.9  ;;; $Id$
    1.10  
    1.11  (require 'yatex)
    1.12 @@ -464,34 +464,23 @@
    1.13  and you write \"%#!jlatex main.tex\" on some line and argument SWITCH
    1.14  is non-nil, then
    1.15  	\"jlatex main.tex\"
    1.16 +
    1.17  will be given to the shell."
    1.18 -  (let*((target (file-name-nondirectory
    1.19 -		 (or YaTeX-parent-file
    1.20 -		     (save-excursion
    1.21 -		       (YaTeX-visit-main t)
    1.22 -		       (buffer-file-name)))))
    1.23 -	(default-command
    1.24 -	  (concat tex-command " " (if switch target ""))));default value
    1.25 -    (save-excursion
    1.26 -      (goto-char (point-min))
    1.27 -      (if (null (re-search-forward "^%#!" (point-max) t))
    1.28 -	  default-command
    1.29 -	(skip-chars-forward "%#! 	")
    1.30 -	(if (eolp)
    1.31 -	    default-command
    1.32 -	  (let ((s (point)))
    1.33 -	    (skip-chars-forward "^ 	" (point-end-of-line)) ;Skip command
    1.34 -	    (skip-chars-forward " 	" (point-end-of-line))
    1.35 -	    (cond
    1.36 -	     ((null switch)
    1.37 -	      (buffer-substring s (point)))
    1.38 -	     ((eolp)			 ;Only return command name
    1.39 -	      (concat (buffer-substring s (point)) " "
    1.40 -		      (file-name-nondirectory
    1.41 -		       (or YaTeX-parent-file (buffer-file-name)))))
    1.42 -	     (t(end-of-line)		   ;Change entire command name
    1.43 -	       (buffer-substring s (point))) ;including arguments.
    1.44 -	    ))))))
    1.45 +  (let (magic command target)
    1.46 +    (setq parent
    1.47 +	  (cond
    1.48 +	   (YaTeX-parent-file YaTeX-parent-file)
    1.49 +	   (t (save-excursion
    1.50 +		(YaTeX-visit-main t)
    1.51 +		(file-name-nondirectory (buffer-file-name)))))
    1.52 +	  magic (YaTeX-get-builtin "!"))
    1.53 +    (cond
    1.54 +     (magic
    1.55 +      (cond
    1.56 +       (switch (if (string-match "\\s " magic) magic
    1.57 +		 (concat magic " " parent)))
    1.58 +       (t (concat (substring magic 0 (string-match "\\s " magic)) " "))))
    1.59 +     (t (concat tex-command " " parent))))
    1.60  )
    1.61  
    1.62  (defun YaTeX-lpr (arg)
    1.63 @@ -540,8 +529,7 @@
    1.64    "Return if current buffer is main LaTeX source."
    1.65    (cond
    1.66     ((YaTeX-get-builtin "!")
    1.67 -    (string-match
    1.68 -     (concat "^" (YaTeX-get-preview-file-name) ".tex")(buffer-name)))
    1.69 +    (string-match (YaTeX-guess-parent (YaTeX-get-builtin "!")) (buffer-name)))
    1.70     (t
    1.71      (save-excursion
    1.72        (let ((latex-main-id (concat "^\\s *" YaTeX-ec-regexp "documentstyle")))
    1.73 @@ -550,13 +538,13 @@
    1.74  )
    1.75  
    1.76  (defun YaTeX-visit-main (&optional setbuf)
    1.77 -  "Switch to buffer main LaTeX source.  Use set-buffer instead of
    1.78 -switch-to-buffer if the optional second argument SETBUF is t(Use it only
    1.79 -in Emacs-Lisp program)."
    1.80 +  "Switch buffer to main LaTeX source.
    1.81 +Use set-buffer instead of switch-to-buffer if the optional second argument
    1.82 +SETBUF is t(Use it only from Emacs-Lisp program)."
    1.83    (interactive)
    1.84 -  (let (main-file)
    1.85 -    (if (YaTeX-get-builtin "!")
    1.86 -	(setq main-file (concat (YaTeX-get-preview-file-name) ".tex")))
    1.87 +  (let (b-in main-file)
    1.88 +    (if (setq b-in (YaTeX-get-builtin "!"))
    1.89 +	(setq main-file (YaTeX-guess-parent b-in)))
    1.90      (if YaTeX-parent-file
    1.91  	(setq main-file YaTeX-parent-file))
    1.92      (if (YaTeX-main-file-p)
    1.93 @@ -577,6 +565,19 @@
    1.94    nil
    1.95  )
    1.96  
    1.97 +
    1.98 +(defun YaTeX-guess-parent (command-line)
    1.99 +  (setq command-line
   1.100 +	(if (string-match ".*\\s " command-line)
   1.101 +	    (substring command-line (match-end 0))
   1.102 +	  (file-name-nondirectory (buffer-file-name)))
   1.103 +	command-line
   1.104 +	(concat (if (string-match "\\(.*\\)\\." command-line)
   1.105 +		    (substring command-line (match-beginning 1) (match-end 1))
   1.106 +		  command-line)
   1.107 +		".tex"))
   1.108 +)
   1.109 +
   1.110  (defun YaTeX-visit-main-other-window ()
   1.111    "Switch to buffer main LaTeX source in other window."
   1.112    (interactive)
   1.113 @@ -589,7 +590,8 @@
   1.114    "Read source built-in command of %# usage."
   1.115    (save-excursion
   1.116      (goto-char (point-min))
   1.117 -    (if (and (search-forward (concat "%#" key) nil t)
   1.118 +    (if (and (re-search-forward
   1.119 +	      (concat "^" (regexp-quote (concat "%#" key))) nil t)
   1.120  	     (not (eolp)))
   1.121  	(buffer-substring
   1.122  	 (progn (skip-chars-forward " 	" (point-end-of-line))(point))