]> git.lyx.org Git - features.git/commitdiff
Allow Input of local includes from local layout files
authorEnrico Forestieri <forenr@lyx.org>
Wed, 1 Mar 2017 08:19:18 +0000 (09:19 +0100)
committerRichard Heck <rgheck@lyx.org>
Wed, 1 Mar 2017 19:55:00 +0000 (14:55 -0500)
When including files, LyX always searches the user and the system
directory, in that order. This means that when using local layout
files broken down into multiple includes, the various includes should
be specified with a path relative to the user layouts directory
(typically ~/.lyx/layouts), making this very impractical.
This commit allows including local files by specifying their path
as explicitly relative to the main layout file position, i.e., by
specifying their path with either "./" or "../". If the main layout
is not loaded from a local file, the usual search order is used,
even if the path are explicitly relative. So, for system layouts,
both "Input ./name.inc" and "Input name.inc" are equivalent.

(cherry picked from commit 17ab47b3e6acafae8f11e6363ee64252b26c81e7)

po/pt_BR.gmo
po/sk.gmo
po/zh_CN.gmo
src/LayoutFile.cpp
src/TextClass.cpp
src/TextClass.h
status.22x

index ea90f6c6f206b9771d27d8a89c1e6114d0d818fd..a2757e4768c7e0200e355089e6bd609ddbff4f13 100644 (file)
Binary files a/po/pt_BR.gmo and b/po/pt_BR.gmo differ
index d4372bad244eb7680dfcc91ab93ff4af92e47ccb..76c98a6bb63a49c217c6a372653041aa43c35208 100644 (file)
Binary files a/po/sk.gmo and b/po/sk.gmo differ
index c21bc982cb505275abf3618932928ee58e123f0a..c6af0003bb58940d1256a133dc3acb54054d7b8b 100644 (file)
Binary files a/po/zh_CN.gmo and b/po/zh_CN.gmo differ
index 8cca663c4b6ace8e872ace70304b801e2074afee..142d566302e200bd67d294697d218564b65c0344 100644 (file)
@@ -44,7 +44,8 @@ LayoutFile::LayoutFile(string const & fn, string const & cln,
                       string const & desc, string const & prereq,
                       string const & category, bool texclassavail) 
 {
-       name_ = fn;
+       name_ = onlyFileName(fn);
+       path_ = fn.rfind('/') == string::npos ? string() : onlyPath(fn);
        latexname_ = cln;
        description_ = desc;
        prerequisites_ = prereq;
@@ -332,7 +333,8 @@ LayoutFileIndex  LayoutFileList::addLocalLayout(
                return string();
 
        LayoutFile * tmpl =
-               new LayoutFile(textclass, class_name, textclass, class_prereq, category, true);
+               new LayoutFile(addName(moved ? oldpath : path, textclass),
+                       class_name, textclass, class_prereq, category, true);
        //FIXME: The prerequisites are available from the layout file and
        //       can be extracted from the above regex, but for now this
        //       field is simply set to class_name + ".cls"
index e1e40272ea0651b71c21a9f657feead535c7cf56..cb8b8c43b2aad52600192e65a7e32494ef095280 100644 (file)
@@ -447,8 +447,13 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
 
                case TC_INPUT: // Include file
                        if (lexrc.next()) {
+                               FileName tmp;
                                string const inc = lexrc.getString();
-                               FileName tmp = libFileSearch("layouts", inc,
+                               if (!path().empty() && (prefixIs(inc, "./") ||
+                                                       prefixIs(inc, "../")))
+                                       tmp = fileSearch(path(), inc, "layout");
+                               else
+                                       tmp = libFileSearch("layouts", inc,
                                                            "layout");
 
                                if (tmp.empty()) {
index 88f93036e029ae4b9c4dd959cf5d7e74cab074fb..f2d31105832265a706e62237c02a823796d43728 100644 (file)
@@ -192,6 +192,8 @@ public:
        ///
        std::string const & name() const { return name_; }
        ///
+       std::string const & path() const { return path_; }
+       ///
        std::string const & category() const { return category_; }
        ///
        std::string const & description() const { return description_; }
@@ -238,6 +240,8 @@ protected:
        mutable LayoutList layoutlist_;
        /// Layout file name
        std::string name_;
+       /// Layout file path (empty for system layout files)
+       std::string path_;
        /// Class category
        std::string category_;
        /// document class name
index 9ba3589fa6419175e6cd88a6ce13390fe5d19e06..9f9e1fc742a1890888e5a235cb8d0d63629bb9ff 100644 (file)
@@ -18,6 +18,9 @@ What's new
 - Allow use of verbatim and quotation environments with IOP articles
   (bug 10505).
 
+- Search for input files relative to local layout files, when those 
+  are provided and relative paths are used.
+
 
 * TEX2LYX IMPROVEMENTS