It is possible to customize the behavior of org-insert-link, so for example when you insert a link in Org-mode (using C-c C-l) that is a URL to a GitHub issue or a GitHub PR, the description of that link automatically turns into the title of that GitHub item.
For the following snippet to work, you’d have to correctly set github-forge authentication. Which boils down to creating a personal access token on GitHub and adding the following line to your ~/.authinfo
(or ~/.authinfo.gpg
)
machine api.github.com login USERNAME^forge password TOKEN
(defun get-gh-item-title (uri &optional include-number?)
"Based on given GitHub URI for pull-request or issue,
return the title of that pull-request or issue."
(when (string-match "\\(github.com\\).*\\(issues\\|pull\\)" uri) ; either PR or issue
(pcase-let* ((`(_ _ ,owner ,repo ,type ,number) (remove "" (split-string uri "/")))
(gh-resource (format "/repos/%s/%s/%s/%s"
owner
repo
(if (string= type "pull") "pulls" type)
number))
(resp (ghub-get gh-resource nil :auth 'forge)))
(when resp
(format "%s%s" (alist-get 'title resp)
(when include-number? (format " #%s" number)))))))
(defun org-link-make-description-function* (link desc)
(cond ((string-match "\\(github.com\\).*\\(issues\\|pull\\)" link)
(get-gh-item-title link :with-number))
(t desc)))
(setq org-link-make-description-function 'org-link-make-description-function*)