[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nnml filename from summary buffer
From: |
Ted Zlatanov |
Subject: |
Re: nnml filename from summary buffer |
Date: |
Tue, 05 Jul 2005 11:31:00 -0400 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.3.50 (gnu/linux) |
On Fri, 01 Jul 2005, jdhunter@ace.bsd.uchicago.edu wrote:
>>>>>> "Ted" == Ted Zlatanov <tzz@lifelogs.com> writes:
>
> Ted> There's probably a way to do it in the API, but why do you
> Ted> need the file name? It's usually better to work in
> Ted> file-independent ways, so your code can be adapted to nnimap
> Ted> or nntp for example.
>
> I need to pass the article contents off to an external script which
> takes a filename. Alternatively I could get the entire buffer
> contents as a string and write it to a temporary file - do you know
> which function/variable provides access to the raw, unwashed, article
> which I could dump to a temp file?
Yes, I've done that in spam.el to pass to an external process. The
discussion below applies to nntp, nnimap, nnml, etc. backends so it's
a clean solution to your problem.
Anyhow, here's how you can get an article into a buffer and then
return the string (from spam.el):
(defun spam-get-article-as-string (article)
(when (numberp article)
(with-temp-buffer
(gnus-request-article-this-buffer
article
gnus-newsgroup-name)
(buffer-string))))
This uses the CURRENT gnus-newsgroup-name, so if you are not in the
summary buffer or gnus-newsgroup-name is unset for another reason, it
won't work (gnus-newsgroup-name is set every time you enter a group
summary buffer).
Is there no way the external script can take STDIN rather than a file?
Many Unix utilities will take a "-" as an argument to mean "read from
STDIN." That way, you can just get the article into a buffer and then
use the call-process-region function, instead of getting a string back
as this function does.
If you must put it into a file, use make-temp-file and write the
string or the temp-buffer contents to it with write-region...
Ted
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----