Jean-Marc Lasgouttes wrote:
> Le 25/11/13 20:49, Georg Baum a écrit :
>> Scott Kostyshak wrote:
>>
>>> On Thu, Nov 21, 2013 at 4:22 PM, Kornel Benko <kor...@lyx.org> wrote:
>>>>
>>>> Should we change the convertor calls?
>>>>
>>>> E.g. LaTeX(plain) -> LyX
>>>>
>>>> ...tex2lyx -userdir $$User -f $$i $$o
>>>>
>>>> (This does not work unfortunately)
>>
>> Yes, something like this would be needed.
>
> Or we could just set LYX_USERDIR_VER to the right value before launching
> any child process (maybe just when Package::explicit_user_support() is
> true).
Even better! This solution is more elegant and requires less code. I
implemented it (by exporting the environment variable generally, so that all
child processes may use it), and it works fine. IMHO it is safe enough to go
in. Any objections?
Georg
diff --git a/src/LyX.cpp b/src/LyX.cpp
index b777e55..b576ac0 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -735,6 +735,18 @@ bool LyX::init()
if (!setEnv("LyXDir", lyx_dir))
LYXERR(Debug::INIT, "\t... failed!");
+ if (package().explicit_user_support() && getEnv(LYX_USERDIR_VER).empty()) {
+ // -userdir was given on the command line.
+ // Make it available to child processes, otherwise tex2lyx
+ // would not find all layout files, and other converters might
+ // use it as well.
+ string const user_dir = package().user_support().absFileName();
+ LYXERR(Debug::INIT, "Setting " LYX_USERDIR_VER "... to \""
+ << user_dir << '"');
+ if (!setEnv(LYX_USERDIR_VER, user_dir))
+ LYXERR(Debug::INIT, "\t... failed!");
+ }
+
//
// Read configuration files
//