From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#67925: 29.1; delete-rectangle fails on multi-column characters Date: Thu, 21 Dec 2023 10:42:35 +0200 Message-ID: <831qbggd50.fsf@gnu.org> References: <83il4tge2z.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7486"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67925@debbugs.gnu.org To: awrhygty@outlook.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 21 09:44:36 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rGEfU-0001jn-9Q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 21 Dec 2023 09:44:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rGEfC-0006yi-EH; Thu, 21 Dec 2023 03:44:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGEet-0006yD-Lr for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2023 03:44:00 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rGEet-00017h-Dx for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2023 03:43:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rGEew-0002M0-Fw for bug-gnu-emacs@gnu.org; Thu, 21 Dec 2023 03:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Dec 2023 08:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67925 X-GNU-PR-Package: emacs Original-Received: via spool by 67925-submit@debbugs.gnu.org id=B67925.17031481868971 (code B ref 67925); Thu, 21 Dec 2023 08:44:02 +0000 Original-Received: (at 67925) by debbugs.gnu.org; 21 Dec 2023 08:43:06 +0000 Original-Received: from localhost ([127.0.0.1]:42353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGEe1-0002Kd-GD for submit@debbugs.gnu.org; Thu, 21 Dec 2023 03:43:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rGEdv-0002K4-2h for 67925@debbugs.gnu.org; Thu, 21 Dec 2023 03:43:03 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rGEdl-0000qm-Pq; Thu, 21 Dec 2023 03:42:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=KEHwgiwyEqHDVE9n6cuxFaZvVm86HH2mrEYjQ69RNRs=; b=GrwLbmMrrqtv 3GlSPh1NLuP/8Rvj/6ZqNkXv3yXPaLPlHM5nKhMa7gW47sAkVfUxvkqjoSW4WHy9XFlKMYd8+ao0d 6z9ViPS6Oq2nj+FHp0gFRRpXNFSQpY6fg/+d5jiHcsufb4Lay0I1ONDP0gpcYetRq8cKX29djqiGU qGruR91gq82b8g0GbrOdB4NkW3UY7CbGSonRaPia0KRzJ/zVerRW79YpVDLeSygmlHmbdNagUz2j0 UeMNh+x/LFDG8Q67vlVDEWvJvuJFmGBg37+Slw1toD40Nw4TQRFWc6uV0BPphCAnoUd+U0b4TpmF1 HC2oTwbK0JdK2OeRR5BiRQ==; In-Reply-To: (awrhygty@outlook.com) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276617 Archived-At: > From: awrhygty@outlook.com > Cc: 67925@debbugs.gnu.org > Date: Thu, 21 Dec 2023 16:30:39 +0900 > > Eli Zaretskii 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. So I think the effect you see after the patch I proposed is the only reasonable outcome. If that is not good enough for keeping the layout of some table (as you hint in your original report, without showing any details about the mode used in that case), then Lisp programs which allow you to keep such tables aligned should be modified to do something that cannot be done in general by delete-rectangle. IOW, the general issue in delete-rectangle cannot do anything smarter than the above, I think, and any solution specific to some particular implementation or use of rectangles will have to be fixed by code specific to that particular implementation (if that is some mode that is part of Emacs). > 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.