Thread View: news.software.readers
13 messages
13 total messages
Started by Mike Vanecek
Tue, 27 Apr 2004 13:28
[slrn] macro help please
Author: Mike Vanecek
Date: Tue, 27 Apr 2004 13:28
Date: Tue, 27 Apr 2004 13:28
28 lines
2104 bytes
2104 bytes
I am trying to write my first macro based on ideas posted in this group and my
reading of the manuals.
my_macros.sl contains
implements ("my");
static define my_quit_group ()
{
call("catchup");
call("next");
}
definekey("my_quit_group", "\033[24~", "article");
.slrnrc has
interpret "my_macros.sl"
setkey article my->my_quit_group "%"
The macro loads. I open a group and press F12 and receive the following error
message:
S-Lang Error: Undefined Name: my_quit_group is undefined
Why am I getting the error message?
--
Thanks, Mike.
Re: [slrn] macro help please
Author: J.B. Nicholson-Owens
Date: Tue, 27 Apr 2004 15:45
Date: Tue, 27 Apr 2004 15:45
19 lines
1764 bytes
1764 bytes
Mike Vanecek wrote:
> definekey("my_quit_group", "\033[24~", "article");
Here you need to include the name of the namespace ("my").
> .slrnrc has [...]
> setkey article my->my_quit_group "%"
If you want to define the key to be F12 and set that in the macro proper,
you don't need this setkey statement. Generally, it's better to define the
keys in your slrnrc so the key definitions are all in one place and it's
easier to coordinate which keys call which function.
> S-Lang Error: Undefined Name: my_quit_group is undefined
> Why am I getting the error message?
Because my_quit_group is the same as Global->my_quit_group() which does not
exist. my->my_quit_group() exists and should run if you press the percent
sign key.
Re: [slrn] macro help please
Author: Mike Vanecek
Date: Thu, 29 Apr 2004 01:07
Date: Thu, 29 Apr 2004 01:07
47 lines
2389 bytes
2389 bytes
On 27 Apr 2004 15:45:55 GMT, J.B. Nicholson-Owens wrote:
> Mike Vanecek wrote:
>> definekey("my_quit_group", "\033[24~", "article");
> Here you need to include the name of the namespace ("my").
>> .slrnrc has [...]
>> setkey article my->my_quit_group "%"
> If you want to define the key to be F12 and set that in the macro proper,
> you don't need this setkey statement. Generally, it's better to define the
> keys in your slrnrc so the key definitions are all in one place and it's
> easier to coordinate which keys call which function.
>> S-Lang Error: Undefined Name: my_quit_group is undefined
>> Why am I getting the error message?
> Because my_quit_group is the same as Global->my_quit_group() which does not
> exist. my->my_quit_group() exists and should run if you press the percent
> sign key.
Thank you for the advice, it was very helpful. I do the setkey to F12 in
.slrnrc now.
OK, making progress. This works, but is not pretty.
implements ("my");
static define my_quit_group ()
{
set_integer_variable("query_next_group",0);
set_integer_variable("confirm_actions", 0);
call("catchup_all");
call("next");
set_integer_variable("query_next_group",1);
set_integer_variable("confirm_actions", 31);
}
I should probably test the contents of query_next_group and not set it to 0
if is already 0 and not set it back to 1. Ditto for confirm_actions since all I
really want to do is decrease it by 1 and then restore it. Any shortcuts on
doing that??
--
Thanks, Mike.
Re: [slrn] macro help please
Author: Lars Stokholm
Date: Thu, 29 Apr 2004 06:04
Date: Thu, 29 Apr 2004 06:04
20 lines
1546 bytes
1546 bytes
Mike Vanecek wrote:
> Ditto for confirm_actions since all I really want to do is decrease
> it by 1 and then restore it. Any shortcuts on doing that??
Well, this is what I've got:
#v+
define quick_read()
{
variable old_ca,new_ca;
old_ca = get_variable_value("confirm_actions");
new_ca = old_ca;
if (old_ca mod 2 != 0) new_ca--;
set_integer_variable("confirm_actions",new_ca);
call("catchup_all");
set_integer_variable("confirm_actions",old_ca);
call("skip_to_next_group");
}
#v-
Re: [slrn] macro help please
Author: Mike Vanecek
Date: Thu, 29 Apr 2004 15:07
Date: Thu, 29 Apr 2004 15:07
27 lines
1617 bytes
1617 bytes
On Thu, 29 Apr 2004 08:04:47 +0200, Lars Stokholm wrote:
> Mike Vanecek wrote:
>> Ditto for confirm_actions since all I really want to do is decrease
>> it by 1 and then restore it. Any shortcuts on doing that??
> Well, this is what I've got:
> #v+
> define quick_read()
> {
> variable old_ca,new_ca;
> old_ca = get_variable_value("confirm_actions");
> new_ca = old_ca;
> if (old_ca mod 2 != 0) new_ca--;
> set_integer_variable("confirm_actions",new_ca);
> call("catchup_all");
> set_integer_variable("confirm_actions",old_ca);
> call("skip_to_next_group");
> }
> #v-
Very nice, thank you.
--
Thanks, Mike.
Re: [slrn] macro help please
Author: Lars Stokholm
Date: Thu, 29 Apr 2004 16:17
Date: Thu, 29 Apr 2004 16:17
20 lines
1739 bytes
1739 bytes
Mike Vanecek wrote:
> Very nice, thank you.
You too. I stole your idea. I didn't even know about the call-
function before I saw your code.
Btw, this has got two fewer lines and only one variable *g*:
#v+
define quick_read()
{
variable old_ca;
old_ca = get_variable_value("confirm_actions");
set_integer_variable("confirm_actions",2*(old_ca/2));
call("catchup_all");
set_integer_variable("confirm_actions",old_ca);
call("skip_to_next_group");
}
#v-
Re: [slrn] macro help please
Author: Scott Eberl
Date: Fri, 30 Apr 2004 02:49
Date: Fri, 30 Apr 2004 02:49
37 lines
2312 bytes
2312 bytes
On 2004-04-29, Lars Stokholm <stokholm@despammed.com> wrote:
> Mike Vanecek wrote:
>
>> Very nice, thank you.
>
> You too. I stole your idea. I didn't even know about the call-
> function before I saw your code.
>
> Btw, this has got two fewer lines and only one variable *g*:
> #v+
> define quick_read()
> {
> variable old_ca;
>
> old_ca = get_variable_value("confirm_actions");
> set_integer_variable("confirm_actions",2*(old_ca/2));
> call("catchup_all");
> set_integer_variable("confirm_actions",old_ca);
> call("skip_to_next_group");
> }
> #v-
Sorry to be the stupid guy at the end of this post but what exactly is
this script/macro suppose to do? I'm new to slrn but willing to learn :)
I started with computer back with DOS and then like most others was
slowly sucked into the GUI/Windows era. I used to say I missed the
command prompt in Windows. A couple years ago I decided to learn Linux
and I now happily run 2 slackware boxes. So back to my original question
whats the script do?
Sorry for rambling but right now I'm feeling pretty good with a few cold
ones!
--
Scott Eberl
Network Technician
Re: [slrn] macro help please
Author: J.B. Nicholson-Owens
Date: Fri, 30 Apr 2004 02:53
Date: Fri, 30 Apr 2004 02:53
52 lines
2941 bytes
2941 bytes
I recommend one of the following. This version works if you are trying to
reset to slrnrc settings:
#v+
implements ("my");
private variable
default_query_next_group = get_variable_value ("query_next_group"),
default_confirm_actions = get_variable_value ("confirm_actions");
static define quit_group ()
{
set_integer_variable ("query_next_group", 0);
set_integer_variable ("confirm_actions", 0);
call ("catchup_all");
call ("next");
set_integer_variable ("query_next_group", default_query_next_group);
set_integer_variable ("confirm_actions", default_confirm_actions);
}
#v-
I recommend the following if you are trying to reset to the current settings
at the moment the function is called:
#v+
implements ("my");
static define quit_group ()
{
variable
query_next_group = get_variable_value ("query_next_group"),
confirm_actions = get_variable_value ("confirm_actions");
set_integer_variable ("query_next_group", 0);
set_integer_variable ("confirm_actions", 0);
call ("catchup_all");
call ("next");
set_integer_variable ("query_next_group", query_next_group);
set_integer_variable ("confirm_actions", confirm_actions);
}
#v-
> I should probably test the contents of query_next_group and not set it to
> 0 if is already 0 and not set it back to 1. Ditto for confirm_actions
> since all I really want to do is decrease it by 1 and then restore it. Any
> shortcuts on doing that??
I wouldn't look for a shortcut nor would I bother with a test because in my
experience these things make code unclear and, in the long run, aren't a
good tradeoff against stating what you want to happen. For code like this,
I tend to favor code I'll understand at a glance in 6 months over clever
code.
Re: [slrn] macro help please
Author: J.B. Nicholson-Owens
Date: Fri, 30 Apr 2004 06:53
Date: Fri, 30 Apr 2004 06:53
7 lines
1509 bytes
1509 bytes
Scott Eberl wrote: > [W]hat exactly is this script/macro suppose to do? What the macro does: Without prompting the user for anything, mark everything in the current newsgroup as read and then enter the next group with unread articles. If there is no such newsgroup, leave the user in group mode.
Re: [slrn] macro help please
Author: J.B. Nicholson-Owens
Date: Fri, 30 Apr 2004 06:57
Date: Fri, 30 Apr 2004 06:57
16 lines
1766 bytes
1766 bytes
I have two suggestions for you: 1. In the event that there is no next newsgroup with unread articles to go to the macro will leave the user in group mode (a side-effect of the next intrinsic). Give the user the option to stay in the current newsgroup. 2. Currently, one can inadvertantly passing a prefix argument to one of the two call()s in the macro--if the user binds the macro to, say, the "%" key, then types ESC 4 % (three keystrokes, Escape, 4, %), one of the call()ed functions may act differently in the future and gobble up the prefix argument. Future-proof the macro by preventing this from occurring but don't disturb the prefix argument passed to the macro.
Re: [slrn] macro help please
Author: Lars Stokholm
Date: Fri, 30 Apr 2004 14:43
Date: Fri, 30 Apr 2004 14:43
8 lines
1380 bytes
1380 bytes
J.B. Nicholson-Owens wrote: > I recommend one of the following. This version works if you are > trying to reset to slrnrc settings: I'm very new to this - would you mind explaining to me why you make the function 'static'? Also I would like to know if it's a good idea to use 'implements', and why.
Re: [slrn] macro help please
Author: J.B. Nicholson-Owens
Date: Fri, 30 Apr 2004 16:45
Date: Fri, 30 Apr 2004 16:45
31 lines
2668 bytes
2668 bytes
Lars Stokholm wrote:
> [W]ould you mind explaining to me why you make the function 'static'? Also
> I would like to know if it's a good idea to use 'implements', and why.
For explanations of what implements and namespace scope declarations
("global", "static", and "private") do, please consult the S-Lang
documentation. In the S-Lang package from http://jedsoft.org/ you can find
text documentation and a tutorial in "doc/text/slang.txt".
We're talking about two lines of code:
implements ("my");
static define function_name_goes_here ()
I recommend naming a namespace for personal use because it avoids clobbering
anything in any other namespace. "my" is a traditional name for something
private to you (widely used in Smalltalk, for instance) so that is the name
I chose.
Strictly speaking, one doesn't need to explicitly say "static" after the
"implements" line. Static declaration is implied here. But I say it so
it's clear when one looks at the code months later or if S-Lang goes back to
requiring such declaration.
I also make the function static because one needs the function to exist in a
particular namespace and yet also be accessible from any other namespace.
Static declaration accomplishes this. For functions and variables one only
needs to (or should) access from within the same file, declaring these as
"private" will be better. "global" declaration places the variable or
function in the Global namespace, also available to all functions and
variables.
Re: [slrn] macro help please
Author: Lars Stokholm
Date: Fri, 30 Apr 2004 16:52
Date: Fri, 30 Apr 2004 16:52
7 lines
1254 bytes
1254 bytes
J.B. Nicholson-Owens wrote: > We're talking about two lines of code: [...] Thank you very much.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads