I'd like to be able to create GitHub issues from Emacs using a simple command, e.g.

M-x create-github-issue RET <title> RET <comment> RET

Ideally, the command would default to the current repo when called from a buffer visiting a file that belongs to a git repository.

I checked the repos (ELPA, MELPA, Marmalade); the closest thing I could find is gh, which is a

GitHub API library for Emacs.

It includes gh-issues.el which looks like it could be used as a starting point for implementing such a feature. But since I don't want to reinvent the wheel:

Does anybody have a hand-rolled solution for this that they could share (or know of a package that I missed that implements this functionality)?

  • emacs-bts-github has a bts-github::add-issue function, I think it already has what you want, but I have not used this package. – xuchunyang Jun 6 '15 at 12:21

I'm using syohex's emacs-helm-open-github which provides a set of commands to open issues/files/commits's URL in Github easily, it uses the gh library as well, I look down its code and change its helm-open-github--collect-issues function into create-github-issue:

(defun create-github-issue (title body)
  (let ((remote-url (helm-open-github--remote-url)))
    (cl-multiple-value-bind (user repo) (helm-open-github--extract-user-host remote-url)
      (gh-issues-issue-new helm-open-github-issues-api
                           user repo
                           (gh-issues-issue :title title
                                            :body body)))))

helm-open-github--extract-user-host is used for getting user/repo, gh-issues-issue-new is used for creating new issue.

To use it, try (create-github-issue "issue title" "issue content"), a example result: https://github.com/xuchunyang/emacs.d/issues/2

| improve this answer | |
  • @Sibi It's easy to do, I mean, read issue title & body from minibuffer, but I don't think it's a good idea. – xuchunyang Jun 6 '15 at 12:25
  • Thanks, Why it isn't a good idea ? – Sibi Jun 6 '15 at 12:26
  • Because minibuffer is usually for reading a small amount text like Emacs command name, file name, while issue's body usually consists of several complete sentences. An interface like M-x mail RET is much better for this use case. – xuchunyang Jun 6 '15 at 13:06
  • Thanks, this seems like a good starting point for implementing what I am looking for. Unfortunately, it doesn't work. When I evaluate (create-github-issue "issue title" "issue content") from a file that belongs to a git repo I get: Debugger entered--Lisp error: (invalid-slot-name "#<gh-issues-issue :title>" "issue title") [...]. – itsjeyd Jun 8 '15 at 8:14
  • It works fine from here. I am unfamiliar with the gh library nor the eieio library, but I guess (gh-issues-issue :title "title" :body "body") will fail as well, so it could be a bug of the gh library. – xuchunyang Jun 8 '15 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.