Problem with import

65 views
Skip to first unread message

tfer

unread,
Jan 27, 2020, 2:56:09 PM1/27/20
to leo-editor
I had a problem when trying to do an import with a "tabwidth 2" directive in effect, below is the body text of the node I was using:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
to match the required use of tabs for indentation, plus how vscode shows the file(s)
@tabwidth 2
-trf Note: wanted to have this in effect for the import as the project guidelines requires the use of tabs for indentation, but importing by the "Flile" menu creates a node at level zero where "@tabwidth  -4" is still in effect!   Had to get around this by by temporally renaming "reveal.js" in Explorer, saving the leo file with a childless "@auto" node and closing its tab, go to Explorer and delete the empty file created, change the renamed file back to "reveal.js", then open .leo the file to get an import with the "@tabwidth 2" in effect.  I seem to remember that there was a context menu available when you clicked an "@auto" node so you could initiate the import, but that no longer seems to be the case.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Tom

Edward K. Ream

unread,
Jan 31, 2020, 6:14:28 AM1/31/20
to leo-editor
On Monday, January 27, 2020 at 1:56:09 PM UTC-6, tfer wrote:

> I had a problem when trying to do an import with a "tabwidth 2" directive in effect, below is the body text of the node I was using:

I mentioned the solution in passing in another thread.  You can set c.tab_width to 2 for the import script as follows:

c.tab_width = 2
try:
    c
.recursiveImport(
        dir_
= r'C:\leo.repo\reveal.js\js',
        kind
= '@auto',
        recursive
= True,
        safe_at_file
= True,
        theTypes
= ['.js',],
   
)
finally:
    c
.tab_width = -4

Edward

tfer

unread,
Jan 31, 2020, 7:59:05 AM1/31/20
to leo-editor
Alright, thanks.  I'm going to have to look at the javascript files for other reveal.js plugins to see what they are doing, I'll see about generalizing this a bit then.

Edward K. Ream

unread,
Jan 31, 2020, 9:19:55 AM1/31/20
to leo-editor
On Fri, Jan 31, 2020 at 6:59 AM 'tfer' via leo-editor <leo-e...@googlegroups.com> wrote:
Alright, thanks.  I'm going to have to look at the javascript files for other reveal.js plugins to see what they are doing, I'll see about generalizing this a bit then.

On my end, I have found the problem, as now described in the first comment of #1481. It appears that the string 'function' is being treated as a real function keyword. The probable culprits are the regex's in js_i.starts_block. A fix could be tricky, because of the horror show involving JS regex's. A context-free scanner is not possible in JS! See the node js_i.scan_line & helpers in @file importers/javascript.py.

There is another serious problem. The JS importer destroys leading whitespace in a seemingly random way, even when it does work. This has got to be fixed.

Edward

tfer

unread,
Feb 5, 2020, 12:20:06 AM2/5/20
to leo-editor
I modified this script to point to the 'js' directory and made it a script button, all it does is create a level one node 'imported files' with two descendants, both @path nodes, one for the directory an one for the reveal.js file.


On Friday, January 31, 2020 at 6:14:28 AM UTC-5, Edward K. Ream wrote:

Edward K. Ream

unread,
Feb 5, 2020, 4:10:08 AM2/5/20
to leo-editor
On Tue, Feb 4, 2020 at 11:20 PM 'tfer' via leo-editor <leo-e...@googlegroups.com> wrote:
I modified this script to point to the 'js' directory and made it a script button, all it does is create a level one node 'imported files' with two descendants, both @path nodes, one for the directory an one for the reveal.js file.

I see this behavior. Importing to @clean works for me for using either tab_width set either to 2 or 4.

I'll investigate.

Edward

Edward K. Ream

unread,
Feb 5, 2020, 4:14:33 AM2/5/20
to leo-editor
I've just created #1486 for this.

Edward

Edward K. Ream

unread,
Feb 5, 2020, 4:37:43 AM2/5/20
to leo-editor
On Wednesday, February 5, 2020 at 3:14:33 AM UTC-6, Edward K. Ream wrote:

> I've just created #1486 for this.

Fixed at 680e7c5 in devel. This bug has been around for a long time. There was a weird special case for @auto that had no chance of doing anything. It's probably never been tested.

In an ideal world I'd do some kind of unit test for it, but this isn't such a world ;-)

Let me know if there are further problems.

Edward
Reply all
Reply to author
Forward
0 new messages