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 oIHZLEfwB2DiIQAAsNZ9tg (envelope-from ) for ; Wed, 20 Jan 2021 08:56:39 +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 ENN3GEbwB2BrdwAA1q6Kng (envelope-from ) for ; Wed, 20 Jan 2021 08:56:38 +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 2A67A94024D for ; Wed, 20 Jan 2021 08:56:37 +0000 (UTC) From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1611132995; bh=I5Dnhucni1FuPlkYQg1CutUqKj21k/SPLvPa7R6sxZY=; h=From:To:Subject:In-Reply-To:References:Date; b=IoUTtYmO6WivLp4piuFynyDxDTqVAF+46hK36q80ZdkjkkEe70Cmb9hlbDH9pqnrS +Y5Yi1+RTeECdg9VPTEP9dC4EZNeSl3sBqdj86aJ8H3C21lfrPh6iWsFWSEd0tyLkp 5uSbMm4K+YXb/vt/2NKwqcVRVe2PUDN+ITAMDK5I= To: piem@inbox.kyleam.com Subject: [RFC PATCH v2] gnus: Add piem-gnus-mid-to-thread In-Reply-To: References: Message-Id: <796fb84d852f2a5adea1502db144dae1bdc4fe0c.1611132172.git.public@yoctocell.xyz> Date: Wed, 20 Jan 2021 09:56:23 +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=1611132998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=opOQhoOPXo980g8CqxxHrRZMk3rjXhuQO7+mAO2exG8=; b=sSCG68tTN6EgWwYZqLQ9EEC1wvyFQt5yV+qWxjwmQS/NN6ikUdk/VgwZTQQHZhsj0Uj/ZA UFR+WVvR2Y6col6XgTKZ2c4hxuSNlSBQWoPyZjGSOYZb3/THT54rqKnfGQ/84tRVZJHoLp gif+V5sRsOfVscBkXtcTmjcWwUn1OtiDFm6aYd7Jr3dFXJwplj6TZJP4nw14tdikYvPQqt Rm2QASK4YdSShyLkr6Mmsd+hnH7GFfPc/r6RVIjd+fy2YHIca5qWv/hqn1J1bfQs/iM8+Q hVxbKdRxUIzL1HVz9aFCImoUTU2ICogn7V4lq4NIDWRHr78sHgQGoceOz2ladA== ARC-Seal: i=1; s=key1; d=kyleam.com; t=1611132998; a=rsa-sha256; cv=none; b=VqQRPxSsQ60LpacZPWX5jPiFL8XGSK8GvIxsUVrmxUmAdAFZnTfxIRA3/H79lq8PYlf3st ELnO75HRwlt7NsSoAnPSn/z3w+CJsOuwqo5vgdfWb4lxqtjl5Q58Midm6AeuuaLS/i3RJw pd3tp9/PapF7+4G6TMJaKY28xlX6mo3UgAnB3DhcExAKkpjibYnEl93/bopQFSRllyTJ+e 3YOi9PPYw9xS0XW3NBRq9G8tVfdjF0p9Uq14WQ8Hng2f9gSkcE5QZowTq6TGO0sRscZjOB dv2eLG/MZVrM4r6PD/HbYz0zoeeLYDoDlnltDQle0jgyBUEpCSsIQJAr/C89TQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=yoctocell.xyz header.s=mail header.b=IoUTtYmO; 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-Spam-Score: 0.77 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=yoctocell.xyz header.s=mail header.b=IoUTtYmO; 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: 2A67A94024D X-Spam-Score: 0.77 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3bZD3SZOeOS+ Inserts a string of the whole thread in mbox format. --- Changes from v1 - Add safety check for major mode and message id before trying to generate the mbox file - Escape "^From" in the body to prevent ambiguity piem-gnus.el | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/piem-gnus.el b/piem-gnus.el index 5f10be8..828ce1f 100644 --- a/piem-gnus.el +++ b/piem-gnus.el @@ -55,8 +55,38 @@ (match-string 1 mid) mid))))) -;; 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) + (when (and (derived-mode-p 'gnus-summary-mode) + (string-equal (substring + (mail-header-id (gnus-summary-article-header)) + 1 -1) ; Remove "<" and ">" + mid)) + (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" + (replace-regexp-in-string ; From-munge + "^From " + "^>From " + (with-current-buffer gnus-article-buffer + (buffer-substring-no-properties + (point-min) + (point-max))))) + message)) + articles) + (lambda () + (insert (apply #'concat (nreverse message)))))))) (defun piem-gnus-am-ready-mbox () "Return a function that inserts an am-ready mbox. @@ -97,10 +127,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