;;; msdos-tex-shell.el --- MS-DOS TeX shell support. ;; Francis Wright , 13 September 1998 ;; (using some ideas from Walter Neumann ) ;; Patch the standard tex-mode IF NECESSARY to work with the MS-DOS ;; COMMAND.COM shell, either via cmdproxy or directly, in GNU Emacs ;; 19.34.6 and 20.3 under Windows 95. Tested with MiKTeX. ;; Background or asynchronous commands: COMMAND starts Windows ;; programs asynchronously by default; MS-DOS programs can be started ;; asynchronously using commands of the form `start program' -- give ;; the MS-DOS command start/? for details. The emTeX previewer ;; (dviscr) seems to REQUIRE the use of start, otherwise it does not ;; terminate correctly. For example, if you normally preview by ;; calling a batch file called `v.bat' then put this in `.emacs': ;; (setq tex-dvi-view-command "start v") ;; and make sure that you quit the previewer explicitly! ;; The MiKTeX previewer does not require the use of start, and this ;; works fine for me: ;; (setq tex-dvi-view-command "yap") ;; I suggest that you put this library somewhere in your `load-path' ;; and hang it on `tex-shell-hook' by putting this in `.emacs', so ;; that it is loaded only if necessary: ;; (add-hook 'tex-shell-hook ;; (function (lambda () (require 'msdos-tex-shell)))) ;; You may also want to consider running my msdos-shell-fix.el (defvar msdos-shellp (let ((shell (or tex-shell-file-name (getenv "ESHELL") (getenv "SHELL"))) (case-fold-search t)) (and shell (string-match "cmdproxy\\|command" shell))) "True if `tex-shell' is using an MS-DOS shell.") (defun msdosify-filepath (file) "Convert all slashes to backslashes." (let ((i -1) (len (length file))) (setq file (copy-sequence file)) ; precaution! (while (< (setq i (1+ i)) len) (if (= (aref file i) ?/) (aset file i ?\\)) ) file)) (defadvice tex-send-command (before msdos-tex-send-command disable) "`MS-DOSify' filepath except for TeX/LaTeX/SliTeX and never append `&'." ;; tex-send-command (command &optional file background) (if (and file (not (eq command tex-command))) (setq file (msdosify-filepath file))) ;; \ should not be escaped (i.e. doubled) in MS-DOS commands: (let ((start 0)) (while (setq start (string-match "\\\\\\\\" command start)) (setq command (replace-match "\\" t t command) start (1+ start)))) (setq background nil)) (cond (msdos-shellp (ad-enable-advice 'tex-send-command 'before 'msdos-tex-send-command) (ad-activate 'tex-send-command))) (defadvice tex-strip-dots (around msdos-tex-strip-dots activate) "Do not append host name to temp file name. \(It's always (?) unnecessary and may break some MS-DOS programs.)" (setq ad-return-value "")) (provide 'msdos-tex-shell) ;;; msdos-tex-shell.el ends here