From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id ACCrL0WZBmCzBgAAsNZ9tg (envelope-from ) for ; Tue, 19 Jan 2021 08:33:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 4JUsHESZBmDrFAAAB5/wlQ (envelope-from ) for ; Tue, 19 Jan 2021 08:33:08 +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 556259403CD for ; Tue, 19 Jan 2021 08:33:08 +0000 (UTC) From: yoctocell DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1611045186; bh=UpxVj3P79/3jJysILUHUrN9DBxLzS1f+pGtVaJ1OZyM=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=gIUfDTm2voMI3hZTecpPxK2RkMh6jfNhgX19qm0D6VmO/lrALd2IBa4gS5zO6uMz4 VxeJurrdLOGtq6WDvA4XSr9t3M+MM1ZoEgLezB5LZ6JuecuMblS5MyFAUsx4EOFGDP v73ER5k3fZwE3pJpYVQkonMhc9zAzCE1EkGULrJc= To: Kyle Meyer Cc: piem@inbox.kyleam.com Subject: Re: [RFC PATCH] gnus: Add piem-gnus-mid-to-thread In-Reply-To: <874kjdlfvf.fsf@kyleam.com> References: <874kjdlfvf.fsf@kyleam.com> Date: Tue, 19 Jan 2021 09:32:54 +0100 Message-ID: <87zh159vih.fsf@yoctocell.xyz> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.00 Authentication-Results: aspmx1.migadu.com; none X-Migadu-Queue-Id: 556259403CD X-Spam-Score: -4.00 X-Migadu-Scanner: scn1.migadu.com X-TUID: rsrGx5zkd8Z0 On Mon, Jan 18 2021, Kyle Meyer wrote: >> --- >> 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. > > Yes, I think you just need to move the lambda deeper so that the > messages are collected outside of the returned function. Ok, I will see if this works. >> 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) > > Hmm, yeah, I don't think we can convince Gnus to do much useful with the > message ID here. However, perhaps there should at least be a check that > the given message ID matches the one for the article at point before > returning a function (i.e. claiming piem-gnus-mid-to-thread can generate > a thread for the given MID). > > Also, I think this would need to be guarded by > > (derived-mode-p 'gnus-summary-mode) Yeah, that's a good idea. `gnus-summary-refer-parent-article` doesn't seem to work in article mode. >> + (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) > > Is the above set of variables (or this approach in general) based off of > an example from the Gnus source code? Yeah, I had to do quite a bit of digging to figure this out. You can find them in the definition of `gnus-summary-show-article`. >> + (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) > > For mboxrd, I suppose there needs to be some From-munging. Sorry, I don't really know much about mbox, I just copied the line from the mbox file generated by public-inbox :)