Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10735 > unrolled thread

Evaluate code fragment without making new cell for it?

Started by"Nasser M. Abbasi" <nma@12000.org>
First post2012-07-02 09:26 +0000
Last post2012-07-20 07:58 +0000
Articles 5 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Evaluate code fragment without making new cell for it? "Nasser M. Abbasi" <nma@12000.org> - 2012-07-02 09:26 +0000
    Re: Evaluate code fragment without making new cell for it? Dominik Hezel <sendme2000@me.com> - 2012-07-04 07:37 +0000
    Re: Evaluate code fragment without making new cell for it? Dominik Hezel <sendme2000@me.com> - 2012-07-05 18:52 +0000
    Re: Evaluate code fragment without making new cell for it? Murta <rodrigomurtax@gmail.com> - 2012-07-19 07:55 +0000
    Re: Evaluate code fragment without making new cell for it? Murta <rodrigomurtax@gmail.com> - 2012-07-20 07:58 +0000

#10735 — Evaluate code fragment without making new cell for it?

From"Nasser M. Abbasi" <nma@12000.org>
Date2012-07-02 09:26 +0000
SubjectEvaluate code fragment without making new cell for it?
Message-ID<jsrpgn$d22$1@smc.vnet.net>
Sometimes I wish the following feature existed in
Mathematica notebook interface, but I can't seem to
find a way to do it.

Sometimes, (while trying things) I find that I want to
evaluate small code fragment which sits in a cell that
contains more code.

Currently what I do is either copy that code fragment to
a new cell and evaluate that cell, and when done, delete
the cell, or split the original cell at places where I want
to isolate the code fragment, then rejoin the cells when
done.

It will be nice, if there was a feature, where one can just
select, using the mouse, the code fragment, and then right-click
and say evaluate-selected.

The output will go into a new output cell as normal.

btw, the above is something one can do with that other
system M____B

For example, assume we have this toy cell

---CELL-----
x = 16
Sqrt[x]
y = 3
Sqrt[y*x]
---------

And I just wanted to evaluate only

x=16
Sqrt[x]

There is no easy way to do it without splitting the
cell or making new cell as I mentioned above.

This feature should not be hard to implement by
the front end I would think.  The front end can
make an 'internal hidden cell' in its own buffer of the
code selected and evaluate it and send the output back.

Do others think such a feature will be useful?

--Nasser

[toc] | [next] | [standalone]


#10788

FromDominik Hezel <sendme2000@me.com>
Date2012-07-04 07:37 +0000
Message-ID<jt0rr4$1hl$1@smc.vnet.net>
In reply to#10735
Wouldn't a set delay command (:=) do this job?
.Dominik

[toc] | [prev] | [next] | [standalone]


#10815

FromDominik Hezel <sendme2000@me.com>
Date2012-07-05 18:52 +0000
Message-ID<jt4nq7$4nf$1@smc.vnet.net>
In reply to#10735
Wouldn't a set delay command (:=) do this job?
.Dominik

[toc] | [prev] | [next] | [standalone]


#10980

FromMurta <rodrigomurtax@gmail.com>
Date2012-07-19 07:55 +0000
Message-ID<ju8egt$9b2$1@smc.vnet.net>
In reply to#10735
Hi
I think you could create it in 2 steeps:
1- Change the file below to create your shortcut
/Applications/Mathematica.app/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr
I use it for Use Command + [ or ] to do [[ or ]] for example. There is how
Item[KeyEvent["[", Modifiers -> {Command}],FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"[[", After]}]],
Item[KeyEvent["]", Modifiers -> {Command}],FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"]]", After]}]],


2- Using some functions like this:
viewNewWindow[expression_] := CreateDialog[expression, Background -> White]
To evaluate the expression in new windows.

Best regard
Murta


On Monday, July 2, 2012 6:26:47 AM UTC-3, Nasser M. Abbasi wrote:
> Sometimes I wish the following feature existed in
> Mathematica notebook interface, but I can&#39;t seem to
> find a way to do it.
> 
> Sometimes, (while trying things) I find that I want to
> evaluate small code fragment which sits in a cell that
> contains more code.
> 
> Currently what I do is either copy that code fragment to
> a new cell and evaluate that cell, and when done, delete
> the cell, or split the original cell at places where I want
> to isolate the code fragment, then rejoin the cells when
> done.
> 
> It will be nice, if there was a feature, where one can just
> select, using the mouse, the code fragment, and then right-click
> and say evaluate-selected.
> 
> The output will go into a new output cell as normal.
> 
> btw, the above is something one can do with that other
> system M____B
> 
> For example, assume we have this toy cell
> 
> ---CELL-----
> x = 16
> Sqrt[x]
> y = 3
> Sqrt[y*x]
> ---------
> 
> And I just wanted to evaluate only
> 
> x=16
> Sqrt[x]
> 
> There is no easy way to do it without splitting the
> cell or making new cell as I mentioned above.
> 
> This feature should not be hard to implement by
> the front end I would think.  The front end can
> make an &#39;internal hidden cell&#39; in its own buffer of the
> code selected and evaluate it and send the output back.
> 
> Do others think such a feature will be useful?
> 
> --Nasser

[toc] | [prev] | [next] | [standalone]


#11001

FromMurta <rodrigomurtax@gmail.com>
Date2012-07-20 07:58 +0000
Message-ID<jub32l$ej4$1@smc.vnet.net>
In reply to#10735
Someone knows how to complete this:

Item[KeyEvent["E", Modifiers -> {Control, Shift}],
	FrontEndExecute[
			FrontEnd`NotebookApply[
				FrontEnd`InputNotebook[],
				"EvaluateInNewCell[\[SelectionPlaceholder]]",
				After
			]
		]
	]

I almost get there.
When I put it in my KeyEventsTranslation and executes in an selectec Text I get this.
EvaluateInNewCell[selectedText]
How do I can Evaluate this in an new cell? 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web