Re: feature request - insert headline before current
Hi Edward On Thursday, 26 September 2013 01:37:02 UTC+1, Edward K. Ream wrote: On Wed, Sep 25, 2013 at 5:00 PM, jkn jkn...@nicorp.f9.co.uk javascript: wrote: Spurred on by my triumph I have experimented with adding a new primitive of my own! Welcome to the world of Leo scripts. Yes indeed ;-). I've now worked out how to create a script and bind it to a key. Took me a while to realise that the @commands-@command part actually had to be @settings-@commands-@command but I think I'm there now. I've also added a couple of config settings: @string insert-headline-time-format-string= ... etc. into my myLeoSettings.leo. BTW there are a few references in the code to LeoConfig.txt, which i think no longer exists? Playing around with these sort of things is getting some good practice in using Leo, as well as thinking about its capabilities... Cheers Jon -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Thu, Sep 26, 2013 at 4:50 PM, jkn jkn...@nicorp.f9.co.uk wrote: BTW there are a few references in the code to LeoConfig.txt, which i think no longer exists? Ha. I didn't know that! Yes. There are a few comments about LeoConfig.txt. I'll remove them. Playing around with these sort of things is getting some good practice in using Leo, as well as thinking about its capabilities... I agree completely. Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
Hi Edward Ah - I think you didn't quite get what I was asking. I've got it now, so have written it below for reference and clarity: A pane-specific keybinding is *created* with entries in @settings-@keys-@shortcuts like: scroll-down-page ! tree = Next but it is *reported* (eg. if I press Tab in the minibuffer) in the form tree: Next = scroll-down-page I originally tried to use the latter form in my @shortcuts node. My changed settings were reported in that form, leading me to think it the setting had been applied, but didn't seem to actually work. When I changed it to the first form, all was fine. (But what is the 'Next' key?! I chose that just as an example, and only later I realised that I don't know what key refers to...) Thanks Regards 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Wednesday, 25 September 2013 22:17:26 UTC+1, jkn wrote: Hi Edward Ah - I think you didn't quite get what I was asking. I've got it now, so have written it below for reference and clarity: A pane-specific keybinding is *created* with entries in @settings-@keys-@shortcuts like: scroll-down-page ! tree = Next but it is *reported* (eg. if I press Tab in the minibuffer) in the form tree: Next = scroll-down-page I originally tried to use the latter form in my @shortcuts node. My changed settings were reported in that form, leading me to think it the setting had been applied, but didn't seem to actually work. When I changed it to the first form, all was fine. (But what is the 'Next' key?! I chose that just as an example, and only later I realised that I don't know what key refers to...) Thanks Regards 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
(oops, apologies for double-posting ... Google Groups grr...) Spurred on by my triumph I have experimented with adding a new primitive of my own! This allows me to have a key combination to expend or contract a node depending on its current state. Apologies if there's already a way of doing this ... I submit the following for possible inclusion into Leo: {{{ in leoCommands.py def toggleExpandState (self,event=None): Toggle the expand state of the current node trace = False and not g.unitTesting c = self; p = c.p # set up the functions to call if p.isExpanded(): fa = p.contract frd = c.redraw_after_contract else: fa = p.expand frd = c.redraw_after_expand # perform the calls fa() if p.isCloned(): if trace: g.trace('***redraw') c.redraw() else: frd(p,setFocus=True) }}} and the obvious entry in leoEditCommands.py: {{{ 'toggle-expand-state': c.toggleExpandState, }}} I bind this to Ctrl-E (Expand) and Ctrl-H (Hide) FWIW. Cheers 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Wed, Sep 25, 2013 at 5:00 PM, jkn jkn...@nicorp.f9.co.uk wrote: Spurred on by my triumph I have experimented with adding a new primitive of my own! Welcome to the world of Leo scripts. Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
Hi Fidel Jacob Thanks both - that's very useful and just the sort of experimenting that will be good for me to have a go at ;-) Regards 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Sun, Sep 22, 2013 at 5:16 PM, Fidel N fidelpe...@gmail.com wrote: This quick script will do what you need ... c.p.insertAfter() c.executeMinibufferCommand('goto-next-sibling') c.executeMinibufferCommand('move-outline-up') c.executeMinibufferCommand('edit-headline') c.redraw() A good start, but the script does not handle undo properly. I'll attempt an improvement. Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
The day I post a script and Edward cant improve ill consider myself Leo literate hehehe On Monday, September 23, 2013 3:19:05 PM UTC+2, Edward K. Ream wrote: On Sun, Sep 22, 2013 at 5:16 PM, Fidel N fidel...@gmail.com javascript: wrote: This quick script will do what you need ... c.p.insertAfter() c.executeMinibufferCommand('goto-next-sibling') c.executeMinibufferCommand('move-outline-up') c.executeMinibufferCommand('edit-headline') c.redraw() A good start, but the script does not handle undo properly. I'll attempt an improvement. Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Sun, 22 Sep 2013 15:16:16 -0700 (PDT) Fidel N fidelpe...@gmail.com wrote: c.p.insertAfter() c.executeMinibufferCommand('goto-next-sibling') c.executeMinibufferCommand('move-outline-up') c.executeMinibufferCommand('edit-headline') c.redraw() It's interesting that I wouldn't think of using executeMinibufferCommand, but in some ways the API is cleaner when you do. I'd so something like nd = p.insertAfter() # nd.moveToThreadBack()... wait, that's not right... # some p.move* methods move the position, some move the node... # source browsing required to get this nd.moveToNthChildOf(p.parent(), p.childIndex()-1) # no idea what the method for entering edit mode is, read source c.editHeadline() c.redraw() or more succinctly nd = p.insertAfter() nd.moveToNthChildOf(p.parent(), p.childIndex()-1) c.editHeadline() c.redraw() so one line shorter, but it doesn't work for top level nodes... So, executeMinibufferCommand really is a simpler, cleaner, approach in some cases (undo not withstanding ;-) Cheers -Terry -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Monday, 23 September 2013 14:19:05 UTC+1, Edward K. Ream wrote: [...] A good start, but the script does not handle undo properly. I'll attempt an improvement. Edward Heh - it was in part understanding the the undo functionality that put me off trying to 'replicate' insertHeadline(), at first anyway. Improvements very gratefully received, I'm hoping I can learn from this discussion, 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Mon, Sep 23, 2013 at 8:19 AM, Edward K. Ream edream...@gmail.com wrote: A good start, but the script does not handle undo properly. I'll attempt an improvement. Rev 6030 adds the new insert-node-before command. It's a fairly straightforward mod of the insert-node command, but there are two complications: 1. It properly handles inserts of top-level nodes. 2. It gives a warning message and does nothing if one attempts to insert a node before the first node of a hoisted outline. Surprisingly, the undo code seems to work using the same undo helpers used by the insert-node command. Undo happens properly in all the situations I've tested, but bugs may lurk. I did add a new unit test for insert-node-before that performs a rudimentary undo test. Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
Hi Edward On Monday, 23 September 2013 15:45:49 UTC+1, Edward K. Ream wrote: On Mon, Sep 23, 2013 at 8:19 AM, Edward K. Ream edre...@gmail.comjavascript: wrote: A good start, but the script does not handle undo properly. I'll attempt an improvement. Rev 6030 adds the new insert-node-before command. many thanks, I'll be trying it out tonight, I hope. One thing, you might want to correct the docstring ;-o 4282 #@+node:ekr.20130922133218.11540: *7* c.insertHeadlineBefore (new in Leo 4.11) 4283 def insertHeadlineBefore (self,event=None): 4284 4285 '''Insert a node after the presently selected node.''' Regards 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Mon, Sep 23, 2013 at 8:43 AM, Terry Brown terry_n_br...@yahoo.comwrote: I'd d o something like : nd = p.insertAfter() nd.moveToNthChildOf(p.parent(), p.childIndex()-1) This will fail in several ways. As you imply, p.parent() does not exist for top-level nodes. Second, undo will spoil the previous hoist result if p is at the top of c.hoistStack. See c.insertHeadlineBefore for details. Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Mon, Sep 23, 2013 at 11:18 AM, jkn jkn...@nicorp.f9.co.uk wrote: you might want to correct the docstring ;-o Fixed at rev 6032. EKR -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
Hi Edward On Monday, 23 September 2013 19:18:26 UTC+1, Edward K. Ream wrote: On Mon, Sep 23, 2013 at 11:18 AM, jkn jkn...@nicorp.f9.co.ukjavascript: wrote: you might want to correct the docstring ;-o Fixed at rev 6032. EKR Looking good, thanks very much! And I can now see eg. def insertHeadline(...) in LeoCommands.py ... not sure why my search-fu wasn't working earlier. I do have a supplementary question ... It looks like you can use 'context' when defining keybindings, for instance a keybinding can be listed as tree: Next = scroll-down-page text: Next = scroll-down-page but I'm not 100% convinced that this is the syntax I should be using in my @settings|@keys|@shortcuts nodes- can you confirm? Thanks muchly 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
On Mon, Sep 23, 2013 at 5:08 PM, jkn jkn...@nicorp.f9.co.uk wrote: It looks like you can use 'context' when defining keybindings, for instance a keybinding can be listed as tree: Next = scroll-down-page text: Next = scroll-down-page but I'm not 100% convinced that this is the syntax I should be using in my @settings|@keys|@shortcuts nodes- can you confirm? Yes, that's correct. There are plenty of examples in leoSettings.leo. The standard term for context is pane-specific bindings. See leoSettings.leo: #@settings--Keyboard shortcuts--About keyboard shortcuts Edward -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
feature request - insert headline before current
Hi Edward (Background - I am experimenting with changing my Leo Key bindings to make it work more closely to other (lesser ;-) outliners I am more used to than Leo) One thing that I think is missing from Leo is a primitive command 'insert headline before current'. I would like to bind 'Insert' to this rather than ''insert-node', which of course inserts after the current headline. I've taken a quick look at def insertHeadline() in key-handling-notes.txt but I'm not initially confident of making the necessary additions. Would it be appropriate to raise a wishlist item for this? Thanks. Also, whilst I'm looking at the source - can you explain to me where/how 'key-handling-notes.txt is 'included' as part of Leo? I can't work this out from an initial skim... Thanks a lot 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
Hey Jkn: This quick script will do what you need, although Im pretty sure someone here will update it with something more eficcient =P c.p.insertAfter() c.executeMinibufferCommand('goto-next-sibling') c.executeMinibufferCommand('move-outline-up') c.executeMinibufferCommand('edit-headline') c.redraw() Just run that code (you can make it a button then click it from any node) and it will do what you need. On Monday, September 23, 2013 12:07:04 AM UTC+2, jkn wrote: Hi Edward (Background - I am experimenting with changing my Leo Key bindings to make it work more closely to other (lesser ;-) outliners I am more used to than Leo) One thing that I think is missing from Leo is a primitive command 'insert headline before current'. I would like to bind 'Insert' to this rather than ''insert-node', which of course inserts after the current headline. I've taken a quick look at def insertHeadline() in key-handling-notes.txt but I'm not initially confident of making the necessary additions. Would it be appropriate to raise a wishlist item for this? Thanks. Also, whilst I'm looking at the source - can you explain to me where/how 'key-handling-notes.txt is 'included' as part of Leo? I can't work this out from an initial skim... Thanks a lot 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.
Re: feature request - insert headline before current
To make this a command (which you can bind to with a key), in myLeoSettings.leo, make the node @commands, and then under it, a node @command insert-node-before. Then bind a key to insert-node-before and you're golden. Nice script, Fidel. That's exactly what I would have done :) --Jake On 9/22/2013 6:16 PM, Fidel N wrote: Hey Jkn: This quick script will do what you need, although Im pretty sure someone here will update it with something more eficcient =P c.p.insertAfter() c.executeMinibufferCommand('goto-next-sibling') c.executeMinibufferCommand('move-outline-up') c.executeMinibufferCommand('edit-headline') c.redraw() Just run that code (you can make it a button then click it from any node) and it will do what you need. On Monday, September 23, 2013 12:07:04 AM UTC+2, jkn wrote: Hi Edward (Background - I am experimenting with changing my Leo Key bindings to make it work more closely to other (lesser ;-) outliners I am more used to than Leo) One thing that I think is missing from Leo is a primitive command 'insert headline before current'. I would like to bind 'Insert' to this rather than ''insert-node', which of course inserts after the current headline. I've taken a quick look at def insertHeadline() in key-handling-notes.txt but I'm not initially confident of making the necessary additions. Would it be appropriate to raise a wishlist item for this? Thanks. Also, whilst I'm looking at the source - can you explain to me where/how 'key-handling-notes.txt is 'included' as part of Leo? I can't work this out from an initial skim... Thanks a lot 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out. -- 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 post to this group, send email to leo-editor@googlegroups.com. Visit this group at http://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/groups/opt_out.