I personally think it would be cleaner to extract the bootstrap-modal functionality into the discard-function. For example
like this:

```
diff --git a/app/assets/javascripts/codemirror-custom.js.coffee b/app/assets/javascripts/codemirror-custom.js.coffee
index abe791e..7a30142 100644
--- a/app/assets/javascripts/codemirror-custom.js.coffee
+++ b/app/assets/javascripts/codemirror-custom.js.coffee
@@ -44,10 +44,7 @@ $ ->
       false
 
     editorDiscard = (e) ->
-      if editor.doc.isClean()
-        discard()
-      else
-        discard_modal.modal('show')
+      discard(editor.doc.isClean())
       false
 
     requireCommitMessage = (e) ->
@@ -58,18 +55,21 @@ $ ->
       else
         true
 
-    discard = ->
-      message_textarea.value = ""
-      editor.setOption "readOnly", true
-      editor.setValue original_editor_content
-      message_group.removeClass hasErrorClass
-      alert_error.hide()
-      $(".show-when-editing").hide()
-      $(".hide-when-editing").show()
-      editorPreventFocus()
-      editor.off "focus", editorSetFocus
-      editor.off "blur", editorSetBlur
-      discard_modal.modal('hide')
+    discard = (use_modal) ->
+      if use_modal == false
+        discard_modal.modal('show')
+      else
+        message_textarea.value = ""
+        editor.setOption "readOnly", true
+        editor.setValue original_editor_content
+        message_group.removeClass hasErrorClass
+        alert_error.hide()
+        $(".show-when-editing").hide()
+        $(".hide-when-editing").show()
+        editorPreventFocus()
+        editor.off "focus", editorSetFocus
+        editor.off "blur", editorSetBlur
+        discard_modal.modal('hide')
       return
 
     enableEditing = (e) ->

```