Subject: Re: [bug#65883] [PATCH] .dir-locals.el: Update bug-reference configuration and document it.

From: brian <[email-masked]>
Date: Tue, 12 Sep 2023 10:20:10 -0400

Maxim Cournoyer <[email-masked]> writes:

> +;;; This extends the default expression (the first complicated blob) to also
> +;;; match URLs such as <https://issues.guix.gnu.org/58697> or
> +;;; <https://bugs.gnu.org/58697>.  It is also extended to detect "Fixes:
> +;;; #NNNNN" git trailers.
> +(setq bug-reference-bug-regexp
> +      (concat
> +       "\\("
> +       "\\(?:\\b\\(?:[Bb]ug ?#?\\|[Pp]atch ?#\\|[Ff]ixes:? ?#\\|\
> +RFE ?#\\|PR [a-z+-]+/\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)\\)"
> +       "\\|"
> +       "\\(?:<https://bugs\\.gnu\\.org/\\(?2:[0-9]+\\)>\\)"
> +       "\\)"))

Is there any reason not to use ‘rx’, rather than, as you say,
“complicated blobs’? Particularly with Emacs' requirement for ‘\\’
everywhere, regexps become even more like line noise.

If I'm reading this regexp right, for example, it could be:
--8<---------------cut here---------------start------------->8---
(setq bug-reference-bug-regexp2
      (rx (group (or (seq word-boundary
                         (or (seq (char "Bb") "ug"
                                 (zero-or-one " ")
                                 (zero-or-one "#"))
                            (seq (char "Pp") "atch"
                                 (zero-or-one " ")
                                 "#")
                            (seq (char "Ff") "ixes"
                                 (zero-or-one ":")
                                 (zero-or-one " ") "#")
                            (seq "RFE"
                                 (zero-or-one " ") "#")
                            (seq "PR "
                                 (one-or-more (char "a-z+-")) "/"))
                         (group (one-or-more (char "0-9"))
                                (zero-or-one
                                 (seq "#" (one-or-more
                                           (char "0-9"))))))
                    (seq "<https://bugs.gnu.org/"
                         (group-n 2 (one-or-more (char "0-9")))
                         ">")))))
--8<---------------cut here---------------end--------------->8---

-bjc