From: am299bv@sdcc15.ucsd.edu (Ravinder Bhumbla)
Newsgroups: gnu.emacs.help,comp.text.tex
Subject: Re: Auc-tex: Previewing without running TeX first
Date: 13 Jan 93 00:58:10 GMT
Reply-To: rbhumbla@ucsd.edu (Ravinder Bhumbla)
Followup-To: gnu.emacs.help
Organization: University of California, San Diego
In-reply-to: am299bv@sdcc15.ucsd.edu's message of 9 Jan 93 13:28:20

After my last posting about a way to preview the current buffer/master
file in auc-tex without running TeX on the buffer first, I received
two replies suggesting a more automatic way.  I tried the first one
(which goes into the .emacs file) and not the second one (which is a
patch to the tex-buf.el file) but they look very similar so either
should work.

Ravi
=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=

--- suggestion 1 from: Kevin Humphreys ---

Try these in your .emacs...
-----------

(setq LaTeX-mode-hook
      (function
       (lambda ()
	 (local-set-key "\C-c\C-p" 'my-TeX-preview)
	 (local-set-key "\C-c!" 'my-TeX-print)
;
; various other Auc-TeX specific bindings here.
;
) ))

(defun my-TeX-preview ()
  (interactive)
  (set-TeX-zap-file)
  (TeX-preview)
)

(defun my-TeX-print ()
  (interactive)
  (set-TeX-zap-file)
  (TeX-print)
)

(defun set-TeX-zap-file ()
  (if (not TeX-zap-file)
      (setq TeX-zap-file 
	    (substring buffer-file-name 0
		       (string-match ".[^.]*$" buffer-file-name)) ) )
)

--- end of suggestion 1 ---

--- suggestion 2 from: Mark Utting <marku@cs.uq.oz.au> ---

A few months ago, I made the following patches to tex-buf.el to
fix this problem (and similarly for printing before running TeX).

The version of tex-buf.el that I edited had the following header:
;;;* Last edited: Jul 22 14:28 1992 (krab)
;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;; tex-buf.el - Invoking TeX from an inferior shell
;; 
;; Copyright (C) 1991 Kresten Krab Thorup (krab@iesd.auc.dk).
;; 
;; This file is part of the AUC TeX package.
;; 
;; $Id: tex-buf.el,v 1.18 1992/09/09 20:55:42 amanda Exp $
;; Author          : Kresten Krab Thorup
;; Created On      : Thu May 30 23:57:16 1991
;; Last Modified By: Per Abrahamsen


Here are the changes in diff -c format:
*** tex-buf.orig.el     Thu Sep 10 06:55:42 1992
--- tex-buf.el  Wed Oct 21 15:17:40 1992
***************
*** 497,502 ****
--- 497,509 ----
           (buffer-file-name))
        (setq TeX-original-file (buffer-file-name)))
    
+   ;; If TeX has not been run before, try previewing buffer-file-name
+   ;;    (we should really check for a `%% Master:' clause too).
+   (if (and (not TeX-zap-file)
+          buffer-file-name)
+       (setq TeX-zap-file (substring buffer-file-name 0
+                               (string-match ".[^.]*$" buffer-file-name))))
+ 
    (TeX-test-process)
    
  ;;; Find out what preview command to use
***************
*** 536,541 ****
--- 543,555 ----
    
    (TeX-test-process)
    
+   ;; If TeX has not been run before, try printing buffer-file-name
+   ;;    (we should really check for a `%% Master:' clause too).
+   (if (and (not TeX-zap-file)
+            (buffer-file-name))
+       (setq TeX-zap-file (substring (buffer-file-name) 0
+                           (string-match ".[^.]*$" (buffer-file-name)))))
+ 
    (let* (                             ; Ask for a printer
         (tmp1 (if TeX-printer-name-alist
                   (completing-read (concat "Printer: (default "
----------------------------------------------------------------------

Although these changes work on single file documents, they really
should be extended to work on multi-file documents by searching for a
%%Master: clause (this would best be done by reorganising some of the
existing code to avoid duplication).  However, I hope that you will
find them a useful starting point.  They are certainly better than
having to type: ESC ESC (setq TeX-zap-file "filename") every time :-).

Mark.

--- end of second suggestion ---
--
Ravinder Bhumbla	rbhumbla@ucsd.edu    U. of California, San Diego