commit 824c1df86c7f9240dd44f7c7122a4f9b14ba65a0
Author: Juergen Spitzmueller <[email protected]>
Date:   Tue Aug 4 11:42:57 2026 +0200

    Amend e569426b158
    
    Use the real command name as argument, i.e.
    \start_of_matter frontmatter
    rather than
    \start of matter front
    
    This will allow us to add more variants (e.g., \frontmatter* from
    memoir or KOMA) later.
    
    It also allows us to slightly simplify the code.
---
 development/FORMAT          |  2 +-
 lib/lyx2lyx/lyx_2_6.py      | 39 ++++++++++++++++---------------
 lib/ui/stdmenus.inc         |  6 ++---
 src/LyXAction.cpp           |  2 +-
 src/ParagraphParameters.cpp | 12 +++++-----
 src/Text.cpp                | 12 +++++-----
 src/tex2lyx/text.cpp        | 56 ++++-----------------------------------------
 7 files changed, 42 insertions(+), 87 deletions(-)

diff --git a/development/FORMAT b/development/FORMAT
index fae968c761..bda751d173 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -10,7 +10,7 @@ changes happened in particular if possible. A good example 
would be
 2026-08-03 Jürgen Spitzmüller <[email protected]>
        * Format incremented to 657: Support for \fronmatter, \mainmatter,
          and \backmatter via paragraph parameter
-         \start_of_matter {front,main,back}
+         \start_of_matter {frontmatter,mainmatter,backmatter}
 
 2026-08-02 Jürgen Spitzmüller <[email protected]>
        * Format incremented to 656: Support for parfillskip
diff --git a/lib/lyx2lyx/lyx_2_6.py b/lib/lyx2lyx/lyx_2_6.py
index 7302e78b02..a335fa5204 100644
--- a/lib/lyx2lyx/lyx_2_6.py
+++ b/lib/lyx2lyx/lyx_2_6.py
@@ -1644,25 +1644,28 @@ def revert_parfillskip(document):
 def revert_matters(document):
     """Revert \\frontmatter, \\mainmatter and \\backmatter to ERT"""
 
-    for matter in ["front", "main", "back"]:
-        i = 0
-        while True:
-            i = find_token(document.body, "\\start_of_matter " + matter, i)
-            if i == -1:
-                break
-            
-            # Add ERT
-            lay = get_containing_layout(document.body, i)
-            if lay == False:
-                document.warning("Matter has no layout!")
-                i += 1
-                continue
-            
-            beglay = lay[1]
+    i = 0
+    while True:
+        i = find_token(document.body, "\\start_of_matter ", i)
+        if i == -1:
+            break
+        matter = get_value(document.body, "\\start_of_matter", i)
+        if matter == "":
             del document.body[i] 
-            ert = put_cmd_in_ert(["\\" + matter + "matter"], as_paragraph=True)
-            document.body[beglay : beglay] = ert
-            i = beglay + len(ert)
+            break
+        
+        # Add ERT
+        lay = get_containing_layout(document.body, i)
+        if lay == False:
+            document.warning("Matter has no layout!")
+            i += 1
+            continue
+          
+        beglay = lay[1]
+        del document.body[i]
+        ert = put_cmd_in_ert(["\\" + matter], as_paragraph=True)
+        document.body[beglay : beglay] = ert
+        i = beglay + len(ert)
 
 ##
 # Conversion hub
diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc
index 33b5b4523c..10f18606f6 100644
--- a/lib/ui/stdmenus.inc
+++ b/lib/ui/stdmenus.inc
@@ -594,9 +594,9 @@ Menuset
        End
 
        Menu "matter"
-               OptItem "Front Matter|F" "matter front"
-               OptItem "Main Matter|M" "matter main"
-               OptItem "Back Matter|B" "matter back"
+               OptItem "Front Matter|F" "matter frontmatter"
+               OptItem "Main Matter|M" "matter mainmatter"
+               OptItem "Back Matter|B" "matter backmatter"
        End
 
 #
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index f7e174e1bf..de5c69f4a8 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -302,7 +302,7 @@ void LyXAction::init()
  * \var lyx::FuncCode lyx::LFUN_MATTER
  * \li Action: Start (or unstart) matter on the given cursor position.
  * \li Syntax: matter <type>
- * \li Params: <type>: front, main, back.
+ * \li Params: <type>: frontmatter, mainmatter, backmatter.
  * \li Origin: daniel/spitz, 3 Aug 2026
  * \endvar
  */
