From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12.migadu.com with LMTPS id ADkDMm5JhGQNAgEATFOONw (envelope-from ) for ; Sat, 10 Jun 2023 11:59:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id oEEfMW5JhGTc5QAAG6o9tA (envelope-from ) for ; Sat, 10 Jun 2023 11:59:10 +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) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 394392B494 for ; Sat, 10 Jun 2023 11:59:09 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=fsfe.org header.s=2021100501 header.b="an0A/pda"; 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=1686391150; 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=RxedX7MjIMn3H43l3cQdgrLGnsA00ZKQLgPeoF+fBxE=; b=c4BNs3UbXRTjd74k7nOqd9XO/JZ5DvHLcHWAPf9rXUEIp64mjVh/cCNfWZQqY5kv87EJ9r gtMJODv2GDUBQ+SNMBct1EJ2CsTB60QmxPXj2RicGIZiSXpJQo21Da+aF6a+FoYDvldme5 raLkKH+UU5giERHJxWEytOjTVCZJLx6E/SdjRVphfZvOjokv44a8L/unuc0fs498/7HW9F kEz3XKGYo2lQGzrs8QPrYppOtZQC6LsZQQNNk5ArnrQf4RO0iNT8gqRGIlCoFoQkW6VZO2 Lcr4jnpy8Mb/L+Ye+JqjjpyvQxowbigsR+dGdGxuw7eMYRMEGp6ECleBiKN59w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=fsfe.org header.s=2021100501 header.b="an0A/pda"; 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-Seal: i=1; s=key1; d=kyleam.com; t=1686391150; a=rsa-sha256; cv=none; b=YqHosRGjr+GWk+dmIaWq6oodlWcTWeEqlfND9x81Q1OdExUCfZOPOLsGKmwNoRrBkwLpUn y0AcCsTdsyNEwDCkRTJIcYPrTg8KZFDp2KylNOYW2BN1t7JGfbPUDySdkdiMtpVosAwOr5 jdpTBKas8/998+TTZYGHYpu8kkMPQVVwcKH0meW/FA/SP82sXRmswa0Vh6TR042GsLaLMr EhzhWfkzsC2pkecv3oDsqHF1WsHGDn1Uo3LhNh88Py2c1JIo1EQ4TRd7PX4MAhSoIvOfT0 oM45A1b1AxgyYi3K2EZZGve9oR7Hon/+q2LwFFyhQhCf6TVLwcCrr5YEe9Ti9Q== From: jlicht@fsfe.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fsfe.org; s=2021100501; t=1686391141; 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=RxedX7MjIMn3H43l3cQdgrLGnsA00ZKQLgPeoF+fBxE=; b=an0A/pdaTRMIfbSkqGeRd9q0D4TI0Xbrjpaik52pV+oUbsPYxCbI8lPC5gZj0wnt9xn5vR P+/jvdk0oMKLM7IMoD0z2wKieAk28Tg0j5UsxAkaPOEPYinllhBii2EEiKCjbbMdU7QEZS pzByqHLuH4iqJsWZwIbCdAGqb5cNOmg= To: piem@inbox.kyleam.com Cc: Jelle Licht Subject: [PATCH v3 2/5] gnus: Skip adding mboxrd from-line when not needed Date: Sat, 10 Jun 2023 11:58:55 +0200 Message-Id: <20230610095858.26982-3-jlicht@fsfe.org> In-Reply-To: <20230610095858.26982-1-jlicht@fsfe.org> References: <20230608165926.12586-1-jlicht@fsfe.org> <20230610095858.26982-1-jlicht@fsfe.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Country: UNKNOWN X-Migadu-Flow: FLOW_IN X-Spam-Score: -4.61 X-Migadu-Queue-Id: 394392B494 X-Migadu-Scanner: in3.migadu.com X-Migadu-Spam-Score: -4.61 X-TUID: F7oOTFKWR0D6 From: Jelle Licht When using Gnus over NNTP, `gnus-summary-display-article' shows a plain message, but when debbugs.el visits an issue message with Gnus, it's already in mbox format. Link: https://inbox.kyleam.com/piem/87cz2dun0y.fsf@kyleam.com --- piem-gnus.el | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/piem-gnus.el b/piem-gnus.el index 4011fa2..7120512 100644 --- a/piem-gnus.el +++ b/piem-gnus.el @@ -56,6 +56,21 @@ (match-string 1 mid) mid))))) +(defun piem-gnus--from-line (buffer) + "Split a buffer into from-line and the rest of the message. + +Returns a cons of the first line of BUFFER, if it is an mboxrd +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 +90,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