[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Handle default index commands similarly to other
From: |
Patrice Dumas |
Subject: |
branch master updated: Handle default index commands similarly to other @-commands |
Date: |
Sat, 11 May 2024 17:25:15 -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 e4a19ed9c9 Handle default index commands similarly to other @-commands
e4a19ed9c9 is described below
commit e4a19ed9c9f57c3130f355c524b82bf65449bc53
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 11 23:25:12 2024 +0200
Handle default index commands similarly to other @-commands
* tp/Texinfo/ParserNonXS.pm (parser, simple_parser),
tp/Texinfo/XS/parsetexi/indices.c (struct def, default_indices)
(init_index_commands), tp/Texinfo/command_data.txt,
tp/maintain/regenerate_commands_perl_info.pl: add default index
commands to tp/Texinfo/command_data.txt like other builtin @-commands.
---
ChangeLog | 10 ++++++++
tp/Texinfo/ParserNonXS.pm | 38 ++++++++++------------------
tp/Texinfo/XS/main/command_ids.h | 14 +++++++++-
tp/Texinfo/XS/parsetexi/indices.c | 31 +++++++++--------------
tp/Texinfo/command_data.txt | 13 ++++++++++
tp/maintain/regenerate_commands_perl_info.pl | 4 +--
6 files changed, 63 insertions(+), 47 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 91212a065a..d081034647 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-05-11 Patrice Dumas <pertusus@free.fr>
+
+ Handle default index commands similarly to other @-commands
+
+ * tp/Texinfo/ParserNonXS.pm (parser, simple_parser),
+ tp/Texinfo/XS/parsetexi/indices.c (struct def, default_indices)
+ (init_index_commands), tp/Texinfo/command_data.txt,
+ tp/maintain/regenerate_commands_perl_info.pl: add default index
+ commands to tp/Texinfo/command_data.txt like other builtin @-commands.
+
2024-05-11 Patrice Dumas <pertusus@free.fr>
Update POD of index_entry extra key.
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 7f02165b85..979e5425bc 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -229,13 +229,14 @@ my %parser_default_configuration = (
# is also in that structure.
# line_commands the same as %line_commands in Texinfo::Common,
# but with index entry commands dynamically added
-# close_paragraph_commands same as %default_close_paragraph_commands, with
-# index commands dynamically added.
+# close_paragraph_commands same as %close_paragraph_commands, with
+# commands dynamically added (no command added
+# in 2024).
# close_preformatted_commands same as %close_preformatted_commands
-# no_paragraph_commands the same as %default_no_paragraph_commands
-# below, with index entry commands dynamically added.
+# no_paragraph_commands the same as %no_paragraph_commands below,
+# with new index entry commands dynamically added.
# basic_inline_commands the same as %contain_basic_inline_commands below, but
-# with index entry commands dynamically added
+# with new index entry commands dynamically added
# current_node last seen node.
# current_section last seen section.
# nodes list of nodes.
@@ -386,18 +387,7 @@ foreach my $not_begin_line_command ('comment', 'c',
'columnfractions',
my %index_names = %Texinfo::Commands::index_names;
# @-commands that do not start a paragraph
-my %default_no_paragraph_commands = %Texinfo::Commands::no_paragraph_commands;
-
-my %default_close_paragraph_commands = %close_paragraph_commands;
-my %default_basic_inline_commands = %contain_basic_inline_commands;
-foreach my $index (keys(%index_names)) {
- my $one_letter_prefix = substr($index, 0, 1);
- foreach my $prefix ($index, $one_letter_prefix) {
- #$default_close_paragraph_commands{$prefix.'index'} = 1;
- $default_basic_inline_commands{$prefix.'index'} = 1;
- $default_no_paragraph_commands{$prefix.'index'} = 1;
- }
-}
+my %no_paragraph_commands = %Texinfo::Commands::no_paragraph_commands;
# does not include index commands
my %close_preformatted_commands = %close_paragraph_commands;
@@ -588,10 +578,10 @@ sub parser(;$$)
$parser->{'line_commands'} = dclone(\%line_commands);
$parser->{'brace_commands'} = dclone(\%brace_commands);
$parser->{'valid_nestings'} = dclone(\%default_valid_nestings);
- $parser->{'no_paragraph_commands'} = {%default_no_paragraph_commands};
+ $parser->{'no_paragraph_commands'} = {%no_paragraph_commands};
$parser->{'index_names'} = dclone(\%index_names);
$parser->{'command_index'} = {%command_index};
- $parser->{'close_paragraph_commands'} = {%default_close_paragraph_commands};
+ $parser->{'close_paragraph_commands'} = {%close_paragraph_commands};
$parser->{'close_preformatted_commands'} = {%close_preformatted_commands};
# following is common with simple_parser
@@ -603,7 +593,7 @@ sub parser(;$$)
$parser->{'nesting_context'}->{'basic_inline_stack_on_line'} = [];
$parser->{'nesting_context'}->{'basic_inline_stack_block'} = [];
$parser->{'nesting_context'}->{'regions_stack'} = [];
- $parser->{'basic_inline_commands'} = {%default_basic_inline_commands};
+ $parser->{'basic_inline_commands'} = {%contain_basic_inline_commands};
$parser->_init_context_stack();
@@ -629,10 +619,10 @@ sub parser(;$$)
my $simple_parser_line_commands = dclone(\%line_commands);
my $simple_parser_brace_commands = dclone(\%brace_commands);
my $simple_parser_valid_nestings = dclone(\%default_valid_nestings);
-my $simple_parser_no_paragraph_commands = {%default_no_paragraph_commands};
+my $simple_parser_no_paragraph_commands = {%no_paragraph_commands};
my $simple_parser_index_names = dclone(\%index_names);
my $simple_parser_command_index = {%command_index};
-my $simple_parser_close_paragraph_commands =
{%default_close_paragraph_commands};
+my $simple_parser_close_paragraph_commands = {%close_paragraph_commands};
my $simple_parser_close_preformatted_commands = {%close_preformatted_commands};
sub simple_parser(;$)
{
@@ -667,7 +657,7 @@ sub simple_parser(;$)
$parser->{'nesting_context'}->{'basic_inline_stack_on_line'} = [];
$parser->{'nesting_context'}->{'basic_inline_stack_block'} = [];
$parser->{'nesting_context'}->{'regions_stack'} = [];
- $parser->{'basic_inline_commands'} = {%default_basic_inline_commands};
+ $parser->{'basic_inline_commands'} = {%contain_basic_inline_commands};
$parser->_init_context_stack();
@@ -7794,7 +7784,6 @@ sub _parse_line_command_args($$$)
delete $self->{'aliases'}->{$cmd_name};
# unset @def*index effect
delete $self->{'line_commands'}->{$cmd_name};
- #delete $self->{'close_paragraph_commands'}->{$cmd_name};
delete $self->{'no_paragraph_commands'}->{$cmd_name};
delete $self->{'basic_inline_commands'}->{$cmd_name};
delete $self->{'command_index'}->{$cmd_name};
@@ -7861,7 +7850,6 @@ sub _parse_line_command_args($$$)
delete $self->{'brace_commands'}->{$index_cmdname};
delete $self->{'valid_nestings'}->{$index_cmdname};
$self->{'line_commands'}->{$index_cmdname} = 'line';
- #$self->{'close_paragraph_commands'}->{$index_cmdname} = 1;
$self->{'no_paragraph_commands'}->{$index_cmdname} = 1;
$self->{'basic_inline_commands'}->{$index_cmdname} = 1;
$self->{'command_index'}->{$index_cmdname} = $name;
diff --git a/tp/Texinfo/XS/main/command_ids.h b/tp/Texinfo/XS/main/command_ids.h
index 88feaddee9..0ef7f9b74d 100644
--- a/tp/Texinfo/XS/main/command_ids.h
+++ b/tp/Texinfo/XS/main/command_ids.h
@@ -95,6 +95,7 @@ CM_center,
CM_centerchap,
CM_chapheading,
CM_chapter,
+CM_cindex,
CM_cite,
CM_clear,
CM_click,
@@ -110,6 +111,7 @@ CM_comment,
CM_contents,
CM_copying,
CM_copyright,
+CM_cpindex,
CM_defblock,
CM_defcodeindex,
CM_defcv,
@@ -198,10 +200,12 @@ CM_exdent,
CM_expansion,
CM_file,
CM_finalout,
+CM_findex,
CM_firstparagraphindent,
CM_float,
CM_flushleft,
CM_flushright,
+CM_fnindex,
CM_fonttextsize,
CM_footnote,
CM_footnotestyle,
@@ -263,6 +267,8 @@ CM_itemx,
CM_kbd,
CM_kbdinputstyle,
CM_key,
+CM_kindex,
+CM_kyindex,
CM_l,
CM_latex,
CM_lbracechar,
@@ -299,6 +305,8 @@ CM_page,
CM_pagesizes,
CM_paragraphindent,
CM_part,
+CM_pgindex,
+CM_pindex,
CM_point,
CM_pounds,
CM_print,
@@ -375,11 +383,13 @@ CM_thissectionnum,
CM_thistitle,
CM_tie,
CM_tieaccent,
+CM_tindex,
CM_title,
CM_titlefont,
CM_titlepage,
CM_today,
CM_top,
+CM_tpindex,
CM_txiinternalvalue,
CM_u,
CM_ubaraccent,
@@ -398,6 +408,8 @@ CM_var,
CM_verb,
CM_verbatim,
CM_verbatiminclude,
+CM_vindex,
+CM_vrindex,
CM_vskip,
CM_vtable,
CM_w,
@@ -409,5 +421,5 @@ CM_hex_7c,
CM_hex_7d,
CM_hex_7e,
};
-#define BUILTIN_CMD_NUMBER 377
+#define BUILTIN_CMD_NUMBER 389
#endif
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index d26bc311e1..628a6453fc 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -93,7 +93,6 @@ add_index_command (char *cmdname, INDEX *idx)
enum command_id new = add_texinfo_command (cmdname);
user_defined_command_data[new & ~USER_COMMAND_BIT].flags
|= CF_line | CF_index_entry_command | CF_contain_basic_inline
- /* | CF_close_paragraph */
| CF_no_paragraph;
user_defined_command_data[new & ~USER_COMMAND_BIT].data = LINE_line;
associate_command_to_index (new, idx);
@@ -142,21 +141,19 @@ init_index_commands (void)
{
INDEX *idx;
- struct def { char *name; int in_code; }
+ struct def { char *name; int in_code;
+ enum command_id cmd2; enum command_id cmd1;}
*p, default_indices[] = {
- "cp", 0, /* concepts */
- "fn", 1, /* functions */
- "vr", 1, /* variables */
- "ky", 1, /* keystrokes */
- "pg", 1, /* programs */
- "tp", 1, /* types */
- 0, 0
+ "cp", 0, CM_cpindex, CM_cindex, /* concepts */
+ "fn", 1, CM_fnindex, CM_findex, /* functions */
+ "vr", 1, CM_vrindex, CM_vindex, /* variables */
+ "ky", 1, CM_kyindex, CM_kindex, /* keystrokes */
+ "pg", 1, CM_pgindex, CM_pindex, /* programs */
+ "tp", 1, CM_tpindex, CM_tindex, /* types */
+ 0, 0, 0, 0
};
int i, j;
- char name[] = "?index";
- char name2[] = "??index";
-
#define MAX (10 * 2)
#define X(command) CM_##command, CM_##command##x
@@ -200,15 +197,11 @@ init_index_commands (void)
for (p = default_indices; p->name; p++)
{
- /* Both @cindex and @cpindex are added. */
idx = add_index_internal (strdup (p->name), p->in_code);
- *name = p->name[0];
- add_index_command (name, idx); /* @cindex */
-
- name2[0] = p->name[0];
- name2[1] = p->name[1];
- add_index_command (name2, idx); /* @cpindex */
+ /* Both @cpindex and @cindex are associated. */
+ associate_command_to_index (p->cmd2, idx);
+ associate_command_to_index (p->cmd1, idx);
}
associate_command_to_index (CM_vtable,
diff --git a/tp/Texinfo/command_data.txt b/tp/Texinfo/command_data.txt
index ab961e297d..c6ee0e3a90 100644
--- a/tp/Texinfo/command_data.txt
+++ b/tp/Texinfo/command_data.txt
@@ -275,6 +275,19 @@ title
line,formatted_line,global_unique,contain_basic_inline
sp
line,formattable_line,close_paragraph,contain_plain_text LINE_specific 1
page line,formatted_line,close_paragraph LINE_lineraw
+# index commands
+cpindex line,index_entry_command,contain_basic_inline
LINE_line
+cindex line,index_entry_command,contain_basic_inline
LINE_line
+fnindex line,index_entry_command,contain_basic_inline
LINE_line
+findex line,index_entry_command,contain_basic_inline
LINE_line
+vrindex line,index_entry_command,contain_basic_inline
LINE_line
+vindex line,index_entry_command,contain_basic_inline
LINE_line
+kyindex line,index_entry_command,contain_basic_inline
LINE_line
+kindex line,index_entry_command,contain_basic_inline
LINE_line
+pgindex line,index_entry_command,contain_basic_inline
LINE_line
+pindex line,index_entry_command,contain_basic_inline
LINE_line
+tpindex line,index_entry_command,contain_basic_inline
LINE_line
+tindex line,index_entry_command,contain_basic_inline
LINE_line
##########################################################
#
diff --git a/tp/maintain/regenerate_commands_perl_info.pl
b/tp/maintain/regenerate_commands_perl_info.pl
index 14920d3300..8558be63fa 100755
--- a/tp/maintain/regenerate_commands_perl_info.pl
+++ b/tp/maintain/regenerate_commands_perl_info.pl
@@ -171,7 +171,8 @@ foreach my $index_name (sort(keys(%index_in_code))) {
}
print OUT ");\n\n";
-# add code that sets %line_commands for index commands based on %index_names
+# add code that sets %default_index_commands for index commands based
+# on %index_names
print OUT 'foreach my $index (keys(%index_names)) {
$index_names{$index}->{"name"} = $index;
}
@@ -180,7 +181,6 @@ our %default_index_commands;
foreach my $index_name (keys (%index_names)) {
my $one_letter_prefix = substr($index_name, 0, 1);
foreach my $prefix ($index_name, $one_letter_prefix) {
- $line_commands{$prefix."index"} = "line";
$default_index_commands{$prefix."index"} = $index_name;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Handle default index commands similarly to other @-commands,
Patrice Dumas <=