FWIW the current options for doing this have always seemed a bit sub-optimal to me, due to the reasons you suggest. c.executeMinibufferCommand('name-of-command') seem like the wrong level to me, I should be able to call something 'lower down' than this...
On Monday, September 4, 2023 at 4:34:01 AM UTC+1 Félix wrote: > I agree, respecting existing parameter orders and signatures in general is > very important. But making it optional does not interfere with normal > usage. > > On Sunday, September 3, 2023 at 11:06:54 PM UTC-4 tbp1...@gmail.com wrote: > >> I've never encountered or used that method. But it's another case where >> I would resist changing the signature of an existing command. If it's only >> a matter of making and argument optional, that would be more palatable. >> The "events" in question here are not Python things but Leo objects. They >> often carry the "c" parameter, for example, so the command can access it. >> >> On Sunday, September 3, 2023 at 9:24:35 PM UTC-4 Félix wrote: >> >>> Having in mind a fresh new user's perspective, I wonder if >>> *doCommandByName*, *the method with the most intuitive name to use for >>> such a task to perform*, could not be relatively easily modified to >>> support not having an 'event' passed to it? >>> >>> ...I'm not familiar with those 'events' concepts in python so I'm >>> curious about Edwards thought on this matter. >>> >>> Hoping it can be changed easily ! :) >>> >>> Félix >>> >>> On Sunday, September 3, 2023 at 9:13:39 PM UTC-4 tbp1...@gmail.com >>> wrote: >>> >>>> There's also c.k.simulateCommand('name-of-command'). I'm not sure why >>>> there are both, since they seem to do the same thing. With either one, >>>> you >>>> don't need to supply a fake event. The method takes care of that. I use >>>> whichever one I remember first. >>>> >>>> On Sunday, September 3, 2023 at 9:08:31 PM UTC-4 gates...@gmail.com >>>> wrote: >>>> >>>>> I tend to use c.executeMinibufferCommand('name-of-command') -- doesn't >>>>> need any extra parameters, and Just Works TM. >>>>> >>>>> Jake >>>>> >>>>> On Sun, Sep 3, 2023 at 8:41 PM Félix <felix...@gmail.com> wrote: >>>>> >>>>>> Making script in Leo is great, with the globally defined vars g, c >>>>>> and p anything is possible. >>>>>> >>>>>> But what is the recommended way of doing a simple command by name in >>>>>> a script? >>>>>> >>>>>> The *c.doCommandByName* method exists, but it insists on having an >>>>>> event as a second parameter. >>>>>> >>>>>> I discovered that I can make it work by passing a fake event such as >>>>>> : {"c": c}, or even a better one: g.app.gui.create_key_event(c), but >>>>>> this >>>>>> is quite unintuitive. Could it not default to a valid default event if >>>>>> the >>>>>> event is not passed? >>>>>> >>>>>> Félix >>>>>> >>>>>> -- >>>>>> 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 leo-editor+...@googlegroups.com. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/leo-editor/68b44f92-c2fd-403b-97aa-58fba041d366n%40googlegroups.com >>>>>> >>>>>> <https://groups.google.com/d/msgid/leo-editor/68b44f92-c2fd-403b-97aa-58fba041d366n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- 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 leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/1583b47e-000f-45e8-ac4f-0c0e085fb09en%40googlegroups.com.