buffer-export without argument exports the default format

buffer-export is proposed as a default binding in the preferences so now it does
what a user expects when binding it to a key.
This commit is contained in:
Guillaume Munch 2017-02-27 20:43:11 +01:00
parent 443eb7bf79
commit a1faa41c83
3 changed files with 15 additions and 7 deletions

View File

@ -2533,7 +2533,8 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
enable = true;
break;
}
string format = to_utf8(arg);
string format =
arg.empty() ? params().getDefaultOutputFormat() : to_utf8(arg);
size_t pos = format.find(' ');
if (pos != string::npos)
format = format.substr(0, pos);
@ -2641,11 +2642,13 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
break;
case LFUN_BUFFER_EXPORT: {
ExportStatus const status = doExport(argument, false);
string const format =
argument.empty() ? params().getDefaultOutputFormat() : argument;
ExportStatus const status = doExport(format, false);
dr.setError(status != ExportSuccess);
if (status != ExportSuccess)
dr.setMessage(bformat(_("Error exporting to format: %1$s."),
func.argument()));
from_utf8(format)));
break;
}

View File

@ -574,7 +574,7 @@ void LyXAction::init()
/*!
* \var lyx::FuncCode lyx::LFUN_BUFFER_EXPORT
* \li Action: Exports the current buffer (document) to the given format.
* \li Syntax: buffer-export <FORMAT> [<DEST>]
* \li Syntax: buffer-export [<FORMAT>] [<DEST>]
* \li Params: <FORMAT> is either "custom" or one of the formats which you
can find in Tools->Preferences->File formats->Format.
Usual format you will enter is "pdf2" (pdflatex),
@ -582,7 +582,9 @@ void LyXAction::init()
In case of "custom" you will be asked for a format you
want to start from and for the command that you want to
apply to this format. Internally the control is then passed
to #LFUN_BUFFER_EXPORT_CUSTOM.
to #LFUN_BUFFER_EXPORT_CUSTOM.\n
If absent, the default output format of the document is
used.
<DEST> If present, this argument provides the export destination
filename. Its containing folder will also be the destination
folder, where all the needed external files will be copied.

View File

@ -3548,14 +3548,17 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
else
target_dir = doc_buffer->fileName().onlyPath();
string const format = argument.empty() ?
doc_buffer->params().getDefaultOutputFormat() : argument;
if ((dest.empty() && doc_buffer->isUnnamed())
|| !target_dir.isDirWritable()) {
exportBufferAs(*doc_buffer, cmd.argument());
exportBufferAs(*doc_buffer, from_utf8(format));
break;
}
/* TODO/Review: Is it a problem to also export the children?
See the update_unincluded flag */
d.asyncBufferProcessing(argument,
d.asyncBufferProcessing(format,
doc_buffer,
_("Exporting ..."),
&GuiViewPrivate::exportAndDestroy,