[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-devel] Can AUCTeX be a pseudo-WYSIWYG device?

From: Ryszard Kubiak
Subject: [AUCTeX-devel] Can AUCTeX be a pseudo-WYSIWYG device?
Date: Mon, 12 May 2008 22:05:16 +0200
User-agent: Thunderbird (X11/20080505)

Hi everybody!

I wonder if you would find it plausible to extend AUCTeX
towards a pseudo-WYSIWYG device. I mean by that that
I imagine a single keystroke invoking a sequence
of the following steps:
1. Saving a document.
2. Processing it as many times as necessary (cross-references)
and possible (errors).
3. Calling a viewer if not done before.
4. Hiding Emacs in order to activate the viewer's window.

For quite a few years now I have been using a solution similar
to the one quoted below. It does steps 1, 2 (partly) and 4
for pdfLaTeX documents. By pressing just F12 I save the
nexessary files, execute TeX and hide Emacs, thus jumping
to a viewer.


;; -*- coding: utf-8 -*-
;; By Ryszard Kubiak, GdaƄsk, Poland, last update 2008-May-11.
;; This little library is an add-on to AucTeX.
;; It makes living within the cicle Editor-TeX-Viewer
;; a bit nicer as you will need just one keypress to
;; save your files, call TeX and exit Emacs to access a PDF viewer.
;; You get a kind of WYSIWYG way of working with TeX documents:
;; call easy-pdfLaTeX-command (by pressing f12) to execute TeX
;; on your document and leave Emacs to view the results, then
;; go back to Emacs, edit your files, f12, and so on.
;; To use the library place this file somewhere on your
;; Emacs's load-path and add these lines to your .emacs
;; or site-start.el file:
;;  (load-library "easy-pdfLaTeX")
;;  (global-set-key [f12] 'easy-PDFTeX-command)
;; If the f12 key is not appropriate for you then choose some
;; other key or stay with AUCTeX's Ctrl-c ... conventions to call
;; easy-pdfLaTeX-command.
;; Before calling easy-pdfLaTeX make sure that the following
;; belongs to the list TeX-command-list:
;;  ("pdfLaTeX" "pdflatex --nonstopmode %t" TeX-run-TeX nil t)
;; Call Ctrl-h v Enter TeX-command-list to verify the list.
;; If there is no PDF variant in it use Emacs's customize
;; procedure to add one to TeX-command-list.
;; At the moment the library does not invoke a PDF viewer.
;; You should open one on your own. You may do it by
;; calling a previewer from TeX-command-list after adding your
;; favorite PDF viewer to the list. A warning: Acrobat Reader
;; is not good for working in the proposed WYSIWYG style
;; since it grabs the viewed PDF file and does not allow
;; other programs to change it, in particular for TeX to
;; generate a new version of the PDF.

(defun easy-pdfLaTeX-sentinel (process name)
  "Hide Emacs when TeX command finishes successfully."
   (if (TeX-TeX-sentinel-check process name) t
     (if (eq system-type 'windows-nt) (iconify-frame) (lower-frame))))

(defun easy-pdfLaTeX-TeXbuffer-p ()
  "Predicate: is a visited buffer a TeX one?"
  (member (file-name-extension (buffer-file-name)) TeX-file-extensions))

(defun easy-pdfLaTeX-command ()
  "Run TeX on TeX-master then hide Emacs to access a viewer."
;; Save changed TeX buffers
  (save-some-buffers t 'easy-pdfLaTeX-TeXbuffer-p)
;; Here is an alternative way of saving. It may not save buffers
;; with external macro libraries needed by TeX-master though:
;;  (TeX-save-document t)
;; Establish TeX-master:
  (setq TeX-master (TeX-dwim-master))
  (if (and (null TeX-master) (not (easy-pdfLaTeX-TeXbuffer-p)))
    (error "Cannot establish TeX-master for this buffer."))
;; Set a sentinel function to define the set of actions
;; to be performed when TeX finishes it's job; we after hiding
  (setq TeX-sentinel-default-function 'easy-pdfLaTeX-sentinel)
;; Run TeX to build the PDF then hide:
  (TeX-command "pdfLaTeX" 'TeX-master-file))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]