texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Reimplement linemacro arguments expansion in a se


From: Patrice Dumas
Subject: branch master updated: Reimplement linemacro arguments expansion in a separate function
Date: Wed, 19 Jul 2023 11:47:58 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 7dbc3da3fc Reimplement linemacro arguments expansion in a separate 
function
7dbc3da3fc is described below

commit 7dbc3da3fcf3599e1fc977dd33b0f3d9c7035655
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jul 19 17:47:46 2023 +0200

    Reimplement linemacro arguments expansion in a separate function
    
    * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments)
    (_end_line_misc_line, _end_line_def_line, _end_line, _handle_macro)
    (_handle_open_brace, _process_remaining_on_line, _parse_texi),
    tp/Texinfo/XS/parsetexi/context_stack.c (context_name),
    tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line)
    (end_line_misc_line, end_line), tp/Texinfo/XS/parsetexi/macro.c
    (count_toplevel_braces, set_toplevel_braces_nr)
    (expand_linemacro_arguments, handle_macro),
    tp/Texinfo/XS/parsetexi/parser.c (linecommand_expansion_delimiters)
    (process_remaining_on_line, parse_texi),
    tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace):
    use the expand_linemacro_arguments function directly in handle_macro
    to parse the linemacro defined user commands arguments, such that they
    are expanded in a second step only.  In the XS parser, use a specific
    counter count_toplevel_braces, and use set_toplevel_braces_nr to count
    closed braces.
    Remove code related to the previous implementation.
    
    * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
    (_end_line_def_line, _process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/api.c (reset_parser_except_conf),
    tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line),
    tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line):
    remove global state in_parsing_only, which is not relevant with
    the new implementation.
---
 ChangeLog                                          |  30 ++
 tp/Texinfo/ParserNonXS.pm                          | 327 ++++++++---------
 tp/Texinfo/XS/parsetexi/api.c                      |   1 -
 tp/Texinfo/XS/parsetexi/context_stack.c            |   1 -
 tp/Texinfo/XS/parsetexi/context_stack.h            |   4 +-
 tp/Texinfo/XS/parsetexi/end_line.c                 | 188 +---------
 tp/Texinfo/XS/parsetexi/macro.c                    | 223 ++++++++++-
 tp/Texinfo/XS/parsetexi/parser.c                   |  58 +--
 tp/Texinfo/XS/parsetexi/parser.h                   |   4 +-
 tp/Texinfo/XS/parsetexi/separator.c                |   3 +-
 tp/t/65linemacro.t                                 |   8 +-
 tp/t/results/linemacro/api_doc_with_linemacro.pl   | 306 ++++++----------
 tp/t/results/linemacro/blockitem_no_item.pl        | 132 +++----
 tp/t/results/linemacro/brace_command_not_closed.pl |  81 ++--
 tp/t/results/linemacro/braces_after_text.pl        |  98 ++---
 tp/t/results/linemacro/empty_last_argument.pl      | 157 +++-----
 .../linemacro/end_conditional_in_linemacro.pl      | 156 +++-----
 .../results/linemacro/last_argument_with_braces.pl | 283 ++++----------
 tp/t/results/linemacro/nested_linemacro_calls.pl   | 408 ++++++++-------------
 .../linemacro/newline_and_continuation_in_brace.pl | 139 ++-----
 tp/t/results/linemacro/no_arguments.pl             |  87 ++---
 tp/t/results/linemacro/paragraph_no_paragraph.pl   | 235 ++++--------
 tp/t/results/linemacro/protected_spaces_on_line.pl | 293 +++++----------
 .../linemacro/simple_nested_linemacro_calls.pl     | 332 +++++------------
 .../linemacro/spaces_after_command_in_call.pl      | 147 +++-----
 tp/t/results/linemacro/spaces_in_args.pl           | 116 ++----
 tp/t/results/linemacro/spaces_in_call.pl           |  65 +---
 tp/t/results/linemacro/text_arguments.pl           |  60 ++-
 tp/t/results/linemacro/verb_not_closed.pl          |  92 ++---
 29 files changed, 1497 insertions(+), 2537 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63e605621a..eb019aa350 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2023-07-19  Patrice Dumas  <pertusus@free.fr>
