On Thu, Jan 23, 2014 at 12:14 PM, Scott Kostyshak <skost...@lyx.org> wrote:
> On Thu, Jan 23, 2014 at 11:32 AM, Jean-Marc Lasgouttes
> <lasgout...@lyx.org> wrote:
>> Le 23/01/2014 17:22, Scott Kostyshak a écrit :
>>
>>> $$s is for the system directory. So to reach those scripts one could
>>> do $$s/scripts/. I don't believe there is a variable for the user
>>> scripts directory and it is this directory that I understand the
>>> Customization manual to suggest.
>>
>>
>> Actually, the filettols.h file says:
>>
>> /** Takes a command such as "python $$s/scripts/convertDefault.py file.in
>> file.out"
>>  *  and replaces "$$s/" with the path to the LyX support directory
>> containing
>>  *  this script. If the script is not found, "$$s/" is removed. Executing
>> the
>>  *  command will still fail, but the error message will make some sort of
>>  *  sense ;-)
>>  */
>> std::string const libScriptSearch(std::string const & command,
>>                 quote_style style = quote_shell);
>>
>> $$s is not really a variable like the others, but a kind of macro. The real
>> syntax is actually $$s/foo/bar, and this searches for bar in user_dir/foo
>> and then system_dir/foo.
>>
>> Therefore $$s/scripts/pdfcopier.sh is correct and finds the script wherever
>> it is.
>
> Ah now I'm starting to understand. Do you happen to know under which
> cases $$s is interpreted? Putting the same copier command in different
> converters leads to the $$s sometimes being substituted and sometimes
> not. And contrary to the message you cited, the $$s/ is still included
> for me when the path is not found (I put in a bogus name). So this
> makes me think there's something that I'm still not understanding.
>
> Scott

If latex=pdflatex is specified, the $$s is not substituted. The only
substitution is for $$i. This is not documented. I have a script that
I want to use to run pdflatex (and do other things like copy the log
file to a different directory). Because my script runs pdflatex,
specifying latex=pdflatex seems like the right thing to do. I'm
actually not sure what latex=pdflatex does. Does it tell LyX to make
sure that the converter is run as many times as necessary? I would
like to put this information in the customization manual, which
currently only says "This converter runs some form of LaTeX. This will
make LyX's LaTeX error logs available." I'm guessing it does more than
that.

The attached patch fixes the "problem" for me. I have no idea if it is
correct. Is there a reason not to do the substitution, i.e. do we want
to disallow user scripts when latex=pdflatex?

Also, it seems that now latex is not a flag and should be listed under
"The following three flags are not really flags at all because they
take an argument in the key = value format:"
Is that correct?

Scott
From c2d276074921967c917768a21092907616164828 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Sat, 25 Jan 2014 13:16:05 -0500
Subject: [PATCH] Allow $$s converter substitution if 'latex' flag

---
 src/Converter.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Converter.cpp b/src/Converter.cpp
index a27d742..a3df839 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -403,6 +403,7 @@ bool Converters::convert(Buffer const * buffer,
 			command = subst(command, token_from, "");
 			command = subst(command, token_latex_encoding, buffer ?
 				buffer->params().encoding().latexName() : string());
+			command = libScriptSearch(command);
 			LYXERR(Debug::FILES, "Running " << command);
 			if (!runLaTeX(*buffer, command, runparams, errorList))
 				return false;
-- 
1.8.3.2

Reply via email to