Created
February 13, 2018 19:10
-
-
Save smashwilson/1e2f08c14aa4b5e9a94207110d874ed4 to your computer and use it in GitHub Desktop.
Atom init.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const util = require('util') | |
const {watchPath} = require('atom') | |
const commands = {} | |
function focusTracer (event) { | |
console.log('window.focus =', event.target) | |
} | |
commands['me:trace-focus'] = () => window.addEventListener('focusin', focusTracer) | |
commands['me:untrace-focus'] = () => window.removeEventListener('focusin', focusTracer) | |
let fsSub = null | |
function reportFilesystemEvents (events) { | |
console.log(`filesystem event batch:\n${util.inspect(events)}`) | |
} | |
commands['me:trace-fs'] = () => { | |
if (fsSub) fsSub.dispose() | |
console.log('tracing filesystem changes') | |
fsSub = atom.project.onDidChangeFiles(reportFilesystemEvents) | |
} | |
commands['me:untrace-fs'] = () => { | |
if (fsSub) fsSub.dispose() | |
console.log('untracing filesystem changes') | |
} | |
commands['me:watcher-log-enable'] = () => { | |
watchPath.configure({ | |
workerLog: '/Users/smashwilson/logs/worker.log', | |
mainLog: '/Users/smashwilson/logs/main.log', | |
pollingLog: '/Users/smashwilson/logs/polling.log' | |
}) | |
} | |
atom.commands.add('atom-workspace', commands) | |
atom.commands.add('atom-text-editor', 'me:fold-all-but-current-row', event => { | |
const editor = event.target.closest('atom-text-editor').getModel() | |
editor.foldAll() | |
editor.unfoldCurrentRow() | |
editor.scrollToCursorPosition() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment