From e52a4c1588590a59029b9827bb1c9beda7a7af82 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:20:51 -0800 Subject: [PATCH 1/7] Rename user.coffee to init.coffee --- dot-atom/{user.coffee => init.coffee} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dot-atom/{user.coffee => init.coffee} (100%) diff --git a/dot-atom/user.coffee b/dot-atom/init.coffee similarity index 100% rename from dot-atom/user.coffee rename to dot-atom/init.coffee From e6e43f688403ebb098f00e51a81ca108b4d34a67 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:30:59 -0800 Subject: [PATCH 2/7] Add Open Your Init Script command --- menus/darwin.cson | 1 + src/atom.coffee | 6 +++++- src/browser/atom-application.coffee | 1 + src/workspace-view.coffee | 1 + src/workspace.coffee | 2 ++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/menus/darwin.cson b/menus/darwin.cson index 346523299..4ac239e8a 100644 --- a/menus/darwin.cson +++ b/menus/darwin.cson @@ -9,6 +9,7 @@ { type: 'separator' } { label: 'Preferences...', command: 'application:show-settings' } { label: 'Open Your Config', command: 'application:open-your-config' } + { label: 'Open Your Init Script', command: 'application:open-your-init-script' } { label: 'Open Your Keymap', command: 'application:open-your-keymap' } { label: 'Open Your Snippets', command: 'application:open-your-snippets' } { label: 'Open Your Stylesheet', command: 'application:open-your-stylesheet' } diff --git a/src/atom.coffee b/src/atom.coffee index bc22aa661..9cfffb74a 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -494,8 +494,12 @@ class Atom extends Model shell.beep() if @config.get('core.audioBeep') @workspaceView.trigger 'beep' + getUserInitScriptPath: -> + initScriptPath = fs.resolve(@getConfigDirPath(), 'init', ['js', 'coffee']) + initScriptPath ? path.join(@getConfigDirPath(), 'init.coffee') + requireUserInitScript: -> - if userInitScriptPath = fs.resolve(@getConfigDirPath(), 'user', ['js', 'coffee']) + if userInitScriptPath = @getUserInitScriptPath() try require userInitScriptPath catch error diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 7966b7cc3..149c6f61c 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -189,6 +189,7 @@ class AtomApplication @openPathOnEvent('application:show-settings', 'atom://config') @openPathOnEvent('application:open-your-config', 'atom://.atom/config') + @openPathOnEvent('application:open-your-init-script', 'atom://.atom/init-script') @openPathOnEvent('application:open-your-keymap', 'atom://.atom/keymap') @openPathOnEvent('application:open-your-snippets', 'atom://.atom/snippets') @openPathOnEvent('application:open-your-stylesheet', 'atom://.atom/stylesheet') diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 7e94f7721..6b62a7829 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -107,6 +107,7 @@ class WorkspaceView extends View @command 'application:zoom', -> ipc.sendChannel('command', 'application:zoom') @command 'application:bring-all-windows-to-front', -> ipc.sendChannel('command', 'application:bring-all-windows-to-front') @command 'application:open-your-config', -> ipc.sendChannel('command', 'application:open-your-config') + @command 'application:open-your-init-script', -> ipc.sendChannel('command', 'application:open-your-init-script') @command 'application:open-your-keymap', -> ipc.sendChannel('command', 'application:open-your-keymap') @command 'application:open-your-snippets', -> ipc.sendChannel('command', 'application:open-your-snippets') @command 'application:open-your-stylesheet', -> ipc.sendChannel('command', 'application:open-your-stylesheet') diff --git a/src/workspace.coffee b/src/workspace.coffee index eec5d88ed..ec5b8fa87 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -35,6 +35,8 @@ class Workspace extends Model @open(atom.keymap.getUserKeymapPath()) when 'atom://.atom/config' @open(atom.config.getUserConfigPath()) + when 'atom://.atom/init-script' + @open(atom.getUserInitScriptPath()) # Called by the Serializable mixin during deserialization deserializeParams: (params) -> From 4219d06bd90da4581b99b96b86fe4859174e41b2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:32:38 -0800 Subject: [PATCH 3/7] :memo: Doc ~/.atom/init.coffee --- dot-atom/init.coffee | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dot-atom/init.coffee b/dot-atom/init.coffee index 60880641d..81700b553 100644 --- a/dot-atom/init.coffee +++ b/dot-atom/init.coffee @@ -1 +1,13 @@ -# For more on how to configure atom open `~/github/atom/docs/configuring-and-extending.md` +# Your init script +# +# Atom will evaluate this file each time a new window is opened. It is run +# after packages are loaded/activated and after the previous editor state +# has been restored. +# +# An example hack to make opened Markdown files have larger text: +# +# path = require 'path' +# +# atom.workspaceView.eachEditorView (editorView) -> +# if path.extname(editorView.getEditor().getPath()) is '.md' +# editorView.setFontSize(20) From 23af7b4072a06cfa42b2b6b713fcfdc6423e1b76 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:34:34 -0800 Subject: [PATCH 4/7] Make font-size larger than the default --- dot-atom/init.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dot-atom/init.coffee b/dot-atom/init.coffee index 81700b553..083470d80 100644 --- a/dot-atom/init.coffee +++ b/dot-atom/init.coffee @@ -10,4 +10,4 @@ # # atom.workspaceView.eachEditorView (editorView) -> # if path.extname(editorView.getEditor().getPath()) is '.md' -# editorView.setFontSize(20) +# editorView.setFontSize(24) From fbdf16a8faa0f644cc3c8589d13e2c8bcbb20b15 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:38:20 -0800 Subject: [PATCH 5/7] Use soft wrap instead of font size in example hack --- dot-atom/init.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dot-atom/init.coffee b/dot-atom/init.coffee index 083470d80..4d10e775b 100644 --- a/dot-atom/init.coffee +++ b/dot-atom/init.coffee @@ -4,10 +4,11 @@ # after packages are loaded/activated and after the previous editor state # has been restored. # -# An example hack to make opened Markdown files have larger text: +# An example hack to make opened Markdown files always be soft wrapped: # # path = require 'path' # # atom.workspaceView.eachEditorView (editorView) -> -# if path.extname(editorView.getEditor().getPath()) is '.md' -# editorView.setFontSize(24) +# editor = editorView.getEditor() +# if path.extname(editor.getPath()) is '.md' +# editor.setSoftWrap(true) From 0bbc63160764b00c1d7663ff8bc1f037fb4c04a7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:52:55 -0800 Subject: [PATCH 6/7] :memo: Update docs for user.coffee rename --- docs/customizing-atom.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/customizing-atom.md b/docs/customizing-atom.md index e6ad89305..49d196e50 100644 --- a/docs/customizing-atom.md +++ b/docs/customizing-atom.md @@ -112,14 +112,16 @@ namespaces: `core` and `editor`. ### Quick Personal Hacks -### user.coffee +### init.coffee -When Atom finishes loading, it will evaluate _user.coffee_ in your _~/.atom_ +When Atom finishes loading, it will evaluate _init.coffee_ in your _~/.atom_ directory, giving you a chance to run arbitrary personal CoffeeScript code to make customizations. You have full access to Atom's API from code in this file. If customizations become extensive, consider [creating a package][create-a-package]. +This file can also be named _init.js_ and contain JavaScript code. + ### styles.css If you want to apply quick-and-dirty personal styling changes without creating From 422c0e36cbba99a9e04829bc00f41a96c3c6abc0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Feb 2014 09:54:58 -0800 Subject: [PATCH 7/7] Assert init.coffee and styles.css are copied --- spec/config-spec.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 77455c5c2..9f8afa408 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -220,6 +220,8 @@ describe "Config", -> expect(fs.existsSync(path.join(atom.config.configDirPath, 'packages'))).toBeTruthy() expect(fs.isFileSync(path.join(atom.config.configDirPath, 'snippets.cson'))).toBeTruthy() expect(fs.isFileSync(path.join(atom.config.configDirPath, 'config.cson'))).toBeTruthy() + expect(fs.isFileSync(path.join(atom.config.configDirPath, 'init.coffee'))).toBeTruthy() + expect(fs.isFileSync(path.join(atom.config.configDirPath, 'styles.css'))).toBeTruthy() describe ".loadUserConfig()", -> beforeEach ->