Fix VC repo URL detection in bug-reference-mode

* lisp/progmodes/bug-reference.el (bug-reference-try-setup-from-vc):
Pass file or directory name in question as the first argument to the
backend's repository-url implementation (bug#50689).  Use when-let
and seq-some to flatten nested conditionals.
This commit is contained in:
Basil L. Contovounesios 2021-09-19 21:13:17 +01:00
parent d16e51e8d2
commit 7d5930a6f0

View file

@ -376,24 +376,19 @@ URL-REGEXP against the VCS URL and returns the value to be set as
Test each configuration in `bug-reference-setup-from-vc-alist'
and `bug-reference--setup-from-vc-alist' and apply it if
applicable."
(let ((file-or-dir (or buffer-file-name
;; Catches modes such as vc-dir and Magit.
default-directory)))
(when file-or-dir
(let* ((backend (vc-responsible-backend file-or-dir t))
(url
(or (ignore-errors
(vc-call-backend backend 'repository-url "upstream"))
(ignore-errors
(vc-call-backend backend 'repository-url)))))
(when url
(catch 'found
(dolist (config (append
bug-reference-setup-from-vc-alist
(bug-reference--setup-from-vc-alist)))
(when (apply #'bug-reference-maybe-setup-from-vc
url config)
(throw 'found t)))))))))
(when-let ((file-or-dir (or buffer-file-name
;; Catches modes such as vc-dir and Magit.
default-directory))
(backend (vc-responsible-backend file-or-dir t))
(url (seq-some (lambda (remote)
(ignore-errors
(vc-call-backend backend 'repository-url
file-or-dir remote)))
'("upstream" nil))))
(seq-some (lambda (config)
(apply #'bug-reference-maybe-setup-from-vc url config))
(append bug-reference-setup-from-vc-alist
(bug-reference--setup-from-vc-alist)))))
(defvar bug-reference-setup-from-mail-alist
`((,(regexp-opt '("emacs" "auctex" "gnus" "tramp" "orgmode") 'words)