Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for repositories that are hosted on gnu #46

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion browse-at-remote.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
(defcustom browse-at-remote-remote-type-domains
'(("bitbucket.org" ."bitbucket")
("github.com" . "github")
("gitlab.com" . "gitlab"))
("gitlab.com" . "gitlab")
("git.savannah.gnu.org" . "gnu"))
"Alist of domain patterns to remote types."

:type '(alist :key-type (string :tag "Domain")
Expand Down Expand Up @@ -199,6 +200,24 @@ If HEAD is detached, return nil."
(if (fboundp formatter)
formatter nil)))

(defun browse-at-remote-gnu-format-url (repo-url)
"Get a gnu formatted URL."
(replace-regexp-in-string
(concat "https://" (car (rassoc "gnu" browse-at-remote-remote-type-domains))
"/\\(git\\).*\\'")
"cgit" repo-url nil nil 1))

(defun browse-at-remote--format-region-url-as-gnu (repo-url location filename &optional linestart lineend)
"URL formatter for gnu."
(let ((repo-url (browse-at-remote-gnu-format-url repo-url)))
(cond
(linestart (format "%s.git/tree/%s?h=%s#n%d" repo-url filename location linestart))
(t (format "%s.git/tree/%s?h=%s" repo-url filename location)))))

(defun browse-at-remote--format-commit-url-as-gnu (repo-url commithash)
"Commit URL formatted for gnu"
(format "%s.git/commit/?id=%s" (browse-at-remote-gnu-format-url repo-url) commithash))

(defun browse-at-remote--format-region-url-as-github (repo-url location filename &optional linestart lineend)
"URL formatted for github."
(cond
Expand Down