- Hi all,
I ran into a strange problem! Given the following macro
; should work, but is buggy,
; if region was marked by mouse or by shift-motion
set-variable #l1 @y
set-variable #l1 ""
; if no region is visibly marked then
; nothing should be cut or inserted, right?
Run this piece of code and look for yourself at the following constellations:
- mark a region with C-space, all works fine
- mark a region with Shift-Right (cursor motion), then you get the
already reported "double the region" behaviour
- but now something new: if nothing seems to be marked (C-g), then still
something is cut and yanked back. Why?
My goal was to write a macro that could either be used when having a
region marked (then incorporate the region) but also without any marked
stuff (then insert a new and empty construct).
Any ideas how to do that?
Gruß / Regards
Da sie sich für weise hielten, sind sie zu Narren geworden. Rö 1,22
>This is because the last thing the shift region macro does is copy the region i.e. consider the shift region to be equivalent to calling copy-region. Try doing:
> Run this piece of code and look for yourself at the following
> - mark a region with C-space, all works fine
> - mark a region with Shift-Right (cursor motion), then you get the
> already reported "double the region" behaviour
And you get the same problem. The reason for this behaviour is because your macro calls kill-region first and a copy-region followed by a kill-region will always lead to 2 copies of the text in the yank buffer.
You could fix this issue by tricking ME into thinking the last command was NOT a copy or kill command, i.e. try:
set-variable @cl void
However there is another more serious issue with this macro, try selecting a large region and then calling this macro - make sure you have undo enabled!
you will find that only the first 1024 bytes of the region remains, the rest has been removed due to the limit in the size of an ME variable which is 1024 chars - the yank buffer has no limit. A fix to this issue could be:
set-variable @cl void
> - but now something new: if nothing seems to be marked (C-g), then stillThere seems to be some confusion here between the use of a set-mark region and the visible region which is understandable as this is a rather grey area, consider:
> something is cut and yanked back. Why?
- Once you have set a mark in a buffer that buffer will always have a mark, i.e. copy-region will always 'work' even if the region is empty, the 'mark' region does not need to be visible for the copy-region command to work which is exactly how you macro is currently working. Try calling kill-region instead of latex-test-yank and you will see the same behaviour.
- Try searching for a string, if found the string is now shown as a visible region, try calling your macro now - it does not wrap the search string in brackets because the search function does not (and must not) set the mark position.
The mark region and shown region are only the same immediately after a copy-region.
You need to decide which region you want your macro to use and if its the shown region then you will need to use the show-region command, look in the standard macro release for examples of its use.
> My goal was to write a macro that could either be used when having a
> region marked (then incorporate the region) but also without any marked
> stuff (then insert a new and empty construct).
> Any ideas how to do that?
> Gruß / Regards
> http://home.in.tum.de/~boeckler/ http://www.spiegel.de/zwiebelfisch
> Da sie sich für weise hielten, sind sie zu Narren geworden. Rö 1,22
> This is an unmoderated list. JASSPA is not responsible for the content of
> any material posted to this list.
> To unsubscribe, send a mail message to
> or visit http://groups.yahoo.com/group/jasspa and
> modify your account settings manually.
> Yahoo! Groups Links