diff --git a/lib/command.coffee b/lib/command.coffee index 393b295..cc85247 100644 --- a/lib/command.coffee +++ b/lib/command.coffee @@ -15,7 +15,7 @@ class Command func = (new Ex)[command] if func? - func(args) + func(args...) else throw new CommandError("#{input.characters}") diff --git a/lib/ex.coffee b/lib/ex.coffee index c208c7b..01560ee 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -1,15 +1,46 @@ -class Ex - write: -> - if atom.workspace.getActiveTextEditor().getPath() isnt undefined - atom.workspace.getActiveEditor().save() - else - atom.workspace.getActivePane().saveActiveItemAs() +path = require 'path' + +class Ex + quit: -> + atom.workspace.getActivePane().destroyActiveItem() + + q: => + @quit() + + tabedit: (filePaths...) -> + pane = atom.workspace.getActivePane() + if filePaths? and filePaths.length > 0 + for file in filePaths + do -> atom.workspace.openURIInPane file, pane + else + atom.workspace.openURIInPane('', pane) + + tabe: (filePaths...) => + @tabedit(filePaths...) + + write: (filePath) => + projectPath = atom.project.getPath() + pane = atom.workspace.getActivePane() + editor = atom.workspace.getActiveEditor() + if atom.workspace.getActiveTextEditor().getPath() isnt undefined + if filePath? + editorPath = editor.getPath() + editor.saveAs(path.join(projectPath, filePath)) + editor.buffer.setPath(editorPath) + else + editor.save() + else + if filePath? + editor.saveAs(path.join(projectPath, filePath)) + else + pane.saveActiveItemAs() + + w: (filePath) => @write(filePath) - w: => @write() wa: -> atom.workspace.saveAll() - split: (filePaths) -> + split: (filePaths...) -> pane = atom.workspace.getActivePane() if filePaths? and filePaths.length > 0 newPane = pane.splitUp() @@ -19,9 +50,9 @@ class Ex else pane.splitUp(copyActiveItem: true) - sp: (filePaths) => @split(filePaths) + sp: (filePaths...) => @split(filePaths...) - vsplit: (filePaths) -> + vsplit: (filePaths...) -> pane = atom.workspace.getActivePane() if filePaths? and filePaths.length > 0 newPane = pane.splitLeft() @@ -31,6 +62,6 @@ class Ex else pane.splitLeft(copyActiveItem: true) - vsp: (filePaths) => @vsplit(filePaths) + vsp: (filePaths...) => @vsplit(filePaths...) module.exports = Ex