+
+       Reimplement linemacro arguments expansion in a separate function
+
+       * tp/Texinfo/ParserNonXS.pm (_expand_linemacro_arguments)
+       (_end_line_misc_line, _end_line_def_line, _end_line, _handle_macro)
+       (_handle_open_brace, _process_remaining_on_line, _parse_texi),
+       tp/Texinfo/XS/parsetexi/context_stack.c (context_name),
+       tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line)
+       (end_line_misc_line, end_line), tp/Texinfo/XS/parsetexi/macro.c
+       (count_toplevel_braces, set_toplevel_braces_nr)
+       (expand_linemacro_arguments, handle_macro),
+       tp/Texinfo/XS/parsetexi/parser.c (linecommand_expansion_delimiters)
+       (process_remaining_on_line, parse_texi),
+       tp/Texinfo/XS/parsetexi/separator.c (handle_open_brace):
+       use the expand_linemacro_arguments function directly in handle_macro
+       to parse the linemacro defined user commands arguments, such that they
+       are expanded in a second step only.  In the XS parser, use a specific
+       counter count_toplevel_braces, and use set_toplevel_braces_nr to count
+       closed braces.
+       Remove code related to the previous implementation.
+
+       * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
+       (_end_line_def_line, _process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/api.c (reset_parser_except_conf),
+       tp/Texinfo/XS/parsetexi/end_line.c (end_line_def_line),
+       tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line):
+       remove global state in_parsing_only, which is not relevant with
+       the new implementation.
+
 2023-07-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_parse_command_name)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 806bfe54bd..e58e5df69d 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -147,8 +147,6 @@ my %parser_state_initialization = (
   'merged_indices' => {},     # the key is merged in the value
   'sections_level' => 0,      # modified by raise/lowersections
   'targets' => [],            # array of elements used to build 'labels'
-  'in_parsing_only' => 0,     # if set, parse only, no error message, no
-                              # rearranging...
   # initialization of information returned by global_information()
   'info' => {
     'input_encoding_name' => 'utf-8',
@@ -1183,6 +1181,8 @@ sub _place_source_mark
   if ($element->{'contents'} and scalar(@{$element->{'contents'}}) > 0) {
     my $current = $element->{'contents'}->[-1];
     $mark_element = $current;
+    # if there is no text, the source mark is supposed to be
+    # at the end of/after the element
     if (defined($current->{'text'}) and $current->{'text'} ne '') {
       $source_mark->{'position'} = length($current->{'text'});
     }
@@ -2512,7 +2512,6 @@ sub _expand_macro_arguments($$$$$)
   my $argument_content = {'text' => '',
                           'parent' => $argument};
   push @{$argument->{'contents'}}, $argument_content;
-  my $arg_nr = 0;
   my $args_total = scalar(@{$macro->{'args'}}) -1;
   my $name = $macro->{'args'}->[0]->{'text'};
 
@@ -2602,6 +2601,125 @@ sub _expand_macro_arguments($$$$$)
   return ($line, $source_info);
 }
 
+sub _expand_linemacro_arguments($$$$$)
+{
+  my ($self, $macro, $line, $source_info, $current) = @_;
+
+  my $braces_level = 0;
+  my $argument = {'contents' => [],
+                  'parent' => $current};
+  push @{$current->{'args'}}, $argument;
+  my $argument_content = {'text' => '',
+                          'parent' => $argument};
+  push @{$argument->{'contents'}}, $argument_content;
+  # based on whitespace_chars_except_newline in XS parser
+  if ($line =~ s/^([ \t\cK\f]+)//) {
+    $argument->{'info'}
+      = {'spaces_before_argument' => {'text' => $1}};
+  }
+  my $args_total = scalar(@{$macro->{'args'}}) -1;
+  my $name = $macro->{'args'}->[0]->{'text'};
+
+  while (1) {
+    # spaces based on whitespace_chars_except_newline in XS parser
+    if ($line =~ s/([^{}\@ \t\cK\f]*)([{}\@]|[ \t\cK\f]+)//) {
+      my $separator = $2;
+      $argument_content->{'text'} .= $1;
+      if ($separator eq '@') {
+        $argument_content->{'text'} .= '@';
+        my ($cmdname, $is_single_letter) = _parse_command_name($line);
+        if (defined($cmdname)) {
+          $argument_content->{'text'} .= $cmdname;
+          substr($line, 0, length($cmdname)) = '';
+          if ((defined($self->{'brace_commands'}->{$cmdname})
+               and $self->{'IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME'})
+              or $accent_commands{$cmdname}) {
+            $line =~ s/^(\s*)//;
+            $argument_content->{'text'} .= $1;
+          }
+        }
+      } elsif ($separator eq '}') {
+        $braces_level--;
+        $argument_content->{'text'} .= $separator;
+        if ($braces_level == 0) {
+          if (! $argument_content->{'extra'}) {
+            $argument_content->{'extra'} = {'toplevel_braces_nr' => 0};
+          }
+          $argument_content->{'extra'}->{'toplevel_braces_nr'}++;
+        }
+      } elsif ($separator eq '{') {
+        $braces_level++;
+        $argument_content->{'text'} .= $separator;
+      # spaces
+      } else {
+        if ($braces_level > 0
+            or scalar(@{$current->{'args'}}) >= $args_total) {
+          $argument_content->{'text'} .= $separator;
+        } else {
+          $argument = {'contents' => [],
+                       'parent' => $current};
+          push @{$current->{'args'}}, $argument;
+          $argument_content = {'text' => '',
+                               'parent' => $argument};
+          push @{$argument->{'contents'}}, $argument_content;
+          $argument->{'info'}
+            = {'spaces_before_argument' => {'text' => $separator}};
+          print STDERR "LINEMACRO NEW ARG\n" if ($self->{'DEBUG'});
+        }
+      }
+    } else {
+      print STDERR "LINEMACRO ARG end of line $braces_level\n" if 
($self->{'DEBUG'});
+      if ($braces_level > 0) {
+        $argument_content->{'text'} .= $line;
+
+        ($line, $source_info) = _new_line($self, $argument);
+        if (!defined($line)) {
+          $self->_line_error(sprintf(__("\@%s missing closing brace"),
+             $name), $source_info);
+          $line = '';
+          last;
+        }
+      } else {
+        $line =~ s/(.*)//;
+        $argument_content->{'text'} .= $1;
+        if ($line =~ /\n/) {
+          last;
+        } else {
+          # happens when @ protects the end of line, at the very end
+          # of a text fragment and probably with macro expansion
+          ($line, $source_info) = _new_line($self, $argument);
+          if (!defined($line)) {
+            $line = '';
+            last;
+          }
+        }
+      }
+    }
+  }
+  my $arg_idx = 0;
+  foreach my $argument (@{$current->{'args'}}) {
+    my $argument_content = $argument->{'contents'}->[0];
+    if ($argument_content->{'extra'}
+        and defined($argument_content->{'extra'}->{'toplevel_braces_nr'})) {
+      my $toplevel_braces_nr = 
$argument_content->{'extra'}->{'toplevel_braces_nr'};
+      delete $argument_content->{'extra'};
+      # FIXME relocate source marks
+      if ($toplevel_braces_nr == 1 and $argument_content->{'text'} =~ 
/^\{(.*)\}$/s) {
+        print STDERR "TURN to bracketed $arg_idx "
+          .Texinfo::Common::debug_print_element($argument_content)."\n"
+            if ($self->{'DEBUG'});
+        $argument_content->{'text'} = $1;
+        $argument_content->{'type'} = 'bracketed_arg';
+      }
+    }
+    # do that?
+    #_remove_empty_content($self, $argument);
+    $arg_idx++;
+  }
+  print STDERR "END LINEMACRO ARGS EXPANSION\n" if ($self->{'DEBUG'});
+  return ($line, $source_info);
+}
+
 sub _lookup_macro_parameter($$) {
   my $macro = shift;
   my $name = shift;
@@ -3280,12 +3398,6 @@ sub _end_line_misc_line($$$)
   my $source_info = shift;
 
   my $command = $current->{'parent'}->{'cmdname'};
-  if (!defined($command)) {
-    if (!defined($current->{'parent'}->{'extra'}->{'name'})) {
-      confess("No command and not linecommand");
-    }
-    $command = $current->{'parent'}->{'extra'}->{'name'};
-  }
   my $data_cmdname = $command;
 
   # we are in a command line context, so the @item command information is
@@ -3301,8 +3413,7 @@ sub _end_line_misc_line($$$)
   _isolate_last_space($self, $current);
 
   if ($current->{'parent'}->{'type'}
-      and ($current->{'parent'}->{'type'} eq 'def_line'
-           or $current->{'parent'}->{'type'} eq 'linemacro_call')) {
+      and $current->{'parent'}->{'type'} eq 'def_line') {
     $current = _end_line_def_line($self, $current, $source_info);
     return $current;
   }
@@ -3668,17 +3779,10 @@ sub _end_line_def_line($$$)
   my $top_context = $self->_top_context();
 
   my $context_command
-   = $self->_pop_context(['ct_def', 'ct_linecommand'], $source_info, $current);
-  if ($top_context eq 'ct_def') {
-    $def_command = $current->{'parent'}->{'extra'}->{'def_command'};
-  } else {
-    $self->{'in_parsing_only'}--;
-    $def_command = $context_command;
-    # or
-    # $def_command = $current->{'parent'}->{'extra'}->{'name'};
-  }
+   = $self->_pop_context(['ct_def'], $source_info, $current);
+  $def_command = $current->{'parent'}->{'extra'}->{'def_command'};
 
-  print STDERR "END DEF LINE $top_context $def_command; current "
+  print STDERR "END DEF LINE $def_command; current "
     .Texinfo::Common::debug_print_element($current, 1)."\n"
       if ($self->{'DEBUG'});
 
@@ -3687,73 +3791,6 @@ sub _end_line_def_line($$$)
   # now $current is the arguments container in case of linemacro
   $current = $current->{'parent'};
 
-  if ($top_context ne 'ct_def') {
-    # convert arguments back to Texinfo and substitute
-    my $macro_args = [];
-    my $macro = $self->{'macros'}->{$def_command}->{'element'};
-    my $args_total = scalar(@{$macro->{'args'}}) -1;
-    if ($args_total > 0) {
-      my $arg_index;
-      # the first argument is the macro name
-      for ($arg_index=1; $arg_index<=$args_total; $arg_index++) {
-        if (defined($macro->{'args'}->[$arg_index])) {
-          my $arg_name = $macro->{'args'}->[$arg_index]->{'text'};
-          if (exists($arguments->{$arg_name})) {
-            my $arg = $arguments->{$arg_name};
-            my $argument_text = '';
-            if ($arg->{'type'} and $arg->{'type'} eq 'bracketed_arg') {
-              if ($arg->{'contents'} or $arg->{'info'}) {
-                my $arg_element = {};
-                $arg_element->{'contents'}
-                  = $arg->{'contents'} if ($arg->{'contents'});
-                $arg_element->{'info'} = $arg->{'info'} if ($arg->{'info'});
-                $argument_text
-                 = Texinfo::Convert::Texinfo::convert_to_texinfo($arg_element);
-                #print STDERR "BBB '$argument_text' ".join('|', 
keys(%{$arg->{'info'}}))."\n";
-              }
-            } else {
-              $argument_text = 
Texinfo::Convert::Texinfo::convert_to_texinfo($arg);
-            }
-            push @$macro_args, {'contents' => [{'text' => $argument_text}]};
-          }
-        }
-      }
-    }
-    my $expanded = _expand_macro_body($self,
-                            $self->{'macros'}->{$def_command},
-                            $macro_args, $source_info);
-    print STDERR "LINEMACROBODY: $expanded".'||||||'."\n"
-      if ($self->{'DEBUG'});
-
-    # macro expansion lines with information on the
-    # pending text
-    _input_push_text($self, $expanded, $source_info->{'line_nr'},
-                     $def_command);
-    my $macro_source_mark = {'sourcemark_type' => 'linemacro_expansion',
-                             'status' => 'start'};
-    delete $current->{'args'}
-       if (scalar(@{$current->{'args'}}) == 0);
-    $macro_source_mark->{'element'} = $current;
-    $current = $current->{'parent'};
-    # remove linemacro call from the tree, it remains associated
-    # to the source mark
-    my $popped = _pop_element_from_contents($self, $current);
-    #if ($popped ne $macro_source_mark->{'element'}) {
-    #  $self->_bug_message("popped $popped ne $macro_source_mark->{'element'}"
-    #            ." in linemacro command call\n", $source_info, $current);
-    #}
-    #if (!$popped->{'type'} or $popped->{'type'} ne 'linemacro_call') {
-    #  $self->_bug_message("unexpected linemacro popped in parse_def "
-    #         .Texinfo::Common::debug_print_element($popped, 1),
-    #            $source_info, $current);
-    #}
-    delete $popped->{'parent'};
-    _register_source_mark($self, $current, $macro_source_mark);
-    $self->{'input'}->[0]->{'input_source_mark'} = $macro_source_mark;
-    return $current;
-  }
-
-
   if (scalar(keys(%$arguments)) == 0) {
     $self->_command_warn($current, $source_info,
                          __('missing category for @%s'),
@@ -4286,8 +4323,6 @@ sub _end_line($$$)
 
   my $current_old = $current;
 
-  my $in_macro_expansion;
-
   # a line consisting only of spaces.
   if ($current->{'contents'} and @{$current->{'contents'}}
       and $current->{'contents'}->[-1]->{'type'}
@@ -4357,28 +4392,13 @@ sub _end_line($$$)
   # misc command line arguments
   # Never go here if lineraw/noarg/...
   } elsif ($current->{'type'} and $current->{'type'} eq 'line_arg') {
-    if ($current->{'parent'}->{'type'}
-        and $current->{'parent'}->{'type'} eq 'linemacro_call') {
-      # we could have checked the context too
-      $in_macro_expansion = $current->{'parent'}->{'extra'}->{'name'};
-    }
     $current = _end_line_misc_line($self, $current, $source_info);
   }
 
   # this happens if there is a nesting of line @-commands on a line.
   # they are reprocessed here.
   my $top_context = $self->_top_context();
-  if ($top_context eq 'ct_line' or $top_context eq 'ct_def'
-      or $top_context eq 'ct_linecommand') {
-    if (defined($in_macro_expansion)) {
-      # if in a linemacro command call nested on a line, we do not close
-      # the preceding commands yet, as they might use the expansion
-      print STDERR "Expanded \@$in_macro_expansion still line/block"
-       ." $top_context: "
-       .Texinfo::Common::debug_print_element($current, 1)."\n"
-        if ($self->{'DEBUG'});
-      return $current;
-    }
+  if ($top_context eq 'ct_line' or $top_context eq 'ct_def') {
     print STDERR "Still opened line/block command $top_context: "
       .Texinfo::Common::debug_print_element($current, 1)."\n"
         if ($self->{'DEBUG'});
@@ -4387,11 +4407,6 @@ sub _end_line($$$)
             and $current->{'parent'}->{'type'} eq 'def_line')) {
         $current = _close_current($self, $current, $source_info);
       }
-    } elsif ($top_context eq 'ct_linecommand') {
-      while ($current->{'parent'} and !($current->{'parent'}->{'type'}
-              and $current->{'parent'}->{'type'} eq 'linemacro_call')) {
-        $current = _close_current($self, $current, $source_info);
-      }
     } else {
       while ($current->{'parent'} and !($current->{'type'}
              and ($current->{'type'} eq 'block_line_arg'
@@ -4812,7 +4827,11 @@ sub _handle_macro($$$$$)
                             'extra' => {'name' => $command},
                             'args' => []};
 
-  if ($expanded_macro->{'cmdname'} ne 'linemacro') {
+  if ($expanded_macro->{'cmdname'} eq 'linemacro') {
+    ($line, $source_info)
+     = _expand_linemacro_arguments($self, $expanded_macro, $line, $source_info,
+                                   $macro_call_element);
+  } else {
     my $args_number = scalar(@{$expanded_macro->{'args'}}) -1;
     if ($line =~ s/^\s*{(\s*)//) { # } macro with args
       if ($1 ne '') {
@@ -4893,10 +4912,6 @@ sub _handle_macro($$$$$)
   print STDERR "MACRO EXPANSION NUMBER $self->{'macro_expansion_nr'} 
$command\n"
     if ($self->{'DEBUG'});
 
-  if ($expanded_macro->{'cmdname'} eq 'linemacro') {
-    return ($macro_call_element, $line, $source_info);
-  }
-
   my $expanded = _expand_macro_body($self,
                             $self->{'macros'}->{$command},
                             $macro_call_element->{'args'}, $source_info);
@@ -4916,7 +4931,13 @@ sub _handle_macro($$$$$)
   print STDERR "MACROBODY: $expanded_macro_text".'||||||'."\n"
     if ($self->{'DEBUG'});
 
-  my $macro_source_mark = {'sourcemark_type' => 'macro_expansion',
+  my $sourcemark_type;
+  if ($expanded_macro->{'cmdname'} eq 'linemacro') {
+    $sourcemark_type = 'linemacro_expansion';
+  } else {
+    $sourcemark_type = 'macro_expansion';
+  }
+  my $macro_source_mark = {'sourcemark_type' => $sourcemark_type,
                            'status' => 'start'};
   $macro_source_mark->{'element'} = $macro_call_element;
   _register_source_mark($self, $current, $macro_source_mark);
@@ -5868,9 +5889,7 @@ sub _handle_open_brace($$$$)
             and (($current->{'parent'}->{'cmdname'}
                   and $current->{'parent'}->{'cmdname'} eq 'multitable')
                  or ($current->{'parent'}->{'type'}
-                     and ($current->{'parent'}->{'type'} eq 'def_line'
-                          or $current->{'parent'}->{'type'}
-                               eq 'linemacro_call')))) {
+                     and $current->{'parent'}->{'type'} eq 'def_line'))) {
     _abort_empty_line($self, $current);
     push @{$current->{'contents'}},
          { 'type' => 'bracketed_arg',
@@ -5901,8 +5920,7 @@ sub _handle_open_brace($$$$)
   # within an @-command as { is simply added as seen just above.
   } elsif ($self->_top_context() eq 'ct_math'
            or $self->_top_context() eq 'ct_rawpreformatted'
-           or $self->_top_context() eq 'ct_inlineraw'
-           or $self->_top_context() eq 'ct_linecommand') {
+           or $self->_top_context() eq 'ct_inlineraw') {
     _abort_empty_line($self, $current);
     my $balanced_braces = {'type' => 'balanced_braces',
                            'contents' => [],
@@ -6640,24 +6658,18 @@ sub _process_remaining_on_line($$$$)
             $macro_call_element->{'info'}->{'alias_of'} = $from_alias;
           }
         }
-        if ($macro_call_element
-            and $macro_call_element->{'type'} eq 'linemacro_call') {
-          # do nothing, the linemacro defined command call is done at the
-          # end of the line after parsing the line similarly as for @def*
-        } else {
-          $line = $arg_line;
-          if ($macro_call_element) {
-            # directly get the following input (macro expansion text) instead
-            # of going through the next call of process_remaining_on_line and
-            # the processing of empty text.  No difference in output, more
-            # efficient.
+        $line = $arg_line;
+        if ($macro_call_element) {
+          # directly get the following input (macro expansion text) instead
+          # of going through the next call of process_remaining_on_line and
+          # the processing of empty text.  No difference in output, more
+          # efficient.
 
-            ($line, $source_info) = _next_text($self, $current);
+          ($line, $source_info) = _next_text($self, $current);
 
-          }
-          return ($current, $line, $source_info, $retval);
-          # goto funexit;  # used in XS code
         }
+        return ($current, $line, $source_info, $retval);
+        # goto funexit;  # used in XS code
       }
       # expand value if it can change the line.  It considered again
       # together with other commands below for all the other cases
@@ -6788,9 +6800,7 @@ sub _process_remaining_on_line($$$$)
            __("command `\@%s' must not be followed by new line"),
            $current->{'cmdname'}), $source_info);
         my $top_context = $self->_top_context();
-        if ($top_context eq 'ct_line' or $top_context eq 'ct_def'
-            # FIXME check that it is correct and add a test case
-            or $top_context eq 'ct_linecommand') {
+        if ($top_context eq 'ct_line' or $top_context eq 'ct_def') {
           # do not consider the end of line to be possibly between
           # the @-command and the argument if at the end of a
           # line or block @-command.
@@ -6926,22 +6936,6 @@ sub _process_remaining_on_line($$$$)
       }
       return ($current, $line, $source_info, $retval);
       # goto funexit;  # used in XS code
-    } elsif ($macro_call_element) {
-      # linemacro defined command call
-      push @{$current->{'contents'}}, $macro_call_element;
-      $macro_call_element->{'parent'} = $current;
-      $self->_push_context('ct_linecommand', $command);
-      $self->{'in_parsing_only'}++;
-      $current = $macro_call_element;
-      $current->{'args'} = [];
-      my $line_arg = { 'type' => 'line_arg',
-                        'parent' => $current };
-      push @{$current->{'args'}}, $line_arg;
-      $current = $line_arg;
-      $line = _start_empty_line_after_command($line, $current,
-                                              $macro_call_element);
-      return ($current, $line, $source_info, $retval);
-      # goto funexit;  # used in XS code
     }
 
     if (defined($deprecated_commands{$command})) {
@@ -6950,13 +6944,7 @@ sub _process_remaining_on_line($$$$)
     }
 
     # special case with @ followed by a newline protecting end of lines
-    # in linemacro invokations and @def*
-    if ($self->_top_context() eq 'ct_linecommand' and $command eq "\n") {
-      my $command_e = {'cmdname' => $command, 'parent' => $current};
-      push @{$current->{'contents'}}, $command_e;
-      $retval = $GET_A_NEW_LINE;
-      return ($current, $line, $source_info, $retval);
-    }
+    # in @def*
     my $def_line_continuation
       = ($self->_top_context() eq 'ct_def' and $command eq "\n");
 
@@ -7131,16 +7119,6 @@ sub _parse_texi($$$)
     ($line, $source_info) = _next_text($self, $current);
     if (!defined($line)) {
       print STDERR "NEXT_LINE NO MORE\n" if ($self->{'DEBUG'});
-      # if we are in a linemacro command expansion and at the end
-      # of input, there may actually be more input after the expansion.
-      # So we call _end_line to trigger the expansion.
-      my @context_stack = $self->_get_context_stack;
-      foreach my $context (@context_stack) {
-        if ($context eq 'ct_linecommand') {
-          $current = _end_line($self, $current, $source_info);
-          next NEXT_LINE;
-        }
-      }
       last;
     }
     #print STDERR 
"@{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}}|$line"
@@ -7183,8 +7161,7 @@ sub _parse_texi($$$)
             and $current->{'parent'}->{'cmdname'} eq 'verb')
           )
         # not def line
-        and $self->_top_context() ne 'ct_def'
-        and $self->_top_context() ne 'ct_linecommand') {
+        and $self->_top_context() ne 'ct_def') {
       next NEXT_LINE if _check_line_directive ($self, $line, $source_info);
       print STDERR "BEGIN LINE\n" if ($self->{'DEBUG'});
 
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index ec0a6d7603..d5b11e5e82 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -148,7 +148,6 @@ reset_parser_except_conf (void)
 
   reset_obstacks ();
 
-  in_parsing_only = 0;
   current_node = current_section = current_part = 0;
 }
 
diff --git a/tp/Texinfo/XS/parsetexi/context_stack.c 
b/tp/Texinfo/XS/parsetexi/context_stack.c
index d6fb9c9ae9..fc142f541d 100644
--- a/tp/Texinfo/XS/parsetexi/context_stack.c
+++ b/tp/Texinfo/XS/parsetexi/context_stack.c
@@ -102,7 +102,6 @@ context_name (enum context c)
          : c == ct_line ? "ct_line"
          : c == ct_def ? "ct_def"
          : c == ct_brace_command ? "ct_brace_command"
-         : c == ct_linecommand ? "ct_linecommand"
          : "";
 }
 
diff --git a/tp/Texinfo/XS/parsetexi/context_stack.h 
b/tp/Texinfo/XS/parsetexi/context_stack.h
index dcf1c1a7b4..0ef0dc5a38 100644
--- a/tp/Texinfo/XS/parsetexi/context_stack.h
+++ b/tp/Texinfo/XS/parsetexi/context_stack.h
@@ -27,7 +27,6 @@ enum context {
     ct_math,
     ct_brace_command,
     ct_inlineraw,
-    ct_linecommand
 };
 
 /* Contexts where an empty line doesn't start a new paragraph. */
@@ -36,8 +35,7 @@ enum context {
    || (c) == ct_def \
    || (c) == ct_preformatted \
    || (c) == ct_rawpreformatted \
-   || (c) == ct_inlineraw \
-   || (c) == ct_linecommand)
+   || (c) == ct_inlineraw)
 
 void push_context (enum context c, enum command_id cmd);
 enum context pop_context (void);
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 972addc860..143b579e4d 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -649,162 +649,21 @@ end_line_def_line (ELEMENT *current)
   enum command_id top_cmd = current_context_command ();
   enum context top_context = pop_context ();
 
-  if (top_context != ct_def && top_context != ct_linecommand)
-    fatal ("def or linecommand context expected");
+  if (top_context != ct_def)
+    fatal ("def context expected");
 
-  if (top_context == ct_def)
-    {
-      k = lookup_extra (current->parent, "def_command");
-      def_command = lookup_command ((char *) k->value);
-    }
-  else
-    {
-      in_parsing_only--;
-      /* The following also works
-      k = lookup_extra (current->parent, "name");
-      def_command = lookup_command ((char *) k->value);
-      */
-      def_command = top_cmd;
-    }
+  k = lookup_extra (current->parent, "def_command");
+  def_command = lookup_command ((char *) k->value);
 
-  debug_nonl ("END DEF LINE %s %s; current ",
-     top_context == ct_def ? "ct_def"
-     : top_context == ct_linecommand ? "ct_linecommand" : "",
-     command_name(def_command));
+  debug_nonl ("END DEF LINE %s; current ",
+               command_name(def_command));
   debug_print_element (current, 1); debug ("");
 
   def_info = parse_def (def_command, current);
 
-  /* def_line or linemacro_call */
+  /* def_line */
   current = current->parent;
 
-  if (top_context != ct_def)
-    {
-      /* convert arguments tree elements back to Texinfo text and substitute */
-      int args_number;
-      MACRO *macro_record = lookup_macro (def_command);
-      ELEMENT *macro;
-      ELEMENT *macro_args = 0;
-      ELEMENT *popped;
-      TEXT expanded;
-      SOURCE_MARK *macro_source_mark;
-      char *expanded_macro_text;
-
-      if (!macro_record)
-        fatal ("no linemacro record for expansion");
-
-      text_init (&expanded);
-
-      macro = macro_record->element;
-      args_number = macro->args.number - 1;
-
-      if (args_number > 0)
-        {
-          int def_info_index;
-          macro_args = new_element (ET_NONE);
-          for (def_info_index = 0; def_info_index < args_number; 
def_info_index++)
-            {
-              char *argument_text;
-              ELEMENT *macro_arg_text;
-              ELEMENT *macro_arg_element;
-
-              if (!def_info[def_info_index])
-                break;
-              /* convert the argument to a Texinfo string */
-              if (def_info[def_info_index]->element)
-                {
-                  ELEMENT *arg = def_info[def_info_index]->element;
-                  if (arg->type == ET_bracketed_arg)
-                    {
-                      /* duplicate leading and trailing spaces info */
-                      ELEMENT *spaces_before
-                        = lookup_info_element (arg, "spaces_before_argument");
-                      ELEMENT *spaces_after
-                        = lookup_info_element (arg, "spaces_after_argument");
-
-                      if (arg->contents.number > 0
-                          || spaces_before || spaces_after)
-                        {
-                          ELEMENT *tmp_element = new_element (ET_NONE);
-                          tmp_element->contents = arg->contents;
-                          if (spaces_before)
-                            {
-                              ELEMENT *spaces_element = new_element (ET_NONE);
-                              text_append (&spaces_element->text,
-                                           (char *)spaces_before->text.text);
-                              add_info_element_oot (tmp_element,
-                                                    "spaces_before_argument",
-                                                    spaces_element);
-                            }
-                          if (spaces_after)
-                            {
-                              ELEMENT *spaces_element = new_element (ET_NONE);
-                              text_append (&spaces_element->text,
-                                           (char *)spaces_after->text.text);
-                              add_info_element_oot (tmp_element,
-                                                    "spaces_after_argument",
-                                                    spaces_element);
-                            }
-                          argument_text = convert_to_texinfo (tmp_element);
-                          tmp_element->contents.list = 0;
-                          destroy_element (tmp_element);
-                        }
-                      else
-                        argument_text = strdup("");
-                    }
-                  else
-                    argument_text = convert_to_texinfo (arg);
-                }
-              else
-                argument_text = strdup("");
-
-              free (def_info[def_info_index]->arg_type);
-              free (def_info[def_info_index]);
-
-              /* setup an argument suitable for expand_macro_body and
-                 add it to macro_args */
-              macro_arg_text = new_element (ET_NONE);
-              text_append (&macro_arg_text->text, argument_text);
-              free (argument_text);
-              macro_arg_element = new_element (ET_NONE);
-              add_to_element_contents (macro_arg_element, macro_arg_text);
-              add_to_element_args (macro_args, macro_arg_element);
-            }
-        }
-      free (def_info);
-
-      expand_macro_body (macro_record, macro_args, &expanded);
-      debug ("LINEMACROBODY: %s||||||", expanded.text);
-
-      if (expanded.text)
-        expanded_macro_text = expanded.text;
-      else
-        /* we want to always have a text for the source mark */
-        expanded_macro_text = strdup ("");
-      input_push_text (expanded_macro_text, current_source_info.line_nr,
-                       command_name(def_command), 0);
-
-      macro_source_mark = new_source_mark (SM_type_linemacro_expansion);
-      macro_source_mark->status = SM_status_start;
-      /* at this point current is the linemacro_call container,
-         associate it to the source mark */
-      macro_source_mark->element = current;
-
-      current = current->parent;
-      /* remove the linemacro_call container from the main tree.
-         The container holds the arguments Texinfo elements tree */
-      popped = pop_element_from_contents (current);
-      popped->parent = 0;
-
-      register_source_mark (current, macro_source_mark);
-      set_input_source_mark (macro_source_mark);
-
-      if (macro_args)
-        destroy_element_and_children (macro_args);
-
-      return current;
-    }
-
   /* Record the index entry if def_info is not empty. */
 
   while (def_info[i] != 0 && def_info[i]->element != 0)
@@ -1327,16 +1186,11 @@ end_line_misc_line (ELEMENT *current)
   if (cmd == CM_item)
     data_cmd = CM_item_LINE;
 
-  if (!cmd && !current->parent->type == ET_linemacro_call)
-    fatal ("command name unknown for line command end");
-
-  /* FIXME add a condition to avoid linecommands? */
   if (command_data(data_cmd).flags & CF_contain_basic_inline)
     (void) pop_command (&nesting_context.basic_inline_stack_on_line);
   isolate_last_space (current);
 
-  if (current->parent->type == ET_def_line
-      || current->parent->type == ET_linemacro_call)
+  if (current->parent->type == ET_def_line)
     return end_line_def_line (current);
 
   current = current->parent;
@@ -1859,7 +1713,6 @@ ELEMENT *
 end_line (ELEMENT *current)
 {
   ELEMENT *current_old = current; /* Used at very end of function */
-  char *in_macro_expansion = 0;
 
   /* If empty line, start a new paragraph. */
   if (last_contents_child (current)
@@ -1930,28 +1783,13 @@ end_line (ELEMENT *current)
 
   else if (current->type == ET_line_arg)
     {
-      if (current->parent->type == ET_linemacro_call)
-        {
-          KEY_PAIR *k = lookup_extra (current->parent, "name");
-          in_macro_expansion = (char *)k->value;
-        }
       current = end_line_misc_line (current);
     }
 
   /* 'line' or 'def' at top of "context stack" - this happens when
      line commands are nested (always incorrectly?) */
-  if (current_context () == ct_line || current_context () == ct_def
-       || current_context () == ct_linecommand)
+  if (current_context () == ct_line || current_context () == ct_def)
     {
-      if (in_macro_expansion)
-        /* if in a linemacro command call nested on a line, we do not close
-           the preceding commands yet, as they might use the expansion */
-        {
-          debug_nonl ("Expanded @%s still line/block %s: ", in_macro_expansion,
-                      context_name (current_context ()));
-          debug_print_element (current, 1); debug("");
-          return current;
-        }
       debug_nonl ("Still opened line/block command %s: ",
                   context_name (current_context ()));
       debug_print_element (current, 1); debug("");
@@ -1963,14 +1801,6 @@ end_line (ELEMENT *current)
               current = close_current (current, 0, 0);
             }
         }
-      else if (current_context () == ct_linecommand)
-        {
-          while (current->parent
-                 && current->parent->type != ET_linemacro_call)
-            {
-              current = close_current (current, 0, 0);
-            }
-        }
       else
         {
           while (current->parent
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index afe2e1eb8d..c1cf1aea06 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <stdio.h>
 
 #include "parser.h"
 #include "debug.h"
@@ -27,6 +28,8 @@
 #include "source_marks.h"
 #include "macro.h"
 
+COUNTER count_toplevel_braces;
+
 static MACRO *macro_list;
 static size_t macro_number;
 static size_t macro_space;
@@ -421,6 +424,210 @@ funexit:
   *line_inout = line;
 }
 
+void
+set_toplevel_braces_nr (COUNTER *counter, ELEMENT* element)
+{
+  int toplevel_braces_nr = counter_value (counter,
+                                          element);
+  if (toplevel_braces_nr)
+    add_extra_integer (element,
+                       "toplevel_braces_nr",
+                       toplevel_braces_nr);
+  counter_pop (counter);
+}
+
+void
+expand_linemacro_arguments (ELEMENT *macro, char **line_inout,
+                            enum command_id cmd, ELEMENT *current)
+{
+  char *line = *line_inout;
+  char *pline = line;
+  TEXT *arg;
+  int braces_level = 0;
+  int args_total;
+  int spaces_nr;
+  int i;
+  ELEMENT *argument = new_element (ET_NONE);
+  ELEMENT *argument_content = new_element (ET_NONE);
+  counter_push (&count_toplevel_braces, argument_content, 0);
+
+  add_to_element_args (current, argument);
+  text_append_n (&argument_content->text, "", 0);
+  add_to_element_contents (argument, argument_content);
+  arg = &(argument_content->text);
+
+  spaces_nr = strspn (pline, whitespace_chars_except_newline);
+  if (spaces_nr)
+    {
+      ELEMENT *spaces_element = new_element (ET_NONE);
+      text_append_n (&spaces_element->text, line, spaces_nr);
+      add_info_element_oot (argument, "spaces_before_argument",
+                            spaces_element);
+
+      pline += spaces_nr;
+    }
+
+  args_total = macro->args.number - 1;
+
+  while (1)
+    {
+      /* At the beginning of this loop pline is at the start
+         of an argument. */
+      char *sep;
+
+      sep = pline + strcspn (pline, linecommand_expansion_delimiters);
+      if (!*sep)
+        {
+          debug ("LINEMACRO ARG end of line %d", braces_level);
+          if (braces_level > 0)
+            {
+              text_append (arg, pline);
+
+              line = new_line (argument);
+              if (!line)
+                {
+                  line_error ("@%s missing closing brace", command_name (cmd));
+                  line = "";
+                  goto funexit;
+                }
+            }
+          else
+            {
+              int text_len = strcspn (pline, "\n");
+              if (*(pline + text_len) == '\n')
+                {
+                  text_append_n (arg, pline, text_len);
+                  line = pline + text_len;
+                  goto funexit;
+                }
+              else
+                {
+                  text_append (arg, pline);
+                  line = new_line (argument);
+                  if (!line)
+                    {
+                    /* happens when @ protects the end of line, at the very end
+                       of a text fragment and probably with macro expansion */
+                      line = "";
+                      goto funexit;
+                    }
+                }
+            }
+          pline = line;
+          continue;
+        }
+
+      text_append_n (arg, pline, sep - pline);
+
+      switch (*sep)
+        {
+        case '@':
+          int single_char;
+          char *command;
+          enum command_id cmd;
+          text_append_n (arg, sep, 1);
+          pline = sep + 1;
+          command = parse_command_name (&pline, &single_char);
+          if (command)
+            {
+              enum command_id cmd = lookup_command (command);
+              text_append (arg, command);
+              if (cmd && (command_data(cmd).flags & CF_brace)
+                  && strchr (whitespace_chars, *pline)
+                  && ((command_flags(current) & CF_accent)
+                   || conf.ignore_space_after_braced_command_name))
+                {
+                  int whitespaces_len = strspn (pline, whitespace_chars);
+                  text_append_n (arg, pline, whitespaces_len);
+                  pline += whitespaces_len;
+                }
+            }
+          break;
+        case '{':
+          braces_level++;
+          text_append_n (arg, sep, 1);
+          pline = sep + 1;
+          break;
+        case '}':
+          braces_level--;
+          text_append_n (arg, sep, 1);
+          pline = sep + 1;
+          if (braces_level == 0)
+            counter_inc (&count_toplevel_braces);
+          break;
+        /* spaces */
+        default:
+          int whitespaces_len;
+          pline = sep;
+          whitespaces_len = strspn (pline, whitespace_chars_except_newline);
+
+          if (braces_level > 0
+              || current->args.number >= args_total)
+            {
+              text_append_n (arg, pline, whitespaces_len);
+            }
+          else
+            {
+
+              set_toplevel_braces_nr (&count_toplevel_braces,
+                                      argument_content);
+
+              argument = new_element (ET_NONE);
+              argument_content = new_element (ET_NONE);
+              counter_push (&count_toplevel_braces, argument_content, 0);
+
+              add_to_element_args (current, argument);
+              text_append_n (&argument_content->text, "", 0);
+              add_to_element_contents (argument, argument_content);
+              arg = &(argument_content->text);
+
+              ELEMENT *spaces_element = new_element (ET_NONE);
+              text_append_n (&spaces_element->text, pline,
+                             whitespaces_len);
+              add_info_element_oot (argument, "spaces_before_argument",
+                                    spaces_element);
+              debug ("LINEMACRO NEW ARG");
+            }
+          pline += whitespaces_len;
+          break;
+        }
+    }
+
+ funexit:
+  set_toplevel_braces_nr (&count_toplevel_braces,
+                          argument_content);
+  for (i = 0; i < current->args.number; i++)
+    {
+      ELEMENT *argument_content = current->args.list[i]->contents.list[0];
+      KEY_PAIR *k = lookup_extra (argument_content, "toplevel_braces_nr");
+      if (k)
+        {
+          if ((intptr_t) k->value == 1)
+            {
+              int text_len = strlen(argument_content->text.text);
+              if (argument_content->text.text[0] == '{'
+                  && argument_content->text.text[text_len -1] == '}')
+                {
+                  char *braced_text = strdup (argument_content->text.text);
+                  debug_nonl ("TURN to bracketed %d ", i);
+                  debug_print_element (argument_content, 0); debug ("");
+
+                  text_reset (&argument_content->text);
+                  text_append_n (&argument_content->text,
+                                 braced_text+1, text_len -2);
+                  free(braced_text);
+                  argument_content->type = ET_bracketed_arg;
+                }
+            }
+
+          k->key = "";
+          k->type = extra_deleted;
+        }
+    }
+  debug ("END LINEMACRO ARGS EXPANSION");
+
+  *line_inout = line;
+}
 /* ARGUMENTS element holds the arguments used in the macro invocation.
    EXPANDED gets the result of the expansion. */
 void
@@ -434,7 +641,7 @@ expand_macro_body (MACRO *macro_record, ELEMENT *arguments, 
TEXT *expanded)
   macro = macro_record->element;
 
   macrobody = macro_record->macrobody;
-  
+
   /* Initialize TEXT object. */
   expanded->end = 0;
 
@@ -584,7 +791,11 @@ handle_macro (ELEMENT *current, char **line_inout, enum 
command_id cmd)
 
   add_extra_string_dup (macro_call_element, "name", command_name(cmd));
 
-  if (macro->cmd != CM_linemacro)
+  if (macro->cmd == CM_linemacro)
+    {
+      expand_linemacro_arguments (macro, &line, cmd, macro_call_element);
+    }
+  else
     {
       /* Get number of args. - 1 for the macro name. */
       args_number = macro->args.number - 1;
@@ -702,9 +913,6 @@ handle_macro (ELEMENT *current, char **line_inout, enum 
command_id cmd)
 
   debug ("MACRO EXPANSION NUMBER %d %s", macro_expansion_nr, 
command_name(cmd));
 
-  if (macro->cmd == CM_linemacro)
-    goto funexit;
-
   expand_macro_body (macro_record, macro_call_element, &expanded);
 
   if (expanded.text)
@@ -719,7 +927,10 @@ handle_macro (ELEMENT *current, char **line_inout, enum 
command_id cmd)
 
   debug ("MACROBODY: %s||||||", expanded_macro_text);
 
-  macro_source_mark = new_source_mark (SM_type_macro_expansion);
+  if (macro->cmd == CM_linemacro)
+    macro_source_mark = new_source_mark (SM_type_linemacro_expansion);
+  else
+    macro_source_mark = new_source_mark (SM_type_macro_expansion);
   macro_source_mark->status = SM_status_start;
   macro_source_mark->element = macro_call_element;
   register_source_mark (current, macro_source_mark);
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 6056a2a0ae..e816c84491 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -34,7 +34,12 @@ const char *digit_chars = "0123456789";
 
 /* in the perl parser, comments including whitespace_chars_except_newline
    show where code should be changed if the list of characters changes here */
-const char *whitespace_chars_except_newline = " \t\v\f";
+#define WHITESPACE_CHARS_EXCEPT_NEWLINE " \t\v\f"
+const char *whitespace_chars_except_newline = WHITESPACE_CHARS_EXCEPT_NEWLINE;
+
+const char *linecommand_expansion_delimiters = WHITESPACE_CHARS_EXCEPT_NEWLINE
+                                               "{}@";
+#undef WHITESPACE_CHARS_EXCEPT_NEWLINE
 
 /* count characters, not bytes. */
 size_t
@@ -187,8 +192,6 @@ check_space_element (ELEMENT *e)
   return 1;
 }
 
-int in_parsing_only = 0;
-
 
 /* Current node, section and part. */
 
@@ -1761,14 +1764,7 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
           if (from_alias != CM_NONE)
             add_info_string_dup (macro_call_element, "alias_of",
                                  command_name (from_alias));
-        }
-      if (macro_call_element && macro_call_element->type == ET_linemacro_call)
-       /* do nothing, the linemacro defined command call is done at the
-          end of the line after parsing the line similarly as for @def* */
-        {
-        }
-      else if (macro_call_element)
-        {
+
           /* directly get the following input (macro expansion text) instead
              of going through the next call of process_remaining_on_line and
              the processing of empty text.  No difference in output, more
@@ -1964,9 +1960,7 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
                    line_warn ("command `@%s' must not be followed by new line",
                               command_name(current->cmd));
                    if (current_context() == ct_def
-                       || current_context() == ct_line
-                     /* FIXME check that it is correct and add a test case */
-                       || current_context() == ct_linecommand)
+                       || current_context() == ct_line)
                      {
                     /* do not consider the end of line to be possibly between
                        the @-command and the argument if at the end of a
@@ -2176,19 +2170,6 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
               goto funexit;
             }
         }
-      else if (macro_call_element)
-        {
-          ELEMENT *line_arg = new_element (ET_line_arg);
-
-          add_to_element_contents (current, macro_call_element);
-          push_context (ct_linecommand, cmd);
-          in_parsing_only++;
-          current = macro_call_element;
-          add_to_element_args (current, line_arg);
-          current = line_arg;
-          start_empty_line_after_command (current, &line, macro_call_element);
-          goto funexit;
-        }
 
       /* Warn on deprecated command */
       if (command_data(cmd).flags & CF_deprecated)
@@ -2209,15 +2190,7 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
         }
 
       /* special case with @ followed by a newline protecting end of lines
-         in linemacro invokations and @def* */
-      if (current_context () == ct_linecommand && cmd == CM_NEWLINE)
-        {
-          ELEMENT *command_e = new_element (ET_NONE);
-          command_e->cmd = cmd;
-          add_to_element_contents (current, command_e);
-          retval = GET_A_NEW_LINE;
-          goto funexit;
-        }
+         in  @def* */
       def_line_continuation = (current_context() == ct_def
                                && cmd == CM_NEWLINE);
 
@@ -2519,16 +2492,6 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
       if (!allocated_line)
         {
           debug ("NEXT_LINE NO MORE");
-          if (in_context (ct_linecommand))
-            {
-              /*
-              if we are in a linemacro command expansion and at the end
-              of input, there may actually be more input after the expansion.
-              So we call end_line to trigger the expansion.
-              */
-              current = end_line (current);
-              continue;
-            }
           break; /* Out of input. */
         }
 
@@ -2545,8 +2508,7 @@ parse_texi (ELEMENT *root_elt, ELEMENT *current_elt)
                  || (command_data(current->cmd).data == BLOCK_format_raw
                      && !format_expanded_p (command_name(current->cmd)))))
             || current->parent && current->parent->cmd == CM_verb)
-          && current_context () != ct_def
-          && current_context () != ct_linecommand)
+          && current_context () != ct_def)
         {
           ELEMENT *e;
           int n;
diff --git a/tp/Texinfo/XS/parsetexi/parser.h b/tp/Texinfo/XS/parsetexi/parser.h
index d0157dac6f..8ee32cf4e2 100644
--- a/tp/Texinfo/XS/parsetexi/parser.h
+++ b/tp/Texinfo/XS/parsetexi/parser.h
@@ -186,6 +186,7 @@ void set_accept_internalvalue (void);
 char *element_type_name (ELEMENT *e);
 int check_space_element (ELEMENT *e);
 void gather_spaces_after_cmd_before_arg (ELEMENT *current);
+char *parse_command_name (char **ptr, int *single_char);
 
 /* Return values */
 #define GET_A_NEW_LINE 0
@@ -193,10 +194,9 @@ void gather_spaces_after_cmd_before_arg (ELEMENT *current);
 #define FINISHED_TOTALLY 2
 
 extern const char *whitespace_chars, *whitespace_chars_except_newline;
+extern const char *linecommand_expansion_delimiters;
 extern const char *digit_chars;
 
-extern int in_parsing_only;
-
 extern ELEMENT *current_node;
 extern ELEMENT *current_section;
 extern ELEMENT *current_part;
diff --git a/tp/Texinfo/XS/parsetexi/separator.c 
b/tp/Texinfo/XS/parsetexi/separator.c
index 9e22b2dd15..e6d3f4a489 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -210,8 +210,7 @@ handle_open_brace (ELEMENT *current, char **line_inout)
    */
   else if (current_context() == ct_math
            || current_context() == ct_rawpreformatted
-           || current_context() == ct_inlineraw
-           || current_context() == ct_linecommand)
+           || current_context() == ct_inlineraw)
     {
       ELEMENT *b = new_element (ET_balanced_braces);
       ELEMENT *open_brace = new_element (ET_NONE);
diff --git a/tp/t/65linemacro.t b/tp/t/65linemacro.t
index 9a96505889..64fd3f385b 100644
--- a/tp/t/65linemacro.t
+++ b/tp/t/65linemacro.t
@@ -41,8 +41,6 @@ Some text @mycommand {a
  call}
 and after.
 '],
-# FIXME currently incorrect output, probably because @end is handled
-# when the linemacro is processed.
 ['blockitem_no_item',
 '@linemacro mycommand {a, b, c}
 \a\, \b\ \c\
@@ -227,9 +225,8 @@ inside {\a\ operator \b\} \rest\
 @outside {type} {a function} @inside {X} {Y} ( remaining, type typed )
 @end defblock
 '],
-# following example has incorrect braces in many places and
-# in particular the bracketed opened with @inside in it is
-# not closed, this makes it an interesting case.
+# note that the bracketed in @inside ends up on the @cindex line where
+# it is not valid
 ['nested_linemacro_calls',
 '@linemacro inside {a, b}
 inside {\a\ operator \b\}
@@ -244,7 +241,6 @@ inside {\a\ operator \b\}
 @outside {type} {@inside {X} {Y}} ( remaining, type typed )
 @end defblock
 '],
-# FIXME this construct is ok in Texinfo TeX, should be valid
 ['end_conditional_in_linemacro',
 '@linemacro lm {a}
 \a\
diff --git a/tp/t/results/linemacro/api_doc_with_linemacro.pl 
b/tp/t/results/linemacro/api_doc_with_linemacro.pl
index d04278660b..85bb6426dd 100644
--- a/tp/t/results/linemacro/api_doc_with_linemacro.pl
+++ b/tp/t/results/linemacro/api_doc_with_linemacro.pl
@@ -498,43 +498,37 @@ $result_trees{'api_doc_with_linemacro'} = {
                                     'contents' => [
                                       {
                                         'text' => 'a'
-                                      },
-                                      {
-                                        'extra' => {
-                                          'def_role' => 'spaces'
-                                        },
-                                        'text' => ' ',
-                                        'type' => 'spaces'
-                                      },
+                                      }
+                                    ],
+                                    'info' => {
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
+                                      }
+                                    }
+                                  },
+                                  {
+                                    'contents' => [
                                       {
                                         'text' => 'array_like'
                                       }
                                     ],
                                     'info' => {
-                                      'spaces_after_argument' => {
-                                        'text' => '
-'
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
                                       }
-                                    },
-                                    'type' => 'line_arg'
+                                    }
                                   }
                                 ],
                                 'extra' => {
                                   'name' => 'param'
                                 },
-                                'info' => {
-                                  'spaces_before_argument' => {
-                                    'text' => ' '
-                                  }
-                                },
                                 'type' => 'linemacro_call'
                               },
                               'sourcemark_type' => 'linemacro_expansion',
                               'status' => 'start'
                             }
                           ],
-                          'text' => '',
-                          'type' => 'empty_line'
+                          'text' => ''
                         }
                       ],
                       'type' => 'def_item'
@@ -603,7 +597,14 @@ $result_trees{'api_doc_with_linemacro'} = {
                                 'file_name' => '',
                                 'line_nr' => 19,
                                 'macro' => 'param'
-                              }
+                              },
+                              'source_marks' => [
+                                {
+                                  'counter' => 1,
+                                  'sourcemark_type' => 'linemacro_expansion',
+                                  'status' => 'end'
+                                }
+                              ]
                             }
                           ],
                           'info' => {
@@ -632,13 +633,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                         'line_nr' => 19,
                         'macro' => 'param'
                       },
-                      'source_marks' => [
-                        {
-                          'counter' => 1,
-                          'sourcemark_type' => 'linemacro_expansion',
-                          'status' => 'end'
-                        }
-                      ],
                       'type' => 'def_line'
                     },
                     {
@@ -652,11 +646,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                           ],
                           'type' => 'paragraph'
                         },
-                        {
-                          'text' => '
-',
-                          'type' => 'empty_line'
-                        },
                         {
                           'source_marks' => [
                             {
@@ -667,57 +656,39 @@ $result_trees{'api_doc_with_linemacro'} = {
                                     'contents' => [
                                       {
                                         'text' => 'n'
-                                      },
-                                      {
-                                        'extra' => {
-                                          'def_role' => 'spaces'
-                                        },
-                                        'text' => ' ',
-                                        'type' => 'spaces'
-                                      },
+                                      }
+                                    ],
+                                    'info' => {
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
+                                      }
+                                    }
+                                  },
+                                  {
+                                    'contents' => [
                                       {
-                                        'contents' => [
-                                          {
-                                            'text' => 'int,'
-                                          },
-                                          {
-                                            'extra' => {
-                                              'def_role' => 'spaces'
-                                            },
-                                            'text' => ' ',
-                                            'type' => 'spaces'
-                                          },
-                                          {
-                                            'text' => 'optional'
-                                          }
-                                        ],
-                                        'type' => 'def_aggregate'
+                                        'text' => 'int, optional'
                                       }
                                     ],
                                     'info' => {
-                                      'spaces_after_argument' => {
-                                        'text' => '
-'
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
                                       }
-                                    },
-                                    'type' => 'line_arg'
+                                    }
                                   }
                                 ],
                                 'extra' => {
                                   'name' => 'param'
                                 },
-                                'info' => {
-                                  'spaces_before_argument' => {
-                                    'text' => ' '
-                                  }
-                                },
                                 'type' => 'linemacro_call'
                               },
+                              'position' => 1,
                               'sourcemark_type' => 'linemacro_expansion',
                               'status' => 'start'
                             }
                           ],
-                          'text' => '',
+                          'text' => '
+',
                           'type' => 'empty_line'
                         }
                       ],
@@ -787,7 +758,14 @@ $result_trees{'api_doc_with_linemacro'} = {
                                 'file_name' => '',
                                 'line_nr' => 22,
                                 'macro' => 'param'
-                              }
+                              },
+                              'source_marks' => [
+                                {
+                                  'counter' => 2,
+                                  'sourcemark_type' => 'linemacro_expansion',
+                                  'status' => 'end'
+                                }
+                              ]
                             }
                           ],
                           'info' => {
@@ -816,13 +794,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                         'line_nr' => 22,
                         'macro' => 'param'
                       },
-                      'source_marks' => [
-                        {
-                          'counter' => 2,
-                          'sourcemark_type' => 'linemacro_expansion',
-                          'status' => 'end'
-                        }
-                      ],
                       'type' => 'def_line'
                     },
                     {
@@ -861,11 +832,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                           ],
                           'type' => 'paragraph'
                         },
-                        {
-                          'text' => '
-',
-                          'type' => 'empty_line'
-                        },
                         {
                           'source_marks' => [
                             {
@@ -876,57 +842,39 @@ $result_trees{'api_doc_with_linemacro'} = {
                                     'contents' => [
                                       {
                                         'text' => 'axis'
-                                      },
-                                      {
-                                        'extra' => {
-                                          'def_role' => 'spaces'
-                                        },
-                                        'text' => ' ',
-                                        'type' => 'spaces'
-                                      },
+                                      }
+                                    ],
+                                    'info' => {
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
+                                      }
+                                    }
+                                  },
+                                  {
+                                    'contents' => [
                                       {
-                                        'contents' => [
-                                          {
-                                            'text' => 'int,'
-                                          },
-                                          {
-                                            'extra' => {
-                                              'def_role' => 'spaces'
-                                            },
-                                            'text' => ' ',
-                                            'type' => 'spaces'
-                                          },
-                                          {
-                                            'text' => 'optional'
-                                          }
-                                        ],
-                                        'type' => 'def_aggregate'
+                                        'text' => 'int, optional'
                                       }
                                     ],
                                     'info' => {
-                                      'spaces_after_argument' => {
-                                        'text' => '
-'
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
                                       }
-                                    },
-                                    'type' => 'line_arg'
+                                    }
                                   }
                                 ],
                                 'extra' => {
                                   'name' => 'param'
                                 },
-                                'info' => {
-                                  'spaces_before_argument' => {
-                                    'text' => ' '
-                                  }
-                                },
                                 'type' => 'linemacro_call'
                               },
+                              'position' => 1,
                               'sourcemark_type' => 'linemacro_expansion',
                               'status' => 'start'
                             }
                           ],
-                          'text' => '',
+                          'text' => '
+',
                           'type' => 'empty_line'
                         }
                       ],
@@ -996,7 +944,14 @@ $result_trees{'api_doc_with_linemacro'} = {
                                 'file_name' => '',
                                 'line_nr' => 26,
                                 'macro' => 'param'
-                              }
+                              },
+                              'source_marks' => [
+                                {
+                                  'counter' => 3,
+                                  'sourcemark_type' => 'linemacro_expansion',
+                                  'status' => 'end'
+                                }
+                              ]
                             }
                           ],
                           'info' => {
@@ -1025,13 +980,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                         'line_nr' => 26,
                         'macro' => 'param'
                       },
-                      'source_marks' => [
-                        {
-                          'counter' => 3,
-                          'sourcemark_type' => 'linemacro_expansion',
-                          'status' => 'end'
-                        }
-                      ],
                       'type' => 'def_line'
                     },
                     {
@@ -1045,11 +993,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                           ],
                           'type' => 'paragraph'
                         },
-                        {
-                          'text' => '
-',
-                          'type' => 'empty_line'
-                        },
                         {
                           'source_marks' => [
                             {
@@ -1060,57 +1003,39 @@ $result_trees{'api_doc_with_linemacro'} = {
                                     'contents' => [
                                       {
                                         'text' => 'out'
-                                      },
-                                      {
-                                        'extra' => {
-                                          'def_role' => 'spaces'
-                                        },
-                                        'text' => ' ',
-                                        'type' => 'spaces'
-                                      },
+                                      }
+                                    ],
+                                    'info' => {
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
+                                      }
+                                    }
+                                  },
+                                  {
+                                    'contents' => [
                                       {
-                                        'contents' => [
-                                          {
-                                            'text' => 'complex'
-                                          },
-                                          {
-                                            'extra' => {
-                                              'def_role' => 'spaces'
-                                            },
-                                            'text' => ' ',
-                                            'type' => 'spaces'
-                                          },
-                                          {
-                                            'text' => 'ndarray'
-                                          }
-                                        ],
-                                        'type' => 'def_aggregate'
+                                        'text' => 'complex ndarray'
                                       }
                                     ],
                                     'info' => {
-                                      'spaces_after_argument' => {
-                                        'text' => '
-'
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
                                       }
-                                    },
-                                    'type' => 'line_arg'
+                                    }
                                   }
                                 ],
                                 'extra' => {
                                   'name' => 'returns'
                                 },
-                                'info' => {
-                                  'spaces_before_argument' => {
-                                    'text' => ' '
-                                  }
-                                },
                                 'type' => 'linemacro_call'
                               },
+                              'position' => 1,
                               'sourcemark_type' => 'linemacro_expansion',
                               'status' => 'start'
                             }
                           ],
-                          'text' => '',
+                          'text' => '
+',
                           'type' => 'empty_line'
                         }
                       ],
@@ -1190,7 +1115,14 @@ $result_trees{'api_doc_with_linemacro'} = {
                                 'file_name' => '',
                                 'line_nr' => 29,
                                 'macro' => 'returns'
-                              }
+                              },
+                              'source_marks' => [
+                                {
+                                  'counter' => 4,
+                                  'sourcemark_type' => 'linemacro_expansion',
+                                  'status' => 'end'
+                                }
+                              ]
                             }
                           ],
                           'info' => {
@@ -1219,13 +1151,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                         'line_nr' => 29,
                         'macro' => 'returns'
                       },
-                      'source_marks' => [
-                        {
-                          'counter' => 4,
-                          'sourcemark_type' => 'linemacro_expansion',
-                          'status' => 'end'
-                        }
-                      ],
                       'type' => 'def_line'
                     },
                     {
@@ -1239,11 +1164,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                           ],
                           'type' => 'paragraph'
                         },
-                        {
-                          'text' => '
-',
-                          'type' => 'empty_line'
-                        },
                         {
                           'source_marks' => [
                             {
@@ -1257,29 +1177,24 @@ $result_trees{'api_doc_with_linemacro'} = {
                                       }
                                     ],
                                     'info' => {
-                                      'spaces_after_argument' => {
-                                        'text' => '
-'
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
                                       }
-                                    },
-                                    'type' => 'line_arg'
+                                    }
                                   }
                                 ],
                                 'extra' => {
                                   'name' => 'raises'
                                 },
-                                'info' => {
-                                  'spaces_before_argument' => {
-                                    'text' => ' '
-                                  }
-                                },
                                 'type' => 'linemacro_call'
                               },
+                              'position' => 1,
                               'sourcemark_type' => 'linemacro_expansion',
                               'status' => 'start'
                             }
                           ],
-                          'text' => '',
+                          'text' => '
+',
                           'type' => 'empty_line'
                         }
                       ],
@@ -1316,6 +1231,14 @@ $result_trees{'api_doc_with_linemacro'} = {
                               'extra' => {
                                 'def_role' => 'name'
                               },
+                              'source_marks' => [
+                                {
+                                  'counter' => 5,
+                                  'position' => 10,
+                                  'sourcemark_type' => 'linemacro_expansion',
+                                  'status' => 'end'
+                                }
+                              ],
                               'text' => 'IndexError'
                             }
                           ],
@@ -1345,13 +1268,6 @@ $result_trees{'api_doc_with_linemacro'} = {
                         'line_nr' => 32,
                         'macro' => 'raises'
                       },
-                      'source_marks' => [
-                        {
-                          'counter' => 5,
-                          'sourcemark_type' => 'linemacro_expansion',
-                          'status' => 'end'
-                        }
-                      ],
                       'type' => 'def_line'
                     },
                     {
diff --git a/tp/t/results/linemacro/blockitem_no_item.pl 
b/tp/t/results/linemacro/blockitem_no_item.pl
index b997b0c1d4..0faa2d12cd 100644
--- a/tp/t/results/linemacro/blockitem_no_item.pl
+++ b/tp/t/results/linemacro/blockitem_no_item.pl
@@ -107,10 +107,6 @@ $result_trees{'blockitem_no_item'} = {
               'contents' => [
                 {
                   'contents' => [
-                    {
-                      'text' => 'AA
-'
-                    },
                     {
                       'source_marks' => [
                         {
@@ -121,63 +117,59 @@ $result_trees{'blockitem_no_item'} = {
                                 'contents' => [
                                   {
                                     'text' => 'd'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              },
+                              {
+                                'contents' => [
                                   {
                                     'text' => 'e'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              },
+                              {
+                                'contents' => [
                                   {
-                                    'contents' => [
-                                      {
-                                        'text' => 'f'
-                                      },
-                                      {
-                                        'extra' => {
-                                          'def_role' => 'spaces'
-                                        },
-                                        'text' => ' ',
-                                        'type' => 'spaces'
-                                      },
-                                      {
-                                        'cmdname' => '
-'
-                                      }
-                                    ],
-                                    'type' => 'def_aggregate'
+                                    'text' => 'f @
+@end itemize'
                                   }
                                 ],
-                                'type' => 'line_arg'
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
                               }
                             ],
                             'extra' => {
                               'name' => 'mycommand'
                             },
-                            'info' => {
-                              'spaces_before_argument' => {
-                                'text' => ' '
-                              }
-                            },
                             'type' => 'linemacro_call'
                           },
+                          'position' => 3,
                           'sourcemark_type' => 'linemacro_expansion',
                           'status' => 'start'
                         }
                       ],
-                      'text' => '',
-                      'type' => 'empty_line'
+                      'text' => 'AA
+'
+                    },
+                    {
+                      'text' => 'd, e f '
+                    },
+                    {
+                      'cmdname' => '
+'
                     }
                   ],
                   'type' => 'paragraph'
@@ -190,6 +182,14 @@ $result_trees{'blockitem_no_item'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 7,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'itemize'
                     }
                   ],
@@ -214,7 +214,7 @@ $result_trees{'blockitem_no_item'} = {
               'source_info' => {
                 'file_name' => '',
                 'line_nr' => 8,
-                'macro' => ''
+                'macro' => 'mycommand'
               }
             }
           ],
@@ -226,31 +226,6 @@ $result_trees{'blockitem_no_item'} = {
             'line_nr' => 5,
             'macro' => ''
           }
-        },
-        {
-          'contents' => [
-            {
-              'text' => 'd, e f '
-            },
-            {
-              'cmdname' => '
-'
-            }
-          ],
-          'type' => 'paragraph'
-        },
-        {
-          'source_marks' => [
-            {
-              'counter' => 1,
-              'position' => 1,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ],
-          'text' => '
-',
-          'type' => 'empty_line'
         }
       ],
       'type' => 'before_node_section'
@@ -266,27 +241,16 @@ $result_texis{'blockitem_no_item'} = '@linemacro 
mycommand {a, b, c}
 
 @itemize
 AA
-@end itemize
 d, e f @
-
+@end itemize
 ';
 
 
 $result_texts{'blockitem_no_item'} = '
 AA
-d, e f  
-';
+d, e f  ';
 
 $result_errors{'blockitem_no_item'} = [
-  {
-    'error_line' => 'warning: @end should only appear at the beginning of a 
line
-',
-    'file_name' => '',
-    'line_nr' => 8,
-    'macro' => '',
-    'text' => '@end should only appear at the beginning of a line',
-    'type' => 'warning'
-  },
   {
     'error_line' => 'warning: @itemize has text but no @item
 ',
diff --git a/tp/t/results/linemacro/brace_command_not_closed.pl 
b/tp/t/results/linemacro/brace_command_not_closed.pl
index c5fda0f4da..ea57264a5b 100644
--- a/tp/t/results/linemacro/brace_command_not_closed.pl
+++ b/tp/t/results/linemacro/brace_command_not_closed.pl
@@ -78,11 +78,6 @@ $result_trees{'brace_command_not_closed'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -92,43 +87,30 @@ $result_trees{'brace_command_not_closed'} = {
                   {
                     'contents' => [
                       {
-                        'args' => [
-                          {
-                            'contents' => [
-                              {
-                                'text' => 'in code
+                        'text' => '@code{in code
+
 '
-                              }
-                            ],
-                            'type' => 'brace_command_arg'
-                          }
-                        ],
-                        'cmdname' => 'code',
-                        'source_info' => {
-                          'file_name' => '',
-                          'line_nr' => 5,
-                          'macro' => ''
-                        }
                       }
                     ],
-                    'type' => 'line_arg'
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'mycommand'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -140,6 +122,11 @@ $result_trees{'brace_command_not_closed'} = {
                     {
                       'text' => 'in code
 '
+                    },
+                    {
+                      'text' => '
+',
+                      'type' => 'empty_line'
                     }
                   ],
                   'type' => 'brace_command_arg'
@@ -148,29 +135,28 @@ $result_trees{'brace_command_not_closed'} = {
               'cmdname' => 'code',
               'source_info' => {
                 'file_name' => '',
-                'line_nr' => 5,
+                'line_nr' => 6,
                 'macro' => 'mycommand'
               }
-            },
+            }
+          ],
+          'type' => 'paragraph'
+        },
+        {
+          'contents' => [
             {
               'source_marks' => [
                 {
                   'counter' => 1,
-                  'position' => 4,
+                  'position' => 3,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
               ],
-              'text' => ',  
-'
+              'text' => ',  '
             }
           ],
           'type' => 'paragraph'
-        },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
         }
       ],
       'type' => 'before_node_section'
@@ -184,24 +170,31 @@ $result_texis{'brace_command_not_closed'} = '@linemacro 
mycommand {a, b, c}
 @end linemacro
 
 @code{in code
-},  
 
-';
+},  ';
 
 
 $result_texts{'brace_command_not_closed'} = '
 in code
-,  
 
-';
+,  ';
 
 $result_errors{'brace_command_not_closed'} = [
   {
-    'error_line' => '@code missing closing brace
+    'error_line' => '@mycommand missing closing brace
 ',
     'file_name' => '',
-    'line_nr' => 5,
+    'line_nr' => 6,
     'macro' => '',
+    'text' => '@mycommand missing closing brace',
+    'type' => 'error'
+  },
+  {
+    'error_line' => '@code missing closing brace (possibly involving 
@mycommand)
+',
+    'file_name' => '',
+    'line_nr' => 6,
+    'macro' => 'mycommand',
     'text' => '@code missing closing brace',
     'type' => 'error'
   }
diff --git a/tp/t/results/linemacro/braces_after_text.pl 
b/tp/t/results/linemacro/braces_after_text.pl
index 45638b647d..ff09c3bb42 100644
--- a/tp/t/results/linemacro/braces_after_text.pl
+++ b/tp/t/results/linemacro/braces_after_text.pl
@@ -108,80 +108,51 @@ $result_trees{'braces_after_text'} = {
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'text'
-                                  },
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'in paren'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
-                              {
-                                'contents' => [
-                                  {
-                                    'text' => 'rest'
-                                  },
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'in paren'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
-                              },
+                                'text' => 'text{in paren}'
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                                'text' => 'rest{in paren}'
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
+                                'text' => '',
                                 'type' => 'bracketed_arg'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'mymacro'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
-                  'type' => 'empty_line'
+                  'text' => ''
                 }
               ],
               'type' => 'def_item'
@@ -248,6 +219,14 @@ $result_trees{'braces_after_text'} = {
                   ],
                   'info' => {
                     'spaces_after_argument' => {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => ' 
 '
                     }
@@ -271,13 +250,6 @@ $result_trees{'braces_after_text'} = {
                 'line_nr' => 6,
                 'macro' => 'mymacro'
               },
-              'source_marks' => [
-                {
-                  'counter' => 1,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
diff --git a/tp/t/results/linemacro/empty_last_argument.pl 
b/tp/t/results/linemacro/empty_last_argument.pl
index 7a21d18cd5..3e3b8ff05f 100644
--- a/tp/t/results/linemacro/empty_last_argument.pl
+++ b/tp/t/results/linemacro/empty_last_argument.pl
@@ -144,43 +144,38 @@ $result_trees{'empty_last_argument'} = {
                             'contents' => [
                               {
                                 'text' => 'foo'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
+                                'text' => '',
                                 'type' => 'bracketed_arg'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'defbuiltin'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
-                  'type' => 'empty_line'
+                  'text' => ''
                 },
                 {
                   'args' => [
@@ -247,6 +242,14 @@ $result_trees{'empty_last_argument'} = {
                   ],
                   'info' => {
                     'spaces_after_argument' => {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => ' 
 '
                     }
@@ -270,22 +273,10 @@ $result_trees{'empty_last_argument'} = {
                 'line_nr' => 8,
                 'macro' => 'defbuiltin'
               },
-              'source_marks' => [
-                {
-                  'counter' => 1,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
               'contents' => [
-                {
-                  'text' => '
-',
-                  'type' => 'empty_line'
-                },
                 {
                   'source_marks' => [
                     {
@@ -299,29 +290,24 @@ $result_trees{'empty_last_argument'} = {
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'defbuiltin'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
+                      'position' => 1,
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
+                  'text' => '
+',
                   'type' => 'empty_line'
                 },
                 {
@@ -389,6 +375,14 @@ $result_trees{'empty_last_argument'} = {
                   ],
                   'info' => {
                     'spaces_after_argument' => {
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => ' 
 '
                     }
@@ -412,22 +406,10 @@ $result_trees{'empty_last_argument'} = {
                 'line_nr' => 10,
                 'macro' => 'defbuiltin'
               },
-              'source_marks' => [
-                {
-                  'counter' => 2,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
               'contents' => [
-                {
-                  'text' => '
-',
-                  'type' => 'empty_line'
-                },
                 {
                   'source_marks' => [
                     {
@@ -438,57 +420,40 @@ $result_trees{'empty_last_argument'} = {
                             'contents' => [
                               {
                                 'text' => 'foo'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => '{}'
-                                      }
-                                    ],
-                                    'source_info' => {
-                                      'file_name' => '',
-                                      'line_nr' => 12,
-                                      'macro' => ''
-                                    },
-                                    'type' => 'balanced_braces'
-                                  }
-                                ],
+                                'text' => '{}',
                                 'type' => 'bracketed_arg'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'defbuiltin'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
+                      'position' => 1,
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
+                  'text' => '
+',
                   'type' => 'empty_line'
                 },
                 {
@@ -569,6 +534,13 @@ $result_trees{'empty_last_argument'} = {
                         'line_nr' => 12,
                         'macro' => 'defbuiltin'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 3,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'type' => 'bracketed_arg'
                     }
                   ],
@@ -597,13 +569,6 @@ $result_trees{'empty_last_argument'} = {
                 'line_nr' => 12,
                 'macro' => 'defbuiltin'
               },
-              'source_marks' => [
-                {
-                  'counter' => 3,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
diff --git a/tp/t/results/linemacro/end_conditional_in_linemacro.pl 
b/tp/t/results/linemacro/end_conditional_in_linemacro.pl
index ae140aa81e..f3c1ebce92 100644
--- a/tp/t/results/linemacro/end_conditional_in_linemacro.pl
+++ b/tp/t/results/linemacro/end_conditional_in_linemacro.pl
@@ -106,14 +106,7 @@ $result_trees{'end_conditional_in_linemacro'} = {
               'position' => 1,
               'sourcemark_type' => 'expanded_conditional_command',
               'status' => 'start'
-            }
-          ],
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
-        {
-          'source_marks' => [
+            },
             {
               'counter' => 1,
               'element' => {
@@ -121,38 +114,30 @@ $result_trees{'end_conditional_in_linemacro'} = {
                   {
                     'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'text'
-                          }
-                        ],
-                        'info' => {
-                          'spaces_after_argument' => {
-                            'text' => '
-'
-                          }
-                        },
+                        'text' => 'text
+  @end ifclear',
                         'type' => 'bracketed_arg'
                       }
                     ],
-                    'type' => 'line_arg'
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'lm'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -160,66 +145,60 @@ $result_trees{'end_conditional_in_linemacro'} = {
             {
               'text' => 'text
 '
-            }
-          ],
-          'type' => 'paragraph'
-        },
-        {
-          'source_marks' => [
-            {
-              'counter' => 1,
-              'position' => 1,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ],
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
-        {
-          'source_marks' => [
+            },
             {
-              'counter' => 1,
-              'element' => {
-                'args' => [
-                  {
-                    'contents' => [
+              'source_marks' => [
+                {
+                  'counter' => 1,
+                  'element' => {
+                    'args' => [
                       {
-                        'text' => 'ifclear'
+                        'contents' => [
+                          {
+                            'source_marks' => [
+                              {
+                                'counter' => 1,
+                                'position' => 7,
+                                'sourcemark_type' => 'linemacro_expansion',
+                                'status' => 'end'
+                              }
+                            ],
+                            'text' => 'ifclear'
+                          }
+                        ],
+                        'info' => {
+                          'spaces_after_argument' => {
+                            'text' => '
+'
+                          }
+                        },
+                        'type' => 'line_arg'
                       }
                     ],
+                    'cmdname' => 'end',
+                    'extra' => {
+                      'text_arg' => 'ifclear'
+                    },
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
                     },
-                    'type' => 'line_arg'
-                  }
-                ],
-                'cmdname' => 'end',
-                'extra' => {
-                  'text_arg' => 'ifclear'
-                },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
-                'source_info' => {
-                  'file_name' => '',
-                  'line_nr' => 7,
-                  'macro' => ''
+                    'source_info' => {
+                      'file_name' => '',
+                      'line_nr' => 7,
+                      'macro' => 'lm'
+                    }
+                  },
+                  'position' => 2,
+                  'sourcemark_type' => 'expanded_conditional_command',
+                  'status' => 'end'
                 }
-              },
-              'position' => 2,
-              'sourcemark_type' => 'expanded_conditional_command',
-              'status' => 'end'
+              ],
+              'text' => '  '
             }
           ],
-          'text' => '  ',
-          'type' => 'spaces_before_paragraph'
+          'type' => 'paragraph'
         }
       ],
       'type' => 'before_node_section'
@@ -233,35 +212,14 @@ $result_texis{'end_conditional_in_linemacro'} = 
'@linemacro lm {a}
 @end linemacro
 
 text
-
   ';
 
 
 $result_texts{'end_conditional_in_linemacro'} = '
 text
+  ';
 
-';
-
-$result_errors{'end_conditional_in_linemacro'} = [
-  {
-    'error_line' => 'misplaced {
-',
-    'file_name' => '',
-    'line_nr' => 6,
-    'macro' => '',
-    'text' => 'misplaced {',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced }
-',
-    'file_name' => '',
-    'line_nr' => 7,
-    'macro' => '',
-    'text' => 'misplaced }',
-    'type' => 'error'
-  }
-];
+$result_errors{'end_conditional_in_linemacro'} = [];
 
 
 $result_floats{'end_conditional_in_linemacro'} = {};
diff --git a/tp/t/results/linemacro/last_argument_with_braces.pl 
b/tp/t/results/linemacro/last_argument_with_braces.pl
index ad7c73cf4b..7bbb2465e2 100644
--- a/tp/t/results/linemacro/last_argument_with_braces.pl
+++ b/tp/t/results/linemacro/last_argument_with_braces.pl
@@ -109,92 +109,39 @@ $result_trees{'last_argument_with_braces'} = {
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'my foo'
-                                  }
-                                ],
+                                'text' => 'my foo',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'a'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'last'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'type' => 'bracketed_arg'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'arg'
-                                  },
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'ument'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
+                                'text' => 'a last {} arg{ument}'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'defbuiltin'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
-                  'type' => 'empty_line'
+                  'text' => ''
                 }
               ],
               'type' => 'def_item'
@@ -383,6 +330,13 @@ $result_trees{'last_argument_with_braces'} = {
                         'line_nr' => 7,
                         'macro' => 'defbuiltin'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'type' => 'bracketed_arg'
                     }
                   ],
@@ -411,22 +365,10 @@ $result_trees{'last_argument_with_braces'} = {
                 'line_nr' => 7,
                 'macro' => 'defbuiltin'
               },
-              'source_marks' => [
-                {
-                  'counter' => 1,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
               'contents' => [
-                {
-                  'text' => '
-',
-                  'type' => 'empty_line'
-                },
                 {
                   'source_marks' => [
                     {
@@ -436,63 +378,41 @@ $result_trees{'last_argument_with_braces'} = {
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'my foo'
-                                  }
-                                ],
+                                'text' => 'my foo',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'type' => 'bracketed_arg'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'type' => 'bracketed_arg'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
+                                'text' => '{} {}'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'defbuiltin'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
+                      'position' => 1,
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
+                  'text' => '
+',
                   'type' => 'empty_line'
                 }
               ],
@@ -645,6 +565,13 @@ $result_trees{'last_argument_with_braces'} = {
                         'line_nr' => 9,
                         'macro' => 'defbuiltin'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'type' => 'bracketed_arg'
                     }
                   ],
@@ -673,22 +600,10 @@ $result_trees{'last_argument_with_braces'} = {
                 'line_nr' => 9,
                 'macro' => 'defbuiltin'
               },
-              'source_marks' => [
-                {
-                  'counter' => 2,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
               'contents' => [
-                {
-                  'text' => '
-',
-                  'type' => 'empty_line'
-                },
                 {
                   'source_marks' => [
                     {
@@ -698,93 +613,41 @@ $result_trees{'last_argument_with_braces'} = {
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'my foo'
-                                  }
-                                ],
+                                'text' => 'my foo',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'second arg'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'remaining'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'on'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'line'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
+                                'text' => '{second arg} remaining on {line}'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'defbuiltin'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
+                      'position' => 1,
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
+                  'text' => '
+',
                   'type' => 'empty_line'
                 }
               ],
@@ -973,6 +836,13 @@ $result_trees{'last_argument_with_braces'} = {
                         'line_nr' => 11,
                         'macro' => 'defbuiltin'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 3,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'type' => 'bracketed_arg'
                     }
                   ],
@@ -1001,13 +871,6 @@ $result_trees{'last_argument_with_braces'} = {
                 'line_nr' => 11,
                 'macro' => 'defbuiltin'
               },
-              'source_marks' => [
-                {
-                  'counter' => 3,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
diff --git a/tp/t/results/linemacro/nested_linemacro_calls.pl 
b/tp/t/results/linemacro/nested_linemacro_calls.pl
index 0fc191544e..279b1abf3e 100644
--- a/tp/t/results/linemacro/nested_linemacro_calls.pl
+++ b/tp/t/results/linemacro/nested_linemacro_calls.pl
@@ -177,201 +177,58 @@ $result_trees{'nested_linemacro_calls'} = {
                 {
                   'source_marks' => [
                     {
-                      'counter' => 2,
+                      'counter' => 1,
                       'element' => {
                         'args' => [
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'type'
-                                  }
-                                ],
+                                'text' => 'type',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'source_marks' => [
-                                      {
-                                        'counter' => 1,
-                                        'element' => {
-                                          'args' => [
-                                            {
-                                              'contents' => [
-                                                {
-                                                  'contents' => [
-                                                    {
-                                                      'text' => 'X'
-                                                    }
-                                                  ],
-                                                  'type' => 'bracketed_arg'
-                                                },
-                                                {
-                                                  'extra' => {
-                                                    'def_role' => 'spaces'
-                                                  },
-                                                  'text' => ' ',
-                                                  'type' => 'spaces'
-                                                },
-                                                {
-                                                  'contents' => [
-                                                    {
-                                                      'contents' => [
-                                                        {
-                                                          'text' => 'Y'
-                                                        }
-                                                      ],
-                                                      'type' => 'bracketed_arg'
-                                                    },
-                                                    {
-                                                      'extra' => {
-                                                        'def_role' => 'spaces'
-                                                      },
-                                                      'text' => ' ',
-                                                      'type' => 'spaces'
-                                                    },
-                                                    {
-                                                      'text' => '('
-                                                    },
-                                                    {
-                                                      'extra' => {
-                                                        'def_role' => 'spaces'
-                                                      },
-                                                      'text' => ' ',
-                                                      'type' => 'spaces'
-                                                    },
-                                                    {
-                                                      'text' => 'remaining,'
-                                                    },
-                                                    {
-                                                      'extra' => {
-                                                        'def_role' => 'spaces'
-                                                      },
-                                                      'text' => ' ',
-                                                      'type' => 'spaces'
-                                                    },
-                                                    {
-                                                      'text' => 'type'
-                                                    },
-                                                    {
-                                                      'extra' => {
-                                                        'def_role' => 'spaces'
-                                                      },
-                                                      'text' => ' ',
-                                                      'type' => 'spaces'
-                                                    },
-                                                    {
-                                                      'text' => 'typed'
-                                                    },
-                                                    {
-                                                      'extra' => {
-                                                        'def_role' => 'spaces'
-                                                      },
-                                                      'text' => ' ',
-                                                      'type' => 'spaces'
-                                                    },
-                                                    {
-                                                      'text' => ')'
-                                                    }
-                                                  ],
-                                                  'type' => 'def_aggregate'
-                                                }
-                                              ],
-                                              'info' => {
-                                                'spaces_after_argument' => {
-                                                  'text' => '
-'
-                                                }
-                                              },
-                                              'type' => 'line_arg'
-                                            }
-                                          ],
-                                          'extra' => {
-                                            'name' => 'inside'
-                                          },
-                                          'info' => {
-                                            'spaces_before_argument' => {
-                                              'text' => ' '
-                                            }
-                                          },
-                                          'type' => 'linemacro_call'
-                                        },
-                                        'sourcemark_type' => 
'linemacro_expansion',
-                                        'status' => 'start'
-                                      }
-                                    ],
-                                    'text' => ''
-                                  },
-                                  {
-                                    'text' => 'inside '
-                                  },
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => '{X operator '
-                                      },
-                                      {
-                                        'contents' => [
-                                          {
-                                            'text' => '{Y}'
-                                          }
-                                        ],
-                                        'source_info' => {
-                                          'file_name' => '',
-                                          'line_nr' => 11,
-                                          'macro' => 'inside'
-                                        },
-                                        'type' => 'balanced_braces'
-                                      },
-                                      {
-                                        'text' => ' ( remaining, type typed )}'
-                                      }
-                                    ],
-                                    'source_info' => {
-                                      'file_name' => '',
-                                      'line_nr' => 11,
-                                      'macro' => 'inside'
-                                    },
-                                    'type' => 'balanced_braces'
-                                  }
-                                ],
-                                'info' => {
-                                  'spaces_after_argument' => {
-                                    'text' => '
-'
-                                  }
-                                },
+                                'text' => '@inside {X} {Y}',
                                 'type' => 'bracketed_arg'
                               }
                             ],
-                            'type' => 'line_arg'
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
+                              {
+                                'text' => '( remaining, type typed )'
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'outside'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
-                  'type' => 'empty_line'
+                  'text' => ''
                 }
               ],
               'type' => 'def_item'
@@ -395,6 +252,49 @@ $result_trees{'nested_linemacro_calls'} = {
                     },
                     {
                       'contents' => [
+                        {
+                          'source_marks' => [
+                            {
+                              'counter' => 2,
+                              'element' => {
+                                'args' => [
+                                  {
+                                    'contents' => [
+                                      {
+                                        'text' => 'X',
+                                        'type' => 'bracketed_arg'
+                                      }
+                                    ],
+                                    'info' => {
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
+                                      }
+                                    }
+                                  },
+                                  {
+                                    'contents' => [
+                                      {
+                                        'text' => '{Y}} ( remaining, type 
typed )'
+                                      }
+                                    ],
+                                    'info' => {
+                                      'spaces_before_argument' => {
+                                        'text' => ' '
+                                      }
+                                    }
+                                  }
+                                ],
+                                'extra' => {
+                                  'name' => 'inside'
+                                },
+                                'type' => 'linemacro_call'
+                              },
+                              'sourcemark_type' => 'linemacro_expansion',
+                              'status' => 'start'
+                            }
+                          ],
+                          'text' => ''
+                        },
                         {
                           'text' => 'inside X operator Y'
                         }
@@ -480,6 +380,14 @@ $result_trees{'nested_linemacro_calls'} = {
                       'extra' => {
                         'def_role' => 'delimiter'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => ')',
                       'type' => 'delimiter'
                     }
@@ -513,17 +421,20 @@ $result_trees{'nested_linemacro_calls'} = {
             },
             {
               'contents' => [
-                {
-                  'text' => ' 
-',
-                  'type' => 'empty_line'
-                },
                 {
                   'args' => [
                     {
                       'contents' => [
                         {
-                          'text' => 'inside X operator Y ( remaining, type 
typed )'
+                          'source_marks' => [
+                            {
+                              'counter' => 3,
+                              'position' => 19,
+                              'sourcemark_type' => 'linemacro_expansion',
+                              'status' => 'end'
+                            }
+                          ],
+                          'text' => 'inside X operator Y'
                         }
                       ],
                       'info' => {
@@ -544,6 +455,56 @@ $result_trees{'nested_linemacro_calls'} = {
                   },
                   'info' => {
                     'spaces_before_argument' => {
+                      'source_marks' => [
+                        {
+                          'counter' => 3,
+                          'element' => {
+                            'args' => [
+                              {
+                                'contents' => [
+                                  {
+                                    'text' => 'X',
+                                    'type' => 'bracketed_arg'
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              },
+                              {
+                                'contents' => [
+                                  {
+                                    'source_marks' => [
+                                      {
+                                        'counter' => 1,
+                                        'position' => 3,
+                                        'sourcemark_type' => 
'linemacro_expansion',
+                                        'status' => 'end'
+                                      }
+                                    ],
+                                    'text' => 'Y',
+                                    'type' => 'bracketed_arg'
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              }
+                            ],
+                            'extra' => {
+                              'name' => 'inside'
+                            },
+                            'type' => 'linemacro_call'
+                          },
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'start'
+                        }
+                      ],
                       'text' => ' '
                     }
                   },
@@ -553,25 +514,6 @@ $result_trees{'nested_linemacro_calls'} = {
                     'macro' => 'outside'
                   },
                   'type' => 'index_entry_command'
-                },
-                {
-                  'source_marks' => [
-                    {
-                      'counter' => 2,
-                      'position' => 1,
-                      'sourcemark_type' => 'linemacro_expansion',
-                      'status' => 'end'
-                    },
-                    {
-                      'counter' => 1,
-                      'position' => 1,
-                      'sourcemark_type' => 'linemacro_expansion',
-                      'status' => 'end'
-                    }
-                  ],
-                  'text' => '
-',
-                  'type' => 'empty_line'
                 }
               ],
               'type' => 'def_item'
@@ -634,9 +576,7 @@ inside {\\a\\ operator \\b\\}
 
 @defblock
 @defline type {inside X operator Y} ( remaining, type typed )
- 
-@cindex inside X operator Y ( remaining, type typed )
-
+@cindex inside X operator Y
 @end defblock
 ';
 
@@ -644,20 +584,9 @@ inside {\\a\\ operator \\b\\}
 $result_texts{'nested_linemacro_calls'} = '
 
 type: inside X operator Y ( remaining, type typed )
- 
-
 ';
 
 $result_errors{'nested_linemacro_calls'} = [
-  {
-    'error_line' => 'misplaced }
-',
-    'file_name' => '',
-    'line_nr' => 11,
-    'macro' => '',
-    'text' => 'misplaced }',
-    'type' => 'error'
-  },
   {
     'error_line' => 'misplaced { (possibly involving @inside)
 ',
@@ -668,83 +597,56 @@ $result_errors{'nested_linemacro_calls'} = [
     'type' => 'error'
   },
   {
-    'error_line' => 'misplaced { (possibly involving @outside)
-',
-    'file_name' => '',
-    'line_nr' => 11,
-    'macro' => 'outside',
-    'text' => 'misplaced {',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced { (possibly involving @outside)
+    'error_line' => 'misplaced { (possibly involving @inside)
 ',
     'file_name' => '',
     'line_nr' => 11,
-    'macro' => 'outside',
+    'macro' => 'inside',
     'text' => 'misplaced {',
     'type' => 'error'
   },
   {
-    'error_line' => 'misplaced } (possibly involving @outside)
+    'error_line' => 'misplaced } (possibly involving @inside)
 ',
     'file_name' => '',
     'line_nr' => 11,
-    'macro' => 'outside',
+    'macro' => 'inside',
     'text' => 'misplaced }',
     'type' => 'error'
   },
   {
-    'error_line' => 'misplaced } (possibly involving @outside)
+    'error_line' => 'misplaced } (possibly involving @inside)
 ',
     'file_name' => '',
     'line_nr' => 11,
-    'macro' => 'outside',
+    'macro' => 'inside',
     'text' => 'misplaced }',
     'type' => 'error'
   },
   {
-    'error_line' => 'misplaced { (possibly involving @outside)
-',
-    'file_name' => '',
-    'line_nr' => 11,
-    'macro' => 'outside',
-    'text' => 'misplaced {',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced { (possibly involving @outside)
+    'error_line' => 'misplaced { (possibly involving @inside)
 ',
     'file_name' => '',
     'line_nr' => 11,
-    'macro' => 'outside',
+    'macro' => 'inside',
     'text' => 'misplaced {',
     'type' => 'error'
   },
   {
-    'error_line' => 'misplaced } (possibly involving @outside)
+    'error_line' => 'misplaced } (possibly involving @inside)
 ',
     'file_name' => '',
     'line_nr' => 11,
-    'macro' => 'outside',
-    'text' => 'misplaced }',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced } (possibly involving @outside)
-',
-    'file_name' => '',
-    'line_nr' => 11,
-    'macro' => 'outside',
+    'macro' => 'inside',
     'text' => 'misplaced }',
     'type' => 'error'
   },
   {
-    'error_line' => 'warning: entry for index `cp\' outside of any node 
(possibly involving @outside)
+    'error_line' => 'warning: entry for index `cp\' outside of any node
 ',
     'file_name' => '',
     'line_nr' => 11,
-    'macro' => 'outside',
+    'macro' => '',
     'text' => 'entry for index `cp\' outside of any node',
     'type' => 'warning'
   }
@@ -756,7 +658,7 @@ $result_floats{'nested_linemacro_calls'} = {};
 
 $result_indices_sort_strings{'nested_linemacro_calls'} = {
   'cp' => [
-    'inside X operator Y ( remaining, type typed )'
+    'inside X operator Y'
   ]
 };
 
diff --git a/tp/t/results/linemacro/newline_and_continuation_in_brace.pl 
b/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
index ad3369b382..c21a679d99 100644
--- a/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
+++ b/tp/t/results/linemacro/newline_and_continuation_in_brace.pl
@@ -113,119 +113,53 @@ $result_trees{'newline_and_continuation_in_brace'} = {
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'a'
-                                  },
-                                  {
-                                    'args' => [
-                                      {
-                                        'contents' => [
-                                          {
-                                            'text' => 'b c'
-                                          }
-                                        ],
-                                        'type' => 'brace_command_arg'
-                                      }
-                                    ],
-                                    'cmdname' => 'code',
-                                    'source_info' => {
-                                      'file_name' => '',
-                                      'line_nr' => 7,
-                                      'macro' => ''
-                                    }
-                                  },
-                                  {
-                                    'text' => 'd'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                                'text' => 'a@code{b c}d'
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'some arg '
-                                  },
-                                  {
-                                    'cmdname' => '
-'
-                                  },
-                                  {
-                                    'text' => '   b'
-                                  }
-                                ],
+                                'text' => 'some arg @
+   b',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'next '
-                                      },
-                                      {
-                                        'cmdname' => '
-'
-                                      },
-                                      {
-                                        'text' => '   last'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'line'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
+                                'text' => '{next @
+   last} line'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'mylinecommand'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
-                  'type' => 'empty_line'
+                  'text' => ''
                 }
               ],
               'type' => 'def_item'
@@ -366,6 +300,14 @@ $result_trees{'newline_and_continuation_in_brace'} = {
                       'extra' => {
                         'def_role' => 'arg'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 4,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'line'
                     }
                   ],
@@ -394,13 +336,6 @@ $result_trees{'newline_and_continuation_in_brace'} = {
                 'line_nr' => 9,
                 'macro' => 'mylinecommand'
               },
-              'source_marks' => [
-                {
-                  'counter' => 1,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
               'type' => 'def_line'
             },
             {
diff --git a/tp/t/results/linemacro/no_arguments.pl 
b/tp/t/results/linemacro/no_arguments.pl
index 56add141b5..dae1a9a4d6 100644
--- a/tp/t/results/linemacro/no_arguments.pl
+++ b/tp/t/results/linemacro/no_arguments.pl
@@ -66,11 +66,6 @@ $result_trees{'no_arguments'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -78,13 +73,11 @@ $result_trees{'no_arguments'} = {
               'element' => {
                 'args' => [
                   {
-                    'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                    'contents' => [
+                      {
+                        'text' => ''
                       }
-                    },
-                    'type' => 'line_arg'
+                    ]
                   }
                 ],
                 'extra' => {
@@ -92,11 +85,13 @@ $result_trees{'no_arguments'} = {
                 },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -105,7 +100,7 @@ $result_trees{'no_arguments'} = {
               'source_marks' => [
                 {
                   'counter' => 1,
-                  'position' => 6,
+                  'position' => 5,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
@@ -116,11 +111,6 @@ $result_trees{'no_arguments'} = {
           ],
           'type' => 'paragraph'
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -130,43 +120,28 @@ $result_trees{'no_arguments'} = {
                   {
                     'contents' => [
                       {
-                        'text' => 'A'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
-                      {
-                        'text' => 'B'
+                        'text' => 'A B'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'noarg'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -175,7 +150,7 @@ $result_trees{'no_arguments'} = {
               'source_marks' => [
                 {
                   'counter' => 2,
-                  'position' => 6,
+                  'position' => 5,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
@@ -186,11 +161,6 @@ $result_trees{'no_arguments'} = {
           ],
           'type' => 'paragraph'
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -200,38 +170,29 @@ $result_trees{'no_arguments'} = {
                   {
                     'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'in brace'
-                          }
-                        ],
+                        'text' => 'in brace',
                         'type' => 'bracketed_arg'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'noarg'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -240,7 +201,7 @@ $result_trees{'no_arguments'} = {
               'source_marks' => [
                 {
                   'counter' => 3,
-                  'position' => 6,
+                  'position' => 5,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
diff --git a/tp/t/results/linemacro/paragraph_no_paragraph.pl 
b/tp/t/results/linemacro/paragraph_no_paragraph.pl
index d74e119408..83123547ac 100644
--- a/tp/t/results/linemacro/paragraph_no_paragraph.pl
+++ b/tp/t/results/linemacro/paragraph_no_paragraph.pl
@@ -95,94 +95,43 @@ $result_trees{'paragraph_no_paragraph'} = {
                   {
                     'contents' => [
                       {
-                        'args' => [
-                          {
-                            'contents' => [
-                              {
-                                'text' => 'aa'
-                              }
-                            ],
-                            'type' => 'brace_command_arg'
-                          }
-                        ],
-                        'cmdname' => 'anchor',
-                        'extra' => {
-                          'normalized' => 'aa'
-                        },
-                        'source_info' => {
-                          'file_name' => '',
-                          'line_nr' => 5,
-                          'macro' => ''
-                        }
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                        'text' => '@anchor{aa}'
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
                         'text' => 'definite'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'and'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'args' => [
-                              {
-                                'contents' => [
-                                  {
-                                    'text' => 'more'
-                                  }
-                                ],
-                                'type' => 'brace_command_arg'
-                              }
-                            ],
-                            'cmdname' => 'code',
-                            'source_info' => {
-                              'file_name' => '',
-                              'line_nr' => 5,
-                              'macro' => ''
-                            }
-                          }
-                        ],
-                        'type' => 'def_aggregate'
+                        'text' => 'and @code{more}'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'mycommand'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
               'position' => 1,
@@ -204,6 +153,9 @@ $result_trees{'paragraph_no_paragraph'} = {
             }
           ],
           'cmdname' => 'anchor',
+          'extra' => {
+            'normalized' => 'aa'
+          },
           'source_info' => {
             'file_name' => '',
             'line_nr' => 5,
@@ -231,17 +183,16 @@ $result_trees{'paragraph_no_paragraph'} = {
                 'file_name' => '',
                 'line_nr' => 5,
                 'macro' => 'mycommand'
-              }
-            },
-            {
+              },
               'source_marks' => [
                 {
                   'counter' => 1,
-                  'position' => 1,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
-              ],
+              ]
+            },
+            {
               'text' => '
 '
             }
@@ -264,31 +215,46 @@ $result_trees{'paragraph_no_paragraph'} = {
                       {
                         'contents' => [
                           {
-                            'contents' => [
-                              {
-                                'text' => 'a'
-                              }
-                            ],
-                            'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
-                              }
-                            },
+                            'text' => 'a
+  protected',
                             'type' => 'bracketed_arg'
                           }
                         ],
-                        'type' => 'line_arg'
+                        'info' => {
+                          'spaces_before_argument' => {
+                            'text' => ' '
+                          }
+                        }
+                      },
+                      {
+                        'contents' => [
+                          {
+                            'text' => 'in'
+                          }
+                        ],
+                        'info' => {
+                          'spaces_before_argument' => {
+                            'text' => ' '
+                          }
+                        }
+                      },
+                      {
+                        'contents' => [
+                          {
+                            'text' => '@var{the
+ call}'
+                          }
+                        ],
+                        'info' => {
+                          'spaces_before_argument' => {
+                            'text' => ' '
+                          }
+                        }
                       }
                     ],
                     'extra' => {
                       'name' => 'mycommand'
                     },
-                    'info' => {
-                      'spaces_before_argument' => {
-                        'text' => ' '
-                      }
-                    },
                     'type' => 'linemacro_call'
                   },
                   'position' => 10,
@@ -300,19 +266,7 @@ $result_trees{'paragraph_no_paragraph'} = {
 '
             },
             {
-              'source_marks' => [
-                {
-                  'counter' => 2,
-                  'position' => 4,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
-              'text' => ',  
-'
-            },
-            {
-              'text' => '  protected in '
+              'text' => '  protected, in '
             },
             {
               'args' => [
@@ -332,9 +286,16 @@ $result_trees{'paragraph_no_paragraph'} = {
               'cmdname' => 'var',
               'source_info' => {
                 'file_name' => '',
-                'line_nr' => 8,
-                'macro' => ''
-              }
+                'line_nr' => 9,
+                'macro' => 'mycommand'
+              },
+              'source_marks' => [
+                {
+                  'counter' => 2,
+                  'sourcemark_type' => 'linemacro_expansion',
+                  'status' => 'end'
+                }
+              ]
             },
             {
               'text' => '
@@ -361,8 +322,7 @@ $result_texis{'paragraph_no_paragraph'} = '@linemacro 
mycommand {a, b, c}
 @* @anchor{aa}, definite and @code{more}
 
 Some text a
-,  
-  protected in @var{the
+  protected, in @var{the
  call}
 and after.
 ';
@@ -373,51 +333,12 @@ $result_texts{'paragraph_no_paragraph'} = '
  , definite and more
 
 Some text a
-,  
-  protected in the
+  protected, in the
  call
 and after.
 ';
 
-$result_errors{'paragraph_no_paragraph'} = [
-  {
-    'error_line' => 'misplaced {
-',
-    'file_name' => '',
-    'line_nr' => 7,
-    'macro' => '',
-    'text' => 'misplaced {',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced }
-',
-    'file_name' => '',
-    'line_nr' => 8,
-    'macro' => '',
-    'text' => 'misplaced }',
-    'type' => 'error'
-  },
-  {
-    'error_line' => '@anchor `aa\' previously defined (possibly involving 
@mycommand)
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => 'mycommand',
-    'text' => '@anchor `aa\' previously defined',
-    'type' => 'error'
-  },
-  {
-    'continuation' => 1,
-    'error_line' => 'here is the previous definition as @anchor
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => '',
-    'text' => 'here is the previous definition as @anchor',
-    'type' => 'error'
-  }
-];
+$result_errors{'paragraph_no_paragraph'} = [];
 
 
 $result_floats{'paragraph_no_paragraph'} = {};
diff --git a/tp/t/results/linemacro/protected_spaces_on_line.pl 
b/tp/t/results/linemacro/protected_spaces_on_line.pl
index 0f24a6f922..1af8858413 100644
--- a/tp/t/results/linemacro/protected_spaces_on_line.pl
+++ b/tp/t/results/linemacro/protected_spaces_on_line.pl
@@ -84,11 +84,6 @@ $result_trees{'protected_spaces_on_line'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -99,81 +94,40 @@ $result_trees{'protected_spaces_on_line'} = {
                     'contents' => [
                       {
                         'text' => 'foo'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => '(bar,'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'baz)'
-                          },
-                          {
-                            'cmdname' => '
-'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'continuation'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'line'
-                          }
-                        ],
-                        'type' => 'def_aggregate'
+                        'text' => '(bar, baz)@
+ continuation line'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'test'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -327,6 +281,14 @@ $result_trees{'protected_spaces_on_line'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 5,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'deffn'
                     }
                   ],
@@ -364,19 +326,7 @@ $result_trees{'protected_spaces_on_line'} = {
             'file_name' => '',
             'line_nr' => 8,
             'macro' => 'test'
-          },
-          'source_marks' => [
-            {
-              'counter' => 1,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ]
-        },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
+          }
         },
         {
           'source_marks' => [
@@ -387,95 +337,40 @@ $result_trees{'protected_spaces_on_line'} = {
                   {
                     'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'foo'
-                          },
-                          {
-                            'cmdname' => ' '
-                          },
-                          {
-                            'text' => 'b'
-                          }
-                        ],
-                        'type' => 'def_aggregate'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                        'text' => 'foo@ b'
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => '(bar,'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'baz)'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'rest'
-                          },
-                          {
-                            'cmdname' => ' '
-                          },
-                          {
-                            'text' => 'and'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'more'
-                          }
-                        ],
-                        'type' => 'def_aggregate'
+                        'text' => '(bar, baz) rest@ and more'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'test'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -645,6 +540,14 @@ $result_trees{'protected_spaces_on_line'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'position' => 5,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'deffn'
                     }
                   ],
@@ -682,19 +585,7 @@ $result_trees{'protected_spaces_on_line'} = {
             'file_name' => '',
             'line_nr' => 10,
             'macro' => 'test'
-          },
-          'source_marks' => [
-            {
-              'counter' => 2,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ]
-        },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
+          }
         },
         {
           'source_marks' => [
@@ -706,60 +597,39 @@ $result_trees{'protected_spaces_on_line'} = {
                     'contents' => [
                       {
                         'text' => 'foo'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => '(bar,'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
-                            },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'text' => 'baz)'
-                          },
-                          {
-                            'cmdname' => '@'
-                          }
-                        ],
-                        'type' => 'def_aggregate'
+                        'text' => '(bar, baz)@@'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'test'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -886,6 +756,14 @@ $result_trees{'protected_spaces_on_line'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 3,
+                          'position' => 5,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'deffn'
                     }
                   ],
@@ -923,14 +801,7 @@ $result_trees{'protected_spaces_on_line'} = {
             'file_name' => '',
             'line_nr' => 12,
             'macro' => 'test'
-          },
-          'source_marks' => [
-            {
-              'counter' => 3,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ]
+          }
         },
         {
           'text' => ' ',
@@ -956,9 +827,9 @@ $result_trees{'protected_spaces_on_line'} = {
   ],
   'type' => 'document_root'
 };
-$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[4]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[4]{'contents'}[0]{'args'}[0]{'contents'}[2];
 
$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[6]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[6]{'contents'}[0]{'args'}[0]{'contents'}[2];
-$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[9]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'protected_spaces_on_line'}{'contents'}[0]{'contents'}[9]{'contents'}[0]{'args'}[0]{'contents'}[2];
 
 $result_texis{'protected_spaces_on_line'} = '@linemacro test {first, rest}
 @deffn Function \\first\\ \\rest\\
diff --git a/tp/t/results/linemacro/simple_nested_linemacro_calls.pl 
b/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
index a3179043a2..0817a48563 100644
--- a/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
+++ b/tp/t/results/linemacro/simple_nested_linemacro_calls.pl
@@ -206,250 +206,58 @@ $result_trees{'simple_nested_linemacro_calls'} = {
                 {
                   'source_marks' => [
                     {
-                      'counter' => 2,
+                      'counter' => 1,
                       'element' => {
                         'args' => [
                           {
                             'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'type'
-                                  }
-                                ],
+                                'text' => 'type',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'a function'
-                                  }
-                                ],
+                                'text' => 'a function',
                                 'type' => 'bracketed_arg'
-                              },
-                              {
-                                'extra' => {
-                                  'def_role' => 'spaces'
-                                },
-                                'source_marks' => [
-                                  {
-                                    'counter' => 1,
-                                    'element' => {
-                                      'args' => [
-                                        {
-                                          'contents' => [
-                                            {
-                                              'contents' => [
-                                                {
-                                                  'text' => 'X'
-                                                }
-                                              ],
-                                              'type' => 'bracketed_arg'
-                                            },
-                                            {
-                                              'extra' => {
-                                                'def_role' => 'spaces'
-                                              },
-                                              'text' => ' ',
-                                              'type' => 'spaces'
-                                            },
-                                            {
-                                              'contents' => [
-                                                {
-                                                  'text' => 'Y'
-                                                }
-                                              ],
-                                              'type' => 'bracketed_arg'
-                                            },
-                                            {
-                                              'extra' => {
-                                                'def_role' => 'spaces'
-                                              },
-                                              'text' => ' ',
-                                              'type' => 'spaces'
-                                            },
-                                            {
-                                              'contents' => [
-                                                {
-                                                  'text' => '('
-                                                },
-                                                {
-                                                  'extra' => {
-                                                    'def_role' => 'spaces'
-                                                  },
-                                                  'text' => ' ',
-                                                  'type' => 'spaces'
-                                                },
-                                                {
-                                                  'text' => 'remaining,'
-                                                },
-                                                {
-                                                  'extra' => {
-                                                    'def_role' => 'spaces'
-                                                  },
-                                                  'text' => ' ',
-                                                  'type' => 'spaces'
-                                                },
-                                                {
-                                                  'text' => 'type'
-                                                },
-                                                {
-                                                  'extra' => {
-                                                    'def_role' => 'spaces'
-                                                  },
-                                                  'text' => ' ',
-                                                  'type' => 'spaces'
-                                                },
-                                                {
-                                                  'text' => 'typed'
-                                                },
-                                                {
-                                                  'extra' => {
-                                                    'def_role' => 'spaces'
-                                                  },
-                                                  'text' => ' ',
-                                                  'type' => 'spaces'
-                                                },
-                                                {
-                                                  'text' => ')'
-                                                }
-                                              ],
-                                              'type' => 'def_aggregate'
-                                            }
-                                          ],
-                                          'info' => {
-                                            'spaces_after_argument' => {
-                                              'text' => '
-'
-                                            }
-                                          },
-                                          'type' => 'line_arg'
-                                        }
-                                      ],
-                                      'extra' => {
-                                        'name' => 'inside'
-                                      },
-                                      'info' => {
-                                        'spaces_before_argument' => {
-                                          'text' => ' '
-                                        }
-                                      },
-                                      'type' => 'linemacro_call'
-                                    },
-                                    'position' => 1,
-                                    'sourcemark_type' => 'linemacro_expansion',
-                                    'status' => 'start'
-                                  }
-                                ],
-                                'text' => ' ',
-                                'type' => 'spaces'
-                              },
+                              }
+                            ],
+                            'info' => {
+                              'spaces_before_argument' => {
+                                'text' => ' '
+                              }
+                            }
+                          },
+                          {
+                            'contents' => [
                               {
-                                'contents' => [
-                                  {
-                                    'text' => 'inside'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'contents' => [
-                                      {
-                                        'text' => 'X operator Y'
-                                      }
-                                    ],
-                                    'type' => 'bracketed_arg'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => '('
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'remaining,'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'type'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => 'typed'
-                                  },
-                                  {
-                                    'extra' => {
-                                      'def_role' => 'spaces'
-                                    },
-                                    'text' => ' ',
-                                    'type' => 'spaces'
-                                  },
-                                  {
-                                    'text' => ')'
-                                  }
-                                ],
-                                'type' => 'def_aggregate'
+                                'text' => '@inside {X} {Y} ( remaining, type 
typed )'
                               }
                             ],
                             'info' => {
-                              'spaces_after_argument' => {
-                                'text' => '
-'
+                              'spaces_before_argument' => {
+                                'text' => ' '
                               }
-                            },
-                            'type' => 'line_arg'
+                            }
                           }
                         ],
                         'extra' => {
                           'name' => 'outside'
                         },
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
                         'type' => 'linemacro_call'
                       },
                       'sourcemark_type' => 'linemacro_expansion',
                       'status' => 'start'
                     }
                   ],
-                  'text' => '',
-                  'type' => 'empty_line'
+                  'text' => ''
                 }
               ],
               'type' => 'def_item'
@@ -491,6 +299,60 @@ $result_trees{'simple_nested_linemacro_calls'} = {
                       'extra' => {
                         'def_role' => 'spaces'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'element' => {
+                            'args' => [
+                              {
+                                'contents' => [
+                                  {
+                                    'text' => 'X',
+                                    'type' => 'bracketed_arg'
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              },
+                              {
+                                'contents' => [
+                                  {
+                                    'text' => 'Y',
+                                    'type' => 'bracketed_arg'
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              },
+                              {
+                                'contents' => [
+                                  {
+                                    'text' => '( remaining, type typed )'
+                                  }
+                                ],
+                                'info' => {
+                                  'spaces_before_argument' => {
+                                    'text' => ' '
+                                  }
+                                }
+                              }
+                            ],
+                            'extra' => {
+                              'name' => 'inside'
+                            },
+                            'type' => 'linemacro_call'
+                          },
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'start'
+                        }
+                      ],
                       'text' => ' ',
                       'type' => 'spaces'
                     },
@@ -519,7 +381,7 @@ $result_trees{'simple_nested_linemacro_calls'} = {
                       'source_info' => {
                         'file_name' => '',
                         'line_nr' => 13,
-                        'macro' => 'outside'
+                        'macro' => 'inside'
                       },
                       'type' => 'bracketed_arg'
                     },
@@ -594,6 +456,14 @@ $result_trees{'simple_nested_linemacro_calls'} = {
                       'extra' => {
                         'def_role' => 'delimiter'
                       },
+                      'source_marks' => [
+                        {
+                          'counter' => 2,
+                          'position' => 1,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => ')',
                       'type' => 'delimiter'
                     }
@@ -632,6 +502,14 @@ $result_trees{'simple_nested_linemacro_calls'} = {
                     {
                       'contents' => [
                         {
+                          'source_marks' => [
+                            {
+                              'counter' => 1,
+                              'position' => 10,
+                              'sourcemark_type' => 'linemacro_expansion',
+                              'status' => 'end'
+                            }
+                          ],
                           'text' => 'a function'
                         }
                       ],
@@ -662,18 +540,6 @@ $result_trees{'simple_nested_linemacro_calls'} = {
                     'line_nr' => 13,
                     'macro' => 'outside'
                   },
-                  'source_marks' => [
-                    {
-                      'counter' => 2,
-                      'sourcemark_type' => 'linemacro_expansion',
-                      'status' => 'end'
-                    },
-                    {
-                      'counter' => 1,
-                      'sourcemark_type' => 'linemacro_expansion',
-                      'status' => 'end'
-                    }
-                  ],
                   'type' => 'index_entry_command'
                 }
               ],
diff --git a/tp/t/results/linemacro/spaces_after_command_in_call.pl 
b/tp/t/results/linemacro/spaces_after_command_in_call.pl
index b7852adf93..ebc9e2555a 100644
--- a/tp/t/results/linemacro/spaces_after_command_in_call.pl
+++ b/tp/t/results/linemacro/spaces_after_command_in_call.pl
@@ -88,11 +88,6 @@ $result_trees{'spaces_after_command_in_call'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -102,78 +97,53 @@ $result_trees{'spaces_after_command_in_call'} = {
                   {
                     'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'd'
-                          }
-                        ],
-                        'type' => 'bracketed_arg'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
-                      {
-                        'args' => [
-                          {
-                            'contents' => [
-                              {
-                                'text' => 'b'
-                              }
-                            ],
-                            'type' => 'following_arg'
-                          }
-                        ],
-                        'cmdname' => 'ringaccent',
-                        'info' => {
-                          'spaces_after_cmd_before_arg' => {
-                            'text' => ' '
-                          }
-                        },
-                        'source_info' => {
-                          'file_name' => '',
-                          'line_nr' => 7,
-                          'macro' => ''
-                        }
-                      },
+                        'text' => '@abc'
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                        'text' => 'd',
+                        'type' => 'bracketed_arg'
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'text' => 'rest'
+                        'text' => '@ringaccent b rest'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'mylinecommand'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => '  '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -204,13 +174,26 @@ $result_trees{'spaces_after_command_in_call'} = {
                       'extra' => {
                         'def_role' => 'spaces'
                       },
-                      'text' => ' ',
+                      'text' => '  ',
                       'type' => 'spaces'
                     },
                     {
                       'extra' => {
                         'def_role' => 'name'
                       },
+                      'text' => 'A'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'spaces'
+                      },
+                      'text' => ' ',
+                      'type' => 'spaces'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'arg'
+                      },
                       'text' => 'd'
                     },
                     {
@@ -224,7 +207,7 @@ $result_trees{'spaces_after_command_in_call'} = {
                       'extra' => {
                         'def_role' => 'arg'
                       },
-                      'text' => 'A'
+                      'text' => 'B'
                     },
                     {
                       'extra' => {
@@ -266,19 +249,6 @@ $result_trees{'spaces_after_command_in_call'} = {
                       'text' => ' ',
                       'type' => 'spaces'
                     },
-                    {
-                      'extra' => {
-                        'def_role' => 'arg'
-                      },
-                      'text' => 'B'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'spaces'
-                      },
-                      'text' => ' ',
-                      'type' => 'spaces'
-                    },
                     {
                       'extra' => {
                         'def_role' => 'arg'
@@ -318,6 +288,14 @@ $result_trees{'spaces_after_command_in_call'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 8,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'defblock'
                     }
                   ],
@@ -350,14 +328,7 @@ $result_trees{'spaces_after_command_in_call'} = {
             'file_name' => '',
             'line_nr' => 7,
             'macro' => 'mylinecommand'
-          },
-          'source_marks' => [
-            {
-              'counter' => 1,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ]
+          }
         }
       ],
       'type' => 'before_node_section'
@@ -365,7 +336,7 @@ $result_trees{'spaces_after_command_in_call'} = {
   ],
   'type' => 'document_root'
 };
-$result_trees{'spaces_after_command_in_call'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'spaces_after_command_in_call'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'spaces_after_command_in_call'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'spaces_after_command_in_call'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'args'}[0]{'contents'}[2];
 
 $result_texis{'spaces_after_command_in_call'} = '@linemacro mylinecommand 
{first, second, rest}
 @defblock
@@ -374,22 +345,22 @@ $result_texis{'spaces_after_command_in_call'} = 
'@linemacro mylinecommand {first
 @end linemacro
 
 @defblock
-@defline category d A @ringaccent b B rest
+@defline category  A d B @ringaccent b rest
 @end defblock
 ';
 
 
 $result_texts{'spaces_after_command_in_call'} = '
-category: d A b* B rest
+category: A d B b* rest
 ';
 
 $result_errors{'spaces_after_command_in_call'} = [
   {
-    'error_line' => 'unknown command `abc\'
+    'error_line' => 'unknown command `abc\' (possibly involving @mylinecommand)
 ',
     'file_name' => '',
     'line_nr' => 7,
-    'macro' => '',
+    'macro' => 'mylinecommand',
     'text' => 'unknown command `abc\'',
     'type' => 'error'
   }
diff --git a/tp/t/results/linemacro/spaces_in_args.pl 
b/tp/t/results/linemacro/spaces_in_args.pl
index 916f16df68..3f42000357 100644
--- a/tp/t/results/linemacro/spaces_in_args.pl
+++ b/tp/t/results/linemacro/spaces_in_args.pl
@@ -88,11 +88,6 @@ $result_trees{'spaces_in_args'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -102,89 +97,55 @@ $result_trees{'spaces_in_args'} = {
                   {
                     'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'a'
-                          }
-                        ],
-                        'info' => {
-                          'spaces_after_argument' => {
-                            'text' => ' '
-                          },
-                          'spaces_before_argument' => {
-                            'text' => '  '
-                          }
-                        },
+                        'text' => '  a ',
                         'type' => 'bracketed_arg'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'd'
-                          }
-                        ],
-                        'info' => {
-                          'spaces_after_argument' => {
-                            'text' => '  '
-                          },
-                          'spaces_before_argument' => {
-                            'text' => ' '
-                          }
-                        },
+                        'text' => ' d  ',
                         'type' => 'bracketed_arg'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'text' => 'rest'
-                          }
-                        ],
-                        'info' => {
-                          'spaces_before_argument' => {
-                            'text' => '   '
-                          }
-                        },
+                        'text' => '   rest',
                         'type' => 'bracketed_arg'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'mylinecommand'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -309,6 +270,14 @@ $result_trees{'spaces_in_args'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 8,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'defblock'
                     }
                   ],
@@ -341,14 +310,7 @@ $result_trees{'spaces_in_args'} = {
             'file_name' => '',
             'line_nr' => 7,
             'macro' => 'mylinecommand'
-          },
-          'source_marks' => [
-            {
-              'counter' => 1,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ]
+          }
         }
       ],
       'type' => 'before_node_section'
@@ -356,7 +318,7 @@ $result_trees{'spaces_in_args'} = {
   ],
   'type' => 'document_root'
 };
-$result_trees{'spaces_in_args'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'spaces_in_args'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'spaces_in_args'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'spaces_in_args'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'args'}[0]{'contents'}[2];
 
 $result_texis{'spaces_in_args'} = '@linemacro mylinecommand {first, second, 
rest}
 @defblock
diff --git a/tp/t/results/linemacro/spaces_in_call.pl 
b/tp/t/results/linemacro/spaces_in_call.pl
index 21d80679ca..311585d26b 100644
--- a/tp/t/results/linemacro/spaces_in_call.pl
+++ b/tp/t/results/linemacro/spaces_in_call.pl
@@ -88,11 +88,6 @@ $result_trees{'spaces_in_call'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -102,42 +97,9 @@ $result_trees{'spaces_in_call'} = {
                   {
                     'contents' => [
                       {
-                        'contents' => [
-                          {
-                            'contents' => [
-                              {
-                                'text' => 'a b'
-                              }
-                            ],
-                            'type' => 'bracketed_arg'
-                          },
-                          {
-                            'contents' => [
-                              {
-                                'text' => 'c d'
-                              }
-                            ],
-                            'type' => 'bracketed_arg'
-                          },
-                          {
-                            'contents' => [
-                              {
-                                'text' => 'rest'
-                              }
-                            ],
-                            'type' => 'bracketed_arg'
-                          }
-                        ],
-                        'type' => 'def_aggregate'
-                      }
-                    ],
-                    'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                        'text' => '{a b}{c d}{rest}'
                       }
-                    },
-                    'type' => 'line_arg'
+                    ]
                   }
                 ],
                 'extra' => {
@@ -145,11 +107,13 @@ $result_trees{'spaces_in_call'} = {
                 },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -289,6 +253,14 @@ $result_trees{'spaces_in_call'} = {
                 {
                   'contents' => [
                     {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 8,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
                       'text' => 'defblock'
                     }
                   ],
@@ -321,14 +293,7 @@ $result_trees{'spaces_in_call'} = {
             'file_name' => '',
             'line_nr' => 7,
             'macro' => 'mylinecommand'
-          },
-          'source_marks' => [
-            {
-              'counter' => 1,
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'end'
-            }
-          ]
+          }
         }
       ],
       'type' => 'before_node_section'
@@ -336,7 +301,7 @@ $result_trees{'spaces_in_call'} = {
   ],
   'type' => 'document_root'
 };
-$result_trees{'spaces_in_call'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'spaces_in_call'}{'contents'}[0]{'contents'}[3]{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'spaces_in_call'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'extra'}{'def_index_element'}
 = 
$result_trees{'spaces_in_call'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'args'}[0]{'contents'}[2];
 
 $result_texis{'spaces_in_call'} = '@linemacro mylinecommand {first, second, 
rest}
 @defblock
diff --git a/tp/t/results/linemacro/text_arguments.pl 
b/tp/t/results/linemacro/text_arguments.pl
index 680c9f1cf8..6081313bdd 100644
--- a/tp/t/results/linemacro/text_arguments.pl
+++ b/tp/t/results/linemacro/text_arguments.pl
@@ -78,11 +78,6 @@ $result_trees{'text_arguments'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -93,52 +88,51 @@ $result_trees{'text_arguments'} = {
                     'contents' => [
                       {
                         'text' => 'X'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
                         'text' => 'Y'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
+                      }
+                    ],
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
+                  },
+                  {
+                    'contents' => [
                       {
                         'text' => 'Z'
                       }
                     ],
                     'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
+                      'spaces_before_argument' => {
+                        'text' => ' '
                       }
-                    },
-                    'type' => 'line_arg'
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'nospace'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -179,7 +173,7 @@ $result_trees{'text_arguments'} = {
               'source_marks' => [
                 {
                   'counter' => 1,
-                  'position' => 2,
+                  'position' => 1,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
diff --git a/tp/t/results/linemacro/verb_not_closed.pl 
b/tp/t/results/linemacro/verb_not_closed.pl
index 799c8a22d5..1f1eef5d6b 100644
--- a/tp/t/results/linemacro/verb_not_closed.pl
+++ b/tp/t/results/linemacro/verb_not_closed.pl
@@ -78,11 +78,6 @@ $result_trees{'verb_not_closed'} = {
             'macro' => ''
           }
         },
-        {
-          'text' => '
-',
-          'type' => 'empty_line'
-        },
         {
           'source_marks' => [
             {
@@ -92,52 +87,30 @@ $result_trees{'verb_not_closed'} = {
                   {
                     'contents' => [
                       {
-                        'args' => [
-                          {
-                            'contents' => [
-                              {
-                                'text' => ' in verb
-',
-                                'type' => 'raw'
-                              },
-                              {
-                                'text' => '
-',
-                                'type' => 'raw'
-                              }
-                            ],
-                            'type' => 'brace_command_arg'
-                          }
-                        ],
-                        'cmdname' => 'verb',
-                        'info' => {
-                          'delimiter' => ':'
-                        },
-                        'source_info' => {
-                          'file_name' => '',
-                          'line_nr' => 5,
-                          'macro' => ''
-                        }
+                        'text' => '@verb{: in verb
+
+'
                       }
                     ],
-                    'type' => 'line_arg'
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    }
                   }
                 ],
                 'extra' => {
                   'name' => 'mycommand'
                 },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
                 'type' => 'linemacro_call'
               },
+              'position' => 1,
               'sourcemark_type' => 'linemacro_expansion',
               'status' => 'start'
             }
           ],
-          'text' => '',
+          'text' => '
+',
           'type' => 'empty_line'
         },
         {
@@ -155,6 +128,18 @@ $result_trees{'verb_not_closed'} = {
                       'text' => '
 ',
                       'type' => 'raw'
+                    },
+                    {
+                      'source_marks' => [
+                        {
+                          'counter' => 1,
+                          'position' => 3,
+                          'sourcemark_type' => 'linemacro_expansion',
+                          'status' => 'end'
+                        }
+                      ],
+                      'text' => ',  ',
+                      'type' => 'raw'
                     }
                   ],
                   'type' => 'brace_command_arg'
@@ -169,18 +154,6 @@ $result_trees{'verb_not_closed'} = {
                 'line_nr' => 6,
                 'macro' => 'mycommand'
               }
-            },
-            {
-              'source_marks' => [
-                {
-                  'counter' => 1,
-                  'position' => 4,
-                  'sourcemark_type' => 'linemacro_expansion',
-                  'status' => 'end'
-                }
-              ],
-              'text' => ',  
-'
             }
           ],
           'type' => 'paragraph'
@@ -198,23 +171,30 @@ $result_texis{'verb_not_closed'} = '@linemacro mycommand 
{a, b, c}
 
 @verb{: in verb
 
-:},  
-';
+,  :}';
 
 
 $result_texts{'verb_not_closed'} = '
  in verb
 
-,  
-';
+,  ';
 
 $result_errors{'verb_not_closed'} = [
   {
-    'error_line' => '@verb missing closing delimiter sequence: :}
+    'error_line' => '@mycommand missing closing brace
 ',
     'file_name' => '',
-    'line_nr' => 5,
+    'line_nr' => 6,
     'macro' => '',
+    'text' => '@mycommand missing closing brace',
+    'type' => 'error'
+  },
+  {
+    'error_line' => '@verb missing closing delimiter sequence: :} (possibly 
involving @mycommand)
+',
+    'file_name' => '',
+    'line_nr' => 6,
+    'macro' => 'mycommand',
     'text' => '@verb missing closing delimiter sequence: :}',
     'type' => 'error'
   }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]