« first day (2594 days earlier)      last day (2188 days later) » 

00:44
@Kuba / @halirutan here's an interesting thing in the function that actually does the FE context switching. They call this: Quiet[$Context = newi @ "$Context", {LinkObject::linkv}] where newi appears to be a symbol that'll look like <ContextBeingSwitchedTo>`Private`SavedContextInfo.
That they need that Quiet on LinkObject::linkv is very odd to me
01:24
0
Q: Linting - Code analysis for bugs, errors and style issues in the Wolfram Language

halirutanI'm not sure we already have something similar, but I'm working on more code inspections for the IntelliJ plugin and it's always a good idea to ask the community. Since it doesn't really fit on main, I'm posting it here on Meta. Linting is an excellent way to point the developer to probable erro...

 
2 hours later…
02:55
Wow there really does not appear to be a way to get the context of a notebook. I even tried seeing if there was a hack through Dynamic and set up a few different forms of link snooping to try to figure it out. Internal`DynamicEvaluate just magically knows the notebook it's being called from. Like I thought other two arguments were to tell it where the content was being evaluated, but it turns out the FE handles all of that instead and preemptively switches the kernel context.
(even when not being evaluated on the preemptive link)
03:08
@halirutan did you ever get around to hooking a front-end/kernel up to IntelliJ?
If I remember correctly it should be possible to simply launch a kernel from IntelliJ and then attach a front-end to that.
Yeah I think if you start a kernel with JLink, then have the kernel evaluate this:
IntelliJListener`linkDrain[link_] :=

  If[LinkConnectedQ[link] && LinkReadyQ[link],
   Flatten@
    Reap[
      While[LinkReadyQ[link],
       Sow@LinkReadHeld[link]
       ]
      ][[2]],
   $Failed
   ];
IntelliJListener`intelliJREPL[link_] :=

  Replace[IntelliJListener`linkDrain[link],
   {
    EvaluatePacket[response_] :>
     LinkWrite[link, ReturnPacket[response]]
    },
   1
   ];
IntelliJListener`startIntelliJListener[link_LinkObject] :=

 If[$VersionNumber < 11.1,
   RunScheduledTask,
Then have the kernel LinkLaunch a front-end and set that as its $ParentLink that should be all you need.
03:34
@b3m2a1 No, but I haven't worked on this for a long time. When I remember correctly, then the last step (launching a front-end) didn't work out. You can launch a front-end from the kernel, but it will start a new kernel.
I have a different idea which I haven't tested yet. A JLink program can share the kernel with the front-end. So it should be possible to have a palette which runs a JLink program that could listen for IDEA commands. The commands could then be forwarded to the kernel or I can control the front-end.
So instead of launching the front-end, I'm controlling and existing one through a JLink palette.
 
3 hours later…
07:01
@halirutan it's certainly possible to share a kernel with an existing FE if the existing FE is willing to create something like a LinkSnooper kernel. On the other hand I'm certain it's possible to get the front-end to automatically attach to the kernel you created, though, as I've done this before, e.g. here.
The trick as I remember it is to start a front-end process and then use some FE programming tricks to get it to attach to your kernel. All in all it was pretty easy I think.
Omg I'm an idiot. I forgot I made a full package to do this...
08:11
@halirutan I just stumbled on another way you could do this. You can change where the FE looks up its preferences via a command line arg. If you pointed that at somewhere in your IntelliJ layout and wrote the link name to the preference file there you'd be able to start a new FE that doesn't even need a specially named kernel.
 
1 hour later…
09:28
@halirutan added some minor enhancements to the package. Here's a GIF of it in action:
The functions I use there are these:
linkDrain[link_] :=
  If[LinkConnectedQ@link,
   Replace[
    Reap[
       While[LinkReadyQ[link], Sow@LinkRead[link]]
       ][[2]] // Flatten,
    ReturnPacket[e_] :> e,
    1
    ],
   $Failed
   ];
linkSubmit[link_, expr_] :=

  LinkWrite[link, Unevaluated@EvaluatePacket[expr]];
linkSubmit~SetAttributes~HoldRest
launchFrontEnd[innerKernel_, name_: "IntelliJ"] :=

 Block[{$ContextPath = {"System`"}},
  LinkWrite[
   innerKernel,
   Unevaluated@
    EvaluatePacket[
     << SubprocessKernel`;
     SubprocessKernel`$SubprocessKernelName = name;
The package itself is here
What I'm showing there is that as long as you can create a KernelLink (e.g. via JLink, LinkLaunch, .NETLink, MLOpenArgv, PJLink if you can get it to compile) you can attach that directly to a new FE
And then the kernel state will be shared between the link and the FE
 
2 hours later…
11:22
Is there a way to change the way the "Local" kernel launches in Mathematica?
It seems like whatever I change it reverts.
11:36
@halirutan okay here's an even nicer solution in terms of kernel consumption. When you launch Mathematica it turns out there's literally no way to prevent it from exhausting a kernel trying to launch "Local". So I changed up the package to create a partial $UserBaseDirectory in the $TemporaryDirectory which the FE initializes from.
This way I can remove the rules for the "Local" kernel and thus prevent it from wasting a seat. I tried to just alter the rules for "Local" but it didn't respect my changes.
On the other hand, when you launch Mathematica it does pop up a dialog complaining about being unable to find "Local".
 
4 hours later…
15:21
Hi @J.M.! Good to see you around!

« first day (2594 days earlier)      last day (2188 days later) »