tsca's S-Lang  page: slrn/jed macros

slrn screenshot The page contains a few S-Lang macros for the slrn newsreader and the jed text editor. If you notice a bug or have some comments, suggestions for improvement, etc, let me know ;-)

I add news macros and improve the old ones from time to time; see the changelog.

Just for the record: I use s-lang 1.4.6, slrn 0.9.7.4+ and jed 0.99.16

CONTENTS:


* REPLY PREFIXES [slrn] or [jed] - this macro changes the reply prefix (back to normal) when you follow up a post written by a person using MS Outlook. Not that it really matters, threading should be based on References:, but some people use Subject: for that purpose anyway. Fx:

The following two macros do the same; use whichever.
Well, if you're into vi, you have to use the second one :)

Download the macro for jed: jsv2re.txt
Download the macro for slrn: sv2re.txt


* RANDOM SIGNATURE [jed] - SigRoT inserts a random (unless wished otherwise) signature at the end of the current buffer. More comments and usage in the macro.

Download the macro: sigrot.zip


* PGP SIGNING [jed] - you can highlight a region in the file you edit, press ESC n, and PGP-sign it (you can also sign the whole buffer). PGP and GPG are supported. The macro won't work in MS Windows.

Download the macro: pgpsign.txt


* CHOOSE ENCODING [slrn] - this post_filter_hook allows you to choose the encoding of your post after writing and before posting it.

Download the macro: encoding.txt


* SAVE AS "SUBJECT" [slrn] - when saving a chosen article to a file the suggested filename is the subject of the post, not the newsgroup.

Download the macro: savex.txt


* MESSAGE-ID's MENU [slrn] - the macro scans current article for message-id's (<mess@ge.id> and <news:mess@ge.id> forms are recognised) and presents the user with a choice-box (like the one with URL's).

Download the macro: msgid.txt
NOTE: a more functional macro performing the same tasks is available from the slrn-pl CVS repository [howto]


* ADDING ADDRESSES TO MUTT'S .mail_aliases [slrn] - the macro adds the author of the currently displayed article to mutt's addressbook (.mail_aliases) or abook database. Aliases can be suggested on the basis of username or last name and can be commented on.

[get it from CVS] [how?] [used in slrn-pl]


* UN_OE_QUOTE [slrn] - reformats improperly broken OE quotes. Eg:.
>> Once upon a time there were three little
foxes
>> Who didn't wear stockings and who didn't wear

sockses
becomes
>> Once upon a time there were three little
>> foxes
>> Who didn't wear stockings and who didn't wear
>> sockses
or, depending on your settings,
>> Once upon a time there were three little foxes
>> Who didn't wear stockings and who didn't wear sockses
The macro can be executed automatically, but, as the conversion is not always perfect, it is safer to call it manually. Standard binding: META-q.

[get it from CVS] [how?] [used in slrn-pl]


* BINPOST [slrn] - attaches binary files to your postings. While composing your post, enter as the first line in the buffer (the first line of the headers)
X-File: /path/to/the/file
The file will automatically get attached (uuencoded) while posting. Only one file can be attached at a time. The macro is Linux-only. Don't use QP encoding with it! More info in the macro.

[get it from CVS] [how?] [used in slrn-pl]


* UNTAB ALL [jed] - an easy macro, helpful when you write a post where the text composition is important, or you make an ascii-art. It simply converts all the tabs into spaces and puts the cursor back to the position it was in when you called the macro.

Download the macro: untaball.txt


* HEADERS incl. random MESSAGE ID [(slrn) + jed] - that's a strange one. When posting to a newsgroup one sometimes needs to look through some other posts (to quote from miscellaneous articles, include msgid's, etc). That is why it is rather convenient to write the post on one console/xterm having slrn handy on another. The following macros add necessary headres and create a random message id. Usage in the macro.

Download the macro: headers.txt


* MULTIPLE PERSONALITIES and GROUP SPECIFIC SETTINGS [slrn] - that's not really a macro, that's a hook. It allows one to automatically change the name/email address/signature/any setting depending on a group.

Download the macro: multi.txt
NOTE: forget it! There's a real macro performing this task way better. Get it from the author's page or from the slrn-pl CVS repository [howto]


* CHARSET CONVERSION [slrn] - this macro can be used to do a simple charset conversion before the article is displayed. In some cases (eg. Unicode) it is probably better to use an external filter, but where it's a matter of replacing 12 characters (eg. CP-1250 to ISO-8859-2), a slang macro will do it, I believe, way faster.

   define konwertuj ()
 {
  variable article = article_as_string ();
   while (str_replace (article,"a","z")) article = ();
   while (str_replace (article,"x","d")) article = ();
  replace_article (article);
 }
% --- end here ----------------------------------------
Sure it doesn't make sense to replace all occurences of an "a" with a "z" -- that's just to show how one does it. As an example you can download a macro using this method to convert QP-> 8bit, (pl) UNICODE-> (pl)iso, La/Te/X-> iso-8859-2, uhtml, etc into the local (plain text) charset. Conversion type is chosen from a menu.

[get it from CVS] [how?] [used in slrn-pl]

Such a conversion can also be triggered automatically based on the charset declaration in article headers; look at the following hook:

  define read_article_hook ()
  {
   variable xcharset = extract_displayed_article_header("Content-Type");
   if (string_match(xcharset,"charset=\"?utf-7\"?",1)){utf72iso();}
% [...] etc, etc, you can put a lot here
  }
(note that in newer versions of slrn it is better to turn the above into a function and then bind it to a hook via the register_hook() function)
In fact, much more can be achieved with such conversions: have a look at the "poor man's mime" macro.
* SAVE SENT POSTS TO MAILBOXES NAMED AFTER A GROUP... [slrn] - ...instead of to one common mailbox. Eg, if you send a post/followup to news.software.readers, the post will be saved into the file of that name (you can configure the macro to uppercase the first letter of the newsgroup and to save your posting into a separate directory).

[get it from CVS] [how?] [used in slrn-pl]


* STRIP "--" and "-- \n" SIGS ON FOLLOWUP/REPLY [(slrn/mutt/whatever)+jed] - deletes (M$) signatures starting with "--" instead of "-- \n"

Download the macro: wywal_ms_siga.txt


* DELETE HTML PART OF THE MESSAGE [slrn] - Removes the html part of message. Automatically, if you call this macro from read_article_hook. But better forget this macro, it is now included in poor man's mime that does much more magic with multipart articles.

Download the macro: uhtml.txt


* POSTING COUNTER & LOGGING [slrn] - This macro keeps a count of your posts in "~/.slrn_counter" file and -- if you define so -- will add an "X-post-counter: no" line into the headers of your posts. It also logs your posting activity in "~/.slrn_post_log" file ([no] [ng] [subject] <msgid> date); it can be accessed by ESC-j . Unfortunatelly, at this point msgid is only retrieved if you generate it in your editor. If you leave this task for slrn, the msgid field in the .slrn_post_log file will by empty :-/

[get it from CVS] [how?] [used in slrn-pl]

SLRNSTAT:
Brzezi <brzezi @ enter.net.pl> wrote a small program generating nice statistics from the .slrn_post_log file:
See an example output of the program. -- Download the program (source + binary)


* DEJA SPY [de_spy.sl] [slrn] - Goes to the current article author's posting profile on Dejanews. This macro is gonna work as long as dejanews doesn't change their URL. It's fun and a great weapon in flamewars! :)

Download the macro: de_spy.txt


* CHOOSE COLOUR ("Farbenwahl") [slrn] - this macro allows you to switch on the fly between colour sets downloaded from WWW/Usenet/whatever (more info in the macro). Can also be used in hooks to assign a colour scheme to a certain group, etc. The macro is capable of remembering what colour scheme you chose the last time and automatically loading it the next time you run slrn. If you use it in connection with slrnface.sl, the macro will cause the displayed X-Face to auto-adjust to the general slrn colour scheme.

See how it looks: colorset.gif * download 30 colour schemes
download a perl script checking if the colour sets you use are complete

[get it from CVS] [how?] [used in slrn-pl]


* INSERTING THE OUTPUT OF AN EXTERNAL COMMAND INTO AN X-HEADER [slrn] - the name says it all. Use fx. ddate, uptime or a similar thing with it.

Download the macro: ext_header.txt


* SHOW RAW (unprocessed) MESSAGE [slrn] - This macro works only with a local spool. I tested it with INN and slrnpull, so it should work with any similar kind of spool (that is NOT with CNFS).
[Yes, it can be done another way (changing the value of "use_mime), but that'd require re-reading the message from server.]

Download the macro for slrn 0.9.6.4 or older: raw_old.txt
Download the macro for slrn 0.9.6.4pl4/0.9.7.0 or newer: raw.txt


* POOR MAN'S MIME :-) [slrn] - What this macro does is automagically converting OE multipart mime messages (QP, UTF, and html part included) in such a way that a message looking like this:

This is a multi-part message in MIME format.
------=_NextPart_000_0185_01BFC683.16E40180
Content-Type: text/plain;
        charset="utf-8"
Content-Transfer-Encoding: 8bit
Życzę krótkiego oglądania i genialnych przemyśleń ! :-)))
------=_NextPart_000_0185_01BFC683.16E40180
Content-Type: text/html;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
[...]
</BODY></HTML>
------=_NextPart_000_0185_01BFC683.16E40180--
is displayed this way:
Życzę krótkiego oglądania i genialnych przemyśleń ! :-)))

 [ Multipart MIME message successfully processed. v0.01 (slrn) ]
 [ HTML part removed. UTF conv. to iso-8859-2. ]

