MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

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

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).

   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",
                 evalnb =
                       Map[Cell[#, "Input"] &, {
                           BoxData@RowBox@{"cpynb", "=", ToBoxes@cpynb},
                       Visible -> False];
                 SelectionMove[evalnb, All, Notebook];
             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.

  • Prev by Date: Re: Nonlinear Programming?
  • Next by Date: RE: Re: A friendly challenge: Generalized Partition
  • Previous by thread: Re: Using Mathgroup Effectively -- cutting and pasting expressions
  • Next by thread: Dashed Arrowheads