🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
3 messages
3 total messages Started by Thorfinn Wed, 14 Oct 1998 00:00
Re: SLRN Macros/Hooks
#43795
Author: Thorfinn
Date: Wed, 14 Oct 1998 00:00
85 lines
3394 bytes
In news.software.readers, on 13 Oct 1998 07:54:11 GMT
Scott H. Perlman <perlman@linguist.dartmouth.edu> wrote:
>IWhat would be the appropriate hook to add
>extract_article_header  I frequently want to look at a header that is
>not displayed by default, and I'd like to set certain groups to do so
>autmatically.

>On the same token is there a comparable function to hide and article header
>I don't want to see?

As other people have said... I don't think there's a way to define the
list of headers that are seen/unseen in slrn.

That would probably be the most useful feature to have added.

Anyway... Here's what I do in order to get slrn to always display
headers and scores in the article list window:

=== begin macros.sl ===

%
% Copyright 1998 Thorfinn <thorfinn@tertius.net.au>
%
% Feel free to use with attribution.

%
% Make it show headers to start with.
%
variable done_singleton_show_headers = 0;
define article_mode_see_headers ()
{
   if (done_singleton_show_headers == 0)
   {
      % Grab the header flags of the article we're pointing to
      % (necessary so that we can restore them later).
      variable oldflags = get_header_flags();

      % Call "toggle_headers", which causes headers to be displayed in the
      % current article, and incidentally displays the current article.
      call("toggle_headers");

      % Call "hide_article", which hides the article again, returning
      % us to the original display of just the article list.
      call("hide_article");

      % Change the header flags back.
      set_header_flags(oldflags);

      % Set the display_score variable to 1, so that we show scores, too.
      set_integer_variable("display_score", 1);

      % Call redraw, so that the screen is redisplayed with scores.
      call("redraw");

      % Set the singleton variable, so we don't try to do all of this again.
      done_singleton_show_headers = 1;
   }
}

define article_mode_hook ()
{
   % I have some other article mode hooks here, 
   % but they're not relevant.
   article_mode_see_headers();
}


=== end macros.sl ===

Something like it on a per newsgroup basis is possible, if you, say,
keep track of the state of "toggle_headers", and remap the current
toggle_headers key so that it doesn't cause problems with your
internal state variable, either by keeping track, or just disallowing
it entirely.

Later,

   Thorf

-- 
<a href="http://www.tertius.net.au/~thorfinn/">thorfinn@tertius.net.au</a>
C++ protects you against Murphy, not Machiavelli.
                -- Damian Conway

Re: SLRN Macros/Hooks
#43757
Author: Dawn Owens-Nicholson
Date: Wed, 14 Oct 1998 00:00
51 lines
2489 bytes
Thorfinn wrote:
> Anyway... Here's what I do in order to get slrn to always display
> headers and scores in the article list window:

Actually, you can't guarantee the full header list will always show.
Another macro could call("toggle_headers") and odd number of times and throw
off your macro entirely.

>    if (done_singleton_show_headers == 0)

If you really want to do this, however, I suggest using:

     !if (done_singleton_show_headers)

it's more S-Langish.

>       variable oldflags = get_header_flags();

Thanks for saving state and restoring it at the end, I appreciate it.  It's
nice to know someone besides me is interested in macros that do this.
However, I don't see what this has to do with showing headers.  You never
use or modify the flags anywhere in your macro (besides the
set_header_flags() at the end); neither call("toggle_headers") nor
call("hide_article") modify the article flags.

>       call("toggle_headers");

This is the buggy part.  If there were a way to conditionally do this, it
could be fixed.

>       call("hide_article");

This should be done conditionally since you don't want to toggle
hiding/unhiding the article:

        if (is_article_visible ()) call ("hide_article");  % hide the article

>       call("redraw");

Actually, you don't need to redraw the screen.  Setting display_scores is
sufficient to show/hide the scores.  But this brings up a larger point--what
does showing scores have to do with showing headers?

> Something like it on a per newsgroup basis is possible, if you, say,
> keep track of the state of "toggle_headers" [...]

In general, macros like this aren't a really good idea for wide
dissemination because when the wrapper functions aren't used consistently,
they fail when they're used.

Re: SLRN Macros/Hooks
#43811
Author: Thorfinn
Date: Thu, 15 Oct 1998 00:00
87 lines
4418 bytes
Dawn Owens-Nicholson wrote:
> Thorfinn wrote:
> > Anyway... Here's what I do in order to get slrn to always display
> > headers and scores in the article list window:
> Actually, you can't guarantee the full header list will always show.
> Another macro could call("toggle_headers") and odd number of times and throw
> off your macro entirely.

Well... that's why I always do it only once.  It's pretty much a hack
workaround, until JED puts in a show_header_hook() or something like
that.

> >    if (done_singleton_show_headers == 0)
> If you really want to do this, however, I suggest using:
>      !if (done_singleton_show_headers)
> it's more S-Langish.

Ahuh.  I tend to stick to my C/C++ish style, since I haven't looked at
much sample slang-code to get a feel of how its style normally is.

> >       variable oldflags = get_header_flags();
> Thanks for saving state and restoring it at the end, I appreciate it.  It's
> nice to know someone besides me is interested in macros that do this.
> However, I don't see what this has to do with showing headers.  You never
> use or modify the flags anywhere in your macro (besides the
> set_header_flags() at the end); neither call("toggle_headers") nor
> call("hide_article") modify the article flags.

Ah.  toggle_headers causes the article to display, and get set to
"read".  I prefer to unset that "read" flag, so that the singleton
causes the headers to display without actually *appearing* to do anything
different.

> >       call("toggle_headers");
> This is the buggy part.  If there were a way to conditionally do this, it
> could be fixed.

Well, yes.  This is why I only do it once, ever, and that's usually the
first time toggle_headers is called... since the only time toggle_headers
can be called is inside article mode... and the hook is called
immediately on entry to article mode...

If toggle_headers gets called *after* this hook runs, it doesn't matter.
It's only *supposed* to be a singleton run, and if the user decides
later that they don't want to see headers any more, fine.

> >       call("hide_article");
> This should be done conditionally since you don't want to toggle
> hiding/unhiding the article:
>         if (is_article_visible ()) call ("hide_article");  % hide the article

Hrm.  That's true.  I should do that.

> >       call("redraw");
> 
> Actually, you don't need to redraw the screen.  Setting display_scores is
> sufficient to show/hide the scores.  But this brings up a larger point--what
> does showing scores have to do with showing headers?

Nothing.  :) It's just another thing I threw in there, and didn't take
out when I posted it.

> > Something like it on a per newsgroup basis is possible, if you, say,
> > keep track of the state of "toggle_headers" [...]
> In general, macros like this aren't a really good idea for wide
> dissemination because when the wrapper functions aren't used consistently,
> they fail when they're used.

Well, yes.  That's why I only posted the singleton, which is pretty safe.
If I posted code that required definekeys to remap stuff, and required
all kinds of calls from different hooks, that would be bad.

So I just described it vaguely, so someone with programming clues would
understand it, and be able to implement it, but people without, wouldn't
try.

Later,

    thorfinn

-- 
<a href="http://www.tertius.net.au/~thorfinn">thorfinn@tertius.net.au</a>
Any sufficiently advanced technology is indistinguishable from a
rigged demo.


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