It seems that this key shortcut added to KeyEventTranslations.tr does what you need:
Item[
KeyEvent["t", Modifiers -> {Control}],
FrontEndExecute[
FrontEnd`SelectionCreateCell[FrontEnd`InputNotebook[]];
FrontEnd`SelectionMove[FrontEnd`InputNotebook[], All, CellContents];
FrontEnd`SelectionEvaluate[FrontEnd`InputNotebook[]];
]
]
This will work if the result is going to be one cell output, otherwise only first cell will stay. If you want all of them then use:
SelectionMove[FrontEnd`InputNotebook[], All, **Cell**]
but doubled input cell will not be overwritten.
I was trying to deal with multiple cell output with tagging input cell and then deleting it just after evaluation but I've faced a problem.
I failed setting CellTags. Is the syntax incorrect? Any comments appreciated.
FrontEnd`SelectionCreateCell[FrontEnd`InputNotebook[]];
FrontEnd`SelectionMove[FrontEnd`InputNotebook[], All, Cell];
FrontEnd`SetOptions[FrontEnd`NotebookSelection[FrontEnd`InputNotebook[]],
CellTags -> "temp"];
FrontEnd`SelectionEvaluate[FrontEnd`InputNotebook[]];
FrontEnd`NotebookDelete[FrontEnd`Cells[FrontEnd`InputNotebook[],
CellTags -> "temp", GeneratedCell -> False]];
]
Those procedures do what I've decribed, when added to Pallete. For complete code go to this answer edit history.
rthat's the same as in the module. So just doing an evaluation in the same notebook might overwrite the globalr, which is not desirable. So a possible solution might be to copy selection, create a new notebook with a context unique to the notebook, evaluate, copy result and discard notebook – rm -rf Sep 14 '13 at 17:21