Article View: news.software.readers
Article #59878Re: [slrn] How about a hook for article view hiding/unhiding?
From: Dawn Owens-Nicholson
Date: Fri, 31 Mar 2000 00:00
Date: Fri, 31 Mar 2000 00:00
51 lines
4085 bytes
4085 bytes
Drazen Kacar wrote:
> Yet another way is to throw away all hooks and register handler functions
> for state changes, where the set of possible states consists of all
> variables present in slrnrc.
This would break a lot of code, require a significant amount of work to be
done (like you said) and remove some current hook functionality (because not
all slrn state is in slrnrc variables). Also, functionally, hooks and
handler functions aren't much different. If your hooks are, essentially, a
list of functions from a variety of macro packages, you could think of it as
a list of the functions "registered" to handle some state. Sure, the
registration process is different but when it comes to execution they're the
same. Furthermore, you get to explicitly specify the order of their
execution (in case ordering is important) in an intuitive way (intuitive to
programmers, at least, since ordering statements is already something
programmers grasp). Hooks also let you do clever conditional execution of
these functions; something simple linear lists can't handle.
If you like, you could make the current hooks look and feel like handlers
where you have to register functions--make a register() and an execute()
then rewrite your hooks to look something like this:
public define hook_name_here ()
{
Register_Handler->execute (string (_function_name ()));
}
Replace "hook_name_here" with the hook's name and off you go. execute()
will execute each function in a linked list of references to functions. The
linked list can be stored inside a hash where the hook name is the key
(hence the string()). register() would add the function to the linked list
(and probably search the list first to make sure any function is only listed
once). Voila--a registration handler. Use hashes everywhere if you're
going to do the searching bit.
I've wanted some function registration process for macro *installation*.
I'd like to tell people all they really need to do to install some macro
package is execute it, but there's one other big piece missing that I'd want
to do at the same time--keymap discovery. I don't often give definekey()
statements because there's no way to tell if a function is bound to any
key(s). I wouldn't want to accidentally remove the only way to get to some
needed function by giving someone a definekey() line that remapped a
previously mapped key.
Anyhow, if you want registration for slrnrc variables changing state, you
could make wrappers for set_integer_variable() and set_string_variable().
Problem is, most people won't use it so most slrnrc variable changes would
go unnoticed by your handlers. But if you only need it for *your* code,
this would be one clean way to go.
Technical Details
Message-ID:
<slrn8e8r34.lgc.bluemoon@ux6.cso.uiuc.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn8dru4f.1fu.ajlewis2@sidekick.com> <slrn8dsj5c.d5.efflandt@efflandt.xnet.com> <slrn8dsllf.nk.ajlewis2@sidekick.com> <slrn8dt1tg.g53.dave@svarozic.srce.hr> <86d7ohw8in.fsf@ragndahl.cx> <slrn8e6k9p.lrb.dave@svarozic.srce.hr> <slrn8e6n1m.lt6.dave@svarozic.srce.hr> <slrn8e7d60.2s1.bluemoon@ux6.cso.uiuc.edu> <slrn8e7ias.mkf.dave@svarozic.srce.hr> <slrn8e88it.lgc.bluemoon@ux6.cso.uiuc.edu> <slrn8e8cuq.oj3.dave@svarozic.srce.hr> <slrn8e8ims.lgc.bluemoon@ux6.cso.uiuc.edu> <slrn8e8l3d.ot3.dave@svarozic.srce.hr>Show Full Headers
Complete Article Headers
Message-ID: <slrn8e8r34.lgc.bluemoon@ux6.cso.uiuc.edu> Subject: Re: [slrn] How about a hook for article view hiding/unhiding? Date: Fri, 31 Mar 2000 00:00:00 +0000 From: bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) References: <slrn8dru4f.1fu.ajlewis2@sidekick.com> <slrn8dsj5c.d5.efflandt@efflandt.xnet.com> <slrn8dsllf.nk.ajlewis2@sidekick.com> <slrn8dt1tg.g53.dave@svarozic.srce.hr> <86d7ohw8in.fsf@ragndahl.cx> <slrn8e6k9p.lrb.dave@svarozic.srce.hr> <slrn8e6n1m.lt6.dave@svarozic.srce.hr> <slrn8e7d60.2s1.bluemoon@ux6.cso.uiuc.edu> <slrn8e7ias.mkf.dave@svarozic.srce.hr> <slrn8e88it.lgc.bluemoon@ux6.cso.uiuc.edu> <slrn8e8cuq.oj3.dave@svarozic.srce.hr> <slrn8e8ims.lgc.bluemoon@ux6.cso.uiuc.edu> <slrn8e8l3d.ot3.dave@svarozic.srce.hr> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 604716373 X-Complaints-To: abuse@uiuc.edu X-Trace: vixen.cso.uiuc.edu 954494037 128.174.5.9 (Fri, 31 Mar 2000 03:13:57 CST) Organization: University of Illinois at Urbana-Champaign User-Agent: slrn/0.9.6.2 (HP-UX) NNTP-Posting-Date: Fri, 31 Mar 2000 03:13:57 CST Newsgroups: news.software.readers