From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id sGuOFCNkBWAGQwAAsNZ9tg (envelope-from ) for ; Mon, 18 Jan 2021 10:34:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qDq2AiJkBWAuWAAA1q6Kng (envelope-from ) for ; Mon, 18 Jan 2021 10:34:10 +0000 Received: from mail.yoctocell.xyz (h87-96-130-155.cust.a3fiber.se [87.96.130.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 056589402D6 for ; Mon, 18 Jan 2021 10:34:05 +0000 (UTC) From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1610966044; bh=G9VfpgVUkpIEOta+g/t8gjSVrn4RDk3YVYtYLiXlwr8=; h=From:To:Subject:Date; b=kF67nrFZHrGNMILT9aLM9d/1N3tYQlzyUyY4fWoAW4rh2BDmrQjLBfb8vEiqZXL0t Oe6qI+US4AVmqB3rYcxm9zhFGlPg1cYCb/B6BTI0X5nkTJNyRZinsOkRvorjVAzlAx 5Kkqor6ctVji6eRC/GpwUVbX9fYTx60+tdqcY0K0= To: piem@inbox.kyleam.com Subject: [RFC PATCH] gnus: Add piem-gnus-mid-to-thread Message-Id: Date: Mon, 18 Jan 2021 11:34:03 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1610966049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: dkim-signature; bh=6f8PS/soq8BwVFWOmQLWd7G+O91sKCr3cA4TVUQBP9E=; b=Tn0Pd/D4l21R9h5R8NO2TUpj6OJ8WdhixEY43pnLIUqoU/RgJiiZ27oYJ9VYEfNT+eY4s2 jAHV9LXQ/7skwK9oS7mu5dHhrbsbHZdPGiNmD026xeIFelDhCzG+1LEQVYXBc7XbvX7GqO fD97lBvugP/dcIgavlyRlDPwt7HITnOw2pDf00EPK9bkRLT4J559yNvP9235JIFIZyjrcP +TiTFk3kF+qHPTk07uY92qA09yTu0PtGMw9lotwQty/vLthAqjTYQnnqKpIHNGOZ1ZC3DS lyklSJkWpkkWM9Erjm7puVX0Y6BQE/65xIG82gQRvgoViPpGQ3l10LZWFSew9w== ARC-Seal: i=1; s=key1; d=kyleam.com; t=1610966049; a=rsa-sha256; cv=none; b=OiNMoHyzNLUdY8+D0As8QrIQrH4TCWPy6nTdMx8GpF3qGdQmyTCT1yPOaQr0EiSIsdnx60 270RXi9+yDWKi7tqMU28NL/e3qfXWJgel+ZilAZO7NLXoHyTitn3tP4qciGvUAWII0NXXd T6EEhgyBaYWPwtU2Pebq92nrzrppMdKz+/sW74PuVg+qyeO6yzcGITiqTLCS3dFZIcrefK lU3CjrjtxA/P+HAgntojtTfgEzotqNZ/QB+GiCa6gZUTJAWqVGgP1svlzaZgauBFDG4gx8 MouDeeiJXPDRCctp+z9Imf5ZbzmJ8cRW9elKofE/x0cTccGKqE1Klwx6a2yeSg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=yoctocell.xyz header.s=mail header.b=kF67nrFZ; spf=pass (aspmx1.migadu.com: domain of public@yoctocell.xyz designates 87.96.130.155 as permitted sender) smtp.mailfrom=public@yoctocell.xyz X-Migadu-Spam-Score: 0.83 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=yoctocell.xyz header.s=mail header.b=kF67nrFZ; dmarc=pass (policy=none) header.from=yoctocell.xyz; spf=pass (aspmx1.migadu.com: domain of public@yoctocell.xyz designates 87.96.130.155 as permitted sender) smtp.mailfrom=public@yoctocell.xyz X-Migadu-Queue-Id: 056589402D6 X-Spam-Score: 0.83 X-Migadu-Scanner: scn1.migadu.com X-TUID: qQoa+UpN1YqI Inserts a string of the whole thread in mbox format. --- The function works as expected when running 'M-: (funcall (piem-gnus-mid-thread t))', but when running piem-b4-am-from-mid interactively, it just inserts an empty string. Any ideas of why this happens? Sorry, my elisp skills are not that great. piem-gnus.el | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/piem-gnus.el b/piem-gnus.el index 5f10be8..f91f91c 100644 --- a/piem-gnus.el +++ b/piem-gnus.el @@ -58,6 +58,30 @@ ;; If there is an easy way to generate an mbox for a thread in Gnus, a ;; function for `piem-mid-to-thread-functions' should be defined. +(defun piem-gnus-mid-to-thread (_mid) + (lambda () + (save-excursion + ;; Cursor has to be at the root of the thread + (gnus-summary-refer-parent-article most-positive-fixnum) + (let ((articles (gnus-summary-articles-in-thread)) + message + ;; Just show raw message + (gnus-have-all-headers t) + gnus-article-prepare-hook + gnus-article-decode-hook + gnus-display-mime-function + gnus-break-pages) + (mapc (lambda (article) + (gnus-summary-display-article article) + (push (format "From mboxrd@z Thu Jan 1 00:00:00 1970\n%s\n" + (with-current-buffer gnus-article-buffer + (buffer-substring-no-properties + (point-min) + (point-max)))) + message)) + articles) + (insert (apply #'concat (nreverse message))))))) + (defun piem-gnus-am-ready-mbox () "Return a function that inserts an am-ready mbox. If the buffer has any MIME parts that look like a patch, use @@ -97,10 +121,12 @@ the mode if ARG is omitted or nil." (progn (add-hook 'piem-am-ready-mbox-functions #'piem-gnus-am-ready-mbox) (add-hook 'piem-get-inbox-functions #'piem-gnus-get-inbox) - (add-hook 'piem-get-mid-functions #'piem-gnus-get-mid)) + (add-hook 'piem-get-mid-functions #'piem-gnus-get-mid) + (add-hook 'piem-mid-to-thread-functions #'piem-gnus-mid-to-thread)) (remove-hook 'piem-am-ready-mbox-functions #'piem-gnus-am-ready-mbox) (remove-hook 'piem-get-inbox-functions #'piem-gnus-get-inbox) - (remove-hook 'piem-get-mid-functions #'piem-gnus-get-mid))) + (remove-hook 'piem-get-mid-functions #'piem-gnus-get-mid) + (remove-hook 'piem-mid-to-thread-functions #'piem-gnus-mid-to-thread))) ;;; piem-gnus.el ends here (provide 'piem-gnus) base-commit: 57f802b2a43ac64c28a5a9ddb9da0afaf910975e -- 2.29.2