ActiveState Community

Macro: run the current macro

Posted by jeffg on 2008-05-13 15:08
OS: All / Any

Here is a quick little macro I wrote because I was sick of clicking around the toolbox just to run the current macro I was working on:

try {
  var view = ko.views.manager.currentView;
  var scimoz = view.scimoz;
  var uri = view.document.displayPath;
  var self = ko.macros.current;
 
  if(/^macro:\/\//.test(uri) && uri !== self.url) { // we don't want to run ourself
    var partName = (view.document.baseName.split('.').shift());
    var project = ko.projects.manager.currentProject;
    var part = ko.projects.findPart('macro', partName, '*', project);
    part.invoke();
  } else {
    ko.statusBar.AddMessage('Not a macro buffer, nothing to do...', 'editor', 3000, true);
  }
} catch(e) {
  ko.dialogs.internalError(e, 'Error: '+e);
}
try {
  var view = ko.views.manager.currentView;
  var scimoz = view.scimoz;
  var uri = view.document.displayPath;
  var self = ko.macros.current;
  
  if(/^macro:\/\//.test(uri) && uri !== self.url) { // we don't want to run ourself
    var partName = (view.document.baseName.split('.').shift());
    var project = ko.projects.manager.currentProject; 
    var part = ko.projects.findPart('macro', partName, '*', project);
    part.invoke();
  } else {
    ko.statusBar.AddMessage('Not a macro buffer, nothing to do...', 'editor', 3000, true);
  }
} catch(e) {
  ko.dialogs.internalError(e, 'Error: '+e);
}