From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12.migadu.com with LMTPS id +CueD6Efg2Q2ZAEATFOONw (envelope-from ) for ; Fri, 09 Jun 2023 14:48:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KPuCDqEfg2RX4gAAauVa8A (envelope-from ) for ; Fri, 09 Jun 2023 14:48:33 +0200 Received: from mail1.fsfe.org (mail1.fsfe.org [IPv6:2001:aa8:ffed:f5f3::151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 02EB33B808 for ; Fri, 9 Jun 2023 14:48:33 +0200 (CEST) From: jlicht@fsfe.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fsfe.org; s=2021100501; t=1686314912; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wX5oFbKr5G6liTnsfKkqpbGf/n8BE2gJqZN/kbg85s8=; b=fsUU+QqN//26snGsCjBL2ITSq3hfvZPeqY96OpdtofgEzjQFNgFHQ/cfOyFYxNiGSvZYEi +8PB1+kg5uD6NAMQ3Qcq8XToqHX6UP4M08t8kTQV7mp7JWUdVx4HissclHcBh34mFxerjf okqM6hKiNZeHJYfspyJUjILjjnRY9xU= To: piem@inbox.kyleam.com Cc: Jelle Licht Subject: [PATCH v2 2/5] gnus: Skip adding mboxrd from-line when not needed. Date: Fri, 9 Jun 2023 14:48:26 +0200 Message-Id: <20230609124829.29629-3-jlicht@fsfe.org> In-Reply-To: <20230609124829.29629-1-jlicht@fsfe.org> References: <20230608165926.12586-1-jlicht@fsfe.org> <20230609124829.29629-1-jlicht@fsfe.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Country: DE X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=kyleam.com; t=1686314913; a=rsa-sha256; cv=none; b=DI3nErQLalZQYmpA45n6XpAfHLBxm8CR6lidIncyxiu3BCwoAWt3LZLyWoL23bJCU4LQoV KuObH9xZmvHdCKajcW4oFcCm1gHdVfke9Tg+njo+1WtooGMg97wc4kXi/oBOn0pvdQ0fGt w112B7N7sfnRAFYBjz8OrhG270XzxCX4ijUUd/4fWGG1ro3m9myouuRAhm09XQJZpmdJ8Q 4QLNu69vmrTb4AY7fd1w1GgvIMUB+fJ7WVF7d0c4ExNtHUfvfo0vb0Uq5PW+816iiOz93n ToHdMNod4jzXb/1PPR41JayfMyNIuEPsaHQtk1Nder9YQEakxFNuTan+2nVrww== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=fsfe.org header.s=2021100501 header.b=fsUU+QqN; dmarc=pass (policy=none) header.from=fsfe.org; spf=pass (aspmx1.migadu.com: domain of jlicht@fsfe.org designates 2001:aa8:ffed:f5f3::151 as permitted sender) smtp.mailfrom=jlicht@fsfe.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1686314913; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wX5oFbKr5G6liTnsfKkqpbGf/n8BE2gJqZN/kbg85s8=; b=t/CV+gMa7AjwYgekZ7IBDV51f75gTdgHxodkKs3b/V27uaFk+klf12mJPlSVQLgxGzJIDa IGyrkSyRGbPDYUJBOKJa5dLbOcQ7lNj1+mNZE67w0OgjxHN0wFb2gYXpeQ6J/vmQAWIiUi G5IK0U/wKgFfg6Qt6EZkEIKWl06bH6JXn6b9Cx3Eb63BEgiIk64CpEOj2Pv+BAcqYPLPyp AZ1CRzZoFj8UkdMR8Lu5Q2Yakuf28qQ3x+lGv/cD9PxCVR1vRJO7C7slRe6c/B34BL0MnS JmFGCgX2tkylghYyLF8bWJR17025uv1lUnBTtCbGogmThHKk06TOqbRkE9bnCQ== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=fsfe.org header.s=2021100501 header.b=fsUU+QqN; dmarc=pass (policy=none) header.from=fsfe.org; spf=pass (aspmx1.migadu.com: domain of jlicht@fsfe.org designates 2001:aa8:ffed:f5f3::151 as permitted sender) smtp.mailfrom=jlicht@fsfe.org X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -7.70 X-Spam-Score: -7.70 X-Migadu-Queue-Id: 02EB33B808 X-TUID: h9ffYMVepEoC From: Jelle Licht --- piem-gnus.el | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/piem-gnus.el b/piem-gnus.el index 4011fa2..e8e5f1e 100644 --- a/piem-gnus.el +++ b/piem-gnus.el @@ -56,6 +56,20 @@ (match-string 1 mid) mid))))) +(defun piem-gnus--from-line (buffer) + "Returns a cons of the first line of BUFFER, if it is an +mbboxrd from-line (or nil if none), and the remaining lines of +BUFFER." + (with-current-buffer buffer + (let ((start (point-min)) + (end (point-max))) + (goto-char start) + (let* ((eol (line-end-position)) + (line (buffer-substring-no-properties start eol))) + (if (string-match-p "^From " line) + (cons line (buffer-substring-no-properties (+ eol 1) end)) + (cons nil (buffer-substring-no-properties start end))))))) + (defun piem-gnus-mid-to-thread (mid) (when (and (derived-mode-p 'gnus-summary-mode) (string-equal (substring @@ -75,16 +89,17 @@ 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 " - ">\\&" - (with-current-buffer gnus-article-buffer - (buffer-substring-no-properties - (point-min) - (point-max))))) - messages)) + (let ((from-line-cons + (piem-gnus--from-line gnus-article-buffer))) + (push (format + "%s\n%s\n" + (or (car from-line-cons) + "From mboxrd@z Thu Jan 1 00:00:00 1970") + (replace-regexp-in-string + "^>*From " + ">\\&" + (cdr from-line-cons))) + messages))) articles) (lambda () (insert (apply #'concat (nreverse messages)))))))) -- 2.40.1