 window.onhelp = -> false # prevent IE from acting silly on F1
 
 prefs.prefixKey (x, old) -> # change listener
-  if x != old then m = CodeMirror.keyMap.dyalog; m["'#{x}'"] = m["'#{old}'"]; delete m["'#{old}'"]
+  if x != old then m = CodeMirror.keyMap.dyalogDefault; m["'#{x}'"] = m["'#{old}'"]; delete m["'#{old}'"]
   return
 
 squiggleDescriptions =

  TL Ctrl-Up
  WI Ctrl-Pause
'''.split('\n').forEach (l) ->
  [xx, keys...] = l.split /\s+/; createCommand xx; keys.forEach (key) -> CodeMirror.keyMap.dyalog[key] = xx; return

# CodeMirror provides a goLineStartSmart but not a goLineEndSmart command.
CodeMirror.keyMap.dyalog.End = 'goLineEndSmart'
CodeMirror.commands.goLineEndSmart = (cm) ->
  cm.extendSelectionsBy(
    ->
      c = cm.getCursor(); l = c.line; s = cm.getLine l; n = s.length; m = s.replace(/\ +$/, '').length

  [70] -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  [80] -- -- -- -- -- -- TO MO -- -- -- -- -- S1 S2 OS
'''.replace(/\[.*?\]/g, '').replace(/^\s*|\s*$/g, '').split(/\s+/).forEach (xx, i) ->
  if xx != '--' then createCommand xx; CodeMirror.keyMap.dyalogDefault["'#{chr 0xf800 + i}'"] = xx
  return

'''
