 
 
   goalTypeCommand: (index) ->
-
-    cursor = @agda.editor.getCursorBufferPosition()
-    goals = @holes.filter (hole) =>
-      hole.getRange().containsPoint cursor
-
-    # in certain hole
-    if goals.length is 1
-
-      goal = goals[0]
+    @currentHole (goal) =>
       goalIndex = goal.index
       command = "IOTCM \"/Users/banacorn/github/agda-mode/test/Banana.agda\" NonInteractive Indirect ( Cmd_goal_type Simplified #{goalIndex} noRange \"\" )\n"
       @agda.executable.process.stdin.write command
 
-    else
-      @agda.panelView.setStatus 'Info'
-      @agda.panelView.setContent ['For this command, please place the cursor in a goal']
-
-
   contextCommand: (index) ->
 
-    cursor = @agda.editor.getCursorBufferPosition()
-    goals = @holes.filter (hole) =>
-      hole.getRange().containsPoint cursor
-
-    # in certain hole
-    if goals.length is 1
-
-      goal = goals[0]
+    @currentHole (goal) =>
       goalIndex = goal.index
       command = "IOTCM \"/Users/banacorn/github/agda-mode/test/Banana.agda\" NonInteractive Indirect ( Cmd_context Simplified #{goalIndex} noRange \"\" )\n"
       @agda.executable.process.stdin.write command
 
-    else
-      @agda.panelView.setStatus 'Info'
-      @agda.panelView.setContent ['For this command, please place the cursor in a goal']
-
 
 
 module.exports = HoleManager

          #{end.column + 1})]) \"#{content}\" )\n"
      @agda.executable.process.stdin.write command

    else
      @agda.panelView.setStatus 'Info'
      @agda.panelView.setContent ['For this command, please place the cursor in a goal']

  giveHandler: (index) ->
    hole = @findHole index

  # agda-mode: give
  #
  giveCommand: ->

    @currentHole (goal) =>
      goalIndex = goal.index
      start = goal.getStart()
      startIndex = goal.toIndex start
