New input cell style with a custom evaluatorLabel cell goes away with SelectionEvaluateSet the style of a cellSelect parts of Input CellDetails of automatic cell-grouping w.r.t. cell-styleWhat is “ (Dialog) Input [ ] := ” after evaluating a cell?Dynamic Tooltips displaying cell contentsHide all code cells in notebook with Style: InputHow to generate an input cell?Print generates a cell with style “Print”Programmatically change cell style
Second map without labels
Can “du tout” be used positively?
What are these clip-like things?
What is the use case for non-breathable waterproof pants?
What did the 'turbo' button actually do?
Why is the Eisenstein ideal paper so great?
Is it legal to have an abortion in another state or abroad?
Why did Jon Snow admit his fault in S08E06?
How to let other coworkers know that I don't share my coworker's political views?
Time complexity of an algorithm: Is it important to state the base of the logarithm?
Can you still travel to America on the ESTA waiver program if you have been to Iran in transit?
Why is 'additive' EQ more difficult to use than 'subtractive'?
One word for 'the thing that attracts me'?
Why do Russians almost not use verbs of possession akin to "have"?
Why isn't 'chemically-strengthened glass' made with potassium carbonate? To begin with?
Why does FOO=bar; export the variable into my environment
Expected maximum number of unpaired socks
Finding all files with a given extension whose base name is the name of the parent directory
shell script is not executed after adding it as a crontab job
Is there a simple example that empirical evidence is misleading?
Best shape for a necromancer's undead minions for battle?
How would a developer who mostly fixed bugs for years at a company call out their contributions in their CV?
Why is this integration method not valid?
I want to ask company flying me out for office tour if I can bring my fiance
New input cell style with a custom evaluator
Label cell goes away with SelectionEvaluateSet the style of a cellSelect parts of Input CellDetails of automatic cell-grouping w.r.t. cell-styleWhat is “ (Dialog) Input [ ] := ” after evaluating a cell?Dynamic Tooltips displaying cell contentsHide all code cells in notebook with Style: InputHow to generate an input cell?Print generates a cell with style “Print”Programmatically change cell style
$begingroup$
I'm interested to implement a custom input style which would appear (mostly?) like a normal "Input" Cell, but which would perform custom evaluation on shift-return or when evaluating a cell as a part of a group of cells. I'm interested of the custom evaluator, but also on easy way of creating such cells (keyboard shortcut?) or converting ordinary input cells to this custom variant.
How to approach this problem? My first assumption is that setting $Pre and applying custom evaluation on basis of either Cell style or CellTags values would be the way to go. I'm a little uncertain if this is the most sensible approach since there are also CellEvaluationFunction and CellProlog. What are the caveats of these approaches?
evaluation notebooks cells
$endgroup$
add a comment |
$begingroup$
I'm interested to implement a custom input style which would appear (mostly?) like a normal "Input" Cell, but which would perform custom evaluation on shift-return or when evaluating a cell as a part of a group of cells. I'm interested of the custom evaluator, but also on easy way of creating such cells (keyboard shortcut?) or converting ordinary input cells to this custom variant.
How to approach this problem? My first assumption is that setting $Pre and applying custom evaluation on basis of either Cell style or CellTags values would be the way to go. I'm a little uncertain if this is the most sensible approach since there are also CellEvaluationFunction and CellProlog. What are the caveats of these approaches?
evaluation notebooks cells
$endgroup$
2
$begingroup$
CellEvaluationFunctionseems by far the best approach.
$endgroup$
– Leonid Shifrin
12 hours ago
add a comment |
$begingroup$
I'm interested to implement a custom input style which would appear (mostly?) like a normal "Input" Cell, but which would perform custom evaluation on shift-return or when evaluating a cell as a part of a group of cells. I'm interested of the custom evaluator, but also on easy way of creating such cells (keyboard shortcut?) or converting ordinary input cells to this custom variant.
How to approach this problem? My first assumption is that setting $Pre and applying custom evaluation on basis of either Cell style or CellTags values would be the way to go. I'm a little uncertain if this is the most sensible approach since there are also CellEvaluationFunction and CellProlog. What are the caveats of these approaches?
evaluation notebooks cells
$endgroup$
I'm interested to implement a custom input style which would appear (mostly?) like a normal "Input" Cell, but which would perform custom evaluation on shift-return or when evaluating a cell as a part of a group of cells. I'm interested of the custom evaluator, but also on easy way of creating such cells (keyboard shortcut?) or converting ordinary input cells to this custom variant.
How to approach this problem? My first assumption is that setting $Pre and applying custom evaluation on basis of either Cell style or CellTags values would be the way to go. I'm a little uncertain if this is the most sensible approach since there are also CellEvaluationFunction and CellProlog. What are the caveats of these approaches?
evaluation notebooks cells
evaluation notebooks cells
edited 11 hours ago
kirma
asked 12 hours ago
kirmakirma
10.4k13160
10.4k13160
2
$begingroup$
CellEvaluationFunctionseems by far the best approach.
$endgroup$
– Leonid Shifrin
12 hours ago
add a comment |
2
$begingroup$
CellEvaluationFunctionseems by far the best approach.
$endgroup$
– Leonid Shifrin
12 hours ago
2
2
$begingroup$
CellEvaluationFunction seems by far the best approach.$endgroup$
– Leonid Shifrin
12 hours ago
$begingroup$
CellEvaluationFunction seems by far the best approach.$endgroup$
– Leonid Shifrin
12 hours ago
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
You can use StyleKeyMapping to easily switch back and forth from "Input" cells to your "CustomInput" cell. For example:
Cell[StyleData["Input"],
StyleKeyMapping->
"=" -> "WolframAlphaShort",
"*" -> "Item",
">" -> "ExternalLanguage",
"Tab" -> "CustomInput"
]
Cell[StyleData["CustomInput"],
StyleKeyMapping->"Tab" -> "Input"
]
For a custom evaluation function, you can use CellProlog or CellEvaluationFunction. For example:
CellEvaluationFunction -> Function @ Replace[#,
BoxData[foo_List] :> ToExpression[
BoxData[Map[RowBox["goo", "[", #, "]"]& , foo]],
#2
],
BoxData[foo_] :> ToExpression[BoxData[RowBox["goo", "[", foo, "]"]], #2]
]
would add the wrapper goo around every input before evaluation. The one downside with this approach is that only the last line of input will get an output, the others are automatically suppressed. If that is a problem, then I could give you a CellProlog approach instead.
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198775%2fnew-input-cell-style-with-a-custom-evaluator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can use StyleKeyMapping to easily switch back and forth from "Input" cells to your "CustomInput" cell. For example:
Cell[StyleData["Input"],
StyleKeyMapping->
"=" -> "WolframAlphaShort",
"*" -> "Item",
">" -> "ExternalLanguage",
"Tab" -> "CustomInput"
]
Cell[StyleData["CustomInput"],
StyleKeyMapping->"Tab" -> "Input"
]
For a custom evaluation function, you can use CellProlog or CellEvaluationFunction. For example:
CellEvaluationFunction -> Function @ Replace[#,
BoxData[foo_List] :> ToExpression[
BoxData[Map[RowBox["goo", "[", #, "]"]& , foo]],
#2
],
BoxData[foo_] :> ToExpression[BoxData[RowBox["goo", "[", foo, "]"]], #2]
]
would add the wrapper goo around every input before evaluation. The one downside with this approach is that only the last line of input will get an output, the others are automatically suppressed. If that is a problem, then I could give you a CellProlog approach instead.
$endgroup$
add a comment |
$begingroup$
You can use StyleKeyMapping to easily switch back and forth from "Input" cells to your "CustomInput" cell. For example:
Cell[StyleData["Input"],
StyleKeyMapping->
"=" -> "WolframAlphaShort",
"*" -> "Item",
">" -> "ExternalLanguage",
"Tab" -> "CustomInput"
]
Cell[StyleData["CustomInput"],
StyleKeyMapping->"Tab" -> "Input"
]
For a custom evaluation function, you can use CellProlog or CellEvaluationFunction. For example:
CellEvaluationFunction -> Function @ Replace[#,
BoxData[foo_List] :> ToExpression[
BoxData[Map[RowBox["goo", "[", #, "]"]& , foo]],
#2
],
BoxData[foo_] :> ToExpression[BoxData[RowBox["goo", "[", foo, "]"]], #2]
]
would add the wrapper goo around every input before evaluation. The one downside with this approach is that only the last line of input will get an output, the others are automatically suppressed. If that is a problem, then I could give you a CellProlog approach instead.
$endgroup$
add a comment |
$begingroup$
You can use StyleKeyMapping to easily switch back and forth from "Input" cells to your "CustomInput" cell. For example:
Cell[StyleData["Input"],
StyleKeyMapping->
"=" -> "WolframAlphaShort",
"*" -> "Item",
">" -> "ExternalLanguage",
"Tab" -> "CustomInput"
]
Cell[StyleData["CustomInput"],
StyleKeyMapping->"Tab" -> "Input"
]
For a custom evaluation function, you can use CellProlog or CellEvaluationFunction. For example:
CellEvaluationFunction -> Function @ Replace[#,
BoxData[foo_List] :> ToExpression[
BoxData[Map[RowBox["goo", "[", #, "]"]& , foo]],
#2
],
BoxData[foo_] :> ToExpression[BoxData[RowBox["goo", "[", foo, "]"]], #2]
]
would add the wrapper goo around every input before evaluation. The one downside with this approach is that only the last line of input will get an output, the others are automatically suppressed. If that is a problem, then I could give you a CellProlog approach instead.
$endgroup$
You can use StyleKeyMapping to easily switch back and forth from "Input" cells to your "CustomInput" cell. For example:
Cell[StyleData["Input"],
StyleKeyMapping->
"=" -> "WolframAlphaShort",
"*" -> "Item",
">" -> "ExternalLanguage",
"Tab" -> "CustomInput"
]
Cell[StyleData["CustomInput"],
StyleKeyMapping->"Tab" -> "Input"
]
For a custom evaluation function, you can use CellProlog or CellEvaluationFunction. For example:
CellEvaluationFunction -> Function @ Replace[#,
BoxData[foo_List] :> ToExpression[
BoxData[Map[RowBox["goo", "[", #, "]"]& , foo]],
#2
],
BoxData[foo_] :> ToExpression[BoxData[RowBox["goo", "[", foo, "]"]], #2]
]
would add the wrapper goo around every input before evaluation. The one downside with this approach is that only the last line of input will get an output, the others are automatically suppressed. If that is a problem, then I could give you a CellProlog approach instead.
answered 8 hours ago
Carl WollCarl Woll
79.9k3102207
79.9k3102207
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198775%2fnew-input-cell-style-with-a-custom-evaluator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
$begingroup$
CellEvaluationFunctionseems by far the best approach.$endgroup$
– Leonid Shifrin
12 hours ago