Author: forenr
Date: Tue Jul 20 17:53:04 2010
New Revision: 34989
URL: http://www.lyx.org/trac/changeset/34989
Log:
By default, overwrite the main file on export, but allow changing default
behavior through the environment variable LYX_FORCE_OVERWRITE.
Modified:
lyx-devel/branches/BRANCH_1_6_X/lyx.1in
lyx-devel/branches/BRANCH_1_6_X/src/LyX.cpp
lyx-devel/branches/BRANCH_1_6_X/src/LyX.h
lyx-devel/branches/BRANCH_1_6_X/status.16x
Modified: lyx-devel/branches/BRANCH_1_6_X/lyx.1in
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/lyx.1in Tue Jul 20 08:45:21 2010
(r34988)
+++ lyx-devel/branches/BRANCH_1_6_X/lyx.1in Tue Jul 20 17:53:04 2010
(r34989)
@@ -74,11 +74,13 @@
where fmt is the import format of choice and file.xxx is the file to be
imported.
.TP
\fB \-f [\-\-force\-overwrite]\fP \fIwhat
-where what is is either "\fBall\fR" or "\fBmain\fR".
-Using "\fBall\fR", all files are overwritten during a batch export, otherwise
-only the main file will be. When this switch is followed by anything else other
-than "\fBall\fR" or "\fBmain\fR", the behavior is as if "\fBall\fR" was
-specified, but what follows is left on the command line for further processing.
+where what is is either "\fBall\fR", "\fBmain\fR" or "\fBnone\fR".
+Specify "\fBall\fR" to allow overwriting all files during a batch export,
+"\fBmain\fR" to allow overwriting the main file only, or "\fBnone\fR"
+to disallow overwriting any file. When this switch is followed by anything
+else other than "\fBall\fR", "\fBmain\fR" or "\fBnone\fR", the behavior is as
+if "\fBall\fR" was specified, but what follows is left on the command line for
+further processing.
.SH ENVIRONMENT
.TP
@@ -113,6 +115,17 @@
.B LYX_LOCALEDIR
can be used to tell LyX where to look for the translations of its GUI
strings in other languages.
+
+.TP
+.B LYX_FORCE_OVERWRITE
+can be used to change the default behavior when exporting from command
+line.
+.PP
+By default, LyX overwrites the main file when exporting from command
+line but not the ancillary files. This behavior can be changed by setting
+this environment variable, which relieves the need of using the \-f switch.
+Allowed values are either "\fBall\fR", "\fBmain\fR" or "\fBnone\fR", with
+same meaning as for the \-f switch.
.SH FILES
.nf
.ta \w'\fILIBDIR\fR/lyxrc.in 'u
Modified: lyx-devel/branches/BRANCH_1_6_X/src/LyX.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/LyX.cpp Tue Jul 20 08:45:21 2010
(r34988)
+++ lyx-devel/branches/BRANCH_1_6_X/src/LyX.cpp Tue Jul 20 17:53:04 2010
(r34989)
@@ -87,9 +87,11 @@
// Tell what files can be silently overwritten during batch export.
-// Possible values are: NO_FILES, MAIN_FILE, ALL_FILES.
+// Possible values are: NO_FILES, MAIN_FILE, ALL_FILES, UNSPECIFIED.
+// Unless specified on command line (through the -f switch) or through the
+// environment variable LYX_FORCE_OVERWRITE, the default will be MAIN_FILE.
-OverwriteFiles force_overwrite = NO_FILES;
+OverwriteFiles force_overwrite = UNSPECIFIED;
namespace {
@@ -701,9 +703,20 @@
if (queryUserLyXDir(package().explicit_user_support()))
reconfigureUserLyXDir();
- // no need for a splash when there is no GUI
if (!use_gui) {
+ // No need for a splash when there is no GUI
first_start = false;
+ // Default is to overwrite the main file during export, unless
+ // the -f switch was specified or LYX_FORCE_OVERWRITE was set
+ if (force_overwrite == UNSPECIFIED) {
+ string const what = getEnv("LYX_FORCE_OVERWRITE");
+ if (what == "all")
+ force_overwrite = ALL_FILES;
+ else if (what == "none")
+ force_overwrite = NO_FILES;
+ else
+ force_overwrite = MAIN_FILE;
+ }
}
// This one is generated in user_support directory by lib/configure.py.
@@ -979,9 +992,9 @@
" where fmt is the import format of choice\n"
" and file.xxx is the file to be imported.\n"
"\t-f [--force-overwrite] what\n"
- " where what is either `all' or `main'.\n"
- " Using `all', all files are overwritten
during\n"
- " a batch export, otherwise only the main
file will be.\n"
+ " where what is either `all', `main' or
`none',\n"
+ " specifying whether all files, main file
only, or no files,\n"
+ " respectively, are to be overwritten during
a batch export.\n"
" Anything else is equivalent to `all', but
is not consumed.\n"
"\t-version summarize version and build info\n"
"Check the LyX man page for more details.")) <<
endl;
@@ -1085,6 +1098,9 @@
} else if (arg == "main") {
force_overwrite = MAIN_FILE;
return 1;
+ } else if (arg == "none") {
+ force_overwrite = NO_FILES;
+ return 1;
}
force_overwrite = ALL_FILES;
return 0;
Modified: lyx-devel/branches/BRANCH_1_6_X/src/LyX.h
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/src/LyX.h Tue Jul 20 08:45:21 2010
(r34988)
+++ lyx-devel/branches/BRANCH_1_6_X/src/LyX.h Tue Jul 20 17:53:04 2010
(r34989)
@@ -36,7 +36,8 @@
enum OverwriteFiles {
NO_FILES,
MAIN_FILE,
- ALL_FILES
+ ALL_FILES,
+ UNSPECIFIED
};
extern bool use_gui;
Modified: lyx-devel/branches/BRANCH_1_6_X/status.16x
==============================================================================
--- lyx-devel/branches/BRANCH_1_6_X/status.16x Tue Jul 20 08:45:21 2010
(r34988)
+++ lyx-devel/branches/BRANCH_1_6_X/status.16x Tue Jul 20 17:53:04 2010
(r34989)
@@ -27,6 +27,12 @@
- Add support for pBibTeX (formerly known as jBibTeX), a specific Japanese
BibTeX variant (bug 6808).
+- New environment variable LYX_FORCE_OVERWRITE allows changing default
+ behavior when exporting from command line. Now LyX overwrites the main
+ main file by default, but not the ancillary files. Set this variable to
+ "all" for letting LyX behave as in 1.6.6 and previous versions; set it
+ to "none" for mimicking the 1.6.7 behavior of not overwriting any file.
+
* USER INTERFACE