This plugin is a first attempt to give Leo a Ctrl-Backspace and Ctrl-Delete like most other editors.

This is now obsolete, as it has since been merged into the core and improved. It should be in Leo release version 4.8.

To use, bind the commands "delete-word" and "backward-delete-word".

#@+leo-ver=5-thin
#@+node:samh.20100813204026.32343: * @thin delete_word.py
#@@language python
#@@tabwidth -4

#@+<< docstring >>
#@+node:samh.20100815151753.5431: ** << docstring >>
'''
These commands implement a more standard Ctrl-Backspace and Ctrl-Delete,
similar to what is seen in most editors on Windows and Linux.
'''
#@-<< docstring >>

__version__ = "0.1"

import leo.core.leoGlobals as g

@g.command('delete-word')
def deleteWord(event):
    deleteWordHelper(event, forward=True)

@g.command('backward-delete-word')
def backwardDeleteWord(event):
    deleteWordHelper(event, forward=False)

#@+others
#@+node:samh.20100815151753.5433: ** deleteWordHelper
def deleteWordHelper(event, forward):
    c = event['c']
    #u = c.undoer
    w = c.frame.body.bodyCtrl
    #p = c.p

    undoType = "delete-word"
    #undoData = u.beforeChangeNodeContents(p)
    c.editCommands.beginCommand(undoType=undoType)

    from_pos = w.getInsertPoint()
    c.editCommands.moveWordHelper(None,extend=False,forward=forward)
    to_pos = w.getInsertPoint()

    w.delete(from_pos, to_pos)

    c.frame.body.forceFullRecolor()

    #u.afterChangeNodeContents(p, undoType, undoData)
    #c.setChanged(True)
    c.editCommands.endCommand(changed=True, setLabel=True)
#@-others
#@-leo