diff --git a/src/ParagraphParameters.cpp b/src/ParagraphParameters.cpp
index ec50faafdf..2e19cdeb20 100644
--- a/src/ParagraphParameters.cpp
+++ b/src/ParagraphParameters.cpp
@@ -235,11 +235,11 @@ void ParagraphParameters::read(Lexer & lex, bool merge)
                } else if (token == "\\start_of_matter") {
                        lex.next();
                        string const tmp = rtrim(lex.getString());
-                       if (tmp == "front")
+                       if (tmp == "frontmatter")
                                startOfMatter(MATTER_FRONT);
-                       else if (tmp == "main")
+                       else if (tmp == "mainmatter")
                                startOfMatter(MATTER_MAIN);
-                       else if (tmp == "back")
+                       else if (tmp == "backmatter")
                                startOfMatter(MATTER_BACK);
                } else if (token == "\\paragraph_spacing") {
                        lex.next();
@@ -307,11 +307,11 @@ void ParagraphParameters::write(ostream & os) const
        if (startOfMatter() != MATTER_NONE) {
                string tmp;
                if (startOfMatter() == MATTER_FRONT)
-                       tmp = "front";
+                       tmp = "frontmatter";
                else if (startOfMatter() == MATTER_MAIN)
-                       tmp = "main";
+                       tmp = "mainmatter";
                else if (startOfMatter() == MATTER_BACK)
-                       tmp = "back";
+                       tmp = "backmatter";
                os << "\\start_of_matter " << tmp << "\n";
        }
 
diff --git a/src/Text.cpp b/src/Text.cpp
index 0a8be834fe..76ff131454 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -4144,13 +4144,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                Paragraph & par = cur.paragraph();
                docstring const & arg = cmd.argument();
                Matter start = MATTER_NONE;
-               if (arg == "front") {
+               if (arg == "frontmatter") {
                        start = par.params().startOfMatter() == MATTER_FRONT
                                                   ? MATTER_NONE : MATTER_FRONT;
-               } else if (arg == "main") {
+               } else if (arg == "mainmatter") {
                        start = par.params().startOfMatter() == MATTER_MAIN
                                                   ? MATTER_NONE : MATTER_MAIN;
-               } else if (arg == "back") {
+               } else if (arg == "backmatter") {
                        start = par.params().startOfMatter() == MATTER_BACK
                                                   ? MATTER_NONE : MATTER_BACK;
                }
@@ -6430,11 +6430,11 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & 
cmd,
                // FIXME We really should not allow this to be put, e.g.,
                // in a footnote, or in ERT. But it would make sense in a
                // branch, so I'm not sure what to do.
-               if (cmd.argument() == "front")
+               if (cmd.argument() == "frontmatter")
                        
status.setOnOff(cur.paragraph().params().startOfMatter() == MATTER_FRONT);
-               else if (cmd.argument() == "main")
+               else if (cmd.argument() == "mainmatter")
                        
status.setOnOff(cur.paragraph().params().startOfMatter() == MATTER_MAIN);
-               else if (cmd.argument() == "back")
+               else if (cmd.argument() == "backmatter")
                        
status.setOnOff(cur.paragraph().params().startOfMatter() == MATTER_BACK);
                else
                        enable = false;
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 31b509ffcc..7cb59232ae 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3945,63 +3945,15 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                        continue;
                }
 
-               if (t.cs() == "frontmatter") {
-                       context.add_par_extra_stuff("\\start_of_matter 
front\n");
+               if (t.cs() == "frontmatter" || t.cs() == "mainmatter" || t.cs() 
== "backmatter") {
+                       context.add_par_extra_stuff("\\start_of_matter " + 
t.cs() + "\n");
                        // We need to start a new paragraph. Otherwise the
-                       // frontmatter in 'bla\frontmatter\chapter{' would start
+                       // switch in 'bla\<type>matter\chapter{' would start
                        // too late.
                        context.new_paragraph(os);
                        // We need to make sure that the paragraph is
                        // generated even if it is empty. Otherwise the
-                       // frontmatter in '\par\frontmatter\par\chapter{' would
-                       // start too late.
-                       context.check_layout(os);
-                       // FIXME: This is a hack to prevent paragraph
-                       // deletion if it is empty. Handle this better!
-                       output_comment(p, os,
-                               "dummy comment inserted by tex2lyx to "
-                               "ensure that this paragraph is not empty",
-                               context);
-                       // Both measures above may generate an additional
-                       // empty paragraph, but that does not hurt, because
-                       // whitespace does not matter here.
-                       eat_whitespace(p, os, context, true);
-                       continue;
-               }
-
-               if (t.cs() == "mainmatter") {
-                       context.add_par_extra_stuff("\\start_of_matter main\n");
-                       // We need to start a new paragraph. Otherwise the
-                       // mainmatter in 'bla\mainmatter\chapter{' would start
-                       // too late.
-                       context.new_paragraph(os);
-                       // We need to make sure that the paragraph is
-                       // generated even if it is empty. Otherwise the
-                       // mainmatter in '\par\mainmatter\par\chapter{' would
-                       // start too late.
-                       context.check_layout(os);
-                       // FIXME: This is a hack to prevent paragraph
-                       // deletion if it is empty. Handle this better!
-                       output_comment(p, os,
-                               "dummy comment inserted by tex2lyx to "
-                               "ensure that this paragraph is not empty",
-                               context);
-                       // Both measures above may generate an additional
-                       // empty paragraph, but that does not hurt, because
-                       // whitespace does not matter here.
-                       eat_whitespace(p, os, context, true);
-                       continue;
-               }
-
-               if (t.cs() == "backmatter") {
-                       context.add_par_extra_stuff("\\start_of_matter back\n");
-                       // We need to start a new paragraph. Otherwise the
-                       // mainmatter in 'bla\mainmatter\chapter{' would start
-                       // too late.
-                       context.new_paragraph(os);
-                       // We need to make sure that the paragraph is
-                       // generated even if it is empty. Otherwise the
-                       // mainmatter in '\par\mainmatter\par\chapter{' would
+                       // switch in '\par\<type>matter\par\chapter{' would
                        // start too late.
                        context.check_layout(os);
                        // FIXME: This is a hack to prevent paragraph
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to