(* ::Package:: *) (* ::Section:: *) (*Keyevents for M9*) (* ::Text:: *) (*Author: Rolf Mertig, http://www.mertig.com, GluonVision GmbH, Berlin, Germany*) (* ::Text:: *) (*Executing the code below generates a KeyEventTranslations.tr in a subdirectory in $UserBaseDirectory *) $OverWriteUserBaseDirectoryKeyEventTranslations = True; mymenuitems=" (* Delete all Output, Message and Print cells in the selected notebook Basically my answer from http://mathematica.stackexchange.com/a/13992/29 Windows: Command (Windows-Key) Alt d deletes all Output and Message and Print Cells MacOSX: Command Option d *) Item[KeyEvent[\"d\", Modifiers -> {Option, Command}], KernelExecute[ Module[{nb = SelectedNotebook[]}, Scan[Function[c, If[NotebookFind[nb, c, All, CellStyle, AutoScroll -> False] =!= $Failed, NotebookDelete[nb, AutoScroll -> False]] ], {\"Message\", \"Output\", \"Print\"} ]; SelectionMove[nb,After,Notebook]; ] ], MenuEvaluator -> Automatic ],\n (* Merge cells fix for M9; instead of Control Shift M Windows: Command Alt m MacOSX: Command Option m can be used instead: *) Item[KeyEvent[\"m\", Modifiers -> {Command,Option}], KernelExecute[ FrontEndExecute[FrontEndToken[\"CellMerge\"]]; Module[{ce=Cells[CellStyle -> \"Input\"]}, Scan[Function[x,NotebookWrite[x,ReplaceRepeated[NotebookRead[x], RuleDelayed[HoldPattern[RowBox[Pattern[a,Blank[]],Pattern[b,BlankSequence[]]]],RowBox[List[a,b]]]]]],ce]; ]; ] , MenuEvaluator -> Automatic ], (* Quit the kernel by Command Alt k from http://mathematica.stackexchange.com/questions/6224/best-way-to-add-keyevents-and-faster-quit?rq=1 *) Item[KeyEvent[\"k\", Modifiers -> {Command,Option}], KernelExecute[ToExpression[\"Quit[]\"] ], MenuEvaluator -> Automatic ], "; With[{os = Switch[$OperatingSystem,"MacOSX","Macintosh","Windows","Windows","Unix","X"]}, Quiet@CreateDirectory@FileNameJoin[{$UserBaseDirectory,"SystemFiles","FrontEnd","TextResources",os}]; mykeyeventtrans=FileNameJoin[{$UserBaseDirectory,"SystemFiles","FrontEnd","TextResources",os,"KeyEventTranslations.tr"}]; If[$OverWriteUserBaseDirectoryKeyEventTranslations===True, If[FileExistsQ[mykeyeventtrans],DeleteFile@mykeyeventtrans]; CopyFile[FileNameJoin[{$InstallationDirectory,"SystemFiles","FrontEnd","TextResources", os,"KeyEventTranslations.tr"}],mykeyeventtrans] ]]; keytext=Import[mykeyeventtrans,"Text"]; mykeytext=StringReplace[keytext,"EventTranslations[{":>StringJoin["EventTranslations[{\n",mymenuitems,"\n"]]; Export[mykeyeventtrans,mykeytext,"Text"]; Print["Please quit the FrontEnd and restart. Then, for Windows ( Command = Windows Key ) Command Alt d deletes all Output and Message and Print Cells Command Alt m merges Cells, like Control Shift m, but fixes a M9 bug Command Alt k quits the kernel for MacOSX : Command Option d deletes all Output and Message and Print Cells Command Option m merges Cells, like Control Shift m, but fixes a M9 bug Command Option k quits the kernel Fox X11 : Mod1 Alt d deletes all Output and Message and Print Cells Mod1 Alt m merges Cells, like Control Shift m, but fixes a M9 bug Mod1 Alt k quits the kernel "]; Quit[];