Article View: news.software.readers
Article #58332Re: slrn: How difficult to implement RE for Subject search?
From: Renaud Colinet
Date: Tue, 22 Feb 2000 00:00
Date: Tue, 22 Feb 2000 00:00
98 lines
3572 bytes
3572 bytes
On Mon, Feb 21 2000 17:32:09 GMT, Open Mike wrote:
>I realize that "waddaya want fah nuthin, rrruuubbbbahhh biskitt?"
>but how difficult would it be to add the capability of regular
>expressions on the "Subject" search? Many newsgroups I look through
>have pages and pages of the same subject and I'd like to be able
>to skip past by searching for not the first few characters of
>the subject.
>
Regexp search functions are already implemented in slrn. All you have to
do is use them in a macro.
For instance, copy the following code in a file called "re_search.sl"
(your home directory should be a fine place for it):
#v+
% This macro allows one to search for a subject regexp through the articles in
% the current newsgroup. It binds the function 're_subject_search_newsgroup'
% to the '$' key in article mode.
variable Search_Last_Re_Subj_Search_Str = "";
define re_subject_search_newsgroup ()
{
variable str;
str = read_mini ("Search for subject regexp",\
Search_Last_Re_Subj_Search_Str, "");
if (str == "")
return;
Search_Last_Re_Subj_Search_Str = str;
if (re_fsearch_subject(str))
return;
error ("Not found.");
}
definekey ("re_subject_search_newsgroup", "$", "article");
#v-
and add the following line in your .slrnrc:
interpret "re_search.sl"
Then pressing the '$' will prompt you for a regexp to be searched.
Note : it does a forward search. Programming a backward search is left
as an exercize to the reader :-)
>On that same subject, would it be possible, maybe with a macro,
>to implement arg count on the "previous" and "next" article
>commands? In other words, ESC 20 CTRL-N would skip 20 articles
>forward.
>
AFAIK, having a prefix argument can't be done without hacking the
source. You can change the header_down function in art.c to:
#v+
static void header_down (void) /*{{{*/
{
int prefix;
if (Slrn_Prefix_Arg_Ptr != NULL)
{
prefix = *Slrn_Prefix_Arg_Ptr;
Slrn_Prefix_Arg_Ptr = NULL;
}
else prefix = 1;
slrn_header_down_n (prefix, 1);
}
#v-
and recompile slrn. (It works, but it hasn't been checked for unwanted
side effects)
Another method is to write a macro that prompts you for the number of
headers you want to go down by:
#v+
variable Header_Down_Last_Number = "";
define header_down_n ()
{
variable str;
variable n;
str = read_mini("How many headers down", Header_Down_Last_Number,"");
if (str == "")
return;
Header_Down_Last_Number = str;
n = integer(str);
header_down (n);
}
definekey ("header_down_n" ,"D","article");
#v-
HTH
--
Renaud
The From: address is valid but filtered. Please use the Reply-To: address
for direct replies.
Technical Details
Message-ID:
<slrn8b61qp.1og.colinet@beige4.ensta.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-mailReferences:
<slrn8b2tkp.s4s.mikeyMUNGE@crush.wwnet.net>Show Full Headers
Complete Article Headers
Message-ID: <slrn8b61qp.1og.colinet@beige4.ensta.fr> Subject: Re: slrn: How difficult to implement RE for Subject search? Date: Tue, 22 Feb 2000 00:00:00 +0000 From: colinet@pervenche10.ensta.fr (Renaud Colinet) References: <slrn8b2tkp.s4s.mikeyMUNGE@crush.wwnet.net> 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: 588573129 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=iso-8859-1 Organization: Ecole Nationale Superieure de Techniques Avancees (ENSTA), Paris Mime-Version: 1.0 User-Agent: slrn/0.9.6.2 (Linux) Reply-To: colinet@saumon4.ensta.fr Newsgroups: news.software.readers