Skip to content

Commit ec3b108

Browse files
committed
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 emacs-mirror#17 and ~user/project#19 for sourcehut (sr.ht). * doc/emacs/maintaining.texi (Bug Reference): Document sourcehut support.
1 parent eaefa44 commit ec3b108

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

doc/emacs/maintaining.texi

+6-4
Original file line numberDiff line numberDiff line change
@@ -3132,10 +3132,12 @@ one is able to set the variables.
31323132
Setup for version-controlled files configurable by the variable
31333133
@code{bug-reference-setup-from-vc-alist}. The default is able to
31343134
setup GNU projects where @url{https://debbugs.gnu.org} is used as
3135-
issue tracker, Github projects where both bugs and pull requests are
3136-
referenced using the @code{#42} notation, and GitLab projects where
3137-
bugs are references with @code{#17}, too, but merge requests use the
3138-
@code{!18} notation.
3135+
issue tracker and issues are usually referenced as @code{bug#13} (but
3136+
many different notations are considered, too), Sourcehut projects
3137+
where issues are referenced using the notation @code{#17}, Github
3138+
projects where both bugs and pull requests are referenced using the
3139+
same notation, and GitLab projects where bugs are references with
3140+
@code{#17}, too, but merge requests use the @code{!18} notation.
31393141

31403142
@item
31413143
Setup for email guessing from mail folder/mbox names, and mail header

lisp/progmodes/bug-reference.el

+25
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,31 @@ The second subexpression should match the bug reference (usually a number)."
201201
(if (string= (match-string 3) "#")
202202
"issues/"
203203
"merge_requests/")
204+
(match-string 2))))))
205+
206+
;;
207+
;; Sourcehut projects.
208+
;;
209+
;; #19 is an issue. Other project's issues can be referenced as
210+
;; #~user/project#19.
211+
;;
212+
;; Caveat: The code assumes that a project on git.sr.ht or
213+
;; hg.sr.ht has a tracker of the same name on todo.sh.ht. That's
214+
;; a very common setup but all sr.ht services are loosely coupled,
215+
;; so you can have a repo without tracker, or a repo with a
216+
;; tracker using a different name, etc. So we can only try to
217+
;; make a good guess.
218+
("[/@]\\(?:git\\|hg\\).sr.ht[/:]\\(~[.A-Za-z0-9_/-]+\\)"
219+
"\\(~[.A-Za-z0-9_/-]+\\)?\\(?:#\\)\\([0-9]+\\)\\>"
220+
,(lambda (groups)
221+
(let ((ns-project (nth 1 groups)))
222+
(lambda ()
223+
(concat "https://todo.sr.ht/"
224+
(or
225+
;; Explicit user/proj#18 link.
226+
(match-string 1)
227+
ns-project)
228+
"/"
204229
(match-string 2)))))))
205230
"An alist for setting up `bug-reference-mode' based on VC URL.
206231

0 commit comments

Comments
 (0)