Macros and slrn
The slrn newsreader can be easily extended using S-Lang scripts that
are most commonly called macros and these scripts can easily be recognised
.sl suffix. This page aims to give a brief introduction
to macros and slrn by describing how to use macros available with slrn,
downloading other macros and even writing your own macros...
Using the Macros Available with slrn
The slrn tarball contains a number of pre-written macros in the
/macros directory and a standard installatioin of slrn
will place these on your system ready for use. For the purpose of demonstration
I will show how to successfully use one of these macros with slrn,
color.sl macro. This macro implements a function called
"edit_colors" that may be used for designing a color scheme
interactively. It is called from the
.slrnrc file as follows:
interpret "color.sl" setkey article edit_colors "\eec"
Because this is a well written macro much of this information can be
gained from opening the macro itself with your favourite editor and this
is really mandatory before using any macro. When the file
is opened you will see that the keybinding of "ESC e c" that I
have suggested is drawn from the file itself. After pressing these keys you
can now interactively select a color scheme by chosing an object, foreground
color and background color.
The same principles hold true for any macro you choose to run with slrn,
either those that came with slrn or those that you have sourced from elsewhere.
Your own macros can be placed in a variety of locations and then sourced
.slrnrc file using the
These locations are:
- A path relative to $HOME (or $SLRNHOME if set).
- An absolute path prefixed with an "/".
- In you "macro_directory" if this string is set in
This can be best illustrated in this brief extract from the slrn manual where the following example:
interpret "News/macros/my-macro.sl" interpret "/usr/share/slrn/slang/util.sl"
could be more efficiently be rendered as:
set macro_directory "News/macros,/usr/share/slrn/slang" interpret "my-macro.sl" interpret "util.sl"
There are many, many slrn macros available on the Internet. An excellent starting point might be the links available on this web site or the macros available for direct download from this page. Perhaps you might also read on and see the information for creating your own macros?
Downloading Other Macros
Several fine macros can be downloaded directly from this website:
- turbo-plonk.sl: This macro kills any article with a score of -666 (or the scorefile number of your choice) as well as killing any articles with its Message-ID in their references, thus kill-filing all replies to the original post. Written by JED.
- create_msg_id.sl: This macro allows the creation of an unique Message-ID based on your system date and time, a random number and a user-specified subdomain and hostname. It also allows for the creation of further custom headers. Written by Troy Piggins.
- fullthreads.sl: This macro allows display of full threads on entering a group when the threads contain at least one unread article. This answers the FAQ: " I want to see full threads as soon as they contain at least one unread article. Can slrn do this?" Written by Christian Ebert.
- gnupg-1.6.6.sl: This macro permits to sign articles with GNU Privacy Guard (GnuPG), or Pretty Good Privacy (PGP). It also consents to verify signed articles and to import new keys into your keyring. Written by Emmanuele Bassi.
- gsort-plus.sl: This macro is a
more sophisticated version of the macro
gsort.slthat comes with the slrn tarball and allows the sorting of slrn's group listing by alphabetical order, Big 8 first or Big 8 last. This macro can be called from a startup hook or simply bound to a key as it is in this version. Written by John E. Davis.
- headers-1.0.3.sl: A macro for setting custom headers containing the output of external programs. Written by Emmanuele Bassi.
- identity.sl: This macro allows the user to assign variable values, concerning his/hers identity, on a per-newsgroup basis: that is, to change some of the displayed informations depending on which newsgroup he/she is posting on a determined moment. Written by Emmanuele Bassi.
- new-search.sl: This macro is
meant to replace
search.slthat comes with slrn. It also searches through the articles in the current newsgroup, but has nicer features: It leaves threads in their collapsed / uncollapsed status, optionally starts the search at the beginning of the buffer or wraps around the end of the article list. Written by Thomas Schultz.
- onekey-score.sl: These are macros that allow you to create scorefile entries based on the current article via a single function call / keystroke. Two interfaces are available - the first is very simple and can be used to watch or ignore subthreads. The second is more complex, but also more versatile: It can put a score on subjects, "From:" lines or references. The scorefile will become quite large if this is used regularly so the perl script Cleanscore can be used to automatically remove expired entries. Written by Thomas Schultz.
- sort-headers.sl: Some people
like to view header lines in a special order. At your option, this
macro set will sort header lines alphabetically, in a user-defined
order or as given in the
visible_headersslrnrc command. It can be automatically called whenever a new article is read. Written by Thomas Schultz.
- temp-score.sl: This macro makes
it possible to assign a "temporary score" on all articles
that match a given regular expression in the subject, author or body.
It will not affect your scorefile, so the scores are lost as soon as
you exit the group. It can also "tag" matching headers, so
they can be selected using the functions defined in
nn.sl. This is done automatically if
nn.slis loaded before this file. Written by Thomas Schultz.
- threads-1.0.sl: A collection of macros that operates on threads. Written by Emmanuele Bassi.
Thanks again to the authors for making these macros available!
Resources for writing your own macros
This page does not offer "hands-on" guidance on the writing of S-Lang macros, although perhaps one day it will. However below are some links that should at the very least furnish an excellent start:
- README.macros: This plain text
document comes as part of the slrn tarball in the
/docdirectory. Its purpose is "to provide some instructions on extending the newsreader in its macro language" and is a recommended starting point when considering writing your own macros.
- S-Lang Library Documentation Page: This page contains a series of essential reference documents on the S-Lang Library and is required reading if you wish to develop your own macros.