parse-body needs some way to tell it which lanugage it is parsing. The @lanugage directive can be present in *any* parent, all the way up to a top level node. My guess is that in your previous attempt when it worked there was a @language directive hiding somewhere.
This probably needs to be better documented. As the result of "help for command" for "parse-body" is essentially empty. On Tuesday, February 21, 2017 at 8:39:10 AM UTC-5, jkn wrote: > > Hi John > > On Tuesday, February 21, 2017 at 1:01:26 PM UTC, john lunzer wrote: >> >> I tried this code too. Once without @language python, in which it >> failed, and once with @language python, in which it was successful. So >> please make sure that this directive is included in a parent of the branch >> you're trying to parse-body on. >> >> On Tuesday, February 21, 2017 at 6:05:12 AM UTC-5, jkn wrote: >>> >>> Hi Edward >>> >>> On Tuesday, February 21, 2017 at 10:46:03 AM UTC, Edward K. Ream wrote: >>>> >>>> On Tue, Feb 21, 2017 at 3:39 AM, jkn <[email protected]> wrote: >>>> >>>> >>>>> [I tried this code...] >>>>> >>>>> >>>>> ''' Test parse-body command ''' >>>>> >>>>> class MyFirstClass(): >>>>> def __init__(self): >>>>> pass >>>>> >>>>> def newFunc(self): >>>>> pass >>>>> >>>>> class MySecondClass(): >>>>> def __init__(self): >>>>> pass >>>>> >>>>> def newFunc(self): >>>>> pass >>>>> >>>>> >>>>> and nothing happens when I execute the parse-body command. >>>>> >>>> >>>> Strange! It works for me. >>>> >>>> I did manage to crash parse-body just now with this code: >>>> >>>> @cmd('reload-settings') >>>> def reloadSettings(self, event=None): >>>> '''Reload all static abbreviations from all config files.''' >>>> self.reloadSettingsHelper(all=False) >>>> >>>> @cmd('reload-all-settings') >>>> def reloadAllSettings(self, event=None): >>>> '''Reload all static abbreviations from all config files.''' >>>> self.reloadSettingsHelper(all=True) >>>> >>>> But this crash shows up prominently in the log window. >>>> >>>> Are you running Leo from a console? >>>> >>> >>> I tried with and without a console. I'm on a different machine ATM but >>> it doesn't work on this either. If I run from a console and then execute >>> parse-body then nothing interesting is shown on the console: >>> >>> >>> Leo 5.4, build 20170221043749, Tue Feb 21 04:37:49 CST 2017 >>> Git repo info: branch = master, commit = f860468937d5 >>> Python 2.7.2, PyQt version 4.8.6 >>> Windows 7 x86 (build 6.1.7601) SP1 >>> reading settings in W:\@leo\jknprojects.leo >>> kill_one_shortcut <KeyStroke: u'Alt+d'> >>> kill_one_shortcut <KeyStroke: u'Ctrl+Home'> >>> kill_one_shortcut <KeyStroke: u'Ctrl+End'> >>> kill_one_shortcut <KeyStroke: u'Ctrl+e'> >>> kill_one_shortcut <KeyStroke: u'F9'> >>> >>> >>> FWIW the 'myLeoSettings.leo' file is shared between these different >>> machines. I can't see any mention of parse-body in there though. >>> >>> Jon N >>> >> > Bingo - Thank you! > > In my defence I had tried something like that in the body in an early > experiment, without success. > > So my next question ... why does this (presumably) work in the thread I > mention earlier? I don't see any mention of a language setting being > required there. Perhaps Edward has a default setting somewhere that I don't? > > Thanks > Jon N > > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.
