[Top][All Lists]

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

Re: [AUCTeX] How to apply different 'style-hook' for a document dependin

From: Vladimir Lomov
Subject: Re: [AUCTeX] How to apply different 'style-hook' for a document depending on option passed to a package?
Date: Thu, 31 Oct 2013 20:30:42 +0900
User-agent: Mutt/1.5.22 (2013-10-16)

** Tassilo Horn [2013-10-28 12:00:32 +0100]:

> Vladimir Lomov <address@hidden> writes:

> Hi Vladimir,

>> In other words: is it possible to apply different 'hook' files on a
>> document depending on option passed to a package?

> Long story short: i think up to 11.87, your style file can check the
> value of `TeX-active-styles'.  Package options are included in there,
> too, so in your example it would contain "conf=set1".  However, if you
> have a document with

I'm using AUCTeX from git, so LaTeX-provided-package-options is my

>   \usepackage[conf=set1]{bar}
>   \usepackage[conf=set2]{some-package}

> it's not really obvious what option belongs to which package, so in case
> 2 used packages have the same options, you're basically out of luck.

Right, but (IMHO) it is unlikely that both packages will be used in one
document and both provides similar functionality, in other words for
both user need a .el file.

> The current AUCTeX version in git has been improved in that respect.
> `TeX-active-styles' doesn't contain package options anymore.  Instead,
> there's a new variable `LaTeX-provided-package-options' which is an
> alist associating with each used package the options given to it.  So
> the above example would result in

>   '(("bar" "conf=set1") ("some-package" "conf=set2"))

> So your some-package.el style file could check the value of
> `LaTeX-provided-package-options' to do whatever needs to be done
> depending if conf=set1 or conf=set2.

I don't know Emacs Lisp well enough, so I tried following: I added
------------------------------ 8< ------------------------------
(lambda () (nth 1 (split-string (nth 1 (assoc "isu-th3" 
LaTeX-provided-package-options)) "=")))
------------------------------ 8< ------------------------------
into function 'TeX-run-style-hooks' of my 'isu-th3.el' (that's the real
name of my package) and tried to run emacs on sample document. It fails
with message:

TeX-member: Wrong type argument: stringp, (lambda nil (nth 1 (split-string (nth 
1 (assoc "isu-th3" LaTeX-provided-package-options)) "=")))

As I understand from definition of 'TeX-run-style-hooks', the
function expects string not a function. Of course if I run the construction
in *scratch* (defining LaTeX-provided-package-options by hand) to test
it, all works fine.

Is it possible to 'evaluate' lambda function, so it returns the string and
that string will be used as hooks-name?

WBR, Vladimir Lomov

If you're crossing the nation in a covered wagon, it's better to have four
strong oxen than 100 chickens.  Chickens are OK but we can't make them work
together yet.
                -- Ross Bott, Pyramid U.S., on multiprocessors at AUUGM '89.

reply via email to

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