From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12.migadu.com with LMTPS id YSxaFPUIgmSzUAAATFOONw (envelope-from ) for ; Thu, 08 Jun 2023 18:59:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id KBYoEvUIgmRaDgEAG6o9tA (envelope-from ) for ; Thu, 08 Jun 2023 18:59:33 +0200 Received: from mail1.fsfe.org (mail1.fsfe.org [217.69.89.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7F7F49713 for ; Thu, 8 Jun 2023 18:59:29 +0200 (CEST) From: jlicht@fsfe.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fsfe.org; s=2021100501; t=1686243568; 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=bgoP0Ps6rebQMD89h1r0PZmYMXaOwb/1MefUXI+EdTUInebL/QzA8eV0KChkLgG6Ftp03j N2Xy4Dj8Osy7cIUoZsXth3zm0WIv2npGBCT7jMvd0vpoQvtYiGljOoRjNidpmm4gf3o3f0 KG/xooMQkqAj+bL1ZTocEBAiIdkVaHA= To: piem@inbox.kyleam.com Cc: Jelle Licht Subject: [PATCH 2/2] gnus: Skip adding mboxrd from-line when not needed. Date: Thu, 8 Jun 2023 18:59:26 +0200 Message-Id: <20230608165926.12586-2-jlicht@fsfe.org> In-Reply-To: <20230608165926.12586-1-jlicht@fsfe.org> References: <20230608165926.12586-1-jlicht@fsfe.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Country: DE X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1686243573; 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=Z3KmH5iEH037kVDfZSpHUY46vzsm6qCBAT/N8u3U2bIYnghfQRbKQel1lGOan/1WiVhp7N d6WCjHY73eBVUrL77AXO5mj/gQoCmJfe9TrmcgwxsaMIbJVtEDq0j5pkK2C0MimqKeyA67 j7EF0adYbMdp+owpUK9UpXNieZd3EJYMThoeXZSooy+nsZo59g3SFiChnNkgQlE1bl9ZA2 lgSdcg6L+J1n5lJz81sMazibpI00itpoWZd5BRvRfNS8TQz4fVwCu2xiU0rL7v3Y+T3dek WjWe+arBS/PxrS9jP85d1jIox6SWJnUqcf4EWiKoMQjAVlmr0zm2uWJalbiiLA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=fsfe.org header.s=2021100501 header.b=bgoP0Ps6; dmarc=pass (policy=none) header.from=fsfe.org; spf=pass (aspmx1.migadu.com: domain of jlicht@fsfe.org designates 217.69.89.151 as permitted sender) smtp.mailfrom=jlicht@fsfe.org ARC-Seal: i=1; s=key1; d=kyleam.com; t=1686243573; a=rsa-sha256; cv=none; b=iQngZyqwydjyK3VBuO8hbQBgX55FBCuCHS2SySOmb0NWzCKcMCLkO0rzeXcVNynRUMMA44 hT3i92E4SPGdRFQPBaPhFdz0Ft4c8c6TMwpGKrKh9Vkrq9awaB8rT6LTo2swQsE+ENW0PY 52lJHqpvUJiwGKvSF3mP+VfCcEDk9WE1WOOlEqR5Kgap4pDxEMwxC1foG+A2g+ocgMHyfD OHloNJvTp6B6o96L3vjWSaj1Z9DK004J+liiYUsVlctpVyfpL+DPnI9SlMgZpasl9EajQ9 E0kf5vbeMqV696kHRbtVVtR3zsRQ2vNK2Kx5yrywm1Ps8/Y3LOLvhBbtN9UjBQ== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -6.18 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=fsfe.org header.s=2021100501 header.b=bgoP0Ps6; dmarc=pass (policy=none) header.from=fsfe.org; spf=pass (aspmx1.migadu.com: domain of jlicht@fsfe.org designates 217.69.89.151 as permitted sender) smtp.mailfrom=jlicht@fsfe.org X-Migadu-Queue-Id: 7F7F49713 X-Spam-Score: -6.18 X-TUID: Ii2LXxYurqlK 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