🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #47998

Re: I like slrn!

#47998
From: Peppe
Date: Wed, 14 Apr 1999 00:00
191 lines
6706 bytes
Thus wrote Vadim Zeitlin <zeitlin@seth.lpthe.jussieu.fr>
> On 13 Apr 99 21:44:56 GMT, Peppe <c928400@student.dtu.dk> wrote:
> >If anyone are interested, I am working on a revised version that will
> >stay put in article mode (rather than go to the last message), if no
> >matching message was found.

>  Hello,

>  could you please post it here when it's done?

Sure. It ended up rather long though. It could probably have been much
simpler, had I allowed the use of marks (";"). It got the better of
me, so I decided to make it as clean as possible with respect to user
environment.

Hope it is useful,

Peppe

% -------------------------------------------------------------------------
% Search body of articles.
%
% Original script:      Tony Summerfelt <tsummerfelt1@myspleenhome.com>
% Revised (heavily):    Preben "Peppe" Guldberg <c928400@student.dtu.dk>
% Last revised:         Wed 14 Apr 1999
% Original appeared in news.software.readers, message id:
%       <slrn7go2cj.3vvjt5f.tsummerfelt1@co146453-a.kico1.on.wave.home.com>
%
% Note: use with caution when reading online. Especially in group
%       mode you might get to download a lot of messages.

% Tag the current article by number.
% Returns two values:
% - the number of the tag
% - whether the article was already tagged (0 or 1)
define tag_stay_put ()
{
    variable collapsed, tagged;
    tagged = get_header_tag_number ();
    if (tagged)
        return tagged, 1;
    else
    {
        collapsed = is_thread_collapsed ();
        if (header_down (1))
        {
            header_up (1);
            call ("tag_header");
            header_up (1);
        }
        else
            call ("tag_header");
        if (collapsed)
            collapse_thread ();
        return get_header_tag_number (), 0;
    }
}

% Untag an article. This is done by retagging the article (as within slrn).
% It must be specified how many times to toggle:
% - once:   tag is the highest numbered tagged article
% - twice:  not the highest numbered
% Call this function only if you know how many times to tag!
define untag_stay_put (n)
{
    variable collapsed;
    collapsed = is_thread_collapsed ();
    loop (n)
        call ("tag_header");
    if (collapsed)
        collapse_thread ();
}

% Untag another message (number tag1)
define untag_other_message (tag1)
{
    variable tag2, tagged, visible;
    (tag2, tagged) = tag_stay_put ();
    visible = is_article_visible ();
    if (visible)
        call ("hide_article");
    () = goto_num_tagged_header (tag1);
    if (tagged)
    {
        untag_stay_put (1);
        goto_num_tagged_header (tag2);
    }
    else
    {
        untag_stay_put (2);
        goto_num_tagged_header (tag1);
        untag_stay_put (1);
    }
    if (visible)
        call ("hide_article");
}

% Search onwards for an article where the criteria is found in the body.
define body_search (criteria)
{
    variable tag, tagged, visible, flags, n;
    (tag, tagged) = tag_stay_put ();
    visible = is_article_visible ();
    n = 0;
    do
    {
        if ( andelse {n == 0} {is_thread_collapsed ()})
        {
            n = thread_size ();
            uncollapse_thread ();
        }
        flags = get_header_flags ();
        if (re_search_article (criteria))
        {
            !if (tagged)
                untag_other_message (tag);
            return 1;
        }
        set_header_flags (flags);
        if (n == 1)
            collapse_thread ();
        if (n)
            n--;
    }
    while (header_down (1));
    goto_num_tagged_header (tag);
    !if (tagged)
        untag_stay_put (1);
    !if (visible)
        call ("hide_article");
    return 0;
}

% The function calling the search routine. Works in group mode,
% aswell as article mode.
%
% First two global variables for later reference:
    variable _criteria = "";
    variable _last_search = _criteria;
% Should we prompt for the use of metamail (probably not)
    variable _prompt_for_metamail = 0;
%
define query_body_search ()
{
    variable group, old_use_metamail, success;
    _criteria = read_mini ("Search message bodies for", "", _criteria);
    !if (strlen (_criteria))
    {  
        _criteria = _last_search;
        !if (strlen (_criteria))
            return;
    }
    group = current_newsgroup ();
    old_use_metamail = get_variable_value ("use_metamail");
    set_integer_variable ("use_metamail", _prompt_for_metamail);
    success = 0;
    if (is_group_mode ())
    {
        %call ("bob");
        do
        {
            if (select_group () == -1)
                continue;
            success = body_search (_criteria);
            if (success)
                break;
            else
                call ("quit");
        }
        while (group_down_n (1));
        !if (success)
            while (group != current_newsgroup ())
                group_up_n (1);
    }
    else
        success = body_search (_criteria);
    set_integer_variable ("use_metamail", old_use_metamail);
    !if (success)
        error ("No articles matched: " + _criteria);
}
definekey ("query_body_search", "\e/", "group");
definekey ("query_body_search", "\e/", "article");

%   vim: ts=4 sw=4 sts=0 et ai si
-- 
Preben Guldberg          __/-\__
c928400@student.dtu.dk    (o o)         There ain't no devil,
----------------------oOOo (_) oOOo     there's just God when he's drunk.
http://www.student.dtu.dk/~c928400/     --Tom Waits: Heartattack and Vine

Technical Details
Message-ID: <slrn7h9qm9.e5.c928400@urdybet.pbk.dk>
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
References: <7du1vh$gab$2@news.inet.tele.dk> <slrn7g5dgu.nk.kew@localhost.localdomain> <7dvkfe$a1p$2@news.inet.tele.dk> <slrn7g7qkg.6m2.sgibier@hermes.olympus.fr> <7eck1q$cqd$1@narses.hrz.tu-chemnitz.de> <slrn7go2cj.3vvjt5f.tsummerfelt1@co146453-a.kico1.on.wave.home.com> <slrn7h7eqp.3c6.c928400@urdybet.pbk.dk> <slrn7h9ckc.chn.zeitlin@seth.lpthe.jussieu.fr>

Show Full Headers
Complete Article Headers
Message-ID: <slrn7h9qm9.e5.c928400@urdybet.pbk.dk>
Subject: Re: I like slrn!
Date: Wed, 14 Apr 1999 00:00:00 +0000
From: c928400@student.dtu.dk (Peppe)
References: <7du1vh$gab$2@news.inet.tele.dk> <slrn7g5dgu.nk.kew@localhost.localdomain> <7dvkfe$a1p$2@news.inet.tele.dk> <slrn7g7qkg.6m2.sgibier@hermes.olympus.fr> <7eck1q$cqd$1@narses.hrz.tu-chemnitz.de> <slrn7go2cj.3vvjt5f.tsummerfelt1@co146453-a.kico1.on.wave.home.com> <slrn7h7eqp.3c6.c928400@urdybet.pbk.dk> <slrn7h9ckc.chn.zeitlin@seth.lpthe.jussieu.fr>
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: 466409579
X-Complaints-To: usenet@news.net.uni-c.dk
X-Trace: news.net.uni-c.dk 924117578 30138 130.225.71.226 (14 Apr 1999 19:19:38 GMT)
Organization: Home of Peppe
User-Agent: slrn/0.9.5.4 (UNIX)
Reply-To: c928400@student.dtu.dk
NNTP-Posting-Date: 14 Apr 1999 19:19:38 GMT
Newsgroups: news.software.readers