1 % =========================================================================
2 % This file: $HOME/.slrn.test
3 % Available: http://nion.modprobe.de/setup/slrn.myfuncs
4 % Purpose: Init file for the news reader "SLRN"
5 % Author: Nico Golde <nico@ngolde.de>
6 % =========================================================================
7
8 % tell the user that this file is being used
9 % in the startup process:
10 message ("reading file: ~/.slrn.myfuncs");
11
12 message ("loading Mack's MID hack...");
13 % 010131 by Daniel E. Macks <dmacks@mail.sas.upenn.edu>:
14 % This allows to enter MIDs *without* the brackets. :-)
15 definekey ("better_locate_header_by_messageid","\el","article");
16 variable search_msgid="";
17 define better_locate_header_by_messageid ()
18 {
19 variable length;
20
21 search_msgid = read_mini ("Enter MID:","","");
22 search_msgid = str_delete_chars(search_msgid,"<>");
23 search_msgid = strtrim(search_msgid);
24
25 !if(strlen(search_msgid))
26 return;
27
28 search_msgid = sprintf("<%s>",search_msgid);
29 () = locate_header_by_msgid(search_msgid,1);
30 }
31
32
33 % this creates the Message-ID: l
34 static define create_msg_id ()
35 {
36 variable tm = gmtime (_time ());
37 return sprintf ("%d-%02d-%02dT%02d-%02d-%02d@ngolde.de",
38 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
39 tm.tm_hour, tm.tm_min, tm.tm_sec);
40 }
41
42 % this creates a Mail-Copies-To: (MCT) line
43 % so CCs of followups can be filtered easily.
44 define followup_hook ()
45 {
46 set_string_variable
47 ("followup_custom_headers",
48 (sprintf ("Mail-Copies-To: dummy@ngolde.de\n" +
49 "Message-ID: <%s>\n", create_msg_id () )
50 )
51 );
52 }
53
54 % define sort_article_header ()
55 % {
56 % variable header, body, article;
57 %
58 % article = article_as_string ();
59 %
60 % % article = header\n\nbody
61 % variable i = is_substr (article, "\n\n");
62 % header = article[[0:i-1]];
63 % body = article[[i:]];
64 %
65 % % Now remove continuation lines from the header
66 % while (str_replace (header, "\n ", " "))
67 % header = ();
68 % while (str_replace (header, "\n\t", " "))
69 % header = ();
70 %
71 % % Now convert the header, which is currently
72 % % a string, to an array of strings
73 %
74 % header = strtok (header, "\n");
75 %
76 % % Now manipulate the array of strings.
77 % % For example, here I am going to sort them
78 % i = array_sort (header); % slang 1.3.x required!
79 % header = header[i];
80 %
81 % % Now join the header to the body
82 % header = strjoin (header, "\n");
83 % article = strcat (header, "\n", body);
84 %
85 % % Now replace the selected article with this
86 % replace_article (article);
87 % }
88
89 % THPXRF
90 % vim: ft=slrnrc