Simon Josefsson [2025-11-15 16:52 +0100] wrote:

> "Basil L. Contovounesios" <[email protected]> writes:
>
>> d. Extend the default patterns to match all reasonably conceivable
>>    heading patterns.  This addresses both concerns (1) and (2), and
>>    allows automatic Markdown detection, but is not configurable.
>
> Yes -- I don't think parametrization is particulary useful here.  It is
> simpler to hard-code the regexp in the script, and people who doesn't
> like it can patch the script using our support mechanism to do so.
> Instead of chasing through the labyrinth of maint.mk and cfg.mk
> variables.
>
> It is better if we just document a recommended style, and adapt our
> tooling to assume it.  Most people will just change to the recommended
> style, and in the odd case where the default style actually is
> sub-optimal, we are likely to find out and can reconsider.

SGTM, thanks.  Updated patches attached.

-- 
Basil

>From fee80090b33daa0442c3248b7012712b143cf36f Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <[email protected]>
Date: Wed, 12 Nov 2025 14:49:46 +0100
Subject: [PATCH 1/2] announce-gen: Accommodate alternative NEWS formats.

Suggested by Simon Josefsson <[email protected]> in:
<https://lists.gnu.org/r/bug-gnulib/2025-11/msg00154.html>.

* build-aux/announce-gen (print_news_deltas): Accept Markdown
ATX-style '#' headings in addition to outline-mode '*' headings.
Allow multiple repetitions of the heading marker.
---
 ChangeLog              | 9 +++++++++
 build-aux/announce-gen | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8f1a59c237..e4d7e7ff05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-11-15  Basil L. Contovounesios  <[email protected]>
+
+	announce-gen: Accommodate alternative NEWS formats.
+	Suggested by Simon Josefsson <[email protected]> in:
+	<https://lists.gnu.org/r/bug-gnulib/2025-11/msg00154.html>.
+	* build-aux/announce-gen (print_news_deltas): Accept Markdown
+	ATX-style '#' headings in addition to outline-mode '*' headings.
+	Allow multiple repetitions of the heading marker.
+
 2025-11-14  Paul Eggert  <[email protected]>
 
 	openat2: fix symlink splicing bug
diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index c90a33e3b2..41f298699f 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -35,7 +35,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2025-07-30 01:47'; # UTC
+my $VERSION = '2025-11-15 18:36'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -235,7 +235,7 @@ sub print_news_deltas ($$$)
   # the first occurrence of $prev_version.
   my $in_items;
 
-  my $re_prefix = qr/(?:\* )?(?:Noteworthy c|Major c|C)(?i:hanges)/;
+  my $re_prefix = qr/(?:[#*]+ )?(?:Noteworthy c|Major c|C)(?i:hanges)/;
 
   my $found_news;
   open NEWS, '<', $news_file
-- 
2.51.0

>From 33be141009d072c311dd78e5e958afed08aeb844 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <[email protected]>
Date: Fri, 14 Nov 2025 23:42:10 +0100
Subject: [PATCH 2/2] maintainer-makefile: Auto-detect NEWS.md.

Suggested by Simon Josefsson <[email protected]> in:
<https://lists.gnu.org/r/bug-gnulib/2025-11/msg00127.html>.

* top/maint.mk (NEWS_file): Default to NEWS.md when present.
(news-check-regexp, news-check-regexp-prev): Accept headings marked
with either '#' or '*'.
(gl_noteworthy_news_): Default to a #-heading in place of
a *-heading when NEWS_file name implies Markdown.
(release-prep): Consistently prefer test over [.
---
 ChangeLog    | 12 ++++++++++++
 top/maint.mk | 17 ++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e4d7e7ff05..d554e967fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-11-15  Basil L. Contovounesios  <[email protected]>
+
+	maintainer-makefile: Auto-detect NEWS.md.
+	Suggested by Simon Josefsson <[email protected]> in:
+	<https://lists.gnu.org/r/bug-gnulib/2025-11/msg00127.html>.
+	* top/maint.mk (NEWS_file): Default to NEWS.md when present.
+	(news-check-regexp, news-check-regexp-prev): Accept headings marked
+	with either '#' or '*'.
+	(gl_noteworthy_news_): Default to a #-heading in place of
+	a *-heading when NEWS_file name implies Markdown.
+	(release-prep): Consistently prefer test over [.
+
 2025-11-15  Basil L. Contovounesios  <[email protected]>
 
 	announce-gen: Accommodate alternative NEWS formats.
diff --git a/top/maint.mk b/top/maint.mk
index 815a23a13e..9a8dee8537 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -146,6 +146,12 @@ url_dir_list ?=
                      https://ftpmirror.gnu.org/$(PACKAGE),		\
                      https://$(gnu_rel_host)/gnu/$(PACKAGE))
 
+# NEWS.md takes precedence over NEWS.
+# Override this in cfg.mk if you use a different file name.
+ifeq ($(origin NEWS_file),undefined)
+  NEWS_file := NEWS$(and $(wildcard $(srcdir)/NEWS.md),.md)
+endif
+
 # An ERE matching the release date (typically today, but not necessarily).
 # Override this in cfg.mk if you are using a different format in your
 # NEWS file.
@@ -158,10 +164,10 @@ today =
 news-check-lines-spec ?= 1,10
 
 # An ERE quoted for the shell, for matching a version+date line prefix.
-news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
+news-check-regexp ?= '^[\#*].* $(VERSION_REGEXP) \($(today)\)'
 
 # Like news-check-regexp, but as an unquoted BRE for .prev-version.
-news-check-regexp-prev ?= ^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)
+news-check-regexp-prev ?= ^[\#*].* $(PREV_VERSION_REGEXP) ([0-9-]*)
 
 # Prevent programs like 'sort' from considering distinct strings to be equal.
 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
@@ -1260,7 +1266,6 @@ sc_const_long_option:
 	halt='add "const" to the above declarations'			\
 	  $(_sc_search_regexp)
 
-NEWS_file ?= NEWS
 NEWS_hash =								\
   $$($(SED) -n '/$(news-check-regexp-prev)/,$$p' $(srcdir)/$(NEWS_file)	\
      | perl -0777 -pe							\
@@ -1698,7 +1703,9 @@ release:
 release-prep-hook ?= release-prep
 
 # Keep consistent with news-check-regexp and news-check-regexp-prev.
-gl_noteworthy_news_ ?= * Noteworthy changes in release ?.? (????-??-??) [?]
+gl_noteworthy_news_ ?= \
+  $(if $(filter %.md,$(NEWS_file)),#,*) \
+  Noteworthy changes in release ?.? (????-??-??) [?]
 .PHONY: release-prep
 release-prep:
 	$(AM_V_GEN)$(MAKE) --no-print-directory -s announcement \
@@ -1711,7 +1718,7 @@ release-prep:
 	$(AM_V_at)$(MAKE) update-NEWS-hash
 	$(AM_V_at)n=$$($(SED) -n -E				\
 	  '$(news-check-lines-spec){/'$(news-check-regexp)'/=}'	\
-	  $(srcdir)/$(NEWS_file)); [ -n "$$n" ]			\
+	  $(srcdir)/$(NEWS_file)); test -n "$$n"		\
 	  && env gl_n=$$n gl_s='$(gl_noteworthy_news_)'		\
 	         perl -pi -e '$$. == $$ENV{gl_n} '		\
 	                  -e '  and print "$$ENV{gl_s}\n\n\n"'	\
-- 
2.51.0

Reply via email to