From 86101ef8aca81f38d588151bf90481edd4df0ef3 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 27 May 2015 22:06:23 -0400 Subject: [PATCH 1/2] fix getFullPath(): support ~ as reference to home dir --- lib/ex.coffee | 2 ++ package.json | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index c159534..17c3aa9 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -1,4 +1,5 @@ path = require 'path' +fs = require 'fs-plus' CommandError = require './command-error' trySave = (func) -> @@ -31,6 +32,7 @@ trySave = (func) -> deferred.promise getFullPath = (filePath) -> + filePath = fs.normalize(filePath) return filePath if path.isAbsolute(filePath) return path.join(atom.project.getPath(), filePath) diff --git a/package.json b/package.json index 3364f3e..310ce60 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,11 @@ "atom": ">=0.200.0 <2.0.0" }, "dependencies": { - "underscore-plus": "1.x", + "atom-space-pen-views": "^2.0.4", "event-kit": "^0.7.2", + "fs-plus": "^2.8.1", "space-pen": "^5.1.1", - "atom-space-pen-views": "^2.0.4" + "underscore-plus": "1.x" }, "consumedServices": { "vim-mode": { From 5fe2f87c24e1c8704a0c63c2877c5b4d8ed204fb Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Wed, 27 May 2015 22:15:05 -0400 Subject: [PATCH 2/2] 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) ->