Skip to content

Instantly share code, notes, and snippets.

@ylixir
Last active November 23, 2015 22:49
Show Gist options
  • Save ylixir/1aa395d09d9cde0aff98 to your computer and use it in GitHub Desktop.
Save ylixir/1aa395d09d9cde0aff98 to your computer and use it in GitHub Desktop.
Focus follows mouse for Atom editor
# Focus Follows Mouse
# -----------------------------------------
# put this in init.coffee
focusPane = (item) ->
item.activate()
try
item.activeItem.focusTerm()
catch err
console.log(err)
followMouse = (item) ->
elem = atom.views.getView(item)
elem.addEventListener('mouseenter', (-> focusPane item))
# Create for additional panes as they are added
handlePaneFocus = (e) ->
followMouse(e.pane)
atom.workspace.onDidAddPane(handlePaneFocus)
# set it up for initial panes
for p in atom.workspace.getPanes()
followMouse p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment