Subject:
|
slrn macro for X-LUGNET-URL: header
|
Newsgroups:
|
lugnet.admin.nntp
|
Date:
|
Fri, 9 Nov 2001 19:27:48 GMT
|
Viewed:
|
921 times
|
| |
| |
I just whipped up an S-Lang macro for slrn that I figured I'd put out there
for anyone else to use. The background is that I usually read LUGNET from
slrn, but often I want to jump to the web interface to finish reading a
particular thread (possibly to re-read earlier posts in the thread I had
glossed over). Obviously, the Xref: header gives you all the info you need,
so I find myself repeatedly displaying that header, copying it, pasting
into Netscape, and doing the simple re-write that turns it into the equivalent
URL.
Well, now I've just written a macro that does that for me. If you use slrn's
read_article_hook(), it can happen automatically every time you read an
article, and it just adds the URL in another header. The header gets picked
up by slrn when you use the 'U' key (default binding), and it presents that
URL as one of the URLs in the article that you can open with an external
browser, which can be Netscape. Now instead of opening Netscape and cutting
and pasting, I just hit 'U' and 'enter' a few times, and I'm immediately
where I want to be in the web interface.
If anybody actually finds this useful, I'd love to hear it.
-Craig
<-----------------------------------cut here---------------------------------->
%% Create LUGNET URL
%% Causes SLRN to add a new header ("X-LUGNET-URL:") to the current article,
%% which makes it much more convenient to jump to the same article using
%% LUGNET's web interface. The most convenient way to use this is to
%% uncomment the definition of the "read_article_hook" function at the
%% bottom, which will automatically add the header every time you read a
%% new article. If you prefer to bind it to a key, so that it will only
%% happen when you specifically want it, uncomment the "definekey" statement.
%%
%% To use this, save this file as .lugnet_macros.sl (or whatever you want),
%% and then add to your .slrnrc the line:
%% interpret ".lugnet_macros.sl"
%% you may also want to add the new header to your visible headers by:
%% visible_headers "From:,Subject:,Date:,X-LUGNET-URL:"
%%
%% As a reminder, the "U" key is usually bound to the function of searching
%% the article for URLs and presenting them for you to open with whatever
%% browser you have set with the Xbrowser or non_Xbrowser variables in your
%% .slrnrc. Using the function below, the LUGNET URL to the article will
%% usually be the first one in the list.
%%
%% (c)2001 Craig B. Agricola
%% Share and enjoy! (No distribution limits, though I'd prefer that you
%% leave all of my comments as is...)
define create_lugnet_url() {
variable art, prec, succ;
variable xref_start, xref_len, xref;
variable group_start, group_len, group;
variable artnum_start, artnum_len, artnum;
% Read the article
art = article_as_string();
% Check to see if it has a lugnet.com Xref: header
if (string_match(art,
"^Xref:[ ]*lugnet.com[ ]*lugnet\.\\([^:]*\\):\\([0-9]*\\).*$",
1))
{
% Since it does, pull the article apart, and rebuild it with a
% new X-LUGNET-URL: header
(xref_start, xref_len) = string_match_nth(0);
(group_start, group_len) = string_match_nth(1);
(artnum_start, artnum_len) = string_match_nth(2);
xref = substr(art, xref_start+1, xref_len);
prec = substr(art, 1, xref_start);
group = substr(art, group_start+1, group_len);
artnum = substr(art, artnum_start+1, artnum_len);
succ = substr(art, xref_start+xref_len+1, -1);
group = strtrans(group, ".", "/");
art = strcat(prec, xref, "\n",
"X-LUGNET-URL: http://www.lugnet.com/", group,
"/?n=", artnum, succ);
% Replace the article that we read with the fixed-up version
replace_article(art);
}
}
%% Uncomment one of these, or else the above function won't do you much
%% good. (ie, it will never get executed)
%definekey("create_lugnet_url", "l", "article");
%define read_article_hook() { create_lugnet_url(); }
|
|
Message has 1 Reply: | | Re: slrn macro for X-LUGNET-URL: header
|
| (...) great idea! I've been meaning to do that for a while now... I went ahead and did the same thing for my lugnetton - my dedicated LUGNET news reader. Thanks for reminding me! I have to admit that in perl it's a lot shorter than in s-lang :) Dan (23 years ago, 10-Nov-01, to lugnet.admin.nntp)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|