]> git.lyx.org Git - features.git/commitdiff
Virtualize the origin tag for the system directory.
authorEnrico Forestieri <forenr@lyx.org>
Mon, 25 May 2015 22:29:46 +0000 (00:29 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 25 May 2015 22:29:46 +0000 (00:29 +0200)
The documents saved to the system directory have now the origin tag
prefix "/systemlyxdir/". This allows both saving them always using
the same virtual path irrespective of the real path and to let the
origin tag work out of the box also on MacOS.

lib/Makefile.am
lib/doc/Makefile.am
src/BufferParams.cpp

index e5d45579e65f786f7300ce5cead63bb7935303ad..c79596f1489738b1c13bd81280d3333710b672b9 100644 (file)
@@ -2308,11 +2308,52 @@ CLEANFILES += lyx@program_suffix@.desktop lyx.desktop-temp \
 endif
 dist_noinst_DATA += lyx.desktop.in images/lyx.svg images/lyx.png
 
+exampleandtemplate_files = \
+                          $(dist_caexamples_DATA) \
+                          $(dist_csexamples_DATA) \
+                          $(dist_daexamples_DATA) \
+                          $(dist_deexamples_DATA) \
+                          $(dist_elexamples_DATA) \
+                          $(dist_esexamples_DATA) \
+                          $(dist_euexamples_DATA) \
+                          $(dist_faexamples_DATA) \
+                          $(dist_frexamples_DATA) \
+                          $(dist_glexamples_DATA) \
+                          $(dist_heexamples_DATA) \
+                          $(dist_huexamples_DATA) \
+                          $(dist_idexamples_DATA) \
+                          $(dist_itexamples_DATA) \
+                          $(dist_jaexamples_DATA) \
+                          $(dist_koexamples_DATA) \
+                          $(dist_nlexamples_DATA) \
+                          $(dist_plexamples_DATA) \
+                          $(dist_ptexamples_DATA) \
+                          $(dist_roexamples_DATA) \
+                          $(dist_ruexamples_DATA) \
+                          $(dist_slexamples_DATA) \
+                          $(dist_skexamples_DATA) \
+                          $(dist_srexamples_DATA) \
+                          $(dist_svexamples_DATA) \
+                          $(dist_springerexamples_DATA) \
+                          $(dist_thesisexamples_DATA) \
+                          $(dist_ukexamples_DATA) \
+                          $(dist_examples_DATA) \
+                          $(dist_templates_DATA)
+
 install-data-hook:
        $(CHMOD) 755 $(DESTDIR)$(pkgdatadir)/configure.py
        for i in $(DESTDIR)$(scriptsdir)/*.py $(DESTDIR)$(scriptsdir)/listerrors ; do \
                $(CHMOD) 755 $$i; \
        done
+       for i in $(exampleandtemplate_files); do \
+               if $(EGREP) -q "^\\\\origin " "$(DESTDIR)$(pkgdatadir)/$$i"; then \
+                       origin=`dirname "/systemlyxdir/$$i"`/; \
+                       sed -e "s|^\\\\origin .*|\\\\origin $$origin|" \
+                               "$(DESTDIR)$(pkgdatadir)/$$i" > "$(DESTDIR)$(pkgdatadir)/$$i.tmp"; \
+                       mv -f "$(DESTDIR)$(pkgdatadir)/$$i.tmp" "$(DESTDIR)$(pkgdatadir)/$$i"; \
+                       chmod 644 "$(DESTDIR)$(pkgdatadir)/$$i"; \
+               fi; \
+       done
 
 alltests: check alltests-recursive
 
index 38c545b1711f75ca1fbac9e41e6122110ae03265..e9b9f64829d8c95b8c371e4f0de20c86e77870a7 100644 (file)
@@ -322,8 +322,8 @@ doc_files = \
 install-data-hook:
        for i in $(doc_files); \
        do \
-               if $(EGREP) -q "LYX_DIR_VER|LYX_USERDIR_VER|^\\origin " "$(DESTDIR)$(docdir)/$$i"; then \
-                       origin=`dirname "$(docdir)/$$i"`/; \
+               if $(EGREP) -q "LYX_DIR_VER|LYX_USERDIR_VER|^\\\\origin " "$(DESTDIR)$(docdir)/$$i"; then \
+                       origin=`dirname "/systemlyxdir/doc/$$i"`/; \
                        sed -e "s/LYX_DIR_VER/$(LYX_DIR_VER)/g" \
                            -e "s/LYX_USERDIR_VER/$(LYX_USERDIR_VER)/g" \
                            -e "s|^\\\\origin .*|\\\\origin $$origin|" \
index 34f1a50187189f189f0d6b9c2d208ba8c5d9e6ad..044c5e32b7e7e18f85f17afb90ab3a9bb04b4507 100644 (file)
@@ -54,6 +54,7 @@
 #include "support/gettext.h"
 #include "support/Messages.h"
 #include "support/mutex.h"
+#include "support/Package.h"
 #include "support/Translator.h"
 #include "support/lstrings.h"
 
@@ -660,6 +661,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\origin") {
                lex.eatLine();
                origin = lex.getString();
+               string const sysdirprefix = "/systemlyxdir/";
+               if (prefixIs(origin, sysdirprefix)) {
+                       origin.replace(0, sysdirprefix.length() - 1,
+                               package().system_support().absFileName());
+               }
        } else if (token == "\\begin_preamble") {
                readPreamble(lex);
        } else if (token == "\\begin_local_layout") {
@@ -983,8 +989,13 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        // Prints out the buffer info into the .lyx file given by file
 
        // the document directory
-       os << "\\origin "
-          << (lyxrc.save_origin ? buf->filePath() : "unavailable") << '\n';
+       string filepath = buf->filePath();
+       string const sysdir = package().system_support().absFileName();
+       if (prefixIs(filepath, sysdir))
+               filepath.replace(0, sysdir.length(), "/systemlyxdir/");
+       else if (!lyxrc.save_origin)
+               filepath = "unavailable";
+       os << "\\origin " << filepath << '\n';
 
        // the textclass
        os << "\\textclass " << buf->includedFilePath(addName(buf->layoutPos(),