Hi,

[ I've not forgotten about this, in case anyone was wondering. ]

On Tue, Nov 06, 2012 at 12:48:54PM +0000, Nicholas Marriott wrote:
> On Sun, Nov 04, 2012 at 01:22:50AM +0000, Thomas Adam wrote:
> >   To "fix" this, we would need to change where and how hooks are run from,
> >   much like the notify_() hooks do now, but there would then be no
> >   before/after mechanism.
> 
> Hmm. Perhaps having per-session hooks doesn't make much sense.

You say that, but even just passing the information through formats requires
having the correct context, because without it, any interpolation of
formatting would still be from the calling context of where the command came
from, not where it's ultimately ending up -- and for global or session
hooks, this is still a problem.

So I started thinking about it.  One way we might solve this is to augment
the cmd_entry struct with an additional function pointer field such as
"context" which shifts out the command-line parsing checks found in the
_exec() functions and parses them, filling out the client, session, winlink,
etc., which the command *would* run it, were it going to.

This information could then be used by the before/after hooks mechanisms to
then detect the session the hook is running for, and when running certain
commands, run within that.

I have a proof-of-concept for this and it seems to work quite well.  But
there's two things here:

1.  We already have a mechanism for this in many respects, and I wonder
whether augmenting struct cmd_ctx would be sufficient for this?

2.  The cmd->entry->check() function seems like the remnants from the
pre-args parsing of tmux, and seemingly only the new-session command
implements this.  To me this function is redundant, and has been shifted in
to the ->exec() functions, so we could just reuse this field and fix
cmd-new-session in the process.

If such a context were set up in this way, then the argument checking in
each of the ->exec() functions can more-or-less disappear and just use the
values in the context struct directly.

Once this is all sorted, then creating a format_tree becomes secondary, and
then everything will Just Work (tm).

Kindly,

-- Thomas Adam

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to