commit 806cfc5a8b53e4d9eefa1250ce4edae969c0b0ad
Author: Enrico Forestieri <[email protected]>
Date: Tue May 26 00:29:46 2015 +0200
Virtualize the origin tag for the system directory.
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.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e5d4557..c79596f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2308,11 +2308,52 @@ CLEANFILES += lyx@[email protected]
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
diff --git a/lib/doc/Makefile.am b/lib/doc/Makefile.am
index 38c545b..e9b9f64 100644
--- a/lib/doc/Makefile.am
+++ b/lib/doc/Makefile.am
@@ -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|" \
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 34f1a50..044c5e3 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -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(),