This is what I would done:
Open leoSettings.leo, there is a menu command in the Settings menu.
Look at the node:
@settings-->Keyboard shortcuts-->@keys EKR bindings-->@shortcuts Cursor 
Moves

There you can see commands for moving cursor in the body pane and their 
default shortcuts.
To select word you can see there is a command named `extend-to-word` which 
by default is bound to Ctrl-w.
Then you can open LeoPyRef.leo (and make your own copy of that file with 
the name LeoPy.leo). Then you can use quick search or find to search for 
the string `extend-to-word` and you would get the node at the:
Code-->Command classes-->@file ../commands/editCommands.py-->class 
EditCommandsClass-->ec: move cursor-->ec.extend-to-word


There is the implementation of the command, so you can learn how it is done 
and perhaps find what you need to change to get the effect you want.

But you should not change that function. Instead you should copy the code 
to a new node and change it there. You can then make a script button out of 
this node but first you should change the headline to something like this:
my-new-word-search-command @key=Ctrl-Shift-f
Of course you should give it a meaningful name and choose shortcut to your 
liking.  When you make script button by clicking in the button in toolbar 
with the label `script-button`, the code inside this node and its subtree 
will be bound to the shortcut and every time you press this key combination 
the code will be executed.

As I understand you wish to start search for the word containing cursor and 
only in the current body. The script to do this is as follows:

c.editCommands.extendToWord(None)

c.frame.nav.children()[4].setCurrentIndex(4)

c.executeMinibufferCommand('find-quick-selected')



To construct this script I had to look in leoPlugins.leo in the 
quicksearch.py plugin, to find that c.frame.nav is the widget representing 
'Nav' pane. To find that combo box is the child at index 4, I used small 
script:
for ch in c.frame.nav.children():
    g.es(ch.objectName())
Looking in the combo box you can find that the item at index 4 is 'Node' 
for searching only inside current node.

Once you are satisfied with the command, you can change its headline to be 
'@command <name of command> @key=<shortcut>' , then copy and paste it in 
your myLeoSettings.leo under the `@settings` node. Every time you start Leo 
after this, it will have this command bound to your shortcut just as if it 
were a command implemented in the Leo core.

HTH Vitalije



On Tuesday, July 23, 2019 at 7:20:51 PM UTC+2, gar wrote:
>
> Stumbled with uncommon and uncomfortable editor behavior I decided to 
> improve it a little.
> I'd like to implement the following functions:
>
> - highlight word under cursor in the current edit
> - fast find word under cursor (similar to C-S-f but w/o but for the 
> current edit only and w/o need the word to be selected, like */# in vim)
> - jump to empty line above/below the current cursor position ({/} in vim)
> - highlight open/closing bracket (and jump to it as % does in vim)
> - delete line from here up to the begin/end (D in vim)
> - join lines (J in vim)
>
> This is the absolute minimum the editor must provide to make me like it :-)
>
> Can somebody please tell me 
>
> - which branch to take as a basis
> - what part of code to investigate (I tried to find something relevant and 
> failed, still dont understand where all this editor commands reside)
>
> Not sure that my attempt succeed but cannot suffer from this missing 
> features anymore :-)
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/bdadbc73-f45a-421c-beef-a91559da05e1%40googlegroups.com.

Reply via email to