Skip to content

Instantly share code, notes, and snippets.

@meggart
Created July 16, 2015 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save meggart/c1e45bae0d60f3d8822d to your computer and use it in GitHub Desktop.
Save meggart/c1e45bae0d60f3d8822d to your computer and use it in GitHub Desktop.
Macroexpand shortcut in the REPL
if VERSION > v"0.4.0-dev+4268"
const marcoexpandkeys = Dict{Any,Any}("^I" => function (s,o...)
if !isempty(s)
line = parse(Base.LineEdit.input_string(s))
s.kill_buffer=Base.LineEdit.input_string(s)
Base.LineEdit.edit_clear(s)
Base.LineEdit.edit_insert(s,string(macroexpand(line)))
end
end,
"^O" => function(s,o...)
Base.LineEdit.edit_clear(s)
Base.LineEdit.edit_insert(Base.LineEdit.buffer(s),s.kill_buffer)
Base.LineEdit.refresh_line(s)
end)
function customize_keys(repl)
repl.interface = Base.REPL.setup_interface(repl; extra_repl_keymap = marcoexpandkeys)
end
Base.LineEdit.atreplinit(customize_keys)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment