Path to extending Lyx to a full featured Jupyter-like IDE

Allen Barker Allen.L.Barker at
Fri Mar 13 18:32:07 UTC 2020

On 3/10/20 10:05 PM, Richard Kimberly Heck wrote:
> On 3/10/20 9:24 PM, Allen Barker wrote:
>> On 6/25/19 12:42 PM, Richard Kimberly Heck wrote:
>>> Thanks for these ideas. I'm not an R user myself, though, so it would be
>>> helpful to me if you could explain what it is you are trying to achieve.
>>> It's best when thinking through issues like this one to separate the
>>> problem from the solution. What's below seems to be a mix between those.
>>> One reason I ask about this is that LyX 2.3.3 has added the ability to
>>> edit the LaTeX preamble or the contents of an ERT inset using some
>>> external editor. LyX 2.4.0 will extend that to 'collapsible' insets
>>> generally, controlled by a layout tag EditExternal. So by activating
>>> this tag for the appropriate kind of inset, you can edit its contents in
>>> whatever editor you define for its format. That seems, if I'm reading
>>> you right, to give you much of what you want---and to use your editor of
>>> choice.
>> I'm very interested to hear about the new 2.4.0 editable insets.  As I
>> mentioned in my other recent posting in a related thread, I ran into this
>> same problem a few years back when I implemented my Lyx Notebook project.
>> I had to resort to an ugly kludge to get the inset text.
>> Is this new feature already implemented in the 2.4.0 code in the git
>> repo?  Does it work for Flex insets, too?  If so, how do you enable it
>> for a Flex inset?
> Yes. Just do:
>      EditExternal 1
> in the inset layout to enable it. The inset should then have a context
> menu item allowing it to be edited, as ERT insets do.
>> I assume this uses the inset-edit LFUN, which opens an editor on the
>> text.  I'm not sure how to set the particular editor to use, though.
> This uses the editor defined in Preferences for the document's output
> format.

I messed around with the feature a bit, and it's a nice addition.  As you
mentioned in another posting, it would be nice to have a way to define a
particular editor to be used to edit certain insets.  As it is it seems
that everything will be edited by default as "LaTeX (plain)".

One thing I noticed is that after an external edit to a text inset
(both Flex and ERT) in either gvim or gedit, where the file is saved
(even if the text is not changed), the inset has an extra newline
added to the end after the inset-end-edit.

>> It would be nice to have an option to have the LFUN just return the
>> filename rather than running an editor process on the file.
>> Sometimes users might want to edit the inset text and sometimes you
>> might want to process the text with your already-running program
>> (Lyx Notebook uses Lyx server pipes).
> There must be some reasonable way to do that. Can't be too hard.

The code fix that I'm working with now is to replace this line (609) in

    theFormats().edit(buffer(), tempfilename, format);

with this:

    if (cmd.argument() == "noeditor")
       theFormats().edit(buffer(), tempfilename, format);

That seems to work (assuming I haven't overlooked something) and creates
the parameter "noeditor" for the inset-edit LFUN which just returns the
temporary filename.

The question is then whether that is good from an API viewpoint.  The
inset-edit LFUN already takes a filename parameter, but that parameter is
not respected in the InsetCollapsible::doDispatch routine anyway.  In
the case of collapsible insets a temp file is always used.

More information about the lyx-devel mailing list