discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
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	[thread overview]
Message-ID: <20210605211402.20304-2-kyle@kyleam.com> (raw)
In-Reply-To: <20210605211402.20304-1-kyle@kyleam.com>

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 <kyle@kyleam.com>
+
+;; Author: Kyle Meyer <kyle@kyleam.com>
+;; 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 <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'piem)
+
+(defgroup piem-lei nil
+  "lei integration for piem."
+  :group 'piem)
+
+\f
+;;;; 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


  reply	other threads:[~2021-06-05 21:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-05 21:13 [PATCH 00/18] Initial lei support Kyle Meyer
2021-06-05 21:13 ` Kyle Meyer [this message]
2021-06-05 21:13 ` [PATCH 02/18] piem-lei-show: Let caller suppress displaying buffer Kyle Meyer
2021-06-05 21:13 ` [PATCH 03/18] piem-lei-show: Highlight headers and quoted text Kyle Meyer
2021-06-05 21:13 ` [PATCH 04/18] lei: Add command and mode for displaying overview of search results Kyle Meyer
2021-06-05 21:13 ` [PATCH 05/18] lei query: Add piem-lei-show wrapper for displaying line's message Kyle Meyer
2021-06-05 21:13 ` [PATCH 06/18] lei: Add command for viewing a thread Kyle Meyer
2021-06-05 21:13 ` [PATCH 07/18] lei query: Fontify results Kyle Meyer
2021-06-05 21:13 ` [PATCH 08/18] piem-lei-query-thread: Position point on seed message Kyle Meyer
2021-06-05 21:13 ` [PATCH 09/18] piem-lei-query-thread: Drop repeated subjects Kyle Meyer
2021-06-05 21:13 ` [PATCH 10/18] piem-lei-query-thread: Deal with multiple "re:"s Kyle Meyer
2021-06-05 21:13 ` [PATCH 11/18] piem-lei-query-thread: Omit main part of subject if shared Kyle Meyer
2021-06-05 21:13 ` [PATCH 12/18] piem-lei-query-thread: Add bug#NNN special case when eliding subject Kyle Meyer
2021-06-05 21:13 ` [PATCH 13/18] lei query: Add next/previous line variants that update message buffer Kyle Meyer
2021-06-05 21:13 ` [PATCH 14/18] piem-lei-show: Record message ID Kyle Meyer
2021-06-05 21:13 ` [PATCH 15/18] lei query: Add commands for showing or scrolling message buffer Kyle Meyer
2021-06-05 21:14 ` [PATCH 16/18] lei: Configure bindings for query and show modes Kyle Meyer
2021-06-05 21:14 ` [PATCH 17/18] lei: Wire up piem.el hooks Kyle Meyer
2021-06-05 21:14 ` [PATCH 18/18] piem-lei-query-thread: Use piem-lei-get-mid to get message ID Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://git.kyleam.com/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210605211402.20304-2-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --subject='Re: [PATCH 01/18] lei: Add command and mode for displaying a message' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.kyleam.com/piem/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).