File: Emacs_Kill_Region.bsh

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (27 lines) | stat: -rw-r--r-- 758 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
 * Emulate GNU Emacs's "kill-region" capability (normally bound to Ctrl-W),
 * which kills the text between the caret and the mark, copying it to the kill
 * ring. This version is slightly different: If there's any selected text, it
 * kills and copies that text. Otherwise, it selects the text between the
 * caret and the mark, and kills and copies that.
 *
 * Does NOT use jEdit markers.
 */
source (MiscUtilities.constructPath(dirname(scriptPath), "EmacsUtil.bsh"));

void emacsKillRegion()
{
    selection = getKillRegion();
    if (selection == null)
        beep();

    else
    {
        addToClipboardAndHistory (selection);
        textArea.replaceSelection ("");
        textArea.removeFromSelection (selection);
    }
}

emacsKillRegion();