]> git.lyx.org Git - features.git/commitdiff
buffer-export without argument exports the default format
authorGuillaume Munch <gm@lyx.org>
Mon, 27 Feb 2017 19:43:11 +0000 (20:43 +0100)
committerGuillaume Munch <gm@lyx.org>
Mon, 27 Feb 2017 23:46:33 +0000 (00:46 +0100)
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
src/LyXAction.cpp
src/frontends/qt4/GuiView.cpp

index 7641741076553a6b9a3131f0bddf1acdeb12a44d..892898b046214f116139d61cffcc42fb65629509 100644 (file)
@@ -2533,7 +2533,8 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                        enable = true;
                        break;
                }
                        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);
                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: {
                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."),
                dr.setError(status != ExportSuccess);
                if (status != ExportSuccess)
                        dr.setMessage(bformat(_("Error exporting to format: %1$s."),
-                                             func.argument()));
+                                             from_utf8(format)));
                break;
        }
 
                break;
        }
 
index 77cf3ea4f1cad394deacdbe25d099861bd4a2cfb..dba6e64fdbfed9cfaa3c31b1a4d92a7902831dad 100644 (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.
 /*!
  * \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),
  * \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
                         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.
                <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.
index a6b5877be1e67a9f8a114c65d378ef828136e273..c4f6b5724ddc92ea84d314285eaf2fe44e4d2547 100644 (file)
@@ -3548,14 +3548,17 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        else
                                target_dir = doc_buffer->fileName().onlyPath();
 
                        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()) {
                        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 */
                                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,
                                                doc_buffer,
                                                _("Exporting ..."),
                                                &GuiViewPrivate::exportAndDestroy,