     false
 
   set_mark: ->
-    editor = atom.workspace.getActiveTextEditor()
+    editor = @getEditor()
+    return unless editor
     editorView = atom.views.getView editor
     $(editorView).toggleClass "transient-marked"
     cursor.clearSelection() for cursor in editor.getCursors()
 
   kill_region_or_backward_word: ->
-    editor = atom.workspace.getActiveTextEditor()
+    editor = @getEditor()
+    return unless editor
     if editor.getLastSelection().isEmpty()
       @kill_backward_word()
     else

    @killring.seal()

  kill_region: ->
    editor = atom.workspace.getActiveTextEditor()
    @_push_regeon_to_killring editor
    editor.transact ->
      s.delete() for s in editor.getSelections() when not s.isEmpty()

  copy_region: ->
    editor = atom.workspace.getActiveTextEditor()
    @_push_regeon_to_killring editor
    cursor.clearSelection() for cursor in editor.getCursors()

  kill_backward_word: ->
    @is_user_command = false
    editor = atom.workspace.getActiveTextEditor()
    editor.transact =>
      editor.selectToBeginningOfWord()
      texts = (s.getText() for s in editor.getSelections())

    editor.scrollToCursorPosition()
    @is_user_command = true

  getEditor: ->
    pane = atom.workspace.getActivePane()
    editor = atom.workspace.getActiveTextEditor()
    return editor if editor == pane.activeItem

  search_next: (word, silent)->
    @_update_statusbar word,true unless silent
    return unless word
    editor = @getEditor()
    return if not editor or editor.mini
    buffer_end = editor.getBuffer().getEndPosition()
    re = @_create_re word
