texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * doc/texi2any_api.texi (Modifying Main Program A


From: Patrice Dumas
Subject: branch master updated: * doc/texi2any_api.texi (Modifying Main Program Array Variables), tp/Texinfo/Config.pm (texinfo_add_to_option_list): add a $prepend optional argument to texinfo_add_to_option_list, in which case the values are prepended.
Date: Sun, 25 Aug 2024 11:53:49 -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 0a0dd1a65f * doc/texi2any_api.texi (Modifying Main Program Array 
Variables), tp/Texinfo/Config.pm (texinfo_add_to_option_list): add a $prepend 
optional argument to texinfo_add_to_option_list, in which case the values are 
prepended.
0a0dd1a65f is described below

commit 0a0dd1a65fad4dd5d30eb23ccb792b4878743214
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 25 17:53:50 2024 +0200

    * doc/texi2any_api.texi (Modifying Main Program Array Variables),
    tp/Texinfo/Config.pm (texinfo_add_to_option_list): add a $prepend
    optional argument to texinfo_add_to_option_list, in which case the
    values are prepended.
---
 ChangeLog             |  7 +++++++
 doc/texi2any_api.texi |  5 ++++-
 tp/Texinfo/Config.pm  | 16 ++++++++++++----
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cc0f500d44..9baab3d17f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-08-25  Patrice Dumas  <pertusus@free.fr>
+
+       * doc/texi2any_api.texi (Modifying Main Program Array Variables),
+       tp/Texinfo/Config.pm (texinfo_add_to_option_list): add a $prepend
+       optional argument to texinfo_add_to_option_list, in which case the
+       values are prepended.
+
 2024-08-25  Patrice Dumas  <pertusus@free.fr>
 
        Add TEXINFO_LANGUAGE_DIRECTORIES customization option
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 583b9537ce..5904623cbd 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -358,12 +358,15 @@ are handled differently. You can use 
@code{texinfo_add_to_option_list} to
 add values to the array and @code{texinfo_remove_from_option_list} to
 remove values from the array associated with the customization variable:
 
-@defun texinfo_add_to_option_list ($variable_name, 
$variable_values_array_reference)
+@defun texinfo_add_to_option_list ($variable_name, 
$variable_values_array_reference, $prepend)
 @defunx texinfo_remove_from_option_list ($variable_name, 
$variable_values_array_reference)
 @var{$variable_name} is the name of the variable; the values in the
 array reference @var{$variable_values_array_reference} are added to the
 list associated with the variable with @code{texinfo_add_to_option_list}, and 
removed with
 @code{texinfo_remove_from_option_list}.
+
+If the optional argument of @code{texinfo_add_to_option_list} @var{$prepend}
+is set, the values are prepended instead of being appended.
 @end defun
 
 
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 4778ef5fdc..5f99809b56 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -310,16 +310,24 @@ sub GNUT_set_customization_default($$)
 
 # called both from main program and init files, for %options_as_lists
 # options with lists set in main program.
-sub texinfo_add_to_option_list($$)
+sub texinfo_add_to_option_list($$;$)
 {
   my $var = shift;
   my $values_array_ref = shift;
+  my $prepend = shift;
+
   if (not $options_as_lists{$var}) {
     return 0;
   }
-  foreach my $value (@$values_array_ref) {
-    push @{$cmdline_options->{$var}}, $value
-      unless (grep {$_ eq $value} @{$cmdline_options->{$var}});
+  if ($prepend) {
+    # accept duplicates in that case, as prepending should in general
+    # be used to override by being first
+    unshift @{$cmdline_options->{$var}}, @$values_array_ref;
+  } else {
+    foreach my $value (@$values_array_ref) {
+      push @{$cmdline_options->{$var}}, $value
+        unless (grep {$_ eq $value} @{$cmdline_options->{$var}});
+    }
   }
   return 1;
 }



reply via email to

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