Quite a difference, isn't it? :-) The macro also deals with UFT messages, X-CHARSET UNKNOWN QP messages, PGP/MIME signatures, vcards, html, etc. (And you can always see how it originally looked like with this macro.)
Charset conversion macro is required for this to work! [see README/CZYTAJTO]

[get it from CVS] [how?] [used in slrn-pl]


* MANIPULATING DATE AND MSGID IN THE FOLLOWUP_STRING ("user wrote:") [slrn] - instead of
                On 9 Jun 2000 06:25:34 GMT, user <user@d.pl> wrote:
you can have eg.
                user wrote
                in news:2w34324532452.23453245.3245@asf.dre.pl on 09.06.2k:
Adjust the macro to your needs (don't re-define the followup_hook if you aready have one).

Download the macro for slrn 0.9.6.4 or older: data_old.txt
Download the macro for slrn 0.9.6.4pl4/0.9.7.0 or newer: data.txt


* LOCKFILE [slrn] - slrn lockfile functionality -- if there are other instances of slrn running in the system, the variable slrn_lock->locked will be 1, otherwise it will be 0. More info in the macro.

Download the macro: slrn-lock.txt

* COUNTEM/AMIALONE [slrn] - "tsca_func->countem(x)" will give you the number of currently running instances of slrn.

                        x = 0 --> in general on your system
                        x = 1 --> owned by you ($USER)
The function requires `ps` and `grep` in your system and due to the use of popen() won't work in Windows. More info in the macro.

Download the macro: tsca-func.txt


* forwarding to pl.rec.humor.najlepsze

Download the macro: frwd.txt (slrnpull required)
Download the macro: frwd-ham.txt (Hamster required)
More mutations of this macro: one * two [howto]


LINKS

.slrnrc, score and other suggestions

.slrnrc / slrn.rc

 % This catches the Supercite-type "TtS> " quotes,
 % and _doesn't_ catch lines starting with ":)" smileys

  ignore_quotes        "^ *[a-zA-Z-]*>" "^ *[\]|)]" "^ *:[^-()^]"

score


[*]

% This scores my posts and three succesive followups made to them

 Score:: 2000
              From: tsca@
              From: sienicki
 Score:  1000
              References: tsca@gate\d*\.has\.dk> *$
 Score:  900
              References: tsca@gate\d*\.has\.dk> *<[^>]*> *$
 Score:  500
              References: tsca@gate\d*\.has\.dk> *<[^>]*> *<[^>]*> *$


% ... and this catches "s-lang", "slang", and "slrn" :)

 Score: 100
              Subject: \<s-?l[ar]ng?

[comp.editors]

% We don't want vi, vim & gvim :)

 Score: -9999
              Subject: \<g?vim?\>

If you want to play with your scorefile in an open text editor and see the results immediately in a running slrn, put
setkey article "reload_scorefile(-1)" "\ek"
in your .slrnrc/slrn.rc. Upon pressing ESC-k the scorefile will be reloaded and changes will be applied.
Read also some notes on S-Lang regular expressions and see more examples: in English or in Polish.

other
This little script makes life way easier when you use slrn with many newsservers. Instead of typing all the data on the command line, just type nwo server. Of course you gotta change the data in the script before using it; add as many newsservers, slrnrc files and options as you wish.


CVS: why? how do I use it?

WHY: As I am one of the slrn-pl developers, some of these macros are included in the slrn-pl package and they are developed in our CVS repository (thanks to the PLD folks for the space). The newest versions of the macros are always available from the repository; there is no use duplicating them here.
HOW: The macros still can be used with the "vanilla" slrn; the only requirement is that the system macro "slrn-pl.sl" must be interpreted before. To get the desired macro click on the version number (the underlined part of the first line), eg:

 1.6 Sat May 4 18:30:35 2002  by tsca
 CVS Tags: HEAD
 Diffs to 1.5 
Hint for OE users: the downloaded files are gzipped; use eg. WinZip or Windows Commander to unpack them. If you still have problems understanding how to download macros from CVS, mail me for assistance.

* page made with jed bar *
* page made with jed bar *
* page made with jed bar *
Get more JED icons.

stat4u * anybrowser
The above should work, but use at your own risk.
Last changes:
$Id: slang.html,v 1.7 2003/08/10 19:59:28 tsca Exp $
mail me at Tomasz.Sienicki@post.cybercity.dk
this page: http://www.geocities.com/tsca.geo/slang.html

Go back to the entry page.

1