commit a1faa41c839089a9f21323af6540926eae90ec6f
Author: Guillaume Munch <[email protected]>
Date:   Mon Feb 27 20:43:11 2017 +0100

    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.
---
 src/Buffer.cpp                |    9 ++++++---
 src/LyXAction.cpp             |    6 ++++--
 src/frontends/qt4/GuiView.cpp |    7 +++++--
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 7641741..892898b 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -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;
        }
 
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 77cf3ea..dba6e64 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -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.
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index a6b5877..c4f6b57 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -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,

Reply via email to