Re: Re: Using Mathgroup Effectively -- cutting and pasting expressions

*To*: mathgroup at smc.vnet.net*Subject*: [mg34943] Re: [mg34910] Re: Using Mathgroup Effectively -- cutting and pasting expressions*From*: Omega Consulting <omega_consulting at yahoo.com>*Date*: Fri, 14 Jun 2002 02:38:47 -0400 (EDT)*References*: <adv5tt$dc$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

At 01:15 AM 6/12/2002, Dave Collins wrote: >Of course, if this were a carefully formatted notebook, I'd need to discard >the changes after conversion and copying. Given all the other options >under the "Edit|Copy as" menu, it would be nice if Wolfram would add >"Copy as input form", perhaps with the option of making it the default. > >-- Dave Collins Here's code for a palette that does just that. It takes a selection and passes it through Cell>Convert To>InputForm and then does Edit>Copy As>Plain Text (all without altering the original selection). NotebookPut@ Notebook[{Cell[BoxData@ButtonBox["Copy As InputForm", ButtonFunction :> Module[{cpy, cpynb, evalnb}, cpy = NotebookRead@InputNotebook[]; If[cpy === {}, Return[]]; cpynb = NotebookCreate[Visible -> False]; NotebookWrite[cpynb, cpy]; SelectionMove[cpynb, All, Notebook]; FrontEndExecute[{FrontEndToken[cpynb, "SelectionConvert", "InputForm"]}]; evalnb = NotebookPut@ Notebook[ Map[Cell[#, "Input"] &, { BoxData@RowBox@{"cpynb", "=", ToBoxes@cpynb}, "FrontEndExecute[{FrontEndToken[cpynb, \"CopySpecial\",\"PlainText\"]}]", "NotebookClose[cpynb]", "NotebookClose[EvaluationNotebook[]]"}], Visible -> False]; SelectionMove[evalnb, All, Notebook]; SelectionEvaluate@evalnb; ], ButtonEvaluator -> Automatic, Active -> True], "Text"]}, WindowClickSelect -> False, ShowCellBracket -> False, WindowSize -> {150, Fit}, WindowElements -> {}, WindowFrame -> "Palette", WindowFrameElements -> {"CloseBox"}, ClosingAutoSave -> True ] -------------------------------------------------------------- Omega Consulting "The final answer to your Mathematica needs" Spend less time searching and more time finding. http://www.wz.com/internet/Mathematica.html