GitHubをEmacsで操作する

GitHub に Git リポジトリをホスティングして開発をする場合、通常は Git の機能だけではなく、イシューやプルリクエストといった GitHub の機能も合わせて利用する事が多い。これらの機能は Git の機能ではないから、当然 Git クライアントには、それらに相当する操作はない。 git コマンドを使い CLI で操作していると、ブランチの push まではできても、プルリクエストを作るにはブラウザを開いてWeb UIで操作する必要がある。これは出来れば CLI で完結したい。そのために GitHub は gh というCLIツールを提供していて、これを使用すると CLI で GitHub の操作ができる。

Emacs での Git の操作については、 Magit というライブラリが人気だ。これは git コマンドを利用して動作する。 Magit は Git クライアントだから、当然 GitHub の機能(つまり gh の機能)をサポートしない。

僕は、GitもGitHubもできればEmacsで使用したい。だから gh を利用し GitHub の操作を行う、ユーティリティライブラリを実装する事にした。

magh.el

;;; magh --- the MAgical GitHub command line interface for Emacs. -*- lexical-binding: t -*-

;; Copyright (C) 2022 TakesxiSximada

;; Author: TakesxiSximada <[email protected]>
;; Maintainer: TakesxiSximada <[email protected]>
;; Version: 1
;; Package-Version: 20240131.0000
;; Package-Requires: ((emacs "27.1"))
;; Date: 2023-01-31

;; This file is part of magh.

;; magh is free software: you can redistribute it and/or
;; modify it under the terms of the GNU Affero General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.

;; magh is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Affero General Public License for more details.

;; You should have received a copy of the GNU Affero General Public
;; License along with this program.  If not, see
;; <https://www.gnu.org/licenses/>.

;;; Code:

;;; Customization
(defgroup magh nil
  "the MAgical GitHub command line interface for Emacs."
  :prefix "magh-"
  :group 'tools
  :link '(url-link :tag "Source" "https://blog.symdon.info/emacs/1706700260/magh.el"))

(defcustom magh-gh-executable "gh"
  "Executables of gh command."
  :type 'string)

;;;###autoload
(defun magh ()
  (interactive)
  nil)


;;;###autoload
(defun magh-pr-list ()
  (interactive)
  (let ((vterm-shell "gh pr list")
	(vterm-buffer-name "*Github*")
	(vterm-kill-buffer-on-exit nil))
    (vterm)))

(provide 'magh)
;;; magh.el ends here