From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id 3akpEDLpu2BxbgAAsNZ9tg (envelope-from ); Sat, 05 Jun 2021 21:14:26 +0000 Received: from out2.migadu.com ([2001:41d0:2:aacc::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id UEPfDy7pu2D0QwAAbx9fmQ (envelope-from ); Sat, 05 Jun 2021 21:14:22 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1622927661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n6Hno6oXQjAk3EEu/zYp2gmoLg6YSCHU1YNORgto1t4=; b=FdZkwDXTm7PfJfoLAi8w/mhNvUlQTcmT1H/HVHW6W0PZrX1NQVf5F8O27cFbpcshcTxje0 ctCXKXwbIaXwZUfhh6ObIAjoI6LB8m40I8VFlH5onmIxzHJUI1XnBivwn/JLOLRekrpLyK aI4IBc/XMXHybgYGcuiNcBrOCuSOTKwdSgM78JYq9TL9nXavkEuaFyuNuCkkFfk+AjAjU4 KfwUn7tUtwgpuRD3SlTGhe0/zkzMLYPYWkA0i8NMvhy4H/0EHDweeXLIMRKnbIgWBYFnp7 aao0jgfayn3fgmtIh+sPwfZMNT6TcPzrRq5i5Q7dndVSrz2r4oM7hzjJCx8XmA== From: Kyle Meyer To: piem@inbox.kyleam.com Subject: [PATCH 01/18] lei: Add command and mode for displaying a message Date: Sat, 5 Jun 2021 17:13:45 -0400 Message-Id: <20210605211402.20304-2-kyle@kyleam.com> In-Reply-To: <20210605211402.20304-1-kyle@kyleam.com> References: <20210605211402.20304-1-kyle@kyleam.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyle@kyleam.com X-TUID: qcVP0qOhusIO This command is a simple wrapper around `lei q --format=text m:MID', letting lei handle the details. Things will eventually need to get more complicated (e.g., attachment handling, signatures, replies), but this should do for now. --- Makefile | 3 ++- piem-lei.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 piem-lei.el diff --git a/Makefile b/Makefile index 4d88b342..dac422b2 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ EMACS = emacs BATCH = $(EMACS) --batch -Q -L . -L tests EL = piem.el piem-b4.el piem-elfeed.el piem-eww.el piem-gnus.el \ - piem-maildir.el piem-notmuch.el piem-rmail.el \ + piem-lei.el piem-maildir.el piem-notmuch.el piem-rmail.el \ tests/piem-rmail-tests.el tests/piem-tests.el ELC = $(EL:.el=.elc) @@ -35,6 +35,7 @@ piem-b4.elc: piem-b4.el piem.elc piem-elfeed.elc: piem-elfeed.el piem.elc piem-eww.elc: piem-eww.el piem.elc piem-gnus.elc: piem-gnus.el piem.elc +piem-lei.elc: piem-lei.el piem.elc piem-maildir.elc: piem-maildir.el piem-notmuch.elc: piem-notmuch.el piem.elc piem-rmail.elc: piem-rmail.el piem.elc diff --git a/piem-lei.el b/piem-lei.el new file mode 100644 index 00000000..5b986fc0 --- /dev/null +++ b/piem-lei.el @@ -0,0 +1,58 @@ +;;; piem-lei.el --- lei integration for piem -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 Kyle Meyer + +;; Author: Kyle Meyer +;; Keywords: vc, tools +;; Package-Requires: ((emacs "26.3")) + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program 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 General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Code: + +(require 'piem) + +(defgroup piem-lei nil + "lei integration for piem." + :group 'piem) + + +;;;; Message display + +(defun piem-lei-show (mid) + "Show message for MID." + (interactive + (list (read-string "Message ID: " nil nil (piem-mid)))) + (with-current-buffer (get-buffer-create "*lei-show*") + (let ((inhibit-read-only t)) + (erase-buffer) + (call-process "lei" nil '(t nil) nil + "q" "--format=text" (concat "m:" mid)) + (goto-char (point-min)) + (when (looking-at-p "# blob:") + (delete-region (line-beginning-position) + (1+ (line-end-position)))) + (piem-lei-show-mode)) + (pop-to-buffer (current-buffer)))) + +(define-derived-mode piem-lei-show-mode special-mode "lei-show" + "Major mode for displaying message via lei." + :group 'piem-lei + (buffer-disable-undo) + (setq truncate-lines t) + (setq buffer-read-only t) + (setq-local line-move-visual t)) + +;;; piem-lei.el ends here +(provide 'piem-lei) -- 2.31.1