Skip to content

Commit f61801b

Browse files
Use git-link-web-host-alist in git-link-commit and git-link-homepage
Links to commits or project homepages now also use the optional translation mechanism from Git hosts to web hosts.
1 parent 8d0f98c commit f61801b

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

git-link.el

+17-10
Original file line numberDiff line numberDiff line change
@@ -917,24 +917,28 @@ With a prefix argument prompt for the remote's name.
917917
Defaults to \"origin\"."
918918

919919
(interactive (list (git-link--select-remote)))
920-
(let* (commit handler remote-info (remote-url (git-link--remote-url remote)))
920+
(let* ((remote-url (git-link--remote-url remote))
921+
commit handler remote-info git-host web-host)
921922
(if (null remote-url)
922923
(message "Remote `%s' not found" remote)
923924

924925
(setq remote-info (git-link--parse-remote remote-url)
926+
git-host (car remote-info)
925927
commit (word-at-point)
926-
handler (git-link--handler git-link-commit-remote-alist (car remote-info)))
928+
handler (git-link--handler git-link-commit-remote-alist git-host)
929+
web-host (or (assoc-default git-host git-link-web-host-alist #'string-match-p)
930+
git-host))
927931

928-
(cond ((null (car remote-info))
932+
(cond ((null git-host)
929933
(message "Remote `%s' contains an unsupported URL" remote))
930934
((not (string-match-p "[a-fA-F0-9]\\{7,40\\}" (or commit "")))
931935
(message "Point is not on a commit hash"))
932936
((not (functionp handler))
933-
(message "No handler for %s" (car remote-info)))
937+
(message "No handler for %s" git-host))
934938
;; null ret val
935939
((git-link--new
936940
(funcall handler
937-
(car remote-info)
941+
web-host
938942
(cadr remote-info)
939943
(substring-no-properties commit))))))))
940944

@@ -951,15 +955,18 @@ Defaults to \"origin\"."
951955

952956
(interactive (list (git-link--select-remote)))
953957

954-
(let* (handler remote-info
955-
(remote-url (git-link--remote-url remote))
956-
(git-link-open-in-browser (or git-link-open-in-browser (equal (list 16) current-prefix-arg))))
958+
(let* ((remote-url (git-link--remote-url remote))
959+
(git-link-open-in-browser (or git-link-open-in-browser (equal (list 16) current-prefix-arg)))
960+
handler remote-info git-host web-host)
957961

958962
(if (null remote-url)
959963
(message "Remote `%s' not found" remote)
960964

961965
(setq remote-info (git-link--parse-remote remote-url)
962-
handler (git-link--handler git-link-homepage-remote-alist (car remote-info)))
966+
git-host (car remote-info)
967+
handler (git-link--handler git-link-homepage-remote-alist git-host)
968+
web-host (or (assoc-default git-host git-link-web-host-alist #'string-match-p)
969+
git-host))
963970

964971
(cond ((null (car remote-info))
965972
(message "Remote `%s' contains an unsupported URL" remote))
@@ -968,7 +975,7 @@ Defaults to \"origin\"."
968975
;; null ret val
969976
((git-link--new
970977
(funcall handler
971-
(car remote-info)
978+
web-host
972979
(cadr remote-info))))))))
973980

974981
(provide 'git-link)

0 commit comments

Comments
 (0)