Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Identify "active" region?



I'd like to write a widget that does

  if [[ there is an active region ]]
  then zle kill-region
  else zle backward-kill-word
  fi

(In fact, I'm tempted to write it in C and make it the default binding
for ^W, but that's somewhat beside the point of this message.)

There doesn't seem to be any way to determine that there's an active
region except to override set-mark-command and exchange-point-and-mark
to stash something in a global variable.  Have I missed something?

(I thought perhaps I could peek into $region_highlight in the latest
from CVS, but that doesn't update on the fly.)

Opinions on usefulness going forward of detecting the active region?
A distinguished value of MARK appears too problematic, so it'd have to
be another zle variable, or ...?

For the time being I'm using the less-than-satisfactory
  (( MARK > 0 && MARK != CURSOR ))
which isn't *that* bad since if I meant to kill all the way to the
beginning of the line I'd probably use kill-whole-line, and at worst
I just have to do exchange-point-and-mark first.



Messages sorted by: Reverse Date, Date, Thread, Author