changeset 37942:0f57d8b106f1

fix live process/dead buffer bub on w32
author Sam Steingold <sds@gnu.org>
date Tue, 29 May 2001 15:47:01 +0000
parents 8c8f2ccf187d
children e4f0e3e1c22e
files lisp/ChangeLog lisp/textmodes/tex-mode.el
diffstat 2 files changed, 33 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue May 29 14:31:01 2001 +0000
+++ b/lisp/ChangeLog	Tue May 29 15:47:01 2001 +0000
@@ -1,3 +1,13 @@
+2001-05-29  Sam Steingold  <sds@gnu.org>
+
+	* textmodes/tex-mode.el (tex-feed-input, tex-display-shell):
+	Use `tex-shell-buf'.
+	(tex-shell-proc): Use `tex-shell-running'.
+	(tex-shell-buf-no-error): New function.
+	(tex-send-tex-command): Use it.
+	(tex-shell-running): Kill tex-shell when the buffer is dead for w32.
+	(tex-kill-job): Check the process before calling `quit-process'.
+
 2001-05-29  Gerd Moellmann  <gerd@gnu.org>
 
 	* international/utf-8.el (ccl-decode-mule-utf-8): Handle
--- a/lisp/textmodes/tex-mode.el	Tue May 29 14:31:01 2001 +0000
+++ b/lisp/textmodes/tex-mode.el	Tue May 29 15:47:01 2001 +0000
@@ -1260,8 +1260,8 @@
 		  (forward-char 1)
 		(forward-sexp 1))))))
       (message "%s words" count))))
-	    
-	    
+
+
 
 ;;; Invoking TeX in an inferior shell.
 
@@ -1292,13 +1292,13 @@
 In the tex buffer this can be used to continue an interactive tex run.
 In the tex shell buffer this command behaves like `comint-send-input'."
   (interactive)
-  (set-buffer (process-buffer (get-process "tex-shell")))
+  (set-buffer (tex-shell-buf))
   (comint-send-input)
   (tex-recenter-output-buffer nil))
 
 (defun tex-display-shell ()
   "Make the TeX shell buffer visible in a window."
-  (display-buffer (process-buffer (get-process "tex-shell")))
+  (display-buffer (tex-shell-buf))
   (tex-recenter-output-buffer nil))
 
 (defun tex-shell-sentinel (proc msg)
@@ -1322,9 +1322,12 @@
 (make-variable-buffer-local 'tex-send-command-modified-tick)
 
 (defun tex-shell-proc ()
-  (or (get-process "tex-shell") (error "No TeX subprocess")))
+  (or (tex-shell-running) (error "No TeX subprocess")))
 (defun tex-shell-buf ()
   (process-buffer (tex-shell-proc)))
+(defun tex-shell-buf-no-error ()
+  (let ((proc (tex-shell-running)))
+    (and proc (process-buffer proc))))
 
 (defun tex-send-command (command &optional file background)
   "Send COMMAND to TeX shell process, substituting optional FILE for *.
@@ -1443,8 +1446,9 @@
     (tex-send-tex-command compile-command dir)))
 
 (defun tex-send-tex-command (cmd &optional dir)
-  (unless (or (equal dir (with-current-buffer (tex-shell-buf)
-			   default-directory))
+  (unless (or (equal dir (let ((buf (tex-shell-buf-no-error)))
+                           (and buf (with-current-buffer buf
+                                      default-directory))))
 	      (not dir))
     (let (shell-dirtrack-verbose)
       (tex-send-command tex-shell-cd-command dir)))
@@ -1685,18 +1689,25 @@
 
 (defun tex-shell-running ()
   (let ((proc (get-process "tex-shell")))
-    (and proc
-         (eq (process-status (get-process "tex-shell")) 'run)
-         (buffer-live-p (process-buffer proc)))))
+    (when proc
+      (if (and (eq (process-status proc) 'run)
+               (buffer-live-p (process-buffer proc)))
+          ;; return the TeX process on success
+          proc
+          ;; get rid of the process permanently
+          ;; this should get rid of the annoying w32 problem with
+          ;; dead tex-shell buffer and live process
+          (delete-process proc)))))
 
 (defun tex-kill-job ()
   "Kill the currently running TeX job."
   (interactive)
-  ;; quit-process leads to core dumps of the tex process (except if
+  ;; `quit-process' leads to core dumps of the tex process (except if
   ;; coredumpsize has limit 0kb as on many environments).  One would
   ;; like to use (kill-process proc 'lambda), however that construct
   ;; does not work on some systems and kills the shell itself.
-  (quit-process (get-process "tex-shell") t))
+  (let ((proc (get-process "tex-shell")))
+    (when proc (quit-process proc t))))
 
 (defun tex-recenter-output-buffer (linenum)
   "Redisplay buffer of TeX job output so that most recent output can be seen.