Skip to main content
18 events
when toggle format what by license comment
Nov 3, 2022 at 2:11 comment added userrandrand $Preread is convenient if you define a lot of functions that use the same variable thing as you only have to use $Preread once per variable. att's method is convenient when you have many variables but few functions. My only concern with $Preread is that you need to use a different name than the variable you want to use and only use it for pasting when you explicitly want the expression to be there and you do not use it in an expression that temporarily or permanently hold its arguments. Basically att's method is safer and probably better.
Nov 3, 2022 at 2:04 comment added userrandrand @IonSme if you are rerunning the whole document then you should be running the $PreRead command too. It would only be hard coded if you explicitly wrote the characters in the expression but I used ToString@thing so the result depends on the expression of thing. With Iconize you might need to re copy and paste the icon each time I do not know. The SetOptions will require you to remove the expression and retype "pastedthing" each time which could be tedious if you rerun the document a lot. I personally think @att's method is the best for rerunning the document multiple times
Nov 3, 2022 at 1:53 comment added userrandrand For a clear list of the order of events each time you execute a command search (with Ctrl+F ) for "All Wolfram System sessions repeatedly execute the following main loop" here
Nov 3, 2022 at 1:53 comment added userrandrand $PreRead makes replacements before anything else. Mathematica still considers it a random string of text at that point so the replace function in my answer is basically doing a search and replace as one would do with "Ctrl+F" for example. Mathematica then checks for syntax errors then does some assignments to keep a record of what has happened and then evaluates and then other details.
Nov 3, 2022 at 1:33 comment added ions me $PreRead I need to look at more, but if reruning the document does not update the definitions of thing, I call it hard coded. h[a1_,b1_]:=.... /.{a-a1,b->b1} is what I mean by ugly. And Activate@Deactivate is a bit long, but one of the best so far. Need to make sure there aren't some other cases where it breaks though.
Nov 3, 2022 at 1:32 comment added userrandrand You could set up an alias for @att's solution with SetOptions[EvaluationNotebook[], InputAutoReplacements -> {"paste" -> "Activate@Inactivate"}]. That will only work in the current notebook. If you want it to always work in every notebook I think I vaguely know what to do but as it could mess up all of your notebooks I rather not say and would suggest to ask that in a separate question. There might be a way with the option inspector. If you do not get an answer then you can ask me and I will tell you what I think one has to do to get it to work on all the notebooks.
Nov 3, 2022 at 1:10 comment added userrandrand Also maybe Activate Deactivate is too lengthy.
Nov 3, 2022 at 1:10 comment added userrandrand (2) By ugly I suppose you mean lengthy to write or adhoc looking such as h[a1_,b1_]:=.... /.{a-a1,b->b1} ?
Nov 3, 2022 at 1:07 comment added userrandrand @IonSme (1) By hard coded I suppose you mean that you do not want to have to set up the notebook or the evaluation process to do that automatically ? For example you do not want to change the notebook settings or change $PreRead ?
Nov 3, 2022 at 0:56 comment added ions me whether its technically front or back end doesn't matter to much to me. However, if I make changes in the fron end inspector, it seems unlikely that it would satisfy (1)
Nov 3, 2022 at 0:55 comment added ions me About (2) I want to not have to type lots of stuff everywhere, and it should be easy to do freqnently.
Nov 3, 2022 at 0:54 comment added ions me About (1) I want to be able to edit the previous calculations, rerun the document and have the stuff I pasted update as well.
Nov 3, 2022 at 0:53 comment added ions me I just want to be able to copy and paste complicated expressions from previous calculations, without it (1) being hardcoded and (2) looking ugly.
Nov 3, 2022 at 0:27 comment added lericr I think you'll need to define them for some context (e.g. current notebook or global or whatever) via the options inspector, so it's not as dynamic as, say, the Iconize idea. In other words, it's a front end thing, not a Wolfram Language thing. Is that what you're after?
Nov 3, 2022 at 0:22 comment added lericr Look at userrandrand's updated answer. I think InputAliases or InputAutoReplacements might be what you want.
Nov 2, 2022 at 23:30 comment added ions me I didn't want to actually paste things because I can't edit previous code, and then rerun the whole document. Is there a way to use this technique but avoid having to actually copy paste?
Nov 2, 2022 at 23:25 comment added ions me This does make copying and pasting less horrible looking, but I still have to use copy and paste. I.E the following does not work thing = a + b y ; thing = Iconize[thing,"thing"]; thingy[a_,b_,y_] =thing;
Nov 2, 2022 at 6:16 history answered lericr CC BY-SA 4.0