[Vimperator] patch autocommands

calmar mac at calmar.ws
Tue Dec 18 07:31:54 PST 2007


On Tue, Dec 18, 2007 at 04:18:40PM +0100, Martin Stubenschrott wrote:
> On Tue, Dec 18, 2007 at 08:04:38AM +0100, calmar wrote:
> > initial patch for autocommands.
> 
> Hurray :)
> 
> 0.6 is becoming soooo feature packed now :), maybe we should stop after
> :autocommands and fix remaining bugs before adding new stuff so that 0.6
> can finally be released?

:command is missing. I think.

> 
> > +    function deleteAutoCommands(auEvent, regs) // args are filters
> > +    function printAutoCommands(auEvent, regs) // args are filters
> 
> Both look fine, but I would make an vimperator.AutoCommands class (but
> still in events.js as they are so closely related).
> 
> this would/could look like:
> 
> vimperator.AutoCommands = function()
> {
> 	// private things like var autocommands = {};
> 
> 	// public interface like:
> 	add: function(...);
> 	remove: ...;
> 	list: ...;
> 	trigger: ...
> 
> };
> 
> and initialized in vimperator.js as vimperator.autocommands;

ok.

> 
> in onPageLoad, you just do:
> vimperator.autocommands.trigger("PageLoad", doc);
> 
> the trigger function itself then checks if the url/title of the doc is ok, and
> calls the autocommand function.
> 
> 
> > +    commandManager.add(new vimperator.Command(["au[tocmd]"],
> > +        // TODO: completer function for events?
> 
> Would be awesome :) But quite hard, could be left for later.

or manaully add the events - maybe that would make it easier?. Vim
completes on events too. very hard to remember those.

> >  
> > +            line += "\n\" Auto-Commands\n";
> > +            for (var item in vimperator.events.autoCommands)
> > +                    for (var i = 0; i < vimperator.events.autoCommands[item].length; i++)
> > +                        line += "autocmd " + item + " " + vimperator.events.autoCommands[item][i][0]  + 
> > +                                             " " + vimperator.events.autoCommands[item][i][1] + "\n";
> 
> Hmm, why is that code here? thought that printAutoCommands handles that?

only print html-outs...

maybe you want an iterator or something, I though...

> 
> > +            if (vimperator.events.autoCommands["onPageLoad"]) // XXX: or this.autoCommands[...] ?
> 
> Definitly this.autoCommands

ok

> 
> But patch looks very good for an initial patch, adding more autocommands
> is the easier part than having the framework! Looking forward for the
> next iteration of the patch :)
> 

yeah, 

+       alert("events.js:237 " + vimperator.events.autoCommands["onPageLoad"][i][1]); //TODO: make it real

how to actually execute the command then? more work to do for
this, is there there already a way?

cheers
marco

-- 
   (o_  It rocks: LINUX + Command-Line-Interface
   //\
   V_/_                     http://www.calmar.ws


More information about the Vimperator mailing list