help with LaTeX-add-environment for pspicture

Patrick Drechsler <[email protected]>
Newsgroups gmane.emacs.auc-tex
Organization Dept. of Zoology 2, Biocenter, University of Wuerzburg, Germany
Message-ID <[email protected]>
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.

If the bug (or problem) is triggered by a specific (La)TeX
file, you should try to produce a minimal sample file showing the
problem and include it in your report.

Your bug report will be posted to the AUCTeX mailing list.

Hi,

I'm trying to customize an environment so that pressing `C-c C-e'
offers me the correct behavior for the pspicture
environment. The problem I'm having is that the syntax for this
environment is a bit different from LaTeX default
environments. `pspicture' has a mandatory and an optional
argument which are both set in parenthesis. The two arguments
define the picture size (x0,y0)(x1,y1). When the optional
argument (x0,y0) is dropped x0 and y0 are set to (0,0) by
PSTricks.

Example usage:

--8<------------------------schnipp------------------------->8---
\documentclass{minimal}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-1,-1)(1,1)
  \psgrid%
  \psline(0,0)(1,1)
\end{pspicture}

\vspace{5ex}

\begin{pspicture}(1,1) % equals \begin{pspicture}(0,0)(1,1)
  \psgrid%
  \psline(0,0)(1,1)
\end{pspicture}

\end{document}
--8<------------------------schnapp------------------------->8---

What I've come up with so far (after reading section 12.3 in the
AUCTeX manual) is passing a single optional argument:

--8<------------------------schnipp------------------------->8---
(add-hook 'LaTeX-mode-hook
          '(lambda nil
             (LaTeX-add-environments 
	      '("pspicture" (lambda (env &rest ignore)
			      (LaTeX-insert-environment
			       env
			       (let ((overlay (read-input "(Optional) x0,y0: ")))
				 (unless (zerop (length overlay))
				   (format "(%s)" overlay)))))))))
--8<------------------------schnapp------------------------->8---

Besides the fact that I do not really understand how the above
works (I'm just experimenting with stuff I found in beamer.el) I
haven't been able to squeeze the mandatory argument in.

Could somebody give me a pointer on what needs to be
added/changed in the above? Or should I take a completely
different approach to this problem?

TIA,

Patrick

Emacs  : GNU Emacs 21.3.50.2 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2005-01-13 on trurl
Package: AUCTeX 11.54

current state:
==============
(setq
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("style/" "auto/"
		  "/home/patrick/uni/literature/bibtex-files/style/"
		  "/home/patrick/.TeX/style/"
 "/usr/share/doc/.TeX/style/"
		  "/usr/doc/.TeX/style/"
		  "/home/patrick/uni/literature/bibtex-files/auto/"
		  "/home/patrick/.TeX/auto/"
 "/usr/share/doc/.TeX/auto/"
		  "/usr/doc/.TeX/auto/"
		  "/usr/local/share/emacs/site-lisp/auctex/style/"
		  "/usr/local/var/auctex/")
 TeX-auto-save t
 TeX-parse-self t
 TeX-master t
 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.