Skip to content

Commit

Permalink
Add support for sourcehut to bug-reference.el
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
tsdh committed Jul 15, 2021
1 parent eaefa44 commit ec3b108
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
10 changes: 6 additions & 4 deletions doc/emacs/maintaining.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions lisp/progmodes/bug-reference.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ec3b108

Please sign in to comment.