From 918ee8e15e45694542f7584ca199454409474112 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Mon, 29 Aug 2011 22:57:30 -0700 Subject: [PATCH] Removing any parens we're not forced to use. Lean into it. --- plugins/project/project.coffee | 14 +++++++------- plugins/tabs/index.coffee | 2 +- plugins/tabs/tabs.coffee | 2 +- src/bootstrap.coffee | 2 +- src/editor.coffee | 12 ++++++------ src/jscocoa.coffee | 5 ++--- src/osx.coffee | 26 ++++++++++++++------------ 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/plugins/project/project.coffee b/plugins/project/project.coffee index 77b0ac00f..0bbbd7b5b 100644 --- a/plugins/project/project.coffee +++ b/plugins/project/project.coffee @@ -7,15 +7,15 @@ Editor = require 'editor' {bindKey} = require 'editor' exports.init = -> - @html = File.read(Chrome.appRoot() + "/plugins/project/project.html") + @html = File.read Chrome.appRoot() + "/plugins/project/project.html" bindKey 'toggleProjectDrawer', 'Command-Ctrl-N', (env) => @toggle() $('#project .file').live 'click', (event) => el = $(event.currentTarget) - path = decodeURIComponent el.attr('path') - Editor.open(path) + path = decodeURIComponent el.attr 'path' + Editor.open path exports.toggle = -> if @showing @@ -28,12 +28,12 @@ exports.toggle = -> exports.reload = -> dir = OSX.NSFileManager.defaultManager.currentDirectoryPath - $('#project .cwd').text(dir) + $('#project .cwd').text dir - files = Dir.list(dir) + files = Dir.list dir listItems = _.map files, (path) -> - filename = path.replace(dir, "").substring(1) + filename = path.replace(dir, "").substring 1 type = if Dir.isDir(path) then 'dir' else 'file' "
  • #{filename}
  • " - $('#project .files').append(listItems.join('\n')) + $('#project .files').append listItems.join '\n' diff --git a/plugins/tabs/index.coffee b/plugins/tabs/index.coffee index c4b2470b2..01bbdbad0 100644 --- a/plugins/tabs/index.coffee +++ b/plugins/tabs/index.coffee @@ -1 +1 @@ -exports.Tabs = Tabs = require('tabs/tabs') +exports.Tabs = Tabs = require 'tabs/tabs' diff --git a/plugins/tabs/tabs.coffee b/plugins/tabs/tabs.coffee index e976096fa..1e903b09a 100644 --- a/plugins/tabs/tabs.coffee +++ b/plugins/tabs/tabs.coffee @@ -26,7 +26,7 @@ bindKey 'toggleTabs', 'Command-Ctrl-T', (env) -> showTabs = -> Chrome.addPane 'top', require('tabs/tabs.html') $('#tabs').parents('.pane').css height: 'inherit' - css = $('').html require('tabs/tabs.css') + css = $('').html require 'tabs/tabs.css' $('head').append css hideTabs = -> diff --git a/src/bootstrap.coffee b/src/bootstrap.coffee index ecc37ec8e..86330cc11 100644 --- a/src/bootstrap.coffee +++ b/src/bootstrap.coffee @@ -3,7 +3,7 @@ console.originalLog = console.log console.log = (thing) -> OSX.NSLog thing.toString() if thing? - console.originalLog(thing) + console.originalLog thing # load require() function diff --git a/src/editor.coffee b/src/editor.coffee index e19f2b00a..485fdd42a 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -35,9 +35,9 @@ save = -> exports.open = open = (path) -> filename = path - if Dir.isDir(filename) - Process.cwd(filename) - Chrome.title _.last filename.split('/') + if Dir.isDir filename + Process.cwd filename + Chrome.title _.last filename.split '/' editor.getSession().setValue "" setMode() Chrome.setDirty false @@ -45,7 +45,7 @@ exports.open = open = (path) -> if /png|jpe?g|gif/i.test filename Chrome.openURL filename else - Chrome.title _.last filename.split('/') + Chrome.title _.last filename.split '/' editor.getSession().setValue File.read filename setMode() Chrome.setDirty false @@ -59,7 +59,7 @@ setMode = -> saveAs = -> if file = Chrome.savePanel() filename = file - Chrome.title _.last filename.split('/') + Chrome.title _.last filename.split '/' save() exports.bindKey = bindKey = (name, shortcut, callback) -> canon.addCommand @@ -73,7 +73,7 @@ exports.bindKey = bindKey = (name, shortcut, callback) -> bindKey 'open', 'Command-O', (env, args, request) -> if file = Chrome.openPanel() - open(file) + open file bindKey 'openURL', 'Command-Shift-O', (env, args, request) -> if url = prompt "Enter URL:" diff --git a/src/jscocoa.coffee b/src/jscocoa.coffee index 3704b65e7..01dca2228 100644 --- a/src/jscocoa.coffee +++ b/src/jscocoa.coffee @@ -3,12 +3,11 @@ exports.outArgument = (args...) -> # Derive to store some javascript data in the internal hash if not @outArgument2? - OSX.JSCocoa.createClass_parentClass_('JSCocoaOutArgument2', 'JSCocoaOutArgument') + OSX.JSCocoa.createClass_parentClass_ 'JSCocoaOutArgument2', 'JSCocoaOutArgument' o = OSX.JSCocoaOutArgument2.instance o.isOutArgument = true if args.length == 2 - o.mateWithMemoryBuffer_atIndex_(args[0], args[1]) - + o.mateWithMemoryBuffer_atIndex_ args[0], args[1] o diff --git a/src/osx.coffee b/src/osx.coffee index 06b178dfd..3bb25240f 100644 --- a/src/osx.coffee +++ b/src/osx.coffee @@ -10,19 +10,19 @@ Chrome = verticalDiv = $('#app-vertical') horizontalDiv = $('#app-horizontal') - el = document.createElement("div") - el.setAttribute('class', "pane " + position) + el = document.createElement "div" + el.setAttribute 'class', "pane " + position el.innerHTML = html switch position when 'top', 'main' - verticalDiv.prepend(el) + verticalDiv.prepend el when 'left' - horizontalDiv.prepend(el) + horizontalDiv.prepend el when 'bottom' - verticalDiv.append(el) + verticalDiv.append el when 'right' - horizontalDiv.append(el) + horizontalDiv.append el else throw "I DON'T KNOW HOW TO DEAL WITH #{position}" @@ -51,7 +51,7 @@ Chrome = # Returns null or a file path. openPanel: -> panel = OSX.NSOpenPanel.openPanel - panel.setCanChooseDirectories(true) + panel.setCanChooseDirectories true if panel.runModal isnt OSX.NSFileHandlingPanelOKButton return null panel.filenames.lastObject @@ -94,7 +94,8 @@ File = path isFile: (path) -> isDir = new jscocoa.outArgument - exists = OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory(path, isDir) + exists = OSX.NSFileManager.defaultManager. + fileExistsAtPath_isDirectory path, isDir exists and not isDir.valueOf() Dir = @@ -108,18 +109,19 @@ Dir = _.map paths, (entry) -> "#{path}/#{entry}" isDir: (path) -> isDir = new jscocoa.outArgument - exists = OSX.NSFileManager.defaultManager.fileExistsAtPath_isDirectory(path, isDir) + exists = OSX.NSFileManager.defaultManager. + fileExistsAtPath_isDirectory path, isDir exists and isDir.valueOf() Process = cwd: (path) -> if path? - OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath(path) + OSX.NSFileManager.defaultManager.changeCurrentDirectoryPath path else - OSX.NSFileManager.defaultManager.currentDirectoryPath() + OSX.NSFileManager.defaultManager.currentDirectoryPath env: -> - OSX.NSProcess.processInfo.environment() + OSX.NSProcess.processInfo.environment exports.Chrome = Chrome exports.File = File