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.
This commit is contained in:
Enrico Forestieri 2015-05-26 00:29:46 +02:00
parent a06b3900d2
commit 806cfc5a8b
3 changed files with 56 additions and 4 deletions

View 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

View 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|" \

View 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(),