GNU bug report logs - #67925
29.1; delete-rectangle fails on multi-column characters

Previous Next

Package: emacs;

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


Message #17 received at 67925 <at> debbugs.gnu.org (full text, mbox):

From: awrhygty <at> outlook.com
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 67925 <at> debbugs.gnu.org
Subject: Re: bug#67925: 29.1; delete-rectangle fails on multi-column characters
Date: Thu, 21 Dec 2023 23:26:05 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: awrhygty <at> outlook.com
>> Cc: 67925 <at> debbugs.gnu.org
>> Date: Thu, 21 Dec 2023 16:30:39 +0900
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > 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.
>
> How can that be done, when the first character takes 2 or more
> columns?  Deleting the first character is IMO wrong, since the other
> lines leave the first character intact.  Adding SPC to other lines is
> also wrong, since delete-rectangle is not supposed to _add_ columns.

I think wide characters may be replaced with SPC like TAB.

>> 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 is a separate issue with the original code.  It also happens with
> kill-rectangle, btw.  We could fix it by temporarily binding
> indent-tabs-mode to nil inside these commands -- would that be
> acceptable?  The result will be that the killed rectangle includes
> spaces, not the leading TAB.

I prefer that the killed rectangle has same column for each line.
If TAB is included when yanking, the current column affects the width of
the yanked string for each line.




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.