Created
November 8, 2019 14:15
-
-
Save mbuczko/b8d674ce037736d9c0e236aacd052bab to your computer and use it in GitHub Desktop.
emacs / visit github issue or PR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; requires git-link package | |
(defun github--goto-issue-or-pr (id type) | |
"Opens a browser with issue or PR (denoted by TYPE) of given ID." | |
(let* ((origin-url (car (git-link--exec "config" "--get" "remote.origin.url"))) | |
(repo-match (string-match "^git@github.com:\\([^\\.]+\\)" origin-url)) | |
(repo-url (concat "https://github.com/" (match-string 1 origin-url))) | |
(sub-path (cond ((eq 'issue type) "/issues") | |
((eq 'pr type) "/pull")))) | |
(message (concat repo-url sub-path "/" id)) | |
(browse-url | |
(concat repo-url sub-path "/" id)))) | |
(defun github--goto-issue (id) | |
"Opens in a browser issue with given ID or with a one found at current line." | |
(interactive | |
(let* ((at-point (github--get-issue-or-pr-at-point)) | |
(default (if at-point (concat "Issue (" at-point ") #") "Issue #")) | |
(str (read-string default nil nil at-point))) | |
(list str))) | |
(github--goto-issue-or-pr id 'issue)) | |
(defun github--goto-pr (id) | |
"Opens in a browser pull request with given ID or with a one found at current line." | |
(interactive | |
(let* ((at-point (github--get-issue-or-pr-at-point)) | |
(default (if at-point (concat "Pull-Request (" at-point ") #") "Pull-Request #")) | |
(str (read-string default nil nil at-point))) | |
(list str))) | |
(github--goto-issue-or-pr id 'pr)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment