diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index a91bfacb9ea0..a84af8535b4f 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -3132,10 +3132,12 @@ one is able to set the variables. Setup for version-controlled files configurable by the variable @code{bug-reference-setup-from-vc-alist}. The default is able to setup GNU projects where @url{https://debbugs.gnu.org} is used as -issue tracker, Github projects where both bugs and pull requests are -referenced using the @code{#42} notation, and GitLab projects where -bugs are references with @code{#17}, too, but merge requests use the -@code{!18} notation. +issue tracker and issues are usually referenced as @code{bug#13} (but +many different notations are considered, too), Sourcehut projects +where issues are referenced using the notation @code{#17}, Github +projects where both bugs and pull requests are referenced using the +same notation, and GitLab projects where bugs are references with +@code{#17}, too, but merge requests use the @code{!18} notation. @item Setup for email guessing from mail folder/mbox names, and mail header diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 61d722f5b9df..918930a8afbc 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -201,6 +201,31 @@ The second subexpression should match the bug reference (usually a number)." (if (string= (match-string 3) "#") "issues/" "merge_requests/") + (match-string 2)))))) + + ;; + ;; Sourcehut projects. + ;; + ;; #19 is an issue. Other project's issues can be referenced as + ;; #~user/project#19. + ;; + ;; Caveat: The code assumes that a project on git.sr.ht or + ;; hg.sr.ht has a tracker of the same name on todo.sh.ht. That's + ;; a very common setup but all sr.ht services are loosely coupled, + ;; so you can have a repo without tracker, or a repo with a + ;; tracker using a different name, etc. So we can only try to + ;; make a good guess. + ("[/@]\\(?:git\\|hg\\).sr.ht[/:]\\(~[.A-Za-z0-9_/-]+\\)" + "\\(~[.A-Za-z0-9_/-]+\\)?\\(?:#\\)\\([0-9]+\\)\\>" + ,(lambda (groups) + (let ((ns-project (nth 1 groups))) + (lambda () + (concat "https://todo.sr.ht/" + (or + ;; Explicit user/proj#18 link. + (match-string 1) + ns-project) + "/" (match-string 2))))))) "An alist for setting up `bug-reference-mode' based on VC URL.