Mercurial > emacs
comparison lisp/textmodes/tex-mode.el @ 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 | 5cc52d5c2f2b |
children | 4192225498c7 |
comparison
equal
deleted
inserted
replaced
37941:8c8f2ccf187d | 37942:0f57d8b106f1 |
---|---|
1258 (forward-comment (point-max))) | 1258 (forward-comment (point-max))) |
1259 (if (not (looking-at "{")) | 1259 (if (not (looking-at "{")) |
1260 (forward-char 1) | 1260 (forward-char 1) |
1261 (forward-sexp 1)))))) | 1261 (forward-sexp 1)))))) |
1262 (message "%s words" count)))) | 1262 (message "%s words" count)))) |
1263 | 1263 |
1264 | 1264 |
1265 | 1265 |
1266 ;;; Invoking TeX in an inferior shell. | 1266 ;;; Invoking TeX in an inferior shell. |
1267 | 1267 |
1268 ;; Why use a shell instead of running TeX directly? Because if TeX | 1268 ;; Why use a shell instead of running TeX directly? Because if TeX |
1269 ;; gets stuck, the user can switch to the shell window and type at it. | 1269 ;; gets stuck, the user can switch to the shell window and type at it. |
1290 (defun tex-feed-input () | 1290 (defun tex-feed-input () |
1291 "Send input to the tex shell process. | 1291 "Send input to the tex shell process. |
1292 In the tex buffer this can be used to continue an interactive tex run. | 1292 In the tex buffer this can be used to continue an interactive tex run. |
1293 In the tex shell buffer this command behaves like `comint-send-input'." | 1293 In the tex shell buffer this command behaves like `comint-send-input'." |
1294 (interactive) | 1294 (interactive) |
1295 (set-buffer (process-buffer (get-process "tex-shell"))) | 1295 (set-buffer (tex-shell-buf)) |
1296 (comint-send-input) | 1296 (comint-send-input) |
1297 (tex-recenter-output-buffer nil)) | 1297 (tex-recenter-output-buffer nil)) |
1298 | 1298 |
1299 (defun tex-display-shell () | 1299 (defun tex-display-shell () |
1300 "Make the TeX shell buffer visible in a window." | 1300 "Make the TeX shell buffer visible in a window." |
1301 (display-buffer (process-buffer (get-process "tex-shell"))) | 1301 (display-buffer (tex-shell-buf)) |
1302 (tex-recenter-output-buffer nil)) | 1302 (tex-recenter-output-buffer nil)) |
1303 | 1303 |
1304 (defun tex-shell-sentinel (proc msg) | 1304 (defun tex-shell-sentinel (proc msg) |
1305 (cond ((null (buffer-name (process-buffer proc))) | 1305 (cond ((null (buffer-name (process-buffer proc))) |
1306 ;; buffer killed | 1306 ;; buffer killed |
1320 | 1320 |
1321 (defvar tex-send-command-modified-tick 0) | 1321 (defvar tex-send-command-modified-tick 0) |
1322 (make-variable-buffer-local 'tex-send-command-modified-tick) | 1322 (make-variable-buffer-local 'tex-send-command-modified-tick) |
1323 | 1323 |
1324 (defun tex-shell-proc () | 1324 (defun tex-shell-proc () |
1325 (or (get-process "tex-shell") (error "No TeX subprocess"))) | 1325 (or (tex-shell-running) (error "No TeX subprocess"))) |
1326 (defun tex-shell-buf () | 1326 (defun tex-shell-buf () |
1327 (process-buffer (tex-shell-proc))) | 1327 (process-buffer (tex-shell-proc))) |
1328 (defun tex-shell-buf-no-error () | |
1329 (let ((proc (tex-shell-running))) | |
1330 (and proc (process-buffer proc)))) | |
1328 | 1331 |
1329 (defun tex-send-command (command &optional file background) | 1332 (defun tex-send-command (command &optional file background) |
1330 "Send COMMAND to TeX shell process, substituting optional FILE for *. | 1333 "Send COMMAND to TeX shell process, substituting optional FILE for *. |
1331 Do this in background if optional BACKGROUND is t. If COMMAND has no *, | 1334 Do this in background if optional BACKGROUND is t. If COMMAND has no *, |
1332 FILE will be appended, preceded by a blank, to COMMAND. If FILE is nil, no | 1335 FILE will be appended, preceded by a blank, to COMMAND. If FILE is nil, no |
1441 (shell-quote-argument tex-start-options-string) " ")) | 1444 (shell-quote-argument tex-start-options-string) " ")) |
1442 (comint-quote-filename file))))) | 1445 (comint-quote-filename file))))) |
1443 (tex-send-tex-command compile-command dir))) | 1446 (tex-send-tex-command compile-command dir))) |
1444 | 1447 |
1445 (defun tex-send-tex-command (cmd &optional dir) | 1448 (defun tex-send-tex-command (cmd &optional dir) |
1446 (unless (or (equal dir (with-current-buffer (tex-shell-buf) | 1449 (unless (or (equal dir (let ((buf (tex-shell-buf-no-error))) |
1447 default-directory)) | 1450 (and buf (with-current-buffer buf |
1451 default-directory)))) | |
1448 (not dir)) | 1452 (not dir)) |
1449 (let (shell-dirtrack-verbose) | 1453 (let (shell-dirtrack-verbose) |
1450 (tex-send-command tex-shell-cd-command dir))) | 1454 (tex-send-command tex-shell-cd-command dir))) |
1451 (with-current-buffer (process-buffer (tex-send-command cmd)) | 1455 (with-current-buffer (process-buffer (tex-send-command cmd)) |
1452 (make-local-variable 'compilation-parse-errors-function) | 1456 (make-local-variable 'compilation-parse-errors-function) |
1683 (if (= (length elt) 0) elt (expand-file-name elt))) | 1687 (if (= (length elt) 0) elt (expand-file-name elt))) |
1684 (nreverse elts) ":"))) | 1688 (nreverse elts) ":"))) |
1685 | 1689 |
1686 (defun tex-shell-running () | 1690 (defun tex-shell-running () |
1687 (let ((proc (get-process "tex-shell"))) | 1691 (let ((proc (get-process "tex-shell"))) |
1688 (and proc | 1692 (when proc |
1689 (eq (process-status (get-process "tex-shell")) 'run) | 1693 (if (and (eq (process-status proc) 'run) |
1690 (buffer-live-p (process-buffer proc))))) | 1694 (buffer-live-p (process-buffer proc))) |
1695 ;; return the TeX process on success | |
1696 proc | |
1697 ;; get rid of the process permanently | |
1698 ;; this should get rid of the annoying w32 problem with | |
1699 ;; dead tex-shell buffer and live process | |
1700 (delete-process proc))))) | |
1691 | 1701 |
1692 (defun tex-kill-job () | 1702 (defun tex-kill-job () |
1693 "Kill the currently running TeX job." | 1703 "Kill the currently running TeX job." |
1694 (interactive) | 1704 (interactive) |
1695 ;; quit-process leads to core dumps of the tex process (except if | 1705 ;; `quit-process' leads to core dumps of the tex process (except if |
1696 ;; coredumpsize has limit 0kb as on many environments). One would | 1706 ;; coredumpsize has limit 0kb as on many environments). One would |
1697 ;; like to use (kill-process proc 'lambda), however that construct | 1707 ;; like to use (kill-process proc 'lambda), however that construct |
1698 ;; does not work on some systems and kills the shell itself. | 1708 ;; does not work on some systems and kills the shell itself. |
1699 (quit-process (get-process "tex-shell") t)) | 1709 (let ((proc (get-process "tex-shell"))) |
1710 (when proc (quit-process proc t)))) | |
1700 | 1711 |
1701 (defun tex-recenter-output-buffer (linenum) | 1712 (defun tex-recenter-output-buffer (linenum) |
1702 "Redisplay buffer of TeX job output so that most recent output can be seen. | 1713 "Redisplay buffer of TeX job output so that most recent output can be seen. |
1703 The last line of the buffer is displayed on | 1714 The last line of the buffer is displayed on |
1704 line LINE of the window, or centered if LINE is nil." | 1715 line LINE of the window, or centered if LINE is nil." |