emacs-diffs
[Top][All Lists]
Advanced

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

master ec3b108: Add support for sourcehut to bug-reference.el


From: Tassilo Horn
Subject: master ec3b108: Add support for sourcehut to bug-reference.el
Date: Thu, 15 Jul 2021 15:45:30 -0400 (EDT)

branch: master
commit ec3b108c1f91f7adb25db46ae6aacddff762ed8a
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>

    Add support for sourcehut to bug-reference.el
    
    * lisp/progmodes/bug-reference.el (bug-reference-setup-from-vc-alist):
    Add support for bug references like #17 and ~user/project#19 for
    sourcehut (sr.ht).
    * doc/emacs/maintaining.texi (Bug Reference): Document sourcehut
    support.
---
 doc/emacs/maintaining.texi      | 10 ++++++----
 lisp/progmodes/bug-reference.el | 25 +++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index a91bfac..a84af85 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 61d722f..918930a 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.
 



reply via email to

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