[PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread Jean-Marc Lasgouttes
 Georg == Georg Baum [EMAIL PROTECTED] writes:

Georg This is the updated patch with layout2layout support. I needed
Georg to change one other place as well (compile error due to
Georg Martin's recent natbib change).

This is finally the working and tested patch. The only thing missing
is the documentation (easy) and maybe the update of the layout files
(Georg, shall we do it now?)

To summarize, the patch replaces things like
  ProvidesAmsmath 1
by
  Provides amsmath 1

This means that any feature handled by LaTeXFeature can be overridden
(of course, some of them will need some fixing, we'll see).

So, what shall I do with it now?

JMarc

Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(révision 17701)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -153,6 +153,12 @@ bool LaTeXFeatures::isRequired(string co
 }
 
 
+bool LaTeXFeatures::mustProvide(string const  name) const
+{
+	return isRequired(name)  !params_.getLyXTextClass().provides(name);
+}
+
+
 bool LaTeXFeatures::isAvailable(string const  name)
 {
 	if (packages_.empty())
@@ -268,7 +274,7 @@ string const LaTeXFeatures::getPackages(
 	//  packages which we just \usepackage{package}
 	//
 	for (int i = 0; i  nb_simplefeatures; ++i) {
-		if (isRequired(simplefeatures[i]))
+		if (mustProvide(simplefeatures[i]))
 			packages  \\usepackage{
   simplefeatures[i]  }\n;
 	}
@@ -278,8 +284,7 @@ string const LaTeXFeatures::getPackages(
 	// than those above.
 	//
 
-	if (isRequired(amsmath)
-	 !tclass.provides(LyXTextClass::amsmath)
+	if (mustProvide(amsmath)
 	 params_.use_amsmath != BufferParams::package_off) {
 		packages  \\usepackage{amsmath}\n;
 	}
@@ -291,12 +296,12 @@ string const LaTeXFeatures::getPackages(
 	// esint is used, since esint redefines all relevant integral
 	// symbols from wasysym and amsmath.
 	// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-	if (isRequired(wasysym)  isRequired(esint) 
+	if (mustProvide(wasysym)  isRequired(esint) 
 	params_.use_esint != BufferParams::package_off)
 		packages  \\usepackage{wasysym}\n;
 
 	// color.sty
-	if (isRequired(color)) {
+	if (mustProvide(color)) {
 		if (params_.graphicsDriver == default)
 			packages  \\usepackage{color}\n;
 		else
@@ -307,13 +312,13 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired(makeidx)) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides(makeidx))
 			packages  \\usepackage{makeidx}\n;
 		packages  \\makeindex\n;
 	}
 
 	// graphicx.sty
-	if (isRequired(graphicx)  params_.graphicsDriver != none) {
+	if (mustProvide(graphicx)  params_.graphicsDriver != none) {
 		if (params_.graphicsDriver == default)
 			packages  \\usepackage{graphicx}\n;
 		else
@@ -322,18 +327,14 @@ string const LaTeXFeatures::getPackages(
   ]{graphicx}\n;
 	}
 	// shadecolor for shaded
-	if (isRequired(framed)) {
+	if (mustProvide(framed)) {
 		RGBColor c = RGBColor(lcolor.getX11Name(LColor::shadedbg));
 		packages  \\definecolor{shadecolor}{rgb}{ 
 			 c.r/255  ','  c.g/255  ','  c.b/255  }\n;
 	}
 
-	//if (algorithm) {
-	//	packages  \\usepackage{algorithm}\n;
-	//}
-
 	// lyxskak.sty --- newer chess support based on skak.sty
-	if (isRequired(chess)) {
+	if (mustProvide(chess)) {
 		packages  \\usepackage[ps,mover]{lyxskak}\n;
 	}
 
@@ -362,22 +363,23 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// amssymb.sty
-	if (isRequired(amssymb) || params_.use_amsmath == BufferParams::package_on)
+	if (mustProvide(amssymb) 
+	|| params_.use_amsmath == BufferParams::package_on)
 		packages  \\usepackage{amssymb}\n;
 
 	// esint must be after amsmath and wasysym, since it will redeclare
 	// inconsistent integral symbols
-	if (isRequired(esint)  params_.use_esint != BufferParams::package_off)
+	if (mustProvide(esint) 
+	 params_.use_esint != BufferParams::package_off)
 		packages  \\usepackage{esint}\n;
 
 	// url.sty
-	if (isRequired(url)  ! tclass.provides(LyXTextClass::url))
+	if (mustProvide(url))
 		packages  \\IfFileExists{url.sty}{\\usepackage{url}}\n
 			  {\\newcommand{\\url}{\\texttt}}\n;
 
-	// float.sty
 	// natbib.sty
-	if (isRequired(natbib)  ! tclass.provides(LyXTextClass::natbib)) {
+	if (mustProvide(natbib)) {
 		packages  \\usepackage[;
 		if (params_.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages  numbers;
@@ -388,20 +390,20 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// jurabib -- we need version 0.6 at least.
-	if (isRequired(jurabib)) {
+	if (mustProvide(jurabib)) {
 		packages  \\usepackage{jurabib}[2004/01/25]\n;
 	}
 
 	// bibtopic -- the dot provides the aux file naming which
 	// LyX can detect.
-	if (isRequired(bibtopic)) {
+	if (mustProvide(bibtopic)) {
 		packages  \\usepackage[dot]{bibtopic}\n;
 	}
 
-	if (isRequired(xy))
+	if (mustProvide(xy))
 		packages  \\usepackage[all]{xy}\n;
 
-	if (isRequired(nomencl)) {
+	if (mustProvide(nomencl)) {
 		packages  

Re: [PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

 Georg This is the updated patch with layout2layout support. I needed
 Georg to change one other place as well (compile error due to
 Georg Martin's recent natbib change).
 
 This is finally the working and tested patch. The only thing missing
 is the documentation (easy) and maybe the update of the layout files
 (Georg, shall we do it now?)

I think so.

 To summarize, the patch replaces things like
   ProvidesAmsmath 1
 by
   Provides amsmath 1
 
 This means that any feature handled by LaTeXFeature can be overridden
 (of course, some of them will need some fixing, we'll see).
 
 So, what shall I do with it now?

I would say commit it.


Georg



Re: [PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread José Matos
On Tuesday 03 April 2007 12:15:22 pm Georg Baum wrote:
 I would say commit it.

  +1

 Georg

-- 
José Abílio


Re: [PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread Martin Vermeer
On Tue, 03 Apr 2007 12:20:39 +0100
José Matos [EMAIL PROTECTED] wrote:

 On Tuesday 03 April 2007 12:15:22 pm Georg Baum wrote:
  I would say commit it.
 
   +1
 
  Georg

+1

Martin
 


[PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread Jean-Marc Lasgouttes
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

Georg> This is the updated patch with layout2layout support. I needed
Georg> to change one other place as well (compile error due to
Georg> Martin's recent natbib change).

This is finally the working and tested patch. The only thing missing
is the documentation (easy) and maybe the update of the layout files
(Georg, shall we do it now?)

To summarize, the patch replaces things like
  ProvidesAmsmath 1
by
  Provides amsmath 1

This means that any feature handled by LaTeXFeature can be overridden
(of course, some of them will need some fixing, we'll see).

So, what shall I do with it now?

JMarc

Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(révision 17701)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -153,6 +153,12 @@ bool LaTeXFeatures::isRequired(string co
 }
 
 
+bool LaTeXFeatures::mustProvide(string const & name) const
+{
+	return isRequired(name) && !params_.getLyXTextClass().provides(name);
+}
+
+
 bool LaTeXFeatures::isAvailable(string const & name)
 {
 	if (packages_.empty())
@@ -268,7 +274,7 @@ string const LaTeXFeatures::getPackages(
 	//  packages which we just \usepackage{package}
 	//
 	for (int i = 0; i < nb_simplefeatures; ++i) {
-		if (isRequired(simplefeatures[i]))
+		if (mustProvide(simplefeatures[i]))
 			packages << "\\usepackage{"
  << simplefeatures[i] << "}\n";
 	}
@@ -278,8 +284,7 @@ string const LaTeXFeatures::getPackages(
 	// than those above.
 	//
 
-	if (isRequired("amsmath")
-	&& !tclass.provides(LyXTextClass::amsmath)
+	if (mustProvide("amsmath")
 	&& params_.use_amsmath != BufferParams::package_off) {
 		packages << "\\usepackage{amsmath}\n";
 	}
@@ -291,12 +296,12 @@ string const LaTeXFeatures::getPackages(
 	// esint is used, since esint redefines all relevant integral
 	// symbols from wasysym and amsmath.
 	// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-	if (isRequired("wasysym") && isRequired("esint") &&
+	if (mustProvide("wasysym") && isRequired("esint") &&
 	params_.use_esint != BufferParams::package_off)
 		packages << "\\usepackage{wasysym}\n";
 
 	// color.sty
-	if (isRequired("color")) {
+	if (mustProvide("color")) {
 		if (params_.graphicsDriver == "default")
 			packages << "\\usepackage{color}\n";
 		else
@@ -307,13 +312,13 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired("makeidx")) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides("makeidx"))
 			packages << "\\usepackage{makeidx}\n";
 		packages << "\\makeindex\n";
 	}
 
 	// graphicx.sty
-	if (isRequired("graphicx") && params_.graphicsDriver != "none") {
+	if (mustProvide("graphicx") && params_.graphicsDriver != "none") {
 		if (params_.graphicsDriver == "default")
 			packages << "\\usepackage{graphicx}\n";
 		else
@@ -322,18 +327,14 @@ string const LaTeXFeatures::getPackages(
  << "]{graphicx}\n";
 	}
 	// shadecolor for shaded
-	if (isRequired("framed")) {
+	if (mustProvide("framed")) {
 		RGBColor c = RGBColor(lcolor.getX11Name(LColor::shadedbg));
 		packages << "\\definecolor{shadecolor}{rgb}{" 
 			<< c.r/255 << ',' << c.g/255 << ',' << c.b/255 << "}\n";
 	}
 
-	//if (algorithm) {
-	//	packages << "\\usepackage{algorithm}\n";
-	//}
-
 	// lyxskak.sty --- newer chess support based on skak.sty
-	if (isRequired("chess")) {
+	if (mustProvide("chess")) {
 		packages << "\\usepackage[ps,mover]{lyxskak}\n";
 	}
 
@@ -362,22 +363,23 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// amssymb.sty
-	if (isRequired("amssymb") || params_.use_amsmath == BufferParams::package_on)
+	if (mustProvide("amssymb") 
+	|| params_.use_amsmath == BufferParams::package_on)
 		packages << "\\usepackage{amssymb}\n";
 
 	// esint must be after amsmath and wasysym, since it will redeclare
 	// inconsistent integral symbols
-	if (isRequired("esint") && params_.use_esint != BufferParams::package_off)
+	if (mustProvide("esint") 
+	&& params_.use_esint != BufferParams::package_off)
 		packages << "\\usepackage{esint}\n";
 
 	// url.sty
-	if (isRequired("url") && ! tclass.provides(LyXTextClass::url))
+	if (mustProvide("url"))
 		packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
 			"  {\\newcommand{\\url}{\\texttt}}\n";
 
-	// float.sty
 	// natbib.sty
-	if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
+	if (mustProvide("natbib")) {
 		packages << "\\usepackage[";
 		if (params_.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages << "numbers";
@@ -388,20 +390,20 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// jurabib -- we need version 0.6 at least.
-	if (isRequired("jurabib")) {
+	if (mustProvide("jurabib")) {
 		packages << "\\usepackage{jurabib}[2004/01/25]\n";
 	}
 
 	// bibtopic -- the dot provides the aux file naming which
 	// LyX can detect.
-	if (isRequired("bibtopic")) {
+	if (mustProvide("bibtopic")) {
 		packages << 

Re: [PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

> Georg> This is the updated patch with layout2layout support. I needed
> Georg> to change one other place as well (compile error due to
> Georg> Martin's recent natbib change).
> 
> This is finally the working and tested patch. The only thing missing
> is the documentation (easy) and maybe the update of the layout files
> (Georg, shall we do it now?)

I think so.

> To summarize, the patch replaces things like
>   ProvidesAmsmath 1
> by
>   Provides amsmath 1
> 
> This means that any feature handled by LaTeXFeature can be overridden
> (of course, some of them will need some fixing, we'll see).
> 
> So, what shall I do with it now?

I would say commit it.


Georg



Re: [PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread José Matos
On Tuesday 03 April 2007 12:15:22 pm Georg Baum wrote:
> I would say commit it.

  +1

> Georg

-- 
José Abílio


Re: [PATCH] new Provide directive for layout files (was: Re: Getting citep etc. to work for egs.cls)

2007-04-03 Thread Martin Vermeer
On Tue, 03 Apr 2007 12:20:39 +0100
José Matos <[EMAIL PROTECTED]> wrote:

> On Tuesday 03 April 2007 12:15:22 pm Georg Baum wrote:
> > I would say commit it.
> 
>   +1
> 
> > Georg

+1

Martin
 


Re: Getting citep etc. to work for egs.cls

2007-04-02 Thread Michael Gerz

Georg Baum schrieb:

Am Donnerstag, 22. März 2007 09:41 schrieb Jean-Marc Lasgouttes:
  

OK, here is the still untested second iteration. I introduce a helper
isNeeded, which is equivalent to isRequired  ! provided (if you
have a better name, please tell). With this change, any feature known
to LyX can be provided by a class. 


What needs to be done

- update layout2layout. I need help there pretty please.

- actually test it. I do not expect any major problem, since I tried
  to be conservative.

- document the changes (trivial).



This is the updated patch with layout2layout support. I needed to change 
one other place as well (compile error due to Martin's recent natbib 
change).
  


While cleaning up my email folder, I stumbled over this patch.

What happened to it?

Michael



Re: Getting citep etc. to work for egs.cls

2007-04-02 Thread Jean-Marc Lasgouttes
 Michael == Michael Gerz [EMAIL PROTECTED] writes:

  This is the updated patch with layout2layout support. I needed to
 change one other place as well (compile error due to Martin's
 recent natbib change).
 

Michael While cleaning up my email folder, I stumbled over this
Michael patch.

Michael What happened to it?

I am slowly working on it.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-04-02 Thread Michael Gerz

Georg Baum schrieb:

Am Donnerstag, 22. März 2007 09:41 schrieb Jean-Marc Lasgouttes:
  

OK, here is the still untested second iteration. I introduce a helper
isNeeded, which is equivalent to "isRequired && ! provided" (if you
have a better name, please tell). With this change, any feature known
to LyX can be provided by a class. 


What needs to be done

- update layout2layout. I need help there pretty please.

- actually test it. I do not expect any major problem, since I tried
  to be conservative.

- document the changes (trivial).



This is the updated patch with layout2layout support. I needed to change 
one other place as well (compile error due to Martin's recent natbib 
change).
  


While cleaning up my email folder, I stumbled over this patch.

What happened to it?

Michael



Re: Getting citep etc. to work for egs.cls

2007-04-02 Thread Jean-Marc Lasgouttes
> "Michael" == Michael Gerz <[EMAIL PROTECTED]> writes:

>>  This is the updated patch with layout2layout support. I needed to
>> change one other place as well (compile error due to Martin's
>> recent natbib change).
>> 

Michael> While cleaning up my email folder, I stumbled over this
Michael> patch.

Michael> What happened to it?

I am slowly working on it.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-28 Thread Jean-Marc Lasgouttes
 Georg == Georg Baum [EMAIL PROTECTED] writes:

 - I did not keep the 0/1 value, because I do not think it is
 useful.

Georg IMHO it is. Otherwise it is not possible to undefine such a
Georg feature that comes from a .inc file (this is used in
Georg ijmpc.layout). 

These uses are bogus, I just removed them.

I will keep the 0/1 argument nevertheless.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-28 Thread Jean-Marc Lasgouttes
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

>> - I did not keep the 0/1 value, because I do not think it is
>> useful.

Georg> IMHO it is. Otherwise it is not possible to "undefine" such a
Georg> feature that comes from a .inc file (this is used in
Georg> ijmpc.layout). 

These uses are bogus, I just removed them.

I will keep the 0/1 argument nevertheless.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread Abdelrazak Younes

Bernhard Roider wrote:

Abdelrazak Younes wrote:

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


done.



Thank you. I just read the log you used and it is from my first mail 
containing this patch. There was a change since that:


the sentence

if you want to know if the lexer still has data to read (either from the 
stream or from the pushed token) then use lex.isOK().


should be

if you want to know if the lexer still has data to read from the stream 
then use lex.isOK().


When you get SVN access, I suggest that you document this properly in 
code ;-)


Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread Jean-Marc Lasgouttes
 Georg == Georg Baum [EMAIL PROTECTED] writes:

Georg This is the updated patch with layout2layout support. I needed
Georg to change one other place as well (compile error due to
Georg Martin's recent natbib change).

Georg, the layout2layout code does not work because the wanted syntax is 
  Provides amsmath
instead of
  Provides Amsmath 1

There are two problems:

- I did not keep the 0/1 value, because I do not think it is useful. 

- the feature should be put in lowecase. I could do it when reading,
  but there may be cases where features should be case-dependent.

I did not manage to grok the python regex myself, but any help would
be welcome.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

 Georg, the layout2layout code does not work because the wanted syntax is
   Provides amsmath
 instead of
   Provides Amsmath 1
 
 There are two problems:
 
 - I did not keep the 0/1 value, because I do not think it is useful.

IMHO it is. Otherwise it is not possible to undefine such a feature that
comes from a .inc file (this is used in ijmpc.layout). If you really want
to get rid of this then we need to add an additional check for the '1', but
then the translated layout file may not be 100% compatible.

 - the feature should be put in lowecase. I could do it when reading,
   but there may be cases where features should be case-dependent.
 
 I did not manage to grok the python regex myself, but any help would
 be welcome.

The regex does not need to be modified (if the current keywords are case
insensitive, but I think they are).

Writing

match.group(1).lower()

instead of

match.group(1) should give you the lowercase version (or maybe
string.lower(match.group(1)), I don't know by heart if the former works).


Georg



Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread José Matos
On Tuesday 27 March 2007 2:32:50 pm Georg Baum wrote:
 Writing

 match.group(1).lower()

 instead of

 match.group(1) should give you the lowercase version (or maybe
 string.lower(match.group(1)), I don't know by heart if the former works).

  Both work, but as you said the former is preferable.

 Georg

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread Abdelrazak Younes

Bernhard Roider wrote:

Abdelrazak Younes wrote:

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


done.



Thank you. I just read the log you used and it is from my first mail 
containing this patch. There was a change since that:


the sentence

if you want to know if the lexer still has data to read (either from the 
stream or from the pushed token) then use "lex.isOK()".


should be

if you want to know if the lexer still has data to read from the stream 
then use "lex.isOK()".


When you get SVN access, I suggest that you document this properly in 
code ;-)


Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread Jean-Marc Lasgouttes
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

Georg> This is the updated patch with layout2layout support. I needed
Georg> to change one other place as well (compile error due to
Georg> Martin's recent natbib change).

Georg, the layout2layout code does not work because the wanted syntax is 
  Provides amsmath
instead of
  Provides Amsmath 1

There are two problems:

- I did not keep the 0/1 value, because I do not think it is useful. 

- the feature should be put in lowecase. I could do it when reading,
  but there may be cases where features should be case-dependent.

I did not manage to grok the python regex myself, but any help would
be welcome.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

> Georg, the layout2layout code does not work because the wanted syntax is
>   Provides amsmath
> instead of
>   Provides Amsmath 1
> 
> There are two problems:
> 
> - I did not keep the 0/1 value, because I do not think it is useful.

IMHO it is. Otherwise it is not possible to "undefine" such a feature that
comes from a .inc file (this is used in ijmpc.layout). If you really want
to get rid of this then we need to add an additional check for the '1', but
then the translated layout file may not be 100% compatible.

> - the feature should be put in lowecase. I could do it when reading,
>   but there may be cases where features should be case-dependent.
> 
> I did not manage to grok the python regex myself, but any help would
> be welcome.

The regex does not need to be modified (if the current keywords are case
insensitive, but I think they are).

Writing

match.group(1).lower()

instead of

match.group(1) should give you the lowercase version (or maybe
string.lower(match.group(1)), I don't know by heart if the former works).


Georg



Re: Getting citep etc. to work for egs.cls

2007-03-27 Thread José Matos
On Tuesday 27 March 2007 2:32:50 pm Georg Baum wrote:
> Writing
>
> match.group(1).lower()
>
> instead of
>
> match.group(1) should give you the lowercase version (or maybe
> string.lower(match.group(1)), I don't know by heart if the former works).

  Both work, but as you said the former is preferable.

> Georg

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

Edwin Leuven wrote:

José Matos wrote:

On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:

José Matos wrote:

What needs to be done?

release 1.5 asap...


  AS long as critical bugs are fixed I don't have any problem with 
that. :-)


bernhard patch fixes one... shall i apply it?


I think that waiting for the last minute before beta 2 is not a good 
idea for this one...


Abdel.



RE: Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Leuven, E.
Abdel wrote:
 I think that waiting for the last minute before beta 2 is
 not a good idea for this one...

why not? it fixes a critical bug and would get some testing. 

(and i haven't experienced any problems myself with it...)



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

Leuven, E. wrote:

Abdel wrote:

I think that waiting for the last minute before beta 2 is
not a good idea for this one...


why not?


I mean that we should apply it ASAP, not two minute before beta 2.


it fixes a critical bug and would get some testing. 


(and i haven't experienced any problems myself with it...)


ditto.

Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread José Matos
On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:
 I can't believe this is still not applied :-)

  Could you apply it please?

 Abdel.

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


OK (even if I think Bernard should apply it himself).

Bernard, I need a log before committing this. Could you please write 
that for me?


Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


done.



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Bernhard Roider

Abdelrazak Younes wrote:

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


done.



Thank you. I just read the log you used and it is from my first mail containing this patch. There 
was a change since that:


the sentence

if you want to know if the lexer still has data to read (either from the stream or from the pushed 
token) then use lex.isOK().


should be

if you want to know if the lexer still has data to read from the stream then use 
lex.isOK().

(i had no time today (till now) to do anything for lyx...)

Bernhard



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

Edwin Leuven wrote:

José Matos wrote:

On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:

José Matos wrote:

What needs to be done?

release 1.5 asap...


  AS long as critical bugs are fixed I don't have any problem with 
that. :-)


bernhard patch fixes one... shall i apply it?


I think that waiting for the last minute before beta 2 is not a good 
idea for this one...


Abdel.



RE: Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Leuven, E.
Abdel wrote:
> I think that waiting for the last minute before beta 2 is
> not a good idea for this one...

why not? it fixes a critical bug and would get some testing. 

(and i haven't experienced any problems myself with it...)



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

Leuven, E. wrote:

Abdel wrote:

I think that waiting for the last minute before beta 2 is
not a good idea for this one...


why not?


I mean that we should apply it ASAP, not two minute before beta 2.


it fixes a critical bug and would get some testing. 


(and i haven't experienced any problems myself with it...)


ditto.

Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread José Matos
On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:
> I can't believe this is still not applied :-)

  Could you apply it please?

> Abdel.

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


OK (even if I think Bernard should apply it himself).

Bernard, I need a log before committing this. Could you please write 
that for me?


Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Abdelrazak Younes

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


done.



Re: Getting citep etc. to work for egs.cls

2007-03-26 Thread Bernhard Roider

Abdelrazak Younes wrote:

José Matos wrote:

On Saturday 24 March 2007 11:24:17 pm Abdelrazak Younes wrote:

I can't believe this is still not applied :-)


  Could you apply it please?


done.



Thank you. I just read the log you used and it is from my first mail containing this patch. There 
was a change since that:


the sentence

if you want to know if the lexer still has data to read (either from the stream or from the pushed 
token) then use "lex.isOK()".


should be

if you want to know if the lexer still has data to read from the stream then use 
"lex.isOK()".

(i had no time today (till now) to do anything for lyx...)

Bernhard



Re: Getting citep etc. to work for egs.cls

2007-03-24 Thread Georg Baum
Am Donnerstag, 22. März 2007 09:41 schrieb Jean-Marc Lasgouttes:

 OK, here is the still untested second iteration. I introduce a helper
 isNeeded, which is equivalent to isRequired  ! provided (if you
 have a better name, please tell). With this change, any feature known
 to LyX can be provided by a class. 
 
 What needs to be done
 
 - update layout2layout. I need help there pretty please.
 
 - actually test it. I do not expect any major problem, since I tried
   to be conservative.
 
 - document the changes (trivial).

This is the updated patch with layout2layout support. I needed to change 
one other place as well (compile error due to Martin's recent natbib 
change).


Georg
Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(Revision 17530)
+++ src/LaTeXFeatures.C	(Arbeitskopie)
@@ -152,6 +152,12 @@ bool LaTeXFeatures::isRequired(string co
 }
 
 
+bool LaTeXFeatures::isNeeded(string const  name) const
+{
+	return isRequired(name)  !params_.getLyXTextClass().provides(name);
+}
+
+
 bool LaTeXFeatures::isAvailable(string const  name)
 {
 	if (packages_.empty())
@@ -267,7 +273,7 @@ string const LaTeXFeatures::getPackages(
 	//  packages which we just \usepackage{package}
 	//
 	for (int i = 0; i  nb_simplefeatures; ++i) {
-		if (isRequired(simplefeatures[i]))
+		if (isNeeded(simplefeatures[i]))
 			packages  \\usepackage{
   simplefeatures[i]  }\n;
 	}
@@ -277,8 +283,7 @@ string const LaTeXFeatures::getPackages(
 	// than those above.
 	//
 
-	if (isRequired(amsmath)
-	 !tclass.provides(LyXTextClass::amsmath)
+	if (isNeeded(amsmath)
 	 params_.use_amsmath != BufferParams::package_off) {
 		packages  \\usepackage{amsmath}\n;
 	}
@@ -290,12 +295,12 @@ string const LaTeXFeatures::getPackages(
 	// esint is used, since esint redefines all relevant integral
 	// symbols from wasysym and amsmath.
 	// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-	if (isRequired(wasysym)  isRequired(esint) 
+	if (isNeeded(wasysym)  isRequired(esint) 
 	params_.use_esint != BufferParams::package_off)
 		packages  \\usepackage{wasysym}\n;
 
 	// color.sty
-	if (isRequired(color)) {
+	if (isNeeded(color)) {
 		if (params_.graphicsDriver == default)
 			packages  \\usepackage{color}\n;
 		else
@@ -306,13 +311,13 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired(makeidx)) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides(makeidx))
 			packages  \\usepackage{makeidx}\n;
 		packages  \\makeindex\n;
 	}
 
 	// graphicx.sty
-	if (isRequired(graphicx)  params_.graphicsDriver != none) {
+	if (isNeeded(graphicx)  params_.graphicsDriver != none) {
 		if (params_.graphicsDriver == default)
 			packages  \\usepackage{graphicx}\n;
 		else
@@ -321,7 +326,7 @@ string const LaTeXFeatures::getPackages(
   ]{graphicx}\n;
 	}
 	// shadecolor for shaded
-	if (isRequired(framed)) {
+	if (isNeeded(framed)) {
 		RGBColor c = RGBColor(lcolor.getX11Name(LColor::shadedbg));
 		packages  \\definecolor{shadecolor}{rgb}{ 
 			 c.r/255  ','  c.g/255  ','  c.b/255  }\n;
@@ -332,7 +337,7 @@ string const LaTeXFeatures::getPackages(
 	//}
 
 	// lyxskak.sty --- newer chess support based on skak.sty
-	if (isRequired(chess)) {
+	if (isNeeded(chess)) {
 		packages  \\usepackage[ps,mover]{lyxskak}\n;
 	}
 
@@ -361,22 +366,22 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// amssymb.sty
-	if (isRequired(amssymb) || params_.use_amsmath == BufferParams::package_on)
+	if (isNeeded(amssymb) || params_.use_amsmath == BufferParams::package_on)
 		packages  \\usepackage{amssymb}\n;
 
 	// esint must be after amsmath and wasysym, since it will redeclare
 	// inconsistent integral symbols
-	if (isRequired(esint)  params_.use_esint != BufferParams::package_off)
+	if (isNeeded(esint)  params_.use_esint != BufferParams::package_off)
 		packages  \\usepackage{esint}\n;
 
 	// url.sty
-	if (isRequired(url)  ! tclass.provides(LyXTextClass::url))
+	if (isNeeded(url))
 		packages  \\IfFileExists{url.sty}{\\usepackage{url}}\n
 			  {\\newcommand{\\url}{\\texttt}}\n;
 
 	// float.sty
 	// natbib.sty
-	if (isRequired(natbib)  ! tclass.provides(LyXTextClass::natbib)) {
+	if (isNeeded(natbib)) {
 		packages  \\usepackage[;
 		if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages  numbers;
@@ -387,20 +392,20 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// jurabib -- we need version 0.6 at least.
-	if (isRequired(jurabib)) {
+	if (isNeeded(jurabib)) {
 		packages  \\usepackage{jurabib}[2004/01/25]\n;
 	}
 
 	// bibtopic -- the dot provides the aux file naming which
 	// LyX can detect.
-	if (isRequired(bibtopic)) {
+	if (isNeeded(bibtopic)) {
 		packages  \\usepackage[dot]{bibtopic}\n;
 	}
 
-	if (isRequired(xy))
+	if (isNeeded(xy))
 		packages  \\usepackage[all]{xy}\n;
 
-	if (isRequired(nomencl)) {
+	if (isNeeded(nomencl)) {
 		packages  \\usepackage{nomencl}[2005/09/22]\n
 			  

Re: Getting citep etc. to work for egs.cls

2007-03-24 Thread Abdelrazak Younes

Martin Vermeer wrote:

On Thu, Mar 01, 2007 at 01:27:17PM +0100, Juergen Spitzmueller wrote:

Martin Vermeer wrote:


Yes, indeed. Still, the question remains, is this sensible.

No. Numerical needs the styles as well, so it should be supported likewise.

Jürgen


Attached an updated version of this patch, so it is not forgotten.

I added a pair of FIXMEs to remind that it is the document class that
knows whether we have a numerical or author-year ciation style, and
ideally LyX should be told this through a layout file option.

Were there any other issues with this? I would like to check this in, as
it would gain us one user who might become a contributor.


I have the same cleanup locally, looks like I'll have to do a bit of 
hand-merging :-(


Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-24 Thread Abdelrazak Younes

Edwin Leuven wrote:

José Matos wrote:

On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:

José Matos wrote:

What needs to be done?

release 1.5 asap...


  AS long as critical bugs are fixed I don't have any problem with 
that. :-)


bernhard patch fixes one... shall i apply it?


I can't believe this is still not applied :-)

Abdel.





Re: Getting citep etc. to work for egs.cls

2007-03-24 Thread Georg Baum
Am Donnerstag, 22. März 2007 09:41 schrieb Jean-Marc Lasgouttes:

> OK, here is the still untested second iteration. I introduce a helper
> isNeeded, which is equivalent to "isRequired && ! provided" (if you
> have a better name, please tell). With this change, any feature known
> to LyX can be provided by a class. 
> 
> What needs to be done
> 
> - update layout2layout. I need help there pretty please.
> 
> - actually test it. I do not expect any major problem, since I tried
>   to be conservative.
> 
> - document the changes (trivial).

This is the updated patch with layout2layout support. I needed to change 
one other place as well (compile error due to Martin's recent natbib 
change).


Georg
Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(Revision 17530)
+++ src/LaTeXFeatures.C	(Arbeitskopie)
@@ -152,6 +152,12 @@ bool LaTeXFeatures::isRequired(string co
 }
 
 
+bool LaTeXFeatures::isNeeded(string const & name) const
+{
+	return isRequired(name) && !params_.getLyXTextClass().provides(name);
+}
+
+
 bool LaTeXFeatures::isAvailable(string const & name)
 {
 	if (packages_.empty())
@@ -267,7 +273,7 @@ string const LaTeXFeatures::getPackages(
 	//  packages which we just \usepackage{package}
 	//
 	for (int i = 0; i < nb_simplefeatures; ++i) {
-		if (isRequired(simplefeatures[i]))
+		if (isNeeded(simplefeatures[i]))
 			packages << "\\usepackage{"
  << simplefeatures[i] << "}\n";
 	}
@@ -277,8 +283,7 @@ string const LaTeXFeatures::getPackages(
 	// than those above.
 	//
 
-	if (isRequired("amsmath")
-	&& !tclass.provides(LyXTextClass::amsmath)
+	if (isNeeded("amsmath")
 	&& params_.use_amsmath != BufferParams::package_off) {
 		packages << "\\usepackage{amsmath}\n";
 	}
@@ -290,12 +295,12 @@ string const LaTeXFeatures::getPackages(
 	// esint is used, since esint redefines all relevant integral
 	// symbols from wasysym and amsmath.
 	// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-	if (isRequired("wasysym") && isRequired("esint") &&
+	if (isNeeded("wasysym") && isRequired("esint") &&
 	params_.use_esint != BufferParams::package_off)
 		packages << "\\usepackage{wasysym}\n";
 
 	// color.sty
-	if (isRequired("color")) {
+	if (isNeeded("color")) {
 		if (params_.graphicsDriver == "default")
 			packages << "\\usepackage{color}\n";
 		else
@@ -306,13 +311,13 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired("makeidx")) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides("makeidx"))
 			packages << "\\usepackage{makeidx}\n";
 		packages << "\\makeindex\n";
 	}
 
 	// graphicx.sty
-	if (isRequired("graphicx") && params_.graphicsDriver != "none") {
+	if (isNeeded("graphicx") && params_.graphicsDriver != "none") {
 		if (params_.graphicsDriver == "default")
 			packages << "\\usepackage{graphicx}\n";
 		else
@@ -321,7 +326,7 @@ string const LaTeXFeatures::getPackages(
  << "]{graphicx}\n";
 	}
 	// shadecolor for shaded
-	if (isRequired("framed")) {
+	if (isNeeded("framed")) {
 		RGBColor c = RGBColor(lcolor.getX11Name(LColor::shadedbg));
 		packages << "\\definecolor{shadecolor}{rgb}{" 
 			<< c.r/255 << ',' << c.g/255 << ',' << c.b/255 << "}\n";
@@ -332,7 +337,7 @@ string const LaTeXFeatures::getPackages(
 	//}
 
 	// lyxskak.sty --- newer chess support based on skak.sty
-	if (isRequired("chess")) {
+	if (isNeeded("chess")) {
 		packages << "\\usepackage[ps,mover]{lyxskak}\n";
 	}
 
@@ -361,22 +366,22 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// amssymb.sty
-	if (isRequired("amssymb") || params_.use_amsmath == BufferParams::package_on)
+	if (isNeeded("amssymb") || params_.use_amsmath == BufferParams::package_on)
 		packages << "\\usepackage{amssymb}\n";
 
 	// esint must be after amsmath and wasysym, since it will redeclare
 	// inconsistent integral symbols
-	if (isRequired("esint") && params_.use_esint != BufferParams::package_off)
+	if (isNeeded("esint") && params_.use_esint != BufferParams::package_off)
 		packages << "\\usepackage{esint}\n";
 
 	// url.sty
-	if (isRequired("url") && ! tclass.provides(LyXTextClass::url))
+	if (isNeeded("url"))
 		packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
 			"  {\\newcommand{\\url}{\\texttt}}\n";
 
 	// float.sty
 	// natbib.sty
-	if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
+	if (isNeeded("natbib")) {
 		packages << "\\usepackage[";
 		if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages << "numbers";
@@ -387,20 +392,20 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// jurabib -- we need version 0.6 at least.
-	if (isRequired("jurabib")) {
+	if (isNeeded("jurabib")) {
 		packages << "\\usepackage{jurabib}[2004/01/25]\n";
 	}
 
 	// bibtopic -- the dot provides the aux file naming which
 	// LyX can detect.
-	if (isRequired("bibtopic")) {
+	if (isNeeded("bibtopic")) {
 		packages << "\\usepackage[dot]{bibtopic}\n";
 	}
 
-	

Re: Getting citep etc. to work for egs.cls

2007-03-24 Thread Abdelrazak Younes

Martin Vermeer wrote:

On Thu, Mar 01, 2007 at 01:27:17PM +0100, Juergen Spitzmueller wrote:

Martin Vermeer wrote:


Yes, indeed. Still, the question remains, is this sensible.

No. Numerical needs the styles as well, so it should be supported likewise.

Jürgen


Attached an updated version of this patch, so it is not forgotten.

I added a pair of FIXMEs to remind that it is the document class that
"knows" whether we have a numerical or author-year ciation style, and
ideally LyX should be told this through a layout file option.

Were there any other issues with this? I would like to check this in, as
it would gain us one user who might become a contributor.


I have the same cleanup locally, looks like I'll have to do a bit of 
hand-merging :-(


Abdel.



Re: Getting citep etc. to work for egs.cls

2007-03-24 Thread Abdelrazak Younes

Edwin Leuven wrote:

José Matos wrote:

On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:

José Matos wrote:

What needs to be done?

release 1.5 asap...


  AS long as critical bugs are fixed I don't have any problem with 
that. :-)


bernhard patch fixes one... shall i apply it?


I can't believe this is still not applied :-)

Abdel.





Re: Getting citep etc. to work for egs.cls

2007-03-23 Thread Jean-Marc Lasgouttes
 Martin == Martin Vermeer [EMAIL PROTECTED] writes:

  OK, here is the still untested second iteration. I introduce a
 helper isNeeded, which is equivalent to isRequired  ! provided
 (if you have a better name, please tell). With this change, any
 feature known to LyX can be provided by a class.

Martin mustProvide

Good idea.

Martin I think this is an important simplification, even deserving
Martin the name bug fix. With it, I can fix the Provide babel bug
Martin for EGS (and presumably others) much more easily.

While this provides the infrastructure for Provides babel, I suspect
that some code changes will be needed to make it work (and the
semantics of this should be defined).

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-23 Thread Jean-Marc Lasgouttes
> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

>>  OK, here is the still untested second iteration. I introduce a
>> helper isNeeded, which is equivalent to "isRequired && ! provided"
>> (if you have a better name, please tell). With this change, any
>> feature known to LyX can be provided by a class.

Martin> "mustProvide"

Good idea.

Martin> I think this is an important simplification, even deserving
Martin> the name "bug fix". With it, I can fix the "Provide babel" bug
Martin> for EGS (and presumably others) much more easily.

While this provides the infrastructure for "Provides babel", I suspect
that some code changes will be needed to make it work (and the
semantics of this should be defined).

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-22 Thread Jean-Marc Lasgouttes
 José == José Matos [EMAIL PROTECTED] writes:

José On Tuesday 20 March 2007 9:23:56 am Jean-Marc Lasgouttes wrote:
  One solution would be to define a isNeeded() for this use case,
 and still use isRequired in the few cases where this makes sense.

José   The patch seems quite interesting indeed. I think that it is
José not yet ready to beta 2 but I would to see it (and to help
José testing it) for a later release.

OK, here is the still untested second iteration. I introduce a helper
isNeeded, which is equivalent to isRequired  ! provided (if you
have a better name, please tell). With this change, any feature known
to LyX can be provided by a class. 

What needs to be done

- update layout2layout. I need help there pretty please.

- actually test it. I do not expect any major problem, since I tried
  to be conservative.

- document the changes (trivial).

JMarc 

Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(révision 17488)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -152,6 +152,12 @@ bool LaTeXFeatures::isRequired(string co
 }
 
 
+bool LaTeXFeatures::isNeeded(string const  name) const
+{
+	return isRequired(name)  !params_.getLyXTextClass().provides(name);
+}
+
+
 bool LaTeXFeatures::isAvailable(string const  name)
 {
 	if (packages_.empty())
@@ -267,7 +273,7 @@ string const LaTeXFeatures::getPackages(
 	//  packages which we just \usepackage{package}
 	//
 	for (int i = 0; i  nb_simplefeatures; ++i) {
-		if (isRequired(simplefeatures[i]))
+		if (isNeeded(simplefeatures[i]))
 			packages  \\usepackage{
   simplefeatures[i]  }\n;
 	}
@@ -277,8 +283,7 @@ string const LaTeXFeatures::getPackages(
 	// than those above.
 	//
 
-	if (isRequired(amsmath)
-	 !tclass.provides(LyXTextClass::amsmath)
+	if (isNeeded(amsmath)
 	 params_.use_amsmath != BufferParams::package_off) {
 		packages  \\usepackage{amsmath}\n;
 	}
@@ -290,12 +295,12 @@ string const LaTeXFeatures::getPackages(
 	// esint is used, since esint redefines all relevant integral
 	// symbols from wasysym and amsmath.
 	// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-	if (isRequired(wasysym)  isRequired(esint) 
+	if (isNeeded(wasysym)  isRequired(esint) 
 	params_.use_esint != BufferParams::package_off)
 		packages  \\usepackage{wasysym}\n;
 
 	// color.sty
-	if (isRequired(color)) {
+	if (isNeeded(color)) {
 		if (params_.graphicsDriver == default)
 			packages  \\usepackage{color}\n;
 		else
@@ -306,13 +311,13 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired(makeidx)) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides(makeidx))
 			packages  \\usepackage{makeidx}\n;
 		packages  \\makeindex\n;
 	}
 
 	// graphicx.sty
-	if (isRequired(graphicx)  params_.graphicsDriver != none) {
+	if (isNeeded(graphicx)  params_.graphicsDriver != none) {
 		if (params_.graphicsDriver == default)
 			packages  \\usepackage{graphicx}\n;
 		else
@@ -321,7 +326,7 @@ string const LaTeXFeatures::getPackages(
   ]{graphicx}\n;
 	}
 	// shadecolor for shaded
-	if (isRequired(framed)) {
+	if (isNeeded(framed)) {
 		RGBColor c = RGBColor(lcolor.getX11Name(LColor::shadedbg));
 		packages  \\definecolor{shadecolor}{rgb}{ 
 			 c.r/255  ','  c.g/255  ','  c.b/255  }\n;
@@ -332,7 +337,7 @@ string const LaTeXFeatures::getPackages(
 	//}
 
 	// lyxskak.sty --- newer chess support based on skak.sty
-	if (isRequired(chess)) {
+	if (isNeeded(chess)) {
 		packages  \\usepackage[ps,mover]{lyxskak}\n;
 	}
 
@@ -361,22 +366,22 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// amssymb.sty
-	if (isRequired(amssymb) || params_.use_amsmath == BufferParams::package_on)
+	if (isNeeded(amssymb) || params_.use_amsmath == BufferParams::package_on)
 		packages  \\usepackage{amssymb}\n;
 
 	// esint must be after amsmath and wasysym, since it will redeclare
 	// inconsistent integral symbols
-	if (isRequired(esint)  params_.use_esint != BufferParams::package_off)
+	if (isNeeded(esint)  params_.use_esint != BufferParams::package_off)
 		packages  \\usepackage{esint}\n;
 
 	// url.sty
-	if (isRequired(url)  ! tclass.provides(LyXTextClass::url))
+	if (isNeeded(url))
 		packages  \\IfFileExists{url.sty}{\\usepackage{url}}\n
 			  {\\newcommand{\\url}{\\texttt}}\n;
 
 	// float.sty
 	// natbib.sty
-	if (isRequired(natbib)  ! tclass.provides(LyXTextClass::natbib)) {
+	if (isNeeded(natbib)) {
 		packages  \\usepackage[;
 		if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages  numbers;
@@ -387,20 +392,20 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// jurabib -- we need version 0.6 at least.
-	if (isRequired(jurabib)) {
+	if (isNeeded(jurabib)) {
 		packages  \\usepackage{jurabib}[2004/01/25]\n;
 	}
 
 	// bibtopic -- the dot provides the aux file naming which
 	// LyX can detect.
-	if (isRequired(bibtopic)) {
+	if (isNeeded(bibtopic)) {
 		packages  \\usepackage[dot]{bibtopic}\n;
 	}
 
-	if 

Re: Getting citep etc. to work for egs.cls

2007-03-22 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

 What needs to be done
 
 - update layout2layout. I need help there pretty please.

I can have a look over the weekend. I need to fix a bug in layout2lyaout
anyway (conversion from version 1 to 3 does not work).


Georg



Re: Getting citep etc. to work for egs.cls

2007-03-22 Thread Martin Vermeer
On Thu, 22 Mar 2007 09:41:07 +0100
Jean-Marc Lasgouttes [EMAIL PROTECTED] wrote:

  José == José Matos [EMAIL PROTECTED] writes:
 
 José On Tuesday 20 March 2007 9:23:56 am Jean-Marc Lasgouttes wrote:
   One solution would be to define a isNeeded() for this use case,
  and still use isRequired in the few cases where this makes sense.
 
 José   The patch seems quite interesting indeed. I think that it is
 José not yet ready to beta 2 but I would to see it (and to help
 José testing it) for a later release.
 
 OK, here is the still untested second iteration. I introduce a helper
 isNeeded, which is equivalent to isRequired  ! provided (if you
 have a better name, please tell). With this change, any feature known
 to LyX can be provided by a class. 

mustProvide

 What needs to be done
 
 - update layout2layout. I need help there pretty please.
 
 - actually test it. I do not expect any major problem, since I tried
   to be conservative.
 
 - document the changes (trivial).
 
 JMarc 

I think this is an important simplification, even deserving the name
bug fix. With it, I can fix the Provide babel bug for EGS (and
presumably others) much more easily.

- Martin


Re: Getting citep etc. to work for egs.cls

2007-03-22 Thread Jean-Marc Lasgouttes
> "José" == José Matos <[EMAIL PROTECTED]> writes:

José> On Tuesday 20 March 2007 9:23:56 am Jean-Marc Lasgouttes wrote:
>>  One solution would be to define a isNeeded() for this use case,
>> and still use isRequired in the few cases where this makes sense.

José>   The patch seems quite interesting indeed. I think that it is
José> not yet ready to beta 2 but I would to see it (and to help
José> testing it) for a later release.

OK, here is the still untested second iteration. I introduce a helper
isNeeded, which is equivalent to "isRequired && ! provided" (if you
have a better name, please tell). With this change, any feature known
to LyX can be provided by a class. 

What needs to be done

- update layout2layout. I need help there pretty please.

- actually test it. I do not expect any major problem, since I tried
  to be conservative.

- document the changes (trivial).

JMarc 

Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(révision 17488)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -152,6 +152,12 @@ bool LaTeXFeatures::isRequired(string co
 }
 
 
+bool LaTeXFeatures::isNeeded(string const & name) const
+{
+	return isRequired(name) && !params_.getLyXTextClass().provides(name);
+}
+
+
 bool LaTeXFeatures::isAvailable(string const & name)
 {
 	if (packages_.empty())
@@ -267,7 +273,7 @@ string const LaTeXFeatures::getPackages(
 	//  packages which we just \usepackage{package}
 	//
 	for (int i = 0; i < nb_simplefeatures; ++i) {
-		if (isRequired(simplefeatures[i]))
+		if (isNeeded(simplefeatures[i]))
 			packages << "\\usepackage{"
  << simplefeatures[i] << "}\n";
 	}
@@ -277,8 +283,7 @@ string const LaTeXFeatures::getPackages(
 	// than those above.
 	//
 
-	if (isRequired("amsmath")
-	&& !tclass.provides(LyXTextClass::amsmath)
+	if (isNeeded("amsmath")
 	&& params_.use_amsmath != BufferParams::package_off) {
 		packages << "\\usepackage{amsmath}\n";
 	}
@@ -290,12 +295,12 @@ string const LaTeXFeatures::getPackages(
 	// esint is used, since esint redefines all relevant integral
 	// symbols from wasysym and amsmath.
 	// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-	if (isRequired("wasysym") && isRequired("esint") &&
+	if (isNeeded("wasysym") && isRequired("esint") &&
 	params_.use_esint != BufferParams::package_off)
 		packages << "\\usepackage{wasysym}\n";
 
 	// color.sty
-	if (isRequired("color")) {
+	if (isNeeded("color")) {
 		if (params_.graphicsDriver == "default")
 			packages << "\\usepackage{color}\n";
 		else
@@ -306,13 +311,13 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired("makeidx")) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides("makeidx"))
 			packages << "\\usepackage{makeidx}\n";
 		packages << "\\makeindex\n";
 	}
 
 	// graphicx.sty
-	if (isRequired("graphicx") && params_.graphicsDriver != "none") {
+	if (isNeeded("graphicx") && params_.graphicsDriver != "none") {
 		if (params_.graphicsDriver == "default")
 			packages << "\\usepackage{graphicx}\n";
 		else
@@ -321,7 +326,7 @@ string const LaTeXFeatures::getPackages(
  << "]{graphicx}\n";
 	}
 	// shadecolor for shaded
-	if (isRequired("framed")) {
+	if (isNeeded("framed")) {
 		RGBColor c = RGBColor(lcolor.getX11Name(LColor::shadedbg));
 		packages << "\\definecolor{shadecolor}{rgb}{" 
 			<< c.r/255 << ',' << c.g/255 << ',' << c.b/255 << "}\n";
@@ -332,7 +337,7 @@ string const LaTeXFeatures::getPackages(
 	//}
 
 	// lyxskak.sty --- newer chess support based on skak.sty
-	if (isRequired("chess")) {
+	if (isNeeded("chess")) {
 		packages << "\\usepackage[ps,mover]{lyxskak}\n";
 	}
 
@@ -361,22 +366,22 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// amssymb.sty
-	if (isRequired("amssymb") || params_.use_amsmath == BufferParams::package_on)
+	if (isNeeded("amssymb") || params_.use_amsmath == BufferParams::package_on)
 		packages << "\\usepackage{amssymb}\n";
 
 	// esint must be after amsmath and wasysym, since it will redeclare
 	// inconsistent integral symbols
-	if (isRequired("esint") && params_.use_esint != BufferParams::package_off)
+	if (isNeeded("esint") && params_.use_esint != BufferParams::package_off)
 		packages << "\\usepackage{esint}\n";
 
 	// url.sty
-	if (isRequired("url") && ! tclass.provides(LyXTextClass::url))
+	if (isNeeded("url"))
 		packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
 			"  {\\newcommand{\\url}{\\texttt}}\n";
 
 	// float.sty
 	// natbib.sty
-	if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
+	if (isNeeded("natbib")) {
 		packages << "\\usepackage[";
 		if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages << "numbers";
@@ -387,20 +392,20 @@ string const LaTeXFeatures::getPackages(
 	}
 
 	// jurabib -- we need version 0.6 at least.
-	if (isRequired("jurabib")) {
+	if (isNeeded("jurabib")) {
 		packages << "\\usepackage{jurabib}[2004/01/25]\n";
 	}
 
 	

Re: Getting citep etc. to work for egs.cls

2007-03-22 Thread Georg Baum
Jean-Marc Lasgouttes wrote:

> What needs to be done
> 
> - update layout2layout. I need help there pretty please.

I can have a look over the weekend. I need to fix a bug in layout2lyaout
anyway (conversion from version 1 to 3 does not work).


Georg



Re: Getting citep etc. to work for egs.cls

2007-03-22 Thread Martin Vermeer
On Thu, 22 Mar 2007 09:41:07 +0100
Jean-Marc Lasgouttes <[EMAIL PROTECTED]> wrote:

> > "José" == José Matos <[EMAIL PROTECTED]> writes:
> 
> José> On Tuesday 20 March 2007 9:23:56 am Jean-Marc Lasgouttes wrote:
> >>  One solution would be to define a isNeeded() for this use case,
> >> and still use isRequired in the few cases where this makes sense.
> 
> José>   The patch seems quite interesting indeed. I think that it is
> José> not yet ready to beta 2 but I would to see it (and to help
> José> testing it) for a later release.
> 
> OK, here is the still untested second iteration. I introduce a helper
> isNeeded, which is equivalent to "isRequired && ! provided" (if you
> have a better name, please tell). With this change, any feature known
> to LyX can be provided by a class. 

"mustProvide"

> What needs to be done
> 
> - update layout2layout. I need help there pretty please.
> 
> - actually test it. I do not expect any major problem, since I tried
>   to be conservative.
> 
> - document the changes (trivial).
> 
> JMarc 

I think this is an important simplification, even deserving the name
"bug fix". With it, I can fix the "Provide babel" bug for EGS (and
presumably others) much more easily.

- Martin


Re: Getting citep etc. to work for egs.cls

2007-03-21 Thread Jean-Marc Lasgouttes
 Martin == Martin Vermeer [EMAIL PROTECTED] writes:

Martin On Tue, Mar 20, 2007 at 06:48:24PM +0100, Jürgen Spitzmüller
Martin wrote:
 Martin Vermeer wrote:  Which changelog? They haven't been updated
 since somewhere october last  year.
 
 Look twice: http://www.lyx.org/trac/changeset/17480

Martin OK, done. Seems I hadn't updated _or_ committed in branch
Martin since last october ;-/

Thanks.

JMarc




Re: Getting citep etc. to work for egs.cls

2007-03-21 Thread Jean-Marc Lasgouttes
 Martin == Martin Vermeer [EMAIL PROTECTED] writes:

  I forgot to add that I do not know how std::set works, so my code
 could be bogus (but at least it compiles :).

Martin From what I remember it is valid...

Very good.

JMarc 




Re: Getting citep etc. to work for egs.cls

2007-03-21 Thread José Matos
On Tuesday 20 March 2007 9:23:56 am Jean-Marc Lasgouttes wrote:

 One solution would be to define a isNeeded() for this use case, and
 still use isRequired in the few cases where this makes sense.

  The patch seems quite interesting indeed. I think that it is not yet ready 
to beta 2 but I would to see it (and to help testing it) for a later release.

 JMarc

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-21 Thread Jean-Marc Lasgouttes
> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

Martin> On Tue, Mar 20, 2007 at 06:48:24PM +0100, Jürgen Spitzmüller
Martin> wrote:
>> Martin Vermeer wrote: > Which changelog? They haven't been updated
>> since somewhere october last > year.
>> 
>> Look twice: http://www.lyx.org/trac/changeset/17480

Martin> OK, done. Seems I hadn't updated _or_ committed in branch
Martin> since last october ;-/

Thanks.

JMarc




Re: Getting citep etc. to work for egs.cls

2007-03-21 Thread Jean-Marc Lasgouttes
> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

>>  I forgot to add that I do not know how std::set works, so my code
>> could be bogus (but at least it compiles :).

Martin> From what I remember it is valid...

Very good.

JMarc 




Re: Getting citep etc. to work for egs.cls

2007-03-21 Thread José Matos
On Tuesday 20 March 2007 9:23:56 am Jean-Marc Lasgouttes wrote:
>
> One solution would be to define a isNeeded() for this use case, and
> still use isRequired in the few cases where this makes sense.

  The patch seems quite interesting indeed. I think that it is not yet ready 
to beta 2 but I would to see it (and to help testing it) for a later release.

> JMarc

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jean-Marc Lasgouttes
 Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:

Jean-Marc The idea is to replace it with a std::setstring and
Jean-Marc change LyXTextClass::provides() accordingly. The rest is
Jean-Marc purely mechanical (replace enum by string). It could be
Jean-Marc possible to simplify further the code, but it is not needed
Jean-Marc now (and may be more dangerous)

This is how the basic (untested patch would look like). layout2layout
support is still missing of course (so that this patch is useless as
is). This trivial patch only works for the features that could already
be provided earlier. Adding a Provides graphics will have no effect,
for example. It is tempting to redefine isRequired() to return false
when provides returns true, but we have to be a bit more careful than
that.

One solution would be to define a isNeeded() for this use case, and
still use isRequired in the few cases where this makes sense.

JMarc

Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(révision 17488)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -278,7 +278,7 @@ string const LaTeXFeatures::getPackages(
 	//
 
 	if (isRequired(amsmath)
-	 !tclass.provides(LyXTextClass::amsmath)
+	 !tclass.provides(amsmath)
 	 params_.use_amsmath != BufferParams::package_off) {
 		packages  \\usepackage{amsmath}\n;
 	}
@@ -306,7 +306,7 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired(makeidx)) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides(makeidx))
 			packages  \\usepackage{makeidx}\n;
 		packages  \\makeindex\n;
 	}
@@ -370,13 +370,13 @@ string const LaTeXFeatures::getPackages(
 		packages  \\usepackage{esint}\n;
 
 	// url.sty
-	if (isRequired(url)  ! tclass.provides(LyXTextClass::url))
+	if (isRequired(url)  ! tclass.provides(url))
 		packages  \\IfFileExists{url.sty}{\\usepackage{url}}\n
 			  {\\newcommand{\\url}{\\texttt}}\n;
 
 	// float.sty
 	// natbib.sty
-	if (isRequired(natbib)  ! tclass.provides(LyXTextClass::natbib)) {
+	if (isRequired(natbib)  ! tclass.provides(natbib)) {
 		packages  \\usepackage[;
 		if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages  numbers;
Index: src/buffer.C
===
--- src/buffer.C	(révision 17488)
+++ src/buffer.C	(copie de travail)
@@ -1195,7 +1195,7 @@ void Buffer::validate(LaTeXFeatures  fe
 
 	// AMS Style is at document level
 	if (params().use_amsmath == BufferParams::package_on
-	|| tclass.provides(LyXTextClass::amsmath))
+	|| tclass.provides(amsmath))
 		features.require(amsmath);
 	if (params().use_esint == BufferParams::package_on)
 		features.require(esint);
Index: src/lyxtextclass.C
===
--- src/lyxtextclass.C	(révision 17488)
+++ src/lyxtextclass.C	(copie de travail)
@@ -113,7 +113,6 @@ LyXTextClass::LyXTextClass(string const 
 	defaultfont_ = LyXFont(LyXFont::ALL_SANE);
 	opt_fontsize_ = 10|11|12;
 	opt_pagestyle_ = empty|plain|headings|fancy;
-	provides_ = nothing;
 	titletype_ = TITLE_COMMAND_AFTER;
 	titlename_ = maketitle;
 	loaded_ = false;
@@ -158,10 +157,7 @@ enum TextClassTags {
 	TC_TOCDEPTH,
 	TC_CLASSOPTIONS,
 	TC_PREAMBLE,
-	TC_PROVIDESAMSMATH,
-	TC_PROVIDESNATBIB,
-	TC_PROVIDESMAKEIDX,
-	TC_PROVIDESURL,
+	TC_PROVIDES,
 	TC_LEFTMARGIN,
 	TC_RIGHTMARGIN,
 	TC_FLOAT,
@@ -199,10 +195,7 @@ bool LyXTextClass::read(FileName const 
 		{ outputtype,  TC_OUTPUTTYPE },
 		{ pagestyle,   TC_PAGESTYLE },
 		{ preamble,TC_PREAMBLE },
-		{ providesamsmath, TC_PROVIDESAMSMATH },
-		{ providesmakeidx, TC_PROVIDESMAKEIDX },
-		{ providesnatbib,  TC_PROVIDESNATBIB },
-		{ providesurl, TC_PROVIDESURL },
+		{ provides,TC_PROVIDES },
 		{ rightmargin, TC_RIGHTMARGIN },
 		{ secnumdepth, TC_SECNUMDEPTH },
 		{ sides,   TC_SIDES },
@@ -383,24 +376,9 @@ bool LyXTextClass::read(FileName const 
 			preamble_ = from_utf8(lexrc.getLongString(EndPreamble));
 			break;
 
-		case TC_PROVIDESAMSMATH:
-			if (lexrc.next()  lexrc.getInteger())
-provides_ |= amsmath;
-			break;
-
-		case TC_PROVIDESNATBIB:
-			if (lexrc.next()  lexrc.getInteger())
-provides_ |= natbib;
-			break;
-
-		case TC_PROVIDESMAKEIDX:
-			if (lexrc.next()  lexrc.getInteger())
-provides_ |= makeidx;
-			break;
-
-		case TC_PROVIDESURL:
-			if (lexrc.next()  lexrc.getInteger())
-provides_ |= url;
+		case TC_PROVIDES:
+			if (lexrc.next())
+provides_.insert(lexrc.getString());
 			break;
 
 		case TC_LEFTMARGIN:	// left margin type
@@ -1067,9 +1045,9 @@ OutputType LyXTextClass::outputType() co
 }
 
 
-bool LyXTextClass::provides(LyXTextClass::Provides p) const
+bool LyXTextClass::provides(string const  p) const
 {
-	return provides_  p;
+	return provides_.find(p) != provides_.end();
 }
 
 
Index: src/lyxtextclass.h

Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jean-Marc Lasgouttes
 Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:

 Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:
Jean-Marc The idea is to replace it with a std::setstring and
Jean-Marc change LyXTextClass::provides() accordingly. The rest is
Jean-Marc purely mechanical (replace enum by string). It could be
Jean-Marc possible to simplify further the code, but it is not needed
Jean-Marc now (and may be more dangerous)

Jean-Marc This is how the basic (untested patch would look like).
Jean-Marc layout2layout support is still missing of course (so that
Jean-Marc this patch is useless as is). This trivial patch only works
Jean-Marc for the features that could already be provided earlier.
Jean-Marc Adding a Provides graphics will have no effect, for
Jean-Marc example. It is tempting to redefine isRequired() to return
Jean-Marc false when provides returns true, but we have to be a bit
Jean-Marc more careful than that.

Jean-Marc One solution would be to define a isNeeded() for this use
Jean-Marc case, and still use isRequired in the few cases where this
Jean-Marc makes sense.

I forgot to add that I do not know how std::set works, so my code
could be bogus (but at least it compiles :).

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Mon, 19 Mar 2007 18:08:48 +0100
Jean-Marc Lasgouttes [EMAIL PROTECTED] wrote:

  Martin == Martin Vermeer [EMAIL PROTECTED] writes:
 
 Martin Yes indeed, why not ;-/ Getting dumber by the day.
 
 Martin New attached.
 
 Very good. If you think it is good enough and working for 1.4, you can
 apply it (since having egs working better in 1.4 would be valuable,
 from what I understand).

It's committed. Log: 

 Get ProvidesNatbib working correctly, esp. for egs.layout.

* insetcite: call getEngine()
* bufferparams: move getEngine() here, and let it sense the provides(natbib)
flag
* ControlBibtex, ControlCitation: correct getEngine() call
* biblio: remove old getEngine()

- Martin


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jean-Marc Lasgouttes
 Martin == Martin Vermeer [EMAIL PROTECTED] writes:

Martin On Mon, 19 Mar 2007 18:08:48 +0100
Martin Jean-Marc Lasgouttes [EMAIL PROTECTED] wrote:

  Martin == Martin Vermeer [EMAIL PROTECTED] writes:
 
Martin Yes indeed, why not ;-/ Getting dumber by the day.

Martin New attached.
  Very good. If you think it is good enough and working for 1.4, you
 can apply it (since having egs working better in 1.4 would be
 valuable, from what I understand).

Martin It's committed. Log:

Thanks.

You forgot status.14x, didn't you? And changelog too, of course.

JMarc



Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Tue, Mar 20, 2007 at 04:59:44PM +0100, Jean-Marc Lasgouttes wrote:
  Martin == Martin Vermeer [EMAIL PROTECTED] writes:

... 
 
 Martin It's committed. Log:
 
 Thanks.
 
 You forgot status.14x, didn't you? And changelog too, of course.

Oops... status.14x is in now.

Which changelog? They haven't been updated since somewhere october last year.

- Martin
 


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jürgen Spitzmüller
Martin Vermeer wrote:
 Which changelog? They haven't been updated since somewhere october last
 year.

Look twice:
http://www.lyx.org/trac/changeset/17480

Jürgen


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Tue, Mar 20, 2007 at 06:48:24PM +0100, Jürgen Spitzmüller wrote:
 Martin Vermeer wrote:
  Which changelog? They haven't been updated since somewhere october last
  year.
 
 Look twice:
 http://www.lyx.org/trac/changeset/17480

OK, done. Seems I hadn't updated _or_ committed in branch since 
last october ;-/

- Martin



Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Tue, Mar 20, 2007 at 10:24:52AM +0100, Jean-Marc Lasgouttes wrote:
  Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:
 
  Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:
 Jean-Marc The idea is to replace it with a std::setstring and
 Jean-Marc change LyXTextClass::provides() accordingly. The rest is
 Jean-Marc purely mechanical (replace enum by string). It could be
 Jean-Marc possible to simplify further the code, but it is not needed
 Jean-Marc now (and may be more dangerous)
 
 Jean-Marc This is how the basic (untested patch would look like).
 Jean-Marc layout2layout support is still missing of course (so that
 Jean-Marc this patch is useless as is). This trivial patch only works
 Jean-Marc for the features that could already be provided earlier.
 Jean-Marc Adding a Provides graphics will have no effect, for
 Jean-Marc example. It is tempting to redefine isRequired() to return
 Jean-Marc false when provides returns true, but we have to be a bit
 Jean-Marc more careful than that.
 
 Jean-Marc One solution would be to define a isNeeded() for this use
 Jean-Marc case, and still use isRequired in the few cases where this
 Jean-Marc makes sense.
 
 I forgot to add that I do not know how std::set works, so my code
 could be bogus (but at least it compiles :).

From what I remember it is valid... 

- Martin
 


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jean-Marc Lasgouttes
> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

Jean-Marc> The idea is to replace it with a std::set and
Jean-Marc> change LyXTextClass::provides() accordingly. The rest is
Jean-Marc> purely mechanical (replace enum by string). It could be
Jean-Marc> possible to simplify further the code, but it is not needed
Jean-Marc> now (and may be more dangerous)

This is how the basic (untested patch would look like). layout2layout
support is still missing of course (so that this patch is useless as
is). This trivial patch only works for the features that could already
be provided earlier. Adding a "Provides graphics" will have no effect,
for example. It is tempting to redefine isRequired() to return false
when provides returns true, but we have to be a bit more careful than
that.

One solution would be to define a isNeeded() for this use case, and
still use isRequired in the few cases where this makes sense.

JMarc

Index: src/LaTeXFeatures.C
===
--- src/LaTeXFeatures.C	(révision 17488)
+++ src/LaTeXFeatures.C	(copie de travail)
@@ -278,7 +278,7 @@ string const LaTeXFeatures::getPackages(
 	//
 
 	if (isRequired("amsmath")
-	&& !tclass.provides(LyXTextClass::amsmath)
+	&& !tclass.provides("amsmath")
 	&& params_.use_amsmath != BufferParams::package_off) {
 		packages << "\\usepackage{amsmath}\n";
 	}
@@ -306,7 +306,7 @@ string const LaTeXFeatures::getPackages(
 
 	// makeidx.sty
 	if (isRequired("makeidx")) {
-		if (!tclass.provides(LyXTextClass::makeidx))
+		if (!tclass.provides("makeidx"))
 			packages << "\\usepackage{makeidx}\n";
 		packages << "\\makeindex\n";
 	}
@@ -370,13 +370,13 @@ string const LaTeXFeatures::getPackages(
 		packages << "\\usepackage{esint}\n";
 
 	// url.sty
-	if (isRequired("url") && ! tclass.provides(LyXTextClass::url))
+	if (isRequired("url") && ! tclass.provides("url"))
 		packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
 			"  {\\newcommand{\\url}{\\texttt}}\n";
 
 	// float.sty
 	// natbib.sty
-	if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
+	if (isRequired("natbib") && ! tclass.provides("natbib")) {
 		packages << "\\usepackage[";
 		if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
 			packages << "numbers";
Index: src/buffer.C
===
--- src/buffer.C	(révision 17488)
+++ src/buffer.C	(copie de travail)
@@ -1195,7 +1195,7 @@ void Buffer::validate(LaTeXFeatures & fe
 
 	// AMS Style is at document level
 	if (params().use_amsmath == BufferParams::package_on
-	|| tclass.provides(LyXTextClass::amsmath))
+	|| tclass.provides("amsmath"))
 		features.require("amsmath");
 	if (params().use_esint == BufferParams::package_on)
 		features.require("esint");
Index: src/lyxtextclass.C
===
--- src/lyxtextclass.C	(révision 17488)
+++ src/lyxtextclass.C	(copie de travail)
@@ -113,7 +113,6 @@ LyXTextClass::LyXTextClass(string const 
 	defaultfont_ = LyXFont(LyXFont::ALL_SANE);
 	opt_fontsize_ = "10|11|12";
 	opt_pagestyle_ = "empty|plain|headings|fancy";
-	provides_ = nothing;
 	titletype_ = TITLE_COMMAND_AFTER;
 	titlename_ = "maketitle";
 	loaded_ = false;
@@ -158,10 +157,7 @@ enum TextClassTags {
 	TC_TOCDEPTH,
 	TC_CLASSOPTIONS,
 	TC_PREAMBLE,
-	TC_PROVIDESAMSMATH,
-	TC_PROVIDESNATBIB,
-	TC_PROVIDESMAKEIDX,
-	TC_PROVIDESURL,
+	TC_PROVIDES,
 	TC_LEFTMARGIN,
 	TC_RIGHTMARGIN,
 	TC_FLOAT,
@@ -199,10 +195,7 @@ bool LyXTextClass::read(FileName const &
 		{ "outputtype",  TC_OUTPUTTYPE },
 		{ "pagestyle",   TC_PAGESTYLE },
 		{ "preamble",TC_PREAMBLE },
-		{ "providesamsmath", TC_PROVIDESAMSMATH },
-		{ "providesmakeidx", TC_PROVIDESMAKEIDX },
-		{ "providesnatbib",  TC_PROVIDESNATBIB },
-		{ "providesurl", TC_PROVIDESURL },
+		{ "provides",TC_PROVIDES },
 		{ "rightmargin", TC_RIGHTMARGIN },
 		{ "secnumdepth", TC_SECNUMDEPTH },
 		{ "sides",   TC_SIDES },
@@ -383,24 +376,9 @@ bool LyXTextClass::read(FileName const &
 			preamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
 			break;
 
-		case TC_PROVIDESAMSMATH:
-			if (lexrc.next() && lexrc.getInteger())
-provides_ |= amsmath;
-			break;
-
-		case TC_PROVIDESNATBIB:
-			if (lexrc.next() && lexrc.getInteger())
-provides_ |= natbib;
-			break;
-
-		case TC_PROVIDESMAKEIDX:
-			if (lexrc.next() && lexrc.getInteger())
-provides_ |= makeidx;
-			break;
-
-		case TC_PROVIDESURL:
-			if (lexrc.next() && lexrc.getInteger())
-provides_ |= url;
+		case TC_PROVIDES:
+			if (lexrc.next())
+provides_.insert(lexrc.getString());
 			break;
 
 		case TC_LEFTMARGIN:	// left margin type
@@ -1067,9 +1045,9 @@ OutputType LyXTextClass::outputType() co
 }
 
 
-bool LyXTextClass::provides(LyXTextClass::Provides p) const
+bool LyXTextClass::provides(string const & p) const
 {
-	return provides_ & p;
+	

Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jean-Marc Lasgouttes
> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
Jean-Marc> The idea is to replace it with a std::set and
Jean-Marc> change LyXTextClass::provides() accordingly. The rest is
Jean-Marc> purely mechanical (replace enum by string). It could be
Jean-Marc> possible to simplify further the code, but it is not needed
Jean-Marc> now (and may be more dangerous)

Jean-Marc> This is how the basic (untested patch would look like).
Jean-Marc> layout2layout support is still missing of course (so that
Jean-Marc> this patch is useless as is). This trivial patch only works
Jean-Marc> for the features that could already be provided earlier.
Jean-Marc> Adding a "Provides graphics" will have no effect, for
Jean-Marc> example. It is tempting to redefine isRequired() to return
Jean-Marc> false when provides returns true, but we have to be a bit
Jean-Marc> more careful than that.

Jean-Marc> One solution would be to define a isNeeded() for this use
Jean-Marc> case, and still use isRequired in the few cases where this
Jean-Marc> makes sense.

I forgot to add that I do not know how std::set works, so my code
could be bogus (but at least it compiles :).

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Mon, 19 Mar 2007 18:08:48 +0100
Jean-Marc Lasgouttes <[EMAIL PROTECTED]> wrote:

> > "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> Martin> Yes indeed, why not ;-/ Getting dumber by the day.
> 
> Martin> New attached.
> 
> Very good. If you think it is good enough and working for 1.4, you can
> apply it (since having egs working better in 1.4 would be valuable,
> from what I understand).

It's committed. Log: 

 Get ProvidesNatbib working correctly, esp. for egs.layout.

* insetcite: call getEngine()
* bufferparams: move getEngine() here, and let it sense the provides(natbib)
flag
* ControlBibtex, ControlCitation: correct getEngine() call
* biblio: remove old getEngine()

- Martin


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jean-Marc Lasgouttes
> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

Martin> On Mon, 19 Mar 2007 18:08:48 +0100
Martin> Jean-Marc Lasgouttes <[EMAIL PROTECTED]> wrote:

>> > "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
>> 
Martin> Yes indeed, why not ;-/ Getting dumber by the day.
>>
Martin> New attached.
>>  Very good. If you think it is good enough and working for 1.4, you
>> can apply it (since having egs working better in 1.4 would be
>> valuable, from what I understand).

Martin> It's committed. Log:

Thanks.

You forgot status.14x, didn't you? And changelog too, of course.

JMarc



Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Tue, Mar 20, 2007 at 04:59:44PM +0100, Jean-Marc Lasgouttes wrote:
> > "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

... 
 
> Martin> It's committed. Log:
> 
> Thanks.
> 
> You forgot status.14x, didn't you? And changelog too, of course.

Oops... status.14x is in now.

Which changelog? They haven't been updated since somewhere october last year.

- Martin
 


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Jürgen Spitzmüller
Martin Vermeer wrote:
> Which changelog? They haven't been updated since somewhere october last
> year.

Look twice:
http://www.lyx.org/trac/changeset/17480

Jürgen


Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Tue, Mar 20, 2007 at 06:48:24PM +0100, Jürgen Spitzmüller wrote:
> Martin Vermeer wrote:
> > Which changelog? They haven't been updated since somewhere october last
> > year.
> 
> Look twice:
> http://www.lyx.org/trac/changeset/17480

OK, done. Seems I hadn't updated _or_ committed in branch since 
last october ;-/

- Martin



Re: Getting citep etc. to work for egs.cls

2007-03-20 Thread Martin Vermeer
On Tue, Mar 20, 2007 at 10:24:52AM +0100, Jean-Marc Lasgouttes wrote:
> > "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
> 
> > "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
> Jean-Marc> The idea is to replace it with a std::set and
> Jean-Marc> change LyXTextClass::provides() accordingly. The rest is
> Jean-Marc> purely mechanical (replace enum by string). It could be
> Jean-Marc> possible to simplify further the code, but it is not needed
> Jean-Marc> now (and may be more dangerous)
> 
> Jean-Marc> This is how the basic (untested patch would look like).
> Jean-Marc> layout2layout support is still missing of course (so that
> Jean-Marc> this patch is useless as is). This trivial patch only works
> Jean-Marc> for the features that could already be provided earlier.
> Jean-Marc> Adding a "Provides graphics" will have no effect, for
> Jean-Marc> example. It is tempting to redefine isRequired() to return
> Jean-Marc> false when provides returns true, but we have to be a bit
> Jean-Marc> more careful than that.
> 
> Jean-Marc> One solution would be to define a isNeeded() for this use
> Jean-Marc> case, and still use isRequired in the few cases where this
> Jean-Marc> makes sense.
> 
> I forgot to add that I do not know how std::set works, so my code
> could be bogus (but at least it compiles :).

>From what I remember it is valid... 

- Martin
 


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes

Why not use 
cite_engine = p.getEngine();
in the code below?

+   // FIXME the class should also provide 
+   // the numerical/ authoryear choce
+   if (p.getLyXTextClass().provides(LyXTextClass::natbib)
+   p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+   cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+   else
+   cite_engine = p.cite_engine;

Also, a trick could be to allow the value '2' for providenatbib, or
add a new ProvideNumericalNatbib tag.

JMarc



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
 Why not use 
 cite_engine = p.getEngine();
 in the code below?
 
 + // FIXME the class should also provide 
 + // the numerical/ authoryear choce
 + if (p.getLyXTextClass().provides(LyXTextClass::natbib)
 + p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
 + cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
 + else
 + cite_engine = p.cite_engine;

Yes indeed, why not ;-/ Getting dumber by the day.

New attached.

 Also, a trick could be to allow the value '2' for providenatbib, or
 add a new ProvideNumericalNatbib tag.

Or make it a string valued thing: No, Numerical, AuthorYear. More
legible. Have to sleep on that...

 JMarc

- Martin

Index: src/insets/insetcite.C
===
--- src/insets/insetcite.C	(revision 17353)
+++ src/insets/insetcite.C	(working copy)
@@ -335,7 +335,7 @@
 
 docstring const InsetCitation::getScreenLabel(Buffer const  buffer) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(buffer);
+	biblio::CiteEngine const engine = buffer.params().getEngine();
 	if (cache.params == params()  cache.engine == engine)
 		return cache.screen_label;
 
@@ -368,7 +368,7 @@
 	docstring str;
 
 	if (cache.params == params() 
-	cache.engine == biblio::getEngine(buffer))
+	cache.engine == buffer.params().getEngine())
 		str = cache.generated_label;
 	else
 		str = generateLabel(buffer);
@@ -424,7 +424,7 @@
 int InsetCitation::latex(Buffer const  buffer, odocstream  os,
  OutputParams const ) const
 {
-	biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+	biblio::CiteEngine cite_engine = buffer.params().getEngine();
 	// FIXME UNICODE
 	docstring const cite_str = from_utf8(
 		biblio::asValidLatexCommand(getCmdName(), cite_engine));
Index: src/bufferparams.C
===
--- src/bufferparams.C	(revision 17353)
+++ src/bufferparams.C	(working copy)
@@ -1482,4 +1482,15 @@
 	return *(language-encoding());
 }
 
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+	// FIXME the class should provide the numerical/
+	// authoryear choice
+	if (getLyXTextClass().provides(LyXTextClass::natbib)
+	 cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		return biblio::ENGINE_NATBIB_AUTHORYEAR;
+	return cite_engine;
+}
+
 } // namespace lyx
Index: src/bufferparams.h
===
--- src/bufferparams.h	(revision 17381)
+++ src/bufferparams.h	(working copy)
@@ -277,6 +277,8 @@
  int const  sfscale, int const  ttscale) const;
 	/// path of the current buffer
 	std::string filepath;
+	/// get the appropriate cite engine (natbib handling)
+	biblio::CiteEngine_enum getEngine() const;
 
 private:
 	/** Use the Pimpl idiom to hide those member variables that would otherwise
Index: lib/layouts/egs.layout
===
--- lib/layouts/egs.layout	(revision 17353)
+++ lib/layouts/egs.layout	(working copy)
@@ -12,6 +12,7 @@
 Columns 2
 Sides   1
 PageStyle   Plain
+ProvidesNatbib  1
 
 
 Style Standard
Index: src/frontends/controllers/ControlBibtex.C
===
--- src/frontends/controllers/ControlBibtex.C	(revision 17353)
+++ src/frontends/controllers/ControlBibtex.C	(working copy)
@@ -134,7 +134,7 @@
 	// the different bibtex packages have (and need) their
 	// own plain stylefiles
 	biblio::CiteEngine_enum const  engine =
-		biblio::getEngine(kernel().buffer());
+		kernel().buffer().params().getEngine();
 	docstring defaultstyle;
 	switch (engine) {
 	case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===
--- src/frontends/controllers/ControlCitation.C	(revision 17353)
+++ src/frontends/controllers/ControlCitation.C	(working copy)
@@ -39,7 +39,7 @@
 	vectorpairstring, docstring  blist;
 	kernel().buffer().fillWithBibKeys(blist);
 
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
 
 	bool use_styles = engine != biblio::ENGINE_BASIC;
 
@@ -79,13 +79,13 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-	return biblio::getEngine(kernel().buffer());
+	return kernel().buffer().params().getEngine();
 }
 
 
 vectordocstring const ControlCitation::getCiteStrings(string const  key) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
 	vectorbiblio::CiteStyle const cs = biblio::getCiteStyles(engine);
 
 	if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
Index: src/frontends/controllers/biblio.C

Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes
 Martin == Martin Vermeer [EMAIL PROTECTED] writes:

Martin Yes indeed, why not ;-/ Getting dumber by the day.

Martin New attached.

Very good. If you think it is good enough and working for 1.4, you can
apply it (since having egs working better in 1.4 would be valuable,
from what I understand).

 Also, a trick could be to allow the value '2' for providenatbib,
 or add a new ProvideNumericalNatbib tag.

Martin Or make it a string valued thing: No, Numerical,
Martin AuthorYear. More legible. Have to sleep on that...

Or have ProvidesNatbib and ProvidesNumNatbib (but the two should be
exclusive). In the future, the idea is to move to something like
  Provides foo
where foo is an arbitrary feature. It would have been good to do
that before 1.5, actually.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Andre Poenitz
On Mon, Mar 19, 2007 at 06:42:53PM +0200, Martin Vermeer wrote:
 On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
  Why not use 
  cite_engine = p.getEngine();
  in the code below?
  
  +   // FIXME the class should also provide 
  +   // the numerical/ authoryear choce
  +   if (p.getLyXTextClass().provides(LyXTextClass::natbib)
  +   p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
  +   cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
  +   else
  +   cite_engine = p.cite_engine;
 
 Yes indeed, why not ;-/ Getting dumber by the day.
 
 New attached.
 
  Also, a trick could be to allow the value '2' for providenatbib, or
  add a new ProvideNumericalNatbib tag.
 
 Or make it a string valued thing: No, Numerical, AuthorYear. More
 legible. Have to sleep on that...

An enum perhaps?

Andre', usually hating enums.


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread José Matos
On Monday 19 March 2007 5:08:48 pm Jean-Marc Lasgouttes wrote:

 Or have ProvidesNatbib and ProvidesNumNatbib (but the two should be
 exclusive). In the future, the idea is to move to something like
   Provides foo
 where foo is an arbitrary feature. It would have been good to do
 that before 1.5, actually.

  What needs to be done?

 JMarc

-- 
José Abílio


RE : Getting citep etc. to work for egs.cls

2007-03-19 Thread Leuven, E.
José Matos wrote:
 What needs to be done?

release 1.5 asap...


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread José Matos
On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:
 José Matos wrote:
  What needs to be done?

 release 1.5 asap...

  AS long as critical bugs are fixed I don't have any problem with that. :-)

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, Mar 19, 2007 at 06:14:25PM +0100, Andre Poenitz wrote:
 On Mon, Mar 19, 2007 at 06:42:53PM +0200, Martin Vermeer wrote:
  On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
   Why not use 
   cite_engine = p.getEngine();
   in the code below?
   
   + // FIXME the class should also provide 
   + // the numerical/ authoryear choce
   + if (p.getLyXTextClass().provides(LyXTextClass::natbib)
   + p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
   + cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
   + else
   + cite_engine = p.cite_engine;
  
  Yes indeed, why not ;-/ Getting dumber by the day.
  
  New attached.
  
   Also, a trick could be to allow the value '2' for providenatbib, or
   add a new ProvideNumericalNatbib tag.
  
  Or make it a string valued thing: No, Numerical, AuthorYear. More
  legible. Have to sleep on that...
 
 An enum perhaps?
 
 Andre', usually hating enums.

That's actually what I thought. A string in the file, converted to an enum on 
imput (like we have already so many of).

However, I think this is not for now. Certainly not for 1.4, where I think a 
version of the current patch (which I still have to create) should go in ASAP.

- Martin



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, Mar 19, 2007 at 06:08:48PM +0100, Jean-Marc Lasgouttes wrote:
  Martin == Martin Vermeer [EMAIL PROTECTED] writes:
 
 Martin Yes indeed, why not ;-/ Getting dumber by the day.
 
 Martin New attached.
 
 Very good. If you think it is good enough and working for 1.4, you can
 apply it (since having egs working better in 1.4 would be valuable,
 from what I understand).

Here is the version for 1.4, tried and works as advertised for me. 
I will apply this tomorrow if nobody spots a problem.

- Martin
 
Index: src/insets/insetcite.C
===
--- src/insets/insetcite.C  (revision 15477)
+++ src/insets/insetcite.C  (working copy)
@@ -304,7 +304,7 @@
string const after  = getOptions();
 
string label;
-   biblio::CiteEngine const engine = buffer.params().cite_engine;
+   biblio::CiteEngine const engine = buffer.params().getEngine();
if (engine != biblio::ENGINE_BASIC) {
label = getNatbibLabel(buffer, getCmdName(), getContents(),
   before, after, engine);
@@ -321,7 +321,7 @@
 
 string const InsetCitation::getScreenLabel(Buffer const  buffer) const
 {
-   biblio::CiteEngine const engine = biblio::getEngine(buffer);
+   biblio::CiteEngine const engine = buffer.params().getEngine();
if (cache.params == params()  cache.engine == engine)
return cache.screen_label;
 
@@ -351,7 +351,7 @@
 int InsetCitation::plaintext(Buffer const  buffer, ostream  os, OutputParams 
const ) const
 {
if (cache.params == params() 
-   cache.engine == biblio::getEngine(buffer))
+   cache.engine == buffer.params().getEngine())
os  cache.generated_label;
else
os  generateLabel(buffer);
Index: src/bufferparams.C
===
--- src/bufferparams.C  (revision 15477)
+++ src/bufferparams.C  (working copy)
@@ -1253,3 +1253,21 @@
tmp = string(\\usepackage[) + lang_opts + ]{babel};
return tmp;
 }
+
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+   // FIXME the class should provide the numerical/
+   // authoryear choice
+   lyxerr  getEngine  endl;
+   if (getLyXTextClass().provides(LyXTextClass::natbib)
+   cite_engine != biblio::ENGINE_NATBIB_NUMERICAL) {
+   lyxerr  authoryear  endl;
+   return biblio::ENGINE_NATBIB_AUTHORYEAR;
+   }
+   lyxerr  cite_engine=  cite_engine  endl;
+   return cite_engine;
+}
+
+
+
Index: src/bufferparams.h
===
--- src/bufferparams.h  (revision 15477)
+++ src/bufferparams.h  (working copy)
@@ -230,7 +230,10 @@
std::string const paperSizeName() const;
///
std::string const babelCall(std::string const  lang_opts) const;
+   /// get the appropriate cite engine (natbib handling)
+   lyx::biblio::CiteEngine_enum getEngine() const;
 
+
 private:
/** Use the Pimpl idiom to hide those member variables that would 
otherwise
 *  drag in other header files.
Index: lib/layouts/egs.layout
===
--- lib/layouts/egs.layout  (revision 15216)
+++ lib/layouts/egs.layout  (working copy)
@@ -12,6 +12,7 @@
 Columns 2
 Sides   1
 PageStyle   Plain
+ProvidesNatbib  1
 
 
 Style Standard
Index: src/frontends/controllers/ControlBibtex.C
===
--- src/frontends/controllers/ControlBibtex.C   (revision 15477)
+++ src/frontends/controllers/ControlBibtex.C   (working copy)
@@ -133,7 +133,7 @@
// the different bibtex packages have (and need) their
// own plain stylefiles
biblio::CiteEngine_enum const  engine =
-   biblio::getEngine(kernel().buffer());
+   kernel().buffer().params().getEngine();
string defaultstyle;
switch (engine) {
case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===
--- src/frontends/controllers/ControlCitation.C (revision 15477)
+++ src/frontends/controllers/ControlCitation.C (working copy)
@@ -39,7 +39,7 @@
vectorpairstring, string  blist;
kernel().buffer().fillWithBibKeys(blist);
 
-   biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+   biblio::CiteEngine const engine = 
kernel().buffer().params().getEngine();
 
bool use_styles = engine != biblio::ENGINE_BASIC;
 
@@ -79,7 +79,7 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-   return biblio::getEngine(kernel().buffer());
+   return kernel().buffer().params().getEngine();
 }
 
 
@@ -87,7 +87,7 @@
 {
vectorstring styles;
 

Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes
 José == José Matos [EMAIL PROTECTED] writes:

José On Monday 19 March 2007 5:08:48 pm Jean-Marc Lasgouttes wrote:
  Or have ProvidesNatbib and ProvidesNumNatbib (but the two should
 be exclusive). In the future, the idea is to move to something like
 Provides foo where foo is an arbitrary feature. It would have
 been good to do that before 1.5, actually.

José   What needs to be done?

Currently we have an enum in lyxtextclass.h:

/// Packages that are already loaded by the class
enum Provides {
///
nothing = 0,
///
amsmath = 1,
///
makeidx = 2,
///
url = 4,
///
natbib = 8
};

The idea is to replace it with a std::setstring and change
LyXTextClass::provides() accordingly. The rest is purely mechanical
(replace enum by string). It could be possible to simplify further the
code, but it is not needed now (and may be more dangerous)

Then layout2layout will need to update ProvidesUrl 1 to Provides
url.

The result will be the we can specify for any feature that LyX knows
about that there is no need to bother.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes
 Martin == Martin Vermeer [EMAIL PROTECTED] writes:

Martin Here is the version for 1.4, tried and works as advertised for
Martin me. I will apply this tomorrow if nobody spots a problem.

It is OK, but please remove the debug commands in getEngine().

JMarc



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Edwin Leuven

José Matos wrote:

On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:

José Matos wrote:

What needs to be done?

release 1.5 asap...


  AS long as critical bugs are fixed I don't have any problem with that. :-)


bernhard patch fixes one... shall i apply it?


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, Mar 19, 2007 at 11:03:18PM +0100, Jean-Marc Lasgouttes wrote:
  José == José Matos [EMAIL PROTECTED] writes:
 
 José On Monday 19 March 2007 5:08:48 pm Jean-Marc Lasgouttes wrote:
   Or have ProvidesNatbib and ProvidesNumNatbib (but the two should
  be exclusive). In the future, the idea is to move to something like
  Provides foo where foo is an arbitrary feature. It would have
  been good to do that before 1.5, actually.
 
 José   What needs to be done?
 
 Currently we have an enum in lyxtextclass.h:
 
   /// Packages that are already loaded by the class
   enum Provides {
   ///
   nothing = 0,
   ///
   amsmath = 1,
   ///
   makeidx = 2,
   ///
   url = 4,
   ///
   natbib = 8
   };
 
 The idea is to replace it with a std::setstring and change
 LyXTextClass::provides() accordingly. The rest is purely mechanical
 (replace enum by string). It could be possible to simplify further the
 code, but it is not needed now (and may be more dangerous)
 
 Then layout2layout will need to update ProvidesUrl 1 to Provides
 url.
 
 The result will be the we can specify for any feature that LyX knows
 about that there is no need to bother.

+1

Very good idea. And we need Provides Babel at least for EGS.

- Martin



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes

Why not use 
cite_engine = p.getEngine();
in the code below?

+   // FIXME the class should also provide 
+   // the numerical/ authoryear choce
+   if (p.getLyXTextClass().provides(LyXTextClass::natbib)
+  && p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+   cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+   else
+   cite_engine = p.cite_engine;

Also, a "trick" could be to allow the value '2' for providenatbib, or
add a new ProvideNumericalNatbib tag.

JMarc



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
> Why not use 
> cite_engine = p.getEngine();
> in the code below?
> 
> + // FIXME the class should also provide 
> + // the numerical/ authoryear choce
> + if (p.getLyXTextClass().provides(LyXTextClass::natbib)
> +&& p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
> + cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
> + else
> + cite_engine = p.cite_engine;

Yes indeed, why not ;-/ Getting dumber by the day.

New attached.

> Also, a "trick" could be to allow the value '2' for providenatbib, or
> add a new ProvideNumericalNatbib tag.

Or make it a string valued thing: "No", "Numerical", "AuthorYear". More
legible. Have to sleep on that...

> JMarc

- Martin

Index: src/insets/insetcite.C
===
--- src/insets/insetcite.C	(revision 17353)
+++ src/insets/insetcite.C	(working copy)
@@ -335,7 +335,7 @@
 
 docstring const InsetCitation::getScreenLabel(Buffer const & buffer) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(buffer);
+	biblio::CiteEngine const engine = buffer.params().getEngine();
 	if (cache.params == params() && cache.engine == engine)
 		return cache.screen_label;
 
@@ -368,7 +368,7 @@
 	docstring str;
 
 	if (cache.params == params() &&
-	cache.engine == biblio::getEngine(buffer))
+	cache.engine == buffer.params().getEngine())
 		str = cache.generated_label;
 	else
 		str = generateLabel(buffer);
@@ -424,7 +424,7 @@
 int InsetCitation::latex(Buffer const & buffer, odocstream & os,
  OutputParams const &) const
 {
-	biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+	biblio::CiteEngine cite_engine = buffer.params().getEngine();
 	// FIXME UNICODE
 	docstring const cite_str = from_utf8(
 		biblio::asValidLatexCommand(getCmdName(), cite_engine));
Index: src/bufferparams.C
===
--- src/bufferparams.C	(revision 17353)
+++ src/bufferparams.C	(working copy)
@@ -1482,4 +1482,15 @@
 	return *(language->encoding());
 }
 
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+	// FIXME the class should provide the numerical/
+	// authoryear choice
+	if (getLyXTextClass().provides(LyXTextClass::natbib)
+	&& cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		return biblio::ENGINE_NATBIB_AUTHORYEAR;
+	return cite_engine;
+}
+
 } // namespace lyx
Index: src/bufferparams.h
===
--- src/bufferparams.h	(revision 17381)
+++ src/bufferparams.h	(working copy)
@@ -277,6 +277,8 @@
  int const & sfscale, int const & ttscale) const;
 	/// path of the current buffer
 	std::string filepath;
+	/// get the appropriate cite engine (natbib handling)
+	biblio::CiteEngine_enum getEngine() const;
 
 private:
 	/** Use the Pimpl idiom to hide those member variables that would otherwise
Index: lib/layouts/egs.layout
===
--- lib/layouts/egs.layout	(revision 17353)
+++ lib/layouts/egs.layout	(working copy)
@@ -12,6 +12,7 @@
 Columns 2
 Sides   1
 PageStyle   Plain
+ProvidesNatbib  1
 
 
 Style Standard
Index: src/frontends/controllers/ControlBibtex.C
===
--- src/frontends/controllers/ControlBibtex.C	(revision 17353)
+++ src/frontends/controllers/ControlBibtex.C	(working copy)
@@ -134,7 +134,7 @@
 	// the different bibtex packages have (and need) their
 	// own "plain" stylefiles
 	biblio::CiteEngine_enum const & engine =
-		biblio::getEngine(kernel().buffer());
+		kernel().buffer().params().getEngine();
 	docstring defaultstyle;
 	switch (engine) {
 	case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===
--- src/frontends/controllers/ControlCitation.C	(revision 17353)
+++ src/frontends/controllers/ControlCitation.C	(working copy)
@@ -39,7 +39,7 @@
 	vector > blist;
 	kernel().buffer().fillWithBibKeys(blist);
 
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
 
 	bool use_styles = engine != biblio::ENGINE_BASIC;
 
@@ -79,13 +79,13 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-	return biblio::getEngine(kernel().buffer());
+	return kernel().buffer().params().getEngine();
 }
 
 
 vector const ControlCitation::getCiteStrings(string const & key) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
 	vector const cs = biblio::getCiteStyles(engine);
 
 	if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
Index: 

Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes
> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

Martin> Yes indeed, why not ;-/ Getting dumber by the day.

Martin> New attached.

Very good. If you think it is good enough and working for 1.4, you can
apply it (since having egs working better in 1.4 would be valuable,
from what I understand).

>> Also, a "trick" could be to allow the value '2' for providenatbib,
>> or add a new ProvideNumericalNatbib tag.

Martin> Or make it a string valued thing: "No", "Numerical",
Martin> "AuthorYear". More legible. Have to sleep on that...

Or have ProvidesNatbib and ProvidesNumNatbib (but the two should be
exclusive). In the future, the idea is to move to something like
  Provides "foo"
where "foo" is an arbitrary feature. It would have been good to do
that before 1.5, actually.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Andre Poenitz
On Mon, Mar 19, 2007 at 06:42:53PM +0200, Martin Vermeer wrote:
> On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
> > Why not use 
> > cite_engine = p.getEngine();
> > in the code below?
> > 
> > +   // FIXME the class should also provide 
> > +   // the numerical/ authoryear choce
> > +   if (p.getLyXTextClass().provides(LyXTextClass::natbib)
> > +  && p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
> > +   cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
> > +   else
> > +   cite_engine = p.cite_engine;
> 
> Yes indeed, why not ;-/ Getting dumber by the day.
> 
> New attached.
> 
> > Also, a "trick" could be to allow the value '2' for providenatbib, or
> > add a new ProvideNumericalNatbib tag.
> 
> Or make it a string valued thing: "No", "Numerical", "AuthorYear". More
> legible. Have to sleep on that...

An enum perhaps?

Andre', usually hating enums.


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread José Matos
On Monday 19 March 2007 5:08:48 pm Jean-Marc Lasgouttes wrote:
>
> Or have ProvidesNatbib and ProvidesNumNatbib (but the two should be
> exclusive). In the future, the idea is to move to something like
>   Provides "foo"
> where "foo" is an arbitrary feature. It would have been good to do
> that before 1.5, actually.

  What needs to be done?

> JMarc

-- 
José Abílio


RE : Getting citep etc. to work for egs.cls

2007-03-19 Thread Leuven, E.
José Matos wrote:
> What needs to be done?

release 1.5 asap...


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread José Matos
On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:
> José Matos wrote:
> > What needs to be done?
>
> release 1.5 asap...

  AS long as critical bugs are fixed I don't have any problem with that. :-)

-- 
José Abílio


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, Mar 19, 2007 at 06:14:25PM +0100, Andre Poenitz wrote:
> On Mon, Mar 19, 2007 at 06:42:53PM +0200, Martin Vermeer wrote:
> > On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
> > > Why not use 
> > > cite_engine = p.getEngine();
> > > in the code below?
> > > 
> > > + // FIXME the class should also provide 
> > > + // the numerical/ authoryear choce
> > > + if (p.getLyXTextClass().provides(LyXTextClass::natbib)
> > > +&& p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
> > > + cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
> > > + else
> > > + cite_engine = p.cite_engine;
> > 
> > Yes indeed, why not ;-/ Getting dumber by the day.
> > 
> > New attached.
> > 
> > > Also, a "trick" could be to allow the value '2' for providenatbib, or
> > > add a new ProvideNumericalNatbib tag.
> > 
> > Or make it a string valued thing: "No", "Numerical", "AuthorYear". More
> > legible. Have to sleep on that...
> 
> An enum perhaps?
> 
> Andre', usually hating enums.

That's actually what I thought. A string in the file, converted to an enum on 
imput (like we have already so many of).

However, I think this is not for now. Certainly not for 1.4, where I think a 
version of the current patch (which I still have to create) should go in ASAP.

- Martin



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, Mar 19, 2007 at 06:08:48PM +0100, Jean-Marc Lasgouttes wrote:
> > "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> Martin> Yes indeed, why not ;-/ Getting dumber by the day.
> 
> Martin> New attached.
> 
> Very good. If you think it is good enough and working for 1.4, you can
> apply it (since having egs working better in 1.4 would be valuable,
> from what I understand).

Here is the version for 1.4, tried and works as advertised for me. 
I will apply this tomorrow if nobody spots a problem.

- Martin
 
Index: src/insets/insetcite.C
===
--- src/insets/insetcite.C  (revision 15477)
+++ src/insets/insetcite.C  (working copy)
@@ -304,7 +304,7 @@
string const after  = getOptions();
 
string label;
-   biblio::CiteEngine const engine = buffer.params().cite_engine;
+   biblio::CiteEngine const engine = buffer.params().getEngine();
if (engine != biblio::ENGINE_BASIC) {
label = getNatbibLabel(buffer, getCmdName(), getContents(),
   before, after, engine);
@@ -321,7 +321,7 @@
 
 string const InsetCitation::getScreenLabel(Buffer const & buffer) const
 {
-   biblio::CiteEngine const engine = biblio::getEngine(buffer);
+   biblio::CiteEngine const engine = buffer.params().getEngine();
if (cache.params == params() && cache.engine == engine)
return cache.screen_label;
 
@@ -351,7 +351,7 @@
 int InsetCitation::plaintext(Buffer const & buffer, ostream & os, OutputParams 
const &) const
 {
if (cache.params == params() &&
-   cache.engine == biblio::getEngine(buffer))
+   cache.engine == buffer.params().getEngine())
os << cache.generated_label;
else
os << generateLabel(buffer);
Index: src/bufferparams.C
===
--- src/bufferparams.C  (revision 15477)
+++ src/bufferparams.C  (working copy)
@@ -1253,3 +1253,21 @@
tmp = string("\\usepackage[") + lang_opts + "]{babel}";
return tmp;
 }
+
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+   // FIXME the class should provide the numerical/
+   // authoryear choice
+   lyxerr << "getEngine" << endl;
+   if (getLyXTextClass().provides(LyXTextClass::natbib)
+  && cite_engine != biblio::ENGINE_NATBIB_NUMERICAL) {
+   lyxerr << "authoryear" << endl;
+   return biblio::ENGINE_NATBIB_AUTHORYEAR;
+   }
+   lyxerr << "cite_engine=" << cite_engine << endl;
+   return cite_engine;
+}
+
+
+
Index: src/bufferparams.h
===
--- src/bufferparams.h  (revision 15477)
+++ src/bufferparams.h  (working copy)
@@ -230,7 +230,10 @@
std::string const paperSizeName() const;
///
std::string const babelCall(std::string const & lang_opts) const;
+   /// get the appropriate cite engine (natbib handling)
+   lyx::biblio::CiteEngine_enum getEngine() const;
 
+
 private:
/** Use the Pimpl idiom to hide those member variables that would 
otherwise
 *  drag in other header files.
Index: lib/layouts/egs.layout
===
--- lib/layouts/egs.layout  (revision 15216)
+++ lib/layouts/egs.layout  (working copy)
@@ -12,6 +12,7 @@
 Columns 2
 Sides   1
 PageStyle   Plain
+ProvidesNatbib  1
 
 
 Style Standard
Index: src/frontends/controllers/ControlBibtex.C
===
--- src/frontends/controllers/ControlBibtex.C   (revision 15477)
+++ src/frontends/controllers/ControlBibtex.C   (working copy)
@@ -133,7 +133,7 @@
// the different bibtex packages have (and need) their
// own "plain" stylefiles
biblio::CiteEngine_enum const & engine =
-   biblio::getEngine(kernel().buffer());
+   kernel().buffer().params().getEngine();
string defaultstyle;
switch (engine) {
case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===
--- src/frontends/controllers/ControlCitation.C (revision 15477)
+++ src/frontends/controllers/ControlCitation.C (working copy)
@@ -39,7 +39,7 @@
vector > blist;
kernel().buffer().fillWithBibKeys(blist);
 
-   biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+   biblio::CiteEngine const engine = 
kernel().buffer().params().getEngine();
 
bool use_styles = engine != biblio::ENGINE_BASIC;
 
@@ -79,7 +79,7 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-   return biblio::getEngine(kernel().buffer());
+   return 

Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes
> "José" == José Matos <[EMAIL PROTECTED]> writes:

José> On Monday 19 March 2007 5:08:48 pm Jean-Marc Lasgouttes wrote:
>>  Or have ProvidesNatbib and ProvidesNumNatbib (but the two should
>> be exclusive). In the future, the idea is to move to something like
>> Provides "foo" where "foo" is an arbitrary feature. It would have
>> been good to do that before 1.5, actually.

José>   What needs to be done?

Currently we have an enum in lyxtextclass.h:

/// Packages that are already loaded by the class
enum Provides {
///
nothing = 0,
///
amsmath = 1,
///
makeidx = 2,
///
url = 4,
///
natbib = 8
};

The idea is to replace it with a std::set and change
LyXTextClass::provides() accordingly. The rest is purely mechanical
(replace enum by string). It could be possible to simplify further the
code, but it is not needed now (and may be more dangerous)

Then layout2layout will need to update "ProvidesUrl 1" to "Provides
url".

The result will be the we can specify for any feature that LyX knows
about that there is no need to bother.

JMarc


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Jean-Marc Lasgouttes
> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:

Martin> Here is the version for 1.4, tried and works as advertised for
Martin> me. I will apply this tomorrow if nobody spots a problem.

It is OK, but please remove the debug commands in getEngine().

JMarc



Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Edwin Leuven

José Matos wrote:

On Monday 19 March 2007 6:02:18 pm Leuven, E. wrote:

José Matos wrote:

What needs to be done?

release 1.5 asap...


  AS long as critical bugs are fixed I don't have any problem with that. :-)


bernhard patch fixes one... shall i apply it?


Re: Getting citep etc. to work for egs.cls

2007-03-19 Thread Martin Vermeer
On Mon, Mar 19, 2007 at 11:03:18PM +0100, Jean-Marc Lasgouttes wrote:
> > "José" == José Matos <[EMAIL PROTECTED]> writes:
> 
> José> On Monday 19 March 2007 5:08:48 pm Jean-Marc Lasgouttes wrote:
> >>  Or have ProvidesNatbib and ProvidesNumNatbib (but the two should
> >> be exclusive). In the future, the idea is to move to something like
> >> Provides "foo" where "foo" is an arbitrary feature. It would have
> >> been good to do that before 1.5, actually.
> 
> José>   What needs to be done?
> 
> Currently we have an enum in lyxtextclass.h:
> 
>   /// Packages that are already loaded by the class
>   enum Provides {
>   ///
>   nothing = 0,
>   ///
>   amsmath = 1,
>   ///
>   makeidx = 2,
>   ///
>   url = 4,
>   ///
>   natbib = 8
>   };
> 
> The idea is to replace it with a std::set and change
> LyXTextClass::provides() accordingly. The rest is purely mechanical
> (replace enum by string). It could be possible to simplify further the
> code, but it is not needed now (and may be more dangerous)
> 
> Then layout2layout will need to update "ProvidesUrl 1" to "Provides
> url".
> 
> The result will be the we can specify for any feature that LyX knows
> about that there is no need to bother.

+1

Very good idea. And we need "Provides Babel" at least for EGS.

- Martin



Re: Getting citep etc. to work for egs.cls

2007-03-18 Thread Martin Vermeer
On Thu, Mar 01, 2007 at 01:27:17PM +0100, Juergen Spitzmueller wrote:
 Martin Vermeer wrote:
 
  Yes, indeed. Still, the question remains, is this sensible.
 
 No. Numerical needs the styles as well, so it should be supported likewise.
 
 Jürgen

Attached an updated version of this patch, so it is not forgotten.

I added a pair of FIXMEs to remind that it is the document class that
knows whether we have a numerical or author-year ciation style, and
ideally LyX should be told this through a layout file option.

Were there any other issues with this? I would like to check this in, as
it would gain us one user who might become a contributor.

- Martin 
Index: src/insets/insetcite.C
===
--- src/insets/insetcite.C	(revision 17353)
+++ src/insets/insetcite.C	(working copy)
@@ -335,7 +335,7 @@
 
 docstring const InsetCitation::getScreenLabel(Buffer const  buffer) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(buffer);
+	biblio::CiteEngine const engine = buffer.params().getEngine();
 	if (cache.params == params()  cache.engine == engine)
 		return cache.screen_label;
 
@@ -368,7 +368,7 @@
 	docstring str;
 
 	if (cache.params == params() 
-	cache.engine == biblio::getEngine(buffer))
+	cache.engine == buffer.params().getEngine())
 		str = cache.generated_label;
 	else
 		str = generateLabel(buffer);
@@ -424,7 +424,15 @@
 int InsetCitation::latex(Buffer const  buffer, odocstream  os,
  OutputParams const ) const
 {
-	biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+	BufferParams const  p = buffer.params();
+	biblio::CiteEngine cite_engine;
+	// FIXME the class should also provide 
+	// the numerical/ authoryear choce
+	if (p.getLyXTextClass().provides(LyXTextClass::natbib)
+	p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+	else	
+		cite_engine = p.cite_engine;
 	// FIXME UNICODE
 	docstring const cite_str = from_utf8(
 		biblio::asValidLatexCommand(getCmdName(), cite_engine));
Index: src/bufferparams.C
===
--- src/bufferparams.C	(revision 17353)
+++ src/bufferparams.C	(working copy)
@@ -1482,4 +1482,15 @@
 	return *(language-encoding());
 }
 
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+	// FIXME the class should provide the numerical/
+	// authoryear choice
+	if (getLyXTextClass().provides(LyXTextClass::natbib)
+	 cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		return biblio::ENGINE_NATBIB_AUTHORYEAR;
+	return cite_engine;
+}
+
 } // namespace lyx
Index: src/bufferparams.h
===
--- src/bufferparams.h	(revision 17381)
+++ src/bufferparams.h	(working copy)
@@ -277,6 +277,8 @@
  int const  sfscale, int const  ttscale) const;
 	/// path of the current buffer
 	std::string filepath;
+	/// get the appropriate cite engine (natbib handling)
+	biblio::CiteEngine_enum getEngine() const;
 
 private:
 	/** Use the Pimpl idiom to hide those member variables that would otherwise
Index: lib/layouts/egs.layout
===
--- lib/layouts/egs.layout	(revision 17353)
+++ lib/layouts/egs.layout	(working copy)
@@ -12,6 +12,7 @@
 Columns 2
 Sides   1
 PageStyle   Plain
+ProvidesNatbib  1
 
 
 Style Standard
Index: src/frontends/controllers/ControlBibtex.C
===
--- src/frontends/controllers/ControlBibtex.C	(revision 17353)
+++ src/frontends/controllers/ControlBibtex.C	(working copy)
@@ -134,7 +134,7 @@
 	// the different bibtex packages have (and need) their
 	// own plain stylefiles
 	biblio::CiteEngine_enum const  engine =
-		biblio::getEngine(kernel().buffer());
+		kernel().buffer().params().getEngine();
 	docstring defaultstyle;
 	switch (engine) {
 	case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===
--- src/frontends/controllers/ControlCitation.C	(revision 17353)
+++ src/frontends/controllers/ControlCitation.C	(working copy)
@@ -39,7 +39,7 @@
 	vectorpairstring, docstring  blist;
 	kernel().buffer().fillWithBibKeys(blist);
 
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
 
 	bool use_styles = engine != biblio::ENGINE_BASIC;
 
@@ -79,13 +79,13 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-	return biblio::getEngine(kernel().buffer());
+	return kernel().buffer().params().getEngine();
 }
 
 
 vectordocstring const ControlCitation::getCiteStrings(string const  key) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = 

Re: Getting citep etc. to work for egs.cls

2007-03-18 Thread Martin Vermeer
On Thu, Mar 01, 2007 at 01:27:17PM +0100, Juergen Spitzmueller wrote:
> Martin Vermeer wrote:
> 
> > Yes, indeed. Still, the question remains, is this sensible.
> 
> No. Numerical needs the styles as well, so it should be supported likewise.
> 
> Jürgen

Attached an updated version of this patch, so it is not forgotten.

I added a pair of FIXMEs to remind that it is the document class that
"knows" whether we have a numerical or author-year ciation style, and
ideally LyX should be told this through a layout file option.

Were there any other issues with this? I would like to check this in, as
it would gain us one user who might become a contributor.

- Martin 
Index: src/insets/insetcite.C
===
--- src/insets/insetcite.C	(revision 17353)
+++ src/insets/insetcite.C	(working copy)
@@ -335,7 +335,7 @@
 
 docstring const InsetCitation::getScreenLabel(Buffer const & buffer) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(buffer);
+	biblio::CiteEngine const engine = buffer.params().getEngine();
 	if (cache.params == params() && cache.engine == engine)
 		return cache.screen_label;
 
@@ -368,7 +368,7 @@
 	docstring str;
 
 	if (cache.params == params() &&
-	cache.engine == biblio::getEngine(buffer))
+	cache.engine == buffer.params().getEngine())
 		str = cache.generated_label;
 	else
 		str = generateLabel(buffer);
@@ -424,7 +424,15 @@
 int InsetCitation::latex(Buffer const & buffer, odocstream & os,
  OutputParams const &) const
 {
-	biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+	BufferParams const & p = buffer.params();
+	biblio::CiteEngine cite_engine;
+	// FIXME the class should also provide 
+	// the numerical/ authoryear choce
+	if (p.getLyXTextClass().provides(LyXTextClass::natbib)
+	   && p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+	else	
+		cite_engine = p.cite_engine;
 	// FIXME UNICODE
 	docstring const cite_str = from_utf8(
 		biblio::asValidLatexCommand(getCmdName(), cite_engine));
Index: src/bufferparams.C
===
--- src/bufferparams.C	(revision 17353)
+++ src/bufferparams.C	(working copy)
@@ -1482,4 +1482,15 @@
 	return *(language->encoding());
 }
 
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+	// FIXME the class should provide the numerical/
+	// authoryear choice
+	if (getLyXTextClass().provides(LyXTextClass::natbib)
+	&& cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		return biblio::ENGINE_NATBIB_AUTHORYEAR;
+	return cite_engine;
+}
+
 } // namespace lyx
Index: src/bufferparams.h
===
--- src/bufferparams.h	(revision 17381)
+++ src/bufferparams.h	(working copy)
@@ -277,6 +277,8 @@
  int const & sfscale, int const & ttscale) const;
 	/// path of the current buffer
 	std::string filepath;
+	/// get the appropriate cite engine (natbib handling)
+	biblio::CiteEngine_enum getEngine() const;
 
 private:
 	/** Use the Pimpl idiom to hide those member variables that would otherwise
Index: lib/layouts/egs.layout
===
--- lib/layouts/egs.layout	(revision 17353)
+++ lib/layouts/egs.layout	(working copy)
@@ -12,6 +12,7 @@
 Columns 2
 Sides   1
 PageStyle   Plain
+ProvidesNatbib  1
 
 
 Style Standard
Index: src/frontends/controllers/ControlBibtex.C
===
--- src/frontends/controllers/ControlBibtex.C	(revision 17353)
+++ src/frontends/controllers/ControlBibtex.C	(working copy)
@@ -134,7 +134,7 @@
 	// the different bibtex packages have (and need) their
 	// own "plain" stylefiles
 	biblio::CiteEngine_enum const & engine =
-		biblio::getEngine(kernel().buffer());
+		kernel().buffer().params().getEngine();
 	docstring defaultstyle;
 	switch (engine) {
 	case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===
--- src/frontends/controllers/ControlCitation.C	(revision 17353)
+++ src/frontends/controllers/ControlCitation.C	(working copy)
@@ -39,7 +39,7 @@
 	vector > blist;
 	kernel().buffer().fillWithBibKeys(blist);
 
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
 
 	bool use_styles = engine != biblio::ENGINE_BASIC;
 
@@ -79,13 +79,13 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-	return biblio::getEngine(kernel().buffer());
+	return kernel().buffer().params().getEngine();
 }
 
 
 vector const ControlCitation::getCiteStrings(string const & key) const
 {
-	biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
+	biblio::CiteEngine const engine = 

  1   2   >