From 5fe2f87c24e1c8704a0c63c2877c5b4d8ed204fb Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 27 May 2015 22:15:05 -0400 Subject: [PATCH] add basic "set" command, with "ft" and "tw" options --- lib/ex.coffee | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/ex.coffee b/lib/ex.coffee index 17c3aa9..989d727 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -165,6 +165,28 @@ class Ex else pane.splitUp(copyActiveItem: true) + set: (args...) -> + editor = -> + atom.workspace.getActiveTextEditor() + + arg = args[1] + regex = /\s*(\w+)(?:\s*=\s*([\d\w]+)\s*|(!))/ + matches = arg.match regex + return unless matches? + + [whole, option, value, bang] = matches + + switch option + when 'tw' + editor().setTabLength(parseInt(value)) + when 'ft' + regex = new RegExp "(source|text)\.#{value}$" + lowerCaseName = value.toLowerCase() + for name, grammar of atom.grammars.grammarsByScopeName + grammarName = grammar.name.toLowerCase() + if name.match(regex) or lowerCaseName is grammarName + editor().setGrammar(grammar) + sp: (args...) => @split(args...) substitute: (range, args) ->