GNU bug report logs -
#67925
29.1; delete-rectangle fails on multi-column characters
Previous Next
Reported by: awrhygty <at> outlook.com
Date: Wed, 20 Dec 2023 11:00:02 UTC
Severity: normal
Found in version 29.1
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: awrhygty <at> outlook.com
>> Date: Wed, 20 Dec 2023 19:58:49 +0900
>>
>>
>> If a multi-column character is crossing the start column of a intended
>> rectangle, no characters are deleted in the same line.
>>
>> For example, type 'C-x r d'(delete-rectangle) from column 1 to column 4
>> of the text below, the second line characters are not deleted.
>>
>> 01234
>> 一二4
>> 01234
>>
>> result:
>> 04
>> 一二4
>> 04
>>
>> This does not apply to #'kill-rectangle.
>> kill-rectangle result:
>> 04
>> 一4
>> 04
>
> Thanks. Does the patch below give good results?
>
> diff --git a/lisp/rect.el b/lisp/rect.el
> index 8dc188b..9049e32 100644
> --- a/lisp/rect.el
> +++ b/lisp/rect.el
> @@ -212,7 +212,10 @@ rectangle-dimensions
> (cons width height))))
>
> (defun delete-rectangle-line (startcol endcol fill)
> - (when (= (move-to-column startcol (if fill t 'coerce)) startcol)
> + ;; We use >= here, not =, for characters that use more than one
> + ;; column on display, when STARTCOL is in the middle of such a
> + ;; character.
> + (when (>= (move-to-column startcol (if fill t 'coerce)) startcol)
> (delete-region (point)
> (progn (move-to-column endcol 'coerce)
> (point)))))
This patch gives similar result of kill-rectangle.
In the example above, I want all '4' characters moved to same column.
And TAB characters crossing the end column are not edited correctly
with delete-rectangle if indent-tabs-mode is on.
012345678
8(TAB at head)
012345678
The text above is edited to the text below.
45678
8(TAB at head)
45678
If indent-tabs-mode is off, the result is the text below.
45678
8(four SPCs)
45678
This bug report was last modified 1 year and 232 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.