Subject: Re: Spawning child processes under Windows 95

From: John Jones <[email-masked]>
Date: Tue, 12 Nov 1996 08:15:49 -0700

Eyssele Helmut writes:

 > Hallo ntemacs-users, I am installing the package AUC-TeX
 > in ntemacs 19.34 under Windows 95.  After some
 > customizations in the AUC-TeX *.el files I could run
 > latex from emacs with the command C-c C-c LaTeX
 > interactive (I use the mikTeX package from Christian
 > Schenk). But when I start the previewer YAP (yet another
 > previewer) with the command C-c C-c View and try after-
 > wards running latex again I get from emacs:

 > 	Spawning child process: resource temporarily unavailable

 > Does the emacs can create only one subprocess by calling
 > command.com?  When not, does anyone know, how one can
 > start more than one subshell?

I don't use auctex, but I don't think that is part of the
problem.  You should change your view command to "start yap"
in place of "yap".  That is the NT way of running a
background process.  I haven't tried this with yap since I
use dviwin (which is much better, IMHO).

  I also went into tex-mode.el and made a few changes.  It
assumes that certain commands should be run in the
background and puts an "&" at the end of the line.  NT
didn't like that, so I took it out.  Ideally, it should
check for a NT-or-Unix variable and prepend with
start/append & accordingly.

  I also found that map-ynp.el needed a little fixing.  If
you run (la)tex on a file from the menu-bar with buffers
unsaved, it gives an error message.  The problem is that it
wants to pop-up a dialog box to ask about saving buffers,
and pop-ups are not supported yet in ntemacs.  If you change
map-ynp.el(c) to work around this (i.e., to never pop up a
dialog), you need to reload it from .emacs; it seems to be
preloaded into the executable.  This will be moot with the
next version which will support pop-ups, right?

                                 John Jones

---------------------------------------------------------------
Department of Mathematics               Office:  PSA 729
Arizona State University                Phone:   965-3725
Tempe, AZ    85287-1804                 FAX:     965-8119
URL: http://math.la.asu.edu/~jj         e-mail:  [email-masked]
---------------------------------------------------------------

---

From: [email-masked] (Eyssele Helmut)
Date: Thu, 14 Nov 1996 09:14:14 +0100

First thanks to all, who have answered my question.

I think too, that auctex isn't part of my problem. But nevertheless
for all, who want to make TeX with ntemacs, here is the address, where
you can get the newest release 9.5a:

	ftp://ftp.iesd.auc.dk/pub/emacs-lisp/auctex.tar.gz

To use the auctex package in your emacs, you have to customize the file
tex-site.el by copying and changing the customization part of tex.el into
tex-site.el. I did this as follows (here only the changed parts):

  (defvar TeX-lisp-directory "d:/emacs/lisp/auctex/"
   "*The directory where the AUC TeX lisp files are located.")

  ;; Change this to point to the place where the TeX macros are stored
  ;; at yourt site.
  (defvar TeX-macro-global '("e:/texmf/tex/")
    "*Directories containing the sites TeX macro files and style files.

  ;; This is the major configuration variable.  Most sites will only
  ;; need to change the second string in each entry, which is the name
  ;; of a command to send to the shell.  If you use other formatters
  ;; like AMSLaTeX or AMSTeX, you can add those to the list.  See
  ;; TeX-expand-list for a description of the % escapes

  (defvar TeX-command-list
    ;; You may have to remove the single quotes around the command
    ;; arguments if you use DOS.
    (list (list "TeX" "tex '\\nonstopmode\\input %t'" 'TeX-run-TeX nil t) 		  (list "TeX Interactive" "tex %t" 'TeX-run-interactive nil t)
	  (list "LaTeX" "%l '\\nonstopmode\\input{%t}'"
	        'TeX-run-LaTeX nil t)
	  (list "LaTeX Interactive" "%l %t" 'TeX-run-interactive nil t)
	  (list "LaTeX2e" "latex '\\nonstopmode\\input{%t}'"
	        'TeX-run-LaTeX nil t)
	  (if (or window-system (getenv "DISPLAY"))
	      (list "View" "%v " 'TeX-run-background t nil)
	    (list "View" "dvi2tty -q -w 132 %s " 'TeX-run-command t nil))
	  (list "Print" "%p " 'TeX-run-command t nil)
	  (list "Queue" "%q" 'TeX-run-background nil nil)
	  (list "File" "dvips %d -o %f " 'TeX-run-command t nil)
	  (list "BibTeX" "bibtex %s" 'TeX-run-BibTeX nil nil)
	  (list "Index" "makeindex %s" 'TeX-run-command nil t)
	  (list "Check" "lacheck %s" 'TeX-run-compile nil t)
	  (list "Spell" "<ignored>" 'TeX-run-ispell nil nil)
	  (list "Other" "" 'TeX-run-command t t)
	  ;; Not part of standard TeX.
	  (list "Makeinfo" "makeinfo %t" 'TeX-run-compile nil t)
	  (list "AmSTeX" "amstex '\\nonstopmode\\input %t'"
	        'TeX-run-TeX nil t))
    "*List of commands to execute on the current document.

  Each element is a list, whose first element is the name of the command
  as it will be presented to the user.  

  The second element is the string handed to the shell after being
  expanded. The expansion is done using the information found in
  TeX-expand-list. 

  The third element is the function which actually start the process.
  Several such hooks has been defined:

  TeX-run-command: Start up the process and show the output in a
  separate buffer.  Check that there is not two commands running for the
  same file.  Return the process object. 

  TeX-run-format: As TeX-run-command, but assume the output is created
  by a TeX macro package.  Return the process object. 

  TeX-run-TeX: For TeX output.

  TeX-run-LaTeX: For LaTeX output.

  TeX-run-interactive: Run TeX or LaTeX interactively.

  TeX-run-BibTeX: For BibTeX output.

  TeX-run-compile: Use `compile' to run the process.  

  TeX-run-shell: Use `shell-command' to run the process.

  TeX-run-discard: Start the process in the background, discarding its
  output.

  TeX-run-background: Start the process in the background, show output
  in other window.

  TeX-run-dviout: Special hook for the Japanese dviout previewer for
  PC-9801.

  To create your own hook, define a function taking three arguments: The
  name of the command, the command string, and the name of the file to
  process.  It might be useful to use TeX-run-command in order to
  create an asynchronous process.

  If the fourth element is non-nil, the user will get a chance to
  modify the expanded string.

  The fifth element is obsolete and ignored.")

  ;; You may want special options to the view command depending on the
  ;; style options.  Only works if parsing is enabled.

  (defvar TeX-view-style '(("^a5$" "yap %d -paper a5")
			   ("^landscape$" "yap %d -paper a4r -s 4")
			   ;; The latest xdvi can show embedded postscript.
			   ;; If you don't have that, uncomment next line.
			   ;; ("^epsf$" "ghostview %f")
			   ;; ey: xdvi durch yap ersetzt
			   ("." "yap %d"))
    "*List of style options and view options.

  If the first element (a regular expresion) matches the name of one of
  the style files, any occurrence of the string %v in a command in
  TeX-command-list will be replaced with the second element.  The first
  match is used, if no match is found the %v is replaced with the empty
  string.")

I have only the intension to latex and view, not to print etc. Therefore
I only customized these two commands. When you look at the View command
you will see, that there is called TeX-run-background, which is defined
in tex-buf.el. To make it run in ntemacs I had to customize tex-buf.el
too. I made this by overload the definitions in tex-buf.el in my _emacs:

  ;; Customizing tex-buf.el:

  (defvar TeX-process-asynchronous (not (eq system-type '(ms-dos windows-nt)))
    "*Use asynchronous processes.")	;; included in this list _^

  (defvar TeX-shell
    (if (memq system-type '(ms-dos emx windows-nt))
        shell-file-name		    ;; ^_ included in this list
      "C:\\WINDOWS\\COMMAND.COM")   ;; "/bin/sh" changed
    "Name of shell used to parse TeX commands.")

  (defvar TeX-shell-command-option  ;; v- included in this list
    (cond ((eq system-type '(ms-dos windows-nt))
	   (if (boundp 'shell-command-option)
	       shell-command-option
	     "/c"))
	  (t				;Unix & EMX (Emacs 19 port to OS/2)
	   "-c"))
    "Shell argument indicating that next argument is the command.")

  ;; End of Site Customization.

In tex-buf.el TeX-run-background is defined as

  (defun TeX-run-background (name command file)
    "Start process with second argument, show output when and if it arrives."
    (save-excursion
      (set-buffer (get-buffer-create "*TeX background*"))
      (erase-buffer))
    (let ((process (start-process (concat name " background")
				  nil TeX-shell
				  TeX-shell-command-option command)))
      (if TeX-after-start-process-function
	  (funcall TeX-after-start-process-function process))
      (set-process-filter process 'TeX-background-filter)
      (process-kill-without-query process)))

With these changes the commands "View" and "LaTeX interactive" run fine,
but with the limitation, that when I call the command "View" and let the
YaP window open ntemacs says after the command "LaTeX interactive":

John Jones wrote:

 > You should change your view command to "start yap"
 > background process.

Until yet I didn't find out, where I can put "start yap" in the tex-buf.el
file. I think the problem is that ntemacs calls yap in the subshell
command.com and then has no resources free to call a second subshell.
Auctex is designed to call the commands yap and latex in subshells (normally
/bin/sh) and now one must find out how this can be realized in windows 95
and windows nt.

Has anyone an idea?

Thanks,
			Helmut EYSSELE
      __   ______	Bosch Telecom GmbH
     / /  / ____/	Abt. UC-RF/EBG
    / /__/ /__		71520 Backnang, GERMANY
   / ___  ___/		  EMAIL: [email-masked]
  / /  / /___		    and: [email-masked]
 /_/  /_____/		  PHONE: +49-7191-13-2795
___________________________________________________________