486Easy way to get exact position in buffer? (Motivation: get region size?)
- Dec 5, 2001What's an easy way to get the cursor's exact position (char #) within
The hard and messy way is to use buffer-info and then parse the
$result string to pull out the char number:
Line 1845/3955 Col 0.0 Char 78267/167172 (46%) Win Line 99/48 Col/0/0
char = 0xA
Or, how about an easy way to get the region's size?
This is not reliable: (not even sure what it does -- 0x02 tells if
the region is "fixed" -- what does that mean?)
!if ¬ &band $result 0x02
ml-write "[No region selected]"
What I'm trying to do is write a safety wrapper around copy-region
(and kill-region) to prevent them from copying empty regions (which
crashes the Exceed X server application when it's set to auto-paste
the clipboard -- yes, I believe it's a bug -- this is v6.2).
Something along the lines of:
set $x <get current location>
set $y <get other location>
!if &equal $x $y
<complain and abort>
Thanks for any ideas,
- Next post in topic >>