Currently in mg, if the cursor is in a region and the 'delete' or 'backspace' keys are pressed mg will not behave any differently than if the cursor wasn't in a region. The diff below makes mg behave like emacs and kills the region and places it into the kill buffer.
ok? Mark Index: mg.1 =================================================================== RCS file: /cvs/src/usr.bin/mg/mg.1,v retrieving revision 1.109 diff -u -p -u -p -r1.109 mg.1 --- mg.1 13 Dec 2018 14:59:16 -0000 1.109 +++ mg.1 17 Dec 2018 16:34:41 -0000 @@ -475,6 +475,8 @@ Delete backwards characters. Like delete-char, this actually does a kill if presented with an argument. +If the cursor is in a region, the region is removed and placed +in to the kill buffer. .It delete-blank-lines Delete blank lines around dot. If dot is sitting on a blank line, this command @@ -486,6 +488,8 @@ Delete characters forward. If any argument is present, it kills rather than deletes, saving the result in the kill buffer. +If the cursor is in a region, the region is removed and placed +in to the kill buffer. .It delete-horizontal-space Delete any whitespace around the dot. .It delete-leading-space Index: util.c =================================================================== RCS file: /cvs/src/usr.bin/mg/util.c,v retrieving revision 1.38 diff -u -p -u -p -r1.38 util.c --- util.c 18 Nov 2015 18:21:06 -0000 1.38 +++ util.c 17 Dec 2018 16:34:41 -0000 @@ -411,7 +411,8 @@ indent(int f, int n) * Delete forward. This is real easy, because the basic delete routine does * all of the work. Watches for negative arguments, and does the right thing. * If any argument is present, it kills rather than deletes, to prevent loss - * of text if typed with a big argument. Normally bound to "C-D". + * of text if typed with a big argument. Normally bound to "C-d". + * If the cursor is in a region, kill the region. */ /* ARGSUSED */ int @@ -420,6 +421,9 @@ forwdel(int f, int n) if (n < 0) return (backdel(f | FFRAND, -n)); + if (curwp->w_markp != NULL) + return(killregion(FFRAND, 1)); + /* really a kill */ if (f & FFARG) { if ((lastflag & CFKILL) == 0) @@ -434,6 +438,7 @@ forwdel(int f, int n) * Delete backwards. This is quite easy too, because it's all done with * other functions. Just move the cursor back, and delete forwards. Like * delete forward, this actually does a kill if presented with an argument. + * If the cursor is in a region, kill the region. */ /* ARGSUSED */ int @@ -443,6 +448,9 @@ backdel(int f, int n) if (n < 0) return (forwdel(f | FFRAND, -n)); + + if (curwp->w_markp != NULL) + return (killregion(FFRAND, 1)); /* really a kill */ if (f & FFARG) {