@@ -588,6 +588,14 @@ return (FILENAME . REVISION) otherwise nil."
588
588
link
589
589
)
590
590
591
+ (defun git-link--web-host (git-host )
592
+ " Determine the web host to use for GIT-HOST.
593
+
594
+ The translation is based on `git-link-web-host-alist' . If there
595
+ is no entry for GIT-HOST in the list, it is returned unmodified."
596
+ (or (assoc-default git-host git-link-web-host-alist #'string-match-p )
597
+ git-host))
598
+
591
599
(defun git-link-codeberg (hostname dirname filename branch commit start end )
592
600
(format " https://%s /%s /src/%s /%s "
593
601
hostname
@@ -872,8 +880,7 @@ With a double prefix argument invert the value of
872
880
branch (git-link--branch)
873
881
commit (git-link--commit)
874
882
handler (git-link--handler git-link-remote-alist git-host)
875
- web-host (or (assoc-default git-host git-link-web-host-alist #'string-match-p )
876
- git-host))
883
+ web-host (git-link--web-host git-host))
877
884
878
885
(cond ((null filename)
879
886
(message " Can't figure out what to link to " ))
@@ -917,24 +924,27 @@ With a prefix argument prompt for the remote's name.
917
924
Defaults to \" origin\" ."
918
925
919
926
(interactive (list (git-link--select-remote)))
920
- (let* (commit handler remote-info (remote-url (git-link--remote-url remote)))
927
+ (let* ((remote-url (git-link--remote-url remote))
928
+ commit handler remote-info git-host web-host)
921
929
(if (null remote-url)
922
930
(message " Remote `%s' not found " remote)
923
931
924
932
(setq remote-info (git-link--parse-remote remote-url)
933
+ git-host (car remote-info)
925
934
commit (word-at-point )
926
- handler (git-link--handler git-link-commit-remote-alist (car remote-info)))
935
+ handler (git-link--handler git-link-commit-remote-alist git-host)
936
+ web-host (git-link--web-host git-host))
927
937
928
- (cond ((null ( car remote-info) )
938
+ (cond ((null git-host )
929
939
(message " Remote `%s' contains an unsupported URL " remote))
930
940
((not (string-match-p " [a-fA-F0-9]\\ {7,40\\ }" (or commit " " )))
931
941
(message " Point is not on a commit hash " ))
932
942
((not (functionp handler))
933
- (message " No handler for %s " ( car remote-info) ))
943
+ (message " No handler for %s " git-host ))
934
944
; ; null ret val
935
945
((git-link--new
936
946
(funcall handler
937
- ( car remote-info)
947
+ web-host
938
948
(cadr remote-info)
939
949
(substring-no-properties commit))))))))
940
950
@@ -951,15 +961,17 @@ Defaults to \"origin\"."
951
961
952
962
(interactive (list (git-link--select-remote)))
953
963
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))) )
964
+ (let* ((remote-url (git-link-- remote-url remote))
965
+ (git-link-open-in-browser ( or git-link-open-in-browser ( equal ( list 16 ) current-prefix-arg) ))
966
+ handler remote-info git-host web-host )
957
967
958
968
(if (null remote-url)
959
969
(message " Remote `%s' not found " remote)
960
970
961
971
(setq remote-info (git-link--parse-remote remote-url)
962
- handler (git-link--handler git-link-homepage-remote-alist (car remote-info)))
972
+ git-host (car remote-info)
973
+ handler (git-link--handler git-link-homepage-remote-alist git-host)
974
+ web-host (git-link--web-host git-host))
963
975
964
976
(cond ((null (car remote-info))
965
977
(message " Remote `%s' contains an unsupported URL " remote))
@@ -968,7 +980,7 @@ Defaults to \"origin\"."
968
980
; ; null ret val
969
981
((git-link--new
970
982
(funcall handler
971
- ( car remote-info)
983
+ web-host
972
984
(cadr remote-info))))))))
973
985
974
986
(provide 'git-link )
0 commit comments