Article View: news.software.readers
Article #48378Re: slrn: Saving posts for later browsing
From: Jan Hlavacek
Date: Wed, 05 May 1999 00:00
Date: Wed, 05 May 1999 00:00
221 lines
7257 bytes
7257 bytes
On Wed, 5 May 1999 17:28:58 +0200 , Paul Moore
<paul.moore@uk.origin-it.com> wrote:
> I use slrn and slrnpull for offline newsreading on Windows. I like the
> programs a lot, but one feature I miss from "windows-style" newsreaders is the
> ability to save postings for later browsing.
>
> I know that I can use 'o' to save a post to a file. However, I don't then have
> a way of reading that file using a slrn-style interface (ie, threaded display,
> with the ability to reply, etc etc.) Ideally, I'd like to load the archived
> posts into slrn itself.
>
> Have I missed something? Is it not possible to do this? I *really* don't like
> looking at archived postings in vim :-(
I just finished writing this. It works well for unix (well the version
I am sending may not work at all, I run another version which is much
more messy and does some wierd things, which I don't want to send out.
The version below should work well after fixing all my stupid errors.
Since you need to modify it for windows, you probably need to change
things anyway.
Oh, and you need the latest snapshot of s-lang,
ftp://space.mit.edu/pub/davis/slang/snapshots/slang1.3.5.tar.gz
Save this to `archive.sl':
#iffalse
Documentation:
WARNING: I have just finished rewriting this for the newest
devel snapshots of s-lang. It doesn't work with older versions of s-lang.
It is not very well tested!
If you run into problems, email me at lahvak@math.mps.ohio-state.edu.
I'll release better more tested version as soon as I have it done.
This lets you archive articles from slrn into an archive spool,
which then can again be accessed by slrn.
To install:
in your .slrnrc file, put the following lines (replace
"/home/lahvak/News/Archive" by the path to your archive):
%reading archive
%
#ifdef ARCHIVE
set spool_inn_root "/home/lahvak/News/Archive"
set spool_root "/home/lahvak/News/Archive/news"
set server_object "spool"
server "/home/lahvak/News/Archive/news" .jnewsrc-archive
set followup_string "While ago, on %d, %r <%f> wrote:"
set reply_string "While ago, in %n, you wrote:"
set read_active 1
set auto_mark_article_as_read 0
#else
interpret "archive.sl"
setkey article archive "whatever key you want, I use o"
#endif
If you already use macros, add to your article_mode_quit_hook ()
function the following:
#ifndef ARCHIVE
Archive->article_mode_quit_hook ();
#endif
Otherwise set up a file in your home dir called .slrn.sl containing the
following:
#ifndef ARCHIVE
define article_mode_quit_hook ()
{
Archive->article_mode_quit_hook ();
}
#endif
and add this line into your .slrnrc:
interpret ".slrn.sl"
When you read news, you press the key you chose,
and current article will be saved into an archive newsgroup.
To access the archive, do
slrn -DARCHIVE
and slrn will read the archive. You may have to do "L*<ENTER>"
to get list of all groups.
#endif
implements ("Archive");
%set this to whatever you want
variable SpoolDir = "/home/lahvak/News/Archive/";
variable padding = "00000000000";
private define pad_string (str)
{
if (strlen (str) > strlen (padding)) error ("string too long");
return (padding[[strlen(str):]] + str); % dirty
}
typedef struct {hi, lo, flags} GroupInfo;
private variable Default_Group_Info = @GroupInfo;
set_struct_fields (Default_Group_Info, 0,0,"y");
variable Groups = Assoc_Type [GroupInfo, Default_Group_Info];
#ifnexists strtrim_beg
private define strtrim_beg (str, whites)
{
!if (string_match (str, "[^" + whites + "]", 1)) return "";
variable pos;
(pos,) = string_match_nth (0);
return str[[pos:]];
}
#endif
define Get_Group_Info (line)
{
variable ar = strchop (line, ' ', 0);
variable gi = @GroupInfo;
set_struct_fields (gi, integer(strtrim_beg (ar[1], " 0")),
integer(strtrim_beg (ar[2], " 0")), ar[3]);
!if (assoc_key_exists (Groups, ar[0])) Groups [ar[0]] = gi;
}
define mk_group_line (name)
{
variable gi = Groups [name];
return sprintf ("%s %s %s %s", name, pad_string(string(gi.hi)),
pad_string(string(gi.lo)), gi.flags);
}
define read_active_file (afile)
{
variable af = fopen (afile, "r");
variable line = "";
if (af == NULL) error ("can't find active file");
while (-1 != fgets (&line, af))
{
Get_Group_Info (line);
}
() = fclose (af);
}
define write_active_file (afile)
{
if (rename (afile, afile + ".bak")) error ("Error creating backup of active file");
variable af = fopen (afile, "w");
if (af == NULL) error ("Panic: can't write active file.");
variable g;
foreach (Groups) using ("keys")
{
g = ();
if (-1 == fputs (mk_group_line (g), af)) error ("error writing active file");
}
() = fclose (af);
}
define chto_group_dir (group)
{
variable newdir;
chdir (strcat (SpoolDir, "news"));
variable parts = strchop (group, '.', 0);
foreach (parts)
{
newdir = ();
!if (mkdir (newdir, 0777)) message ("New group...");
if (-1 == chdir (newdir)) error ("Chdir failed.");
}
}
define save_art_to (group)
{
variable dir = getcwd ();
ERROR_BLOCK {chdir (dir);}
variable no = Groups[group].hi + 1;
chto_group_dir (group);
save_current_article (string (no));
Groups[group].hi++;
EXECUTE_ERROR_BLOCK;
}
public define archive ()
{
% Saves article into archive newsgroup based on some criteria.
% Offers the newsgroup name to edit.
if (is_group_mode) return ();
variable file = "arch." + current_newsgroup ();
% Not very likely that I'll edit the name,
% if I don't like it, I'll just type in a new one.
file = read_mini ("Archive to newsgroup", file, "");
save_art_to (file);
}
%initialization
read_active_file (SpoolDir + "data/active");
define article_mode_quit_hook ()
{
write_active_file (SpoolDir + "data/active");
}
--
Jan Hlav\'{a}\v{c}ek <lahvak@math.mps.ohio-state.edu> (BCC's will bounce)
home page: http://www.math.ohio-state.edu/~lahvak/
slrn page: http://www.math.ohio-state.edu/~lahvak/software/slrn.html
slrn documentation: http://www.math.ohio-state.edu/~lahvak/software/slrn/
Technical Details
Message-ID:
<slrn7j19e0.ug.lahvak@octagon.mps.ohio-state.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn7j0oqe.3vv7dbb.paul.moore@ukrup480.rundc.uk.origin-it.com>Show Full Headers
Complete Article Headers
Message-ID: <slrn7j19e0.ug.lahvak@octagon.mps.ohio-state.edu> Subject: Re: slrn: Saving posts for later browsing Date: Wed, 05 May 1999 00:00:00 +0000 From: lahvak@math.mps.ohio-state.edu (Jan Hlavacek) References: <slrn7j0oqe.3vv7dbb.paul.moore@ukrup480.rundc.uk.origin-it.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 474452600 X-Complaints-To: usenet@math.ohio-state.edu X-Trace: mathserv.mps.ohio-state.edu 925935040 9442 128.146.111.74 (5 May 1999 20:10:40 GMT) Organization: Department of Mathematics, The Ohio State University User-Agent: slrn/0.9.5.5 (UNIX) Reply-To: lahvak@math.mps.ohio-state.edu NNTP-Posting-Date: 5 May 1999 20:10:40 GMT Newsgroups: news.software.readers