Git patches in Gnus —
I took over maintaining the Linux kernel’s MMC/SD/SDIO subsystem recently, and quickly found that I was spending too much time saving, applying and compile-testing submitted patches (and trying to remember which of these I’d done for a given patch). The following Emacs/Gnus function helps with that — with a single keypress when looking at a mail that contains a patch, it applies the patch to my git tree, runs the kernel’s “checkpatch” tool to check for common errors, and kicks off a compile test in the background. I’m not much of an elisp coder, so feel free to critique it if you can.
(defun apply-mmc-patch () "Take a gnus patch: apply; compile-test; checkpatch." (interactive) (setq default-directory "/home/cjb/git/mmc/") (setq compilation-directory "/home/cjb/git/mmc/") ; First, apply the patch. (dvc-gnus-article-apply-patch 2) ; Run 'git format-patch', and save the filename. (let ((patchfile (dvc-run-dvc-sync 'xgit (delq nil (list "format-patch" "-k" "-1")) :finished 'dvc-output-buffer-handler))) ; Compile the result. (compile "make modules") ; Now run checkpatch. (let ((exit-code (call-process "perl" nil nil nil "scripts/checkpatch.pl" patchfile))) (if (eq exit-code 0) (message "Checkpatch: OK") (message "Checkpatch: Failed"))))) (define-key gnus-summary-mode-map "A" 'apply-mmc-patch)