# Tag Info

23

First of all, I agree, as OP mentioned in his comment, ANTLR is one of the proper ways to go. Now for this specific task, it might be easier to just compose a parser in the "dirty" way, except we don't have to go so far to regex. In my opinion Mathematica's StringExpression is much more powerful and very suitable for the job. All we have to do is (as OP ...

22

This syntax was deprecated in the version 6.0 era. According to the legacy documentation, For example, in version 5.2, the following strings are interpreted differently string1 = "first line second line" string2 = "\<first line second line\>"

21

Intro One day I was playing with Developer package and found DateSetter which uses some kind of floating elements that I found useful. After taking a look at a source code I found out it was FrontEndAttachedCell. From the code one could learn enough to create something useful: Usage FrontEndAttachCell[ parentObject, (*Box or Cell ...

18

The following seems to work, however I think it's not general enough: At a clean nb, enter: For[i = 0, i < 4, i++, Print[{i, {33, i}}]] For[i = 0, i < 4, i++, Print[Graphics[Circle[], ImageSize -> 20]]] And then retrieve the Print[ ] output as: c = Cases[NotebookRead /@ Cells[GeneratedCell -> True], Cell[___, "Print", ___]]; ToExpression /@ ...

18

The case when the evaluation is finished Some of my calculations take hours or even days, so I don't want to restart the entire evaluation just to add Timing[] to it. If your code generates an Output Cell then you can find at least an upper bound of the evaluation time as the difference between last CellChangeTimes of the Output and Input Cells. It can be ...

17

You can use this to create a functionality which will fit your need the best. Here's how you can preview your input cell with c highlighted Red. CellPrint[ NotebookRead @ PreviousCell[] /. "c" -> InterpretationBox[ StyleBox["c", FontColor -> RGBColor[1, 0, 0]], c ] ] You can even evaluate such cell. General ...

17

Update I have incorporated Kuba's improvement into the code. Here is how I would do it. In a working notebook (not the target notebook) put the following code. With[{nb = target}, SetOptions[nb, ShowCellBracket -> False]; SetOptions[#, CellOpen -> False] & /@ Cells[nb, CellStyle -> "Input"];] With[{nb = taget}, SetOptions[nb, ...

15

You can use something like this. (I have added extra steps to demonstrate practical usage.) Selectable code x = 3 y = x + 2; Clear[x, y, z] SelectionMove[EvaluationNotebook[], Previous, Cell, 3]; z = ToExpression@First@NotebookRead[EvaluationNotebook[]]; y + z Addendum Further to xzczd's comment, you can also use a cell tag :-

15

TL;DR; To set ShowGroupOpener on a global level, previously done by CurrentValue[$FrontEnd, ShowGroupOpener] = True, now use: CurrentValue[$FrontEnd, {StyleHints, "GroupOpener"}] = "OutsideFrame" This is what preferences menu does too. Further explanation The direct cause is Core.nb / All / Working style which, as a stylesheet setting, comes between the ...

15

Evaluate SetOptions[\$FrontEnd, EvaluationCompletionAction -> "ShowTiming"] and then the evaluation time for the last evaluation will be shown in the lower left corner of the notebook: Like many front end options, this setting is sticky. Set it once, and forget it; it also works across all versions of Mathematica installed.

14

Version 9 offers a couple of new ways to access cells that are useful to meet the needs of this question. The first way involves the use of the Cells and EvaluationCell functions. They can be used in the present context like this: previousCell[] := Cells @ EvaluationNotebook[] /. {___, prev_, EvaluationCell[], ___} :> ToExpression @ First @ ...

13

It is not straightforward to access the clipboard contents but one way, that doesn't involve writing and reading from temporary notebooks is to use the undocumented ClipboardNotebook function: CellPrint /@ StringSplit[NotebookGet[ClipboardNotebook[]][[1, 1, 1]], "\n"]; See also this answer which mentions some caveats. This prints strings as text cells. ...

12

I don't know if any of them can be callled documented but I know three ways to do this: mentioned above: FrontEndToken way: ( SelectionMove[#, All, Cell]; FrontEndTokenExecute[EvaluationNotebook[], "Style", "Title"] ) & /@ Cells[CellStyle -> "Section"] or SelectionSetStyle way: ( SelectionMove[#, All, Cell]; ...

12

Another possibility is to modify the notebooks style sheet by defining a new "Screen Environment" that hides cell brackets and closes input cells: SetOptions[ EvaluationNotebook[], StyleDefinitions -> Notebook[{ Cell[StyleData[StyleDefinitions->"Default.nb"]], Cell[StyleData[All, "Working"], MenuCommandKey->"D"], ...

12

Type > at the start of a cell (or when between cells). This is documented in an example on ref/ExternalEvaluate (last Basic Example). I'm a bit suprised it's not in the details section. It probably should be...

11

There are a number of nonlinear filters that are possible. One that might help is the RidgeFilter img=Import["http://i.stack.imgur.com/IyUPZ.jpg"]; ImageAdjust[RidgeFilter[img, 5]] Let's now clean it up a bit: Pruning[Thinning[SelectComponents[Binarize[ImageAdjust[RidgeFilter[img, 5]], 0.094], "Count", # > 800 &]]] The above binarizes the ...

11

Thanks to andre's comment (where this link is provided), I now see the effect of those delimiters (I tested it in Mathematica 11 and also some earlier versions). When I add 2 newlines to the box representation of the cell: Cell[BoxData["\"\<a bc\>\""], "Input", CellChangeTimes->{{3.662918813714031*^9, 3.6629188530623317*^9}}] and switch back ...

11

Here is a quick way of doing it: NotebookFind[nb = EvaluationNotebook[], "Print", All, CellStyle]; CreateDocument[NotebookRead[nb]]

11

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"], ...

10

More stable answer, in case of images and stuff evaluated in place in input cells: NotebookDelete /@ Select[Cells[GeneratedCell -> False], StringMatchQ[ First@ FrontEndExecute[ FrontEnd`ExportPacket[NotebookRead@#, "InputText"]], (" " | "\t" | "\r" | "\n" | "\[IndentingNewLine]") ... ] & ] It may be slower than the original ...

10

There is a special cell attribute called CellID. I would suggest using this instead of cell tags to avoid the problem that you mentioned with cell tags being inherited. Here's an example of how Select can be used to retrieve a cell with a specific cell ID: nb = CreateWindow[]; cells = <| "name" -> RandomInteger[10^6], "status" -> ...

10

Here's beta version, basic functionality is delivered. I have to polish it but probably I won't have time for that this year. It has to be packed into self contained module and styling options have to be enabled. I will update a nice description of an approach too, but meanwhile, if anything is not clear, feel free to ask. ActionNestedMenu[ "Test menu" -&...

10

Summary of the all available information In the hoarier days space-like characters (spaces, newlines, tabs) inside strings were interpreted on input in an odd way: for example single newlines followed by spaces or tabs were converted to a single space. The \<\> syntax was introduced as a way to avoid this: between \< and \> the space-like ...

10

You don't have to write all your code within ParallelSubmit. You can wrap your code in Module or Block and assign it to a variable using SetDelayed (:=) so it won't be evaluated immediately. Here is a toy example: eval1 := PrimeQ[528973465287364528736543] eval2 := Module[{}, Pause[2]; 3] evaluators = ParallelSubmit[{eval1, eval2}] You then run the ...

10

You can increase the CellMargins for the styles "Input" and "Output" in your style sheet to accommodate the increased size of the cell labels. For example, the following setting: CellMargins -> {{80, 10}, {10, 5}} fixes the issue for me with a Magnification of 2. If you don't want to mess around with editing the style sheet, you could evaluate the ...

10

Update It turns out that there is a much simpler method than my previous answer. If you need the actual cell label value, than I think messing around with the CellLabelAutoDelete option is necessary. On the other hand, if you know what the CellLabel is, then Cells is perfectly capable of returning the corresponding Cell. So, the following is a simpler ...

10

Those symbols are in fact special characters: Row@{"\:f442", "\:f443"}

10

From comments, these are the two options Use cell/open/close Use Iconize, as suggested by Carl Lange, which I think is a better option, since you still see the LHS of the assignment and so know what is one that cell, as compared to open/close the cell, where you'd have to open the cell again to see what is there.

9

I agree that it can be hard to tell that you have selected the correct cell bracket and that having a global option to highlight the whole cell when it is selected would be good. But I don't know how to do that. What I have done to alleviate the problem is to set Option Inspector > Global Preferences > Cell Options > Display Options > CellBracketOptions > "...

9

The purpose can be achieved with CellFrameLabels. Cell-expressions and Boxes can be used directly here, so styling can be done with StyleBox, alignment can be done with PanelBox etc. The counter mechanics is exact as Simon demonstrated in the linked Q/A in OP. Here is an example: cellFrameLabelFunc uses PanelBox with Alignment to align label lbl from left (...

Only top voted, non community-wiki answers of a minimum length are eligible