auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] Full file names in style system


From: Ralf Angeli
Subject: [AUCTeX-devel] Full file names in style system
Date: Mon, 26 Dec 2005 18:06:50 +0100

Attached you can find a patch which changes the style system in a way
that file names with extensions are used in case of \documentclass,
\usepackage, \include and \input macros.  In addition options will not
be put into `TeX-active-styles' on their own but rather encapsulated
with the files they belong to.

For the parser this means, if you have a file style-test.tex with the
contents

\documentclass[ngerman,a4paper,11pt]{scrartcl}
\usepackage{graphicx}
\begin{document}
\input{foo}
\end{document}

you will get the following auto/style-test.tex.el:

(TeX-add-style-hook "style-test.tex"
 (lambda ()
    (TeX-run-style-hooks
     '("graphicx.sty" :type package :options nil)
     "latex2e"
     "scrartcl11"
     '("scrartcl.cls" :type class :options ("11pt" "a4paper" "ngerman"))
     '("foo.tex" :type file))))

The stuff for `TeX-run-style-hooks' will also be put into
`TeX-active-styles'.  I'm not yet sure if this is the way to go.
Until know we had only strings in `TeX-active-styles' which made it
very easy to look for certain styles by means of regular expressions
(e.g. in case of `LaTeX-command-style').  With the scheme above this
will be more difficult because there will have to be a way to look for
partially matching property lists.  That means one should be able to
say "do a certain action if option foo is given for style bar".  The
interface for the user could probably allow for the specification of
regular expressions for file names and properties.  For example if you
wanted to match all KOMA-Script classes in connection with 11 or 12
point font size you could specify
("\\`scr.+\\.cls\\'" :options "\\`1[12]pt\\'")
Usually one does not need complicated stuff like that but rather match
a single option of a single file but I don't consider this overly
user-friendly in any way.

A related problem is the determination of the document language for
running language hooks with the scheme above because the language can
be indicated in the document class, as an option of the babel package,
or as a package of its own.  For example in case of ngerman you'd have
to find ("ngerman.sty" :type package), ("<any class>" :type class
:options ("ngerman" ...)), or ("babel.sty" :type package :options
(... "ngerman")).  (Note that the ngerman entry for babel has to the
last one as this indicates its usage as the main language in the
document.)  Well, okay, this particular problem is one we can deal
with internally but it still shows that there might be cases where
matching can get complicated.

Anyway, the patch is certainly not ready for production but rather a
proof of concept.  It has been lying around here for a few weeks and I
haven't really had time to make up my mind about the scheme for
representing different types of files and storing related options.

I guess for starters I could check in the part of the patch which
makes the style system use full file names and put aside handling of
package options.  After all, this is a very LaTeX-centric solution
until now and might have to get some thought with respect to the other
AUCTeX modes.  And the switch to full file names alone will already
introduce quite some incompatibilities compared to former versions of
AUCTeX.

Oh, by the way, for the patch to work you will have to rename
style/graphicx.el to style/graphicx.sty.el and style/babel.el to
style/babel.sty.el and change

(TeX-add-style-hook
 "<style>"

to

(TeX-add-style-hook
 "<style>.sty"

inside those files.

graphicx and babel are the packages I used for testing.  For the
transition all file-related style files will have to be renamed and
changed, of course.

-- 
Ralf

Attachment: style-system.patch
Description: Text Data


reply via email to

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