emacs-patch-review

Port of Thunderbird Patch Review to mu4e.

git clone git://mccd.space/emacs-patch-review

patch-review-mu4e.el (1679B)

      1 ;;; patch-review-mu4e.el --- mu4e integration for patch-review -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2026 Marc Coquand
      4 
      5 ;; This program is free software: you can redistribute it and/or modify
      6 ;; it under the terms of the GNU General Public License as published by
      7 ;; the Free Software Foundation, either version 3 of the License, or
      8 ;; (at your option) any later version.
      9 
     10 ;;; Commentary:
     11 
     12 ;; Thin mu4e adapter: open the message shown in the current *mu4e-view*
     13 ;; buffer as a patch review.  Suggested binding:
     14 ;;
     15 ;;   (define-key mu4e-view-mode-map (kbd "R") #'patch-review-mu4e-review)
     16 ;;
     17 ;; The adapter only locates the raw message file and hands it to
     18 ;; `patch-review-open-message-file'; everything else lives in the core.
     19 
     20 ;;; Code:
     21 
     22 (require 'patch-review)
     23 
     24 (declare-function mu4e-message-at-point "mu4e-message" (&optional noerror))
     25 (declare-function mu4e-message-field "mu4e-message" (msg field))
     26 
     27 ;;;###autoload
     28 (defun patch-review-mu4e-review ()
     29   "Review the patch message at point (mu4e view or headers buffer).
     30 From a mu4e article buffer (`mu4e-view-mode') the review takes over
     31 that buffer in place instead of opening a new window; from a
     32 headers buffer it opens a new review buffer."
     33   (interactive nil mu4e-view-mode mu4e-headers-mode)
     34   (unless (require 'mu4e-message nil t)
     35     (user-error "mu4e is not available"))
     36   (let* ((in-place (derived-mode-p 'mu4e-view-mode))
     37          (path (mu4e-message-field (mu4e-message-at-point) :path)))
     38     (unless (and path (file-readable-p path))
     39       (user-error "No message file at point"))
     40     (patch-review-open-message-file path nil in-place)))
     41 
     42 (provide 'patch-review-mu4e)
     43 ;;; patch-review-mu4e.el ends here