[comp.emacs] TeX mode -- can't find included file.

chris@ASYLUM.GSFC.NASA.GOV (Chris Shenton) (07/18/90)

I'm editing a LaTeX file, and want to run an inferior LaTeX on the buffer.
When I do C-c C-b (TeX-buffer), it bombs because it can't find the include
file, which lives in the original directory, not /tmp.

The relevant part of the file looks like:

    \documentstyle{letter}
    \include{macros}

and C-c C-b generates the output:

    cd /tmp/
    latex "#tza26720.tex"
    TeX 2.1, ArborText Apollo version 2.1.0.7
    (//asylum/sys/node_data/tmp/#tza26720.tex
    LaTeX Version 2.09 <9 Mar 1987>
    (//thalia/local/arbortext/inputs/letter.sty
    Document Style 'letter'. Released 5 March 1986
    )
    No file macros.tex.

Is there a way to tell it to get the includes from the source directory
instead of /tmp? Is this a problem with the Abortext port of TeX?

If I set TeX-directory to "." (the current directory) rather than "/tmp/",
then things work OK, but it's a drag having all those temporary files lying
around.

Thanks in advance...

ueda@iias.fujitsu.co.jp (HALuyasu Ueda) (07/20/90)

>>>>> In article <9007181452.AA27255@asylum.gsfc.nasa.gov>, chris@ASYLUM.GSFC.NASA.GOV (Chris Shenton) writes:

chris> When I do C-c C-b (TeX-buffer), it bombs because it can't find the include
chris> file, which lives in the original directory, not /tmp.

chris> The relevant part of the file looks like:

chris>     \documentstyle{letter}
chris>     \include{macros}

chris> and C-c C-b generates the output:
..del..
chris> Is there a way to tell it to get the includes from the source directory
chris> instead of /tmp? Is this a problem with the Abortext port of TeX?

This also happend on my machine: SUN4. 
It is popular problem.

To avoid this, I changed TEXINPUT environment variable for inferrior
shell so that TEXINPUT includes the directory of processed file.

----------original TeX-start-shell in the tex-mode.el-------------------
;;; The utility functions:

(defun TeX-start-shell ()
  (require 'shell)
  (save-excursion
!    (set-buffer (make-shell "TeX-shell" nil nil "-v"))
    (setq TeX-shell-map (copy-keymap shell-mode-map))
    (TeX-define-common-keys TeX-shell-map)
    (use-local-map TeX-shell-map)
    (if (zerop (buffer-size))
	(sleep-for 1))))
----------And my reviced version ---------------------------------------
(defun TeX-start-shell ()
  (require 'shell)
  (save-excursion
!    (set-buffer (make-shell "TeX-shell" 
!			    (concat exec-directory "env")
!			    "/dev/null"
!			    (format "TEXINPUTS=%s:%s"
!				    (getenv "TEXINPUTS")
!				    default-directory
!				    )
!			    "-"
!			    "sh" "-v"))
    (setq TeX-shell-map (copy-keymap shell-mode-map))
    (TeX-define-common-keys TeX-shell-map)
    (use-local-map TeX-shell-map)
    (if (zerop (buffer-size))
	(sleep-for 1))
    ))
------------------------------------------------------------------------

Of cource this still has a problem. 
If you edit many tex-files under different directory,
just the first processed directory is available.

However, I haven't experenced such the situation yet.
Because I use '\include{}' just for a big document like Theses or Book,
and I NEVER edit such big documents at the same time.

PS. 
 This is my first article to the world.
 So, please ignore something strange character this article may
 include.
 It may be my signature written in Japanease/Kanji.

kitagawa@wave.ntt.JP (Masahiro Kitagawa) (07/28/90)

In article <9007181452.AA27255@asylum.gsfc.nasa.gov> chris@ASYLUM.GSFC.NASA.GOV (Chris Shenton) writes:

   When I do C-c C-b (TeX-buffer), it bombs because it can't find the include
   file, which lives in the original directory, not /tmp.

   If I set TeX-directory to "." (the current directory) rather than "/tmp/",
   then things work OK, but it's a drag having all those temporary files lying
   around.

It would be realy messy.
Then how about specifying temporary file name yourself.

(defvar TeX-zap-file "TEMPORARY"
  "Temporary file name used for text being sent as input to TeX.
Should be a simple file name with no extension or directory specification.")

I know this causes problem if you are working on more than one files
at a time. But do you realy do it ?

Masahiro Kitagawa
NTT Research Labs. Tokyo Japan
kitagawa@wave.ntt.jp

Mike.Williams@comp.vuw.ac.nz (Mike Williams) (07/30/90)

+-- chris@ASYLUM.GSFC.NASA.GOV (Chris Shenton) writes:
| 
| I'm editing a LaTeX file, and want to run an inferior LaTeX on the buffer.
| When I do C-c C-b (TeX-buffer), it bombs because it can't find the include
| file, which lives in the original directory, not /tmp.
| 
| [...blah...]
| 
| Is there a way to tell it to get the includes from the source directory
| instead of /tmp? Is this a problem with the Abortext port of TeX?
| 
| If I set TeX-directory to "." (the current directory) rather than "/tmp/",
| then things work OK, but it's a drag having all those temporary files lying
| around.

	I got really annoyed with creating temporary files everywhere ...
     so I wrote something to run TeX on the input file directly.  If you're
     not editing a file, but just writing something small in a buffer, it
     just runs TeX-buffer.  I don't know if this is what you want ... but
     this is what I use.  If anyone has a better way of doing it, please
     speak up.

--- cut here -------------------------------------------------------------

(defun TeX-file (&optional arg)
  "Run LaTeX on file specified - defaults to file shown in current buffer"
  (interactive)
  (let ((TeX-input-file (file-name-nondirectory (or arg (buffer-file-name))))
	(TeX-directory (file-name-directory (or arg (buffer-file-name)))))
    (if (not TeX-input-file)
	(TeX-buffer)
      (progn
	(save-some-buffers)
	(if (get-buffer "*TeX-shell*")
	    (TeX-kill-job)
	  (TeX-start-shell))
	(send-string "TeX-shell" (concat TeX-shell-cd-command " "
					 TeX-directory "\n"))
	(send-string "TeX-shell" (concat TeX-command " \""
					 TeX-input-file "\"\n"))
	(TeX-recenter-output-buffer 2)))
    ))

(define-key TeX-mode-map "\C-c\C-f" 'TeX-file)

--
      /-------------------- byrd@comp.vuw.ac.nz --------------------\ 
      | Mike Williams, Victoria University of Wellington, Aotearoa. |
      \------------ "Everyone thinks I'm paranoid ..." -------------/