From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#46621: Copy line Date: Sun, 3 Jul 2022 19:21:33 +0200 Message-ID: <12B2D02B-5658-4AAC-B9A9-3E1E79F47C1D@acm.org> References: <87tuq99ova.fsf@mail.linkov.net> <07496A25-CD5D-46E6-8F1C-7BD29143F3C8@acm.org> <8335g1onbr.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_74E5CCB6-E974-4BA0-9790-633FE6ABA147" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16803"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46621@debbugs.gnu.org, larsi@gnus.org, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 03 19:22:09 2022 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 1o83IP-0004Co-MK for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Jul 2022 19:22:09 +0200 Original-Received: from localhost ([::1]:44190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o83IN-0005rv-Uz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Jul 2022 13:22:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o83II-0005rm-Fu for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2022 13:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o83II-0006Fh-7E for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2022 13:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o83II-00083N-2N for bug-gnu-emacs@gnu.org; Sun, 03 Jul 2022 13:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Jul 2022 17:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46621 X-GNU-PR-Package: emacs Original-Received: via spool by 46621-submit@debbugs.gnu.org id=B46621.165686890630933 (code B ref 46621); Sun, 03 Jul 2022 17:22:02 +0000 Original-Received: (at 46621) by debbugs.gnu.org; 3 Jul 2022 17:21:46 +0000 Original-Received: from localhost ([127.0.0.1]:45468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o83I2-00082r-Gw for submit@debbugs.gnu.org; Sun, 03 Jul 2022 13:21:46 -0400 Original-Received: from mail1443c50.megamailservers.eu ([91.136.14.43]:57646 helo=mail264c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o83Hz-00082Z-67 for 46621@debbugs.gnu.org; Sun, 03 Jul 2022 13:21:44 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1656868896; bh=KkZqXJPRMnklhaaS58BSp/T7UPT0hb3rLHTNHwwd0OI=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=cjJR+32QAkONKb0g5HY0fMMya+dKf3enLocQnkvZTFb7AgZ3f8RVe6TF82nOQOja/ Kjo/HUDlJZqVL3I3zeR32Q9Hc7MSpk3zMWSEOo/+QjjtfbMyXTh/Podw2RaqPJbkfa SyQYis2xJ34eCTlAc4AtNwH/aGbo1sjS6UzdDa/I= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail264c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 263HLXOj111958; Sun, 3 Jul 2022 17:21:35 +0000 In-Reply-To: <8335g1onbr.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A782F26.62C1D020.001B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE 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" Xref: news.gmane.io gmane.emacs.bugs:236014 Archived-At: --Apple-Mail=_74E5CCB6-E974-4BA0-9790-633FE6ABA147 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Here is an updated patch. It sounded like Eli was largely happy with it = but Lars wanted a change of name? I don't mind either, but please do tell. --Apple-Mail=_74E5CCB6-E974-4BA0-9790-633FE6ABA147 Content-Disposition: attachment; filename=0001-Make-duplicate-line-work-on-regions-bug-46621.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Make-duplicate-line-work-on-regions-bug-46621.patch" Content-Transfer-Encoding: quoted-printable =46rom=20aa0d3d5b1eadbc7adcf9d12461c5855a6847730a=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=2020=20Jun=202022=2011:16:26=20+0200=0A= Subject:=20[PATCH]=20Make=20duplicate-line=20work=20on=20regions=20= (bug#46621)=0A=0AWith=20an=20active=20region,=20duplicate=20that=20= region=20instead=20of=20the=20current=0Aline.=20=20Rectangular=20regions=20= are=20duplicated=20on=20the=20right-hand=20side.=0AThe=20region=20= remains=20active=20afterwards,=20to=20facilitate=20further=0Aduplication=20= or=20other=20operations=20on=20the=20same=20text.=0A=0A*=20lisp/rect.el=20= (rectangle--duplicate-right):=20New.=0A*=20lisp/misc.el=20= (duplicate-line):=20Work=20on=20regions.=0A*=20test/lisp/misc-tests.el=20= (misc--duplicate-line):=20Add=20tests.=0A---=0A=20etc/NEWS=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20|=20=202=20++=0A=20lisp/misc.el=20=20=20= =20=20=20=20=20=20=20=20=20|=2044=20= ++++++++++++++++++++++++++++++++++-------=0A=20lisp/rect.el=20=20=20=20=20= =20=20=20=20=20=20=20|=2021=20++++++++++++++++++++=0A=20= test/lisp/misc-tests.el=20|=2032=20+++++++++++++++++++++++++++++-=0A=204=20= files=20changed,=2091=20insertions(+),=208=20deletions(-)=0A=0Adiff=20= --git=20a/etc/NEWS=20b/etc/NEWS=0Aindex=203d679fdec6..1b9d690e92=20= 100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-372,6=20+372,8=20@@=20= between=20these=20modes=20while=20the=20user=20is=20inputting=20a=20= command=20by=20hitting=0A=20---=0A=20**=20New=20command=20= 'duplicate-line'.=0A=20This=20command=20duplicates=20the=20current=20= line=20the=20specified=20number=20of=20times.=0A+When=20the=20region=20= is=20active,=20the=20command=20duplicates=20that=20region=20instead,=0A= +on=20the=20right-hand=20side=20if=20the=20region=20is=20rectangular.=0A=20= =0A=20---=0A=20**=20Files=20with=20the=20'.eld'=20extension=20are=20now=20= visited=20in=20'lisp-data-mode'.=0Adiff=20--git=20a/lisp/misc.el=20= b/lisp/misc.el=0Aindex=208a01b51c6d..80ba1517c8=20100644=0A---=20= a/lisp/misc.el=0A+++=20b/lisp/misc.el=0A@@=20-63,21=20+63,51=20@@=20= copy-from-above-command=0A=20=09=09=09=09=20(+=20n=20(point)))))))=0A=20=20= =20=20=20(insert=20string)))=0A=20=0A+(declare-function=20= rectangle--duplicate-right=20"rect"=20(n))=0A+=0A+;;=20`duplicate-line'=20= preserves=20an=20active=20region=20and=20changes=20the=20buffer=0A+;;=20= outside=20of=20it:=20disregard=20the=20region=20when=20immediately=20= undoing=20the=0A+;;=20actions=20of=20this=20command.=0A+(put=20= 'duplicate-line=20'undo-inhibit-region=20t)=0A+=0A=20;;;###autoload=0A=20= (defun=20duplicate-line=20(&optional=20n)=0A=20=20=20"Duplicate=20the=20= current=20line=20N=20times.=0A+If=20the=20region=20is=20inactive,=20= duplicate=20the=20current=20line.=0A+Otherwise,=20duplicate=20the=20= region's=20contents.=20=20The=20region=20remains=20active.=0A+If=20the=20= region=20is=20rectangular,=20duplicate=20on=20its=20right-hand=20side.=0A= =20Interactively,=20N=20is=20the=20prefix=20numeric=20argument,=20and=20= defaults=20to=201.=0A=20Also=20see=20the=20`copy-from-above-command'=20= command."=0A=20=20=20(interactive=20"p")=0A=20=20=20(unless=20n=0A=20=20=20= =20=20(setq=20n=201))=0A-=20=20(let=20((line=20(buffer-substring=20= (line-beginning-position)=20(line-end-position))))=0A-=20=20=20=20= (save-excursion=0A-=20=20=20=20=20=20(forward-line=201)=0A-=20=20=20=20=20= =20(unless=20(bolp)=0A-=20=20=20=20=20=20=20=20(insert=20"\n"))=0A-=20=20= =20=20=20=20(dotimes=20(_=20n)=0A-=20=20=20=20=20=20=20=20(insert=20line=20= "\n")))))=0A+=20=20(cond=0A+=20=20=20;;=20Duplicate=20rectangle.=0A+=20=20= =20((bound-and-true-p=20rectangle-mark-mode)=0A+=20=20=20=20= (rectangle--duplicate-right=20n)=0A+=20=20=20=20(setq=20deactivate-mark=20= nil))=0A+=0A+=20=20=20;;=20Duplicate=20(contiguous)=20region.=0A+=20=20=20= ((use-region-p)=0A+=20=20=20=20(let*=20((beg=20(region-beginning))=0A+=20= =20=20=20=20=20=20=20=20=20=20(end=20(region-end))=0A+=20=20=20=20=20=20=20= =20=20=20=20(text=20(buffer-substring=20beg=20end)))=0A+=20=20=20=20=20=20= (save-excursion=0A+=20=20=20=20=20=20=20=20(goto-char=20end)=0A+=20=20=20= =20=20=20=20=20(dotimes=20(_=20n)=0A+=20=20=20=20=20=20=20=20=20=20= (insert=20text))))=0A+=20=20=20=20(setq=20deactivate-mark=20nil))=0A+=0A= +=20=20=20;;=20Duplicate=20line.=0A+=20=20=20(t=0A+=20=20=20=20(let=20= ((line=20(buffer-substring=20(line-beginning-position)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(line-end-position))))=0A+=20=20=20=20=20=20(save-excursion=0A= +=20=20=20=20=20=20=20=20(forward-line=201)=0A+=20=20=20=20=20=20=20=20= (unless=20(bolp)=0A+=20=20=20=20=20=20=20=20=20=20(insert=20"\n"))=0A+=20= =20=20=20=20=20=20=20(dotimes=20(_=20n)=0A+=20=20=20=20=20=20=20=20=20=20= (insert=20line=20"\n")))))))=0A=20=0A=20;;=20Variation=20of=20= `zap-to-char'.=0A=20=0Adiff=20--git=20a/lisp/rect.el=20b/lisp/rect.el=0A= index=20e717d2ac7e..c41a545e85=20100644=0A---=20a/lisp/rect.el=0A+++=20= b/lisp/rect.el=0A@@=20-931,6=20+931,27=20@@=20= rectangle--unhighlight-for-redisplay=0A=20=20=20=20=20(mapc=20= #'delete-overlay=20(nthcdr=205=20rol))=0A=20=20=20=20=20(setcar=20(cdr=20= rol)=20nil)))=0A=20=0A+(defun=20rectangle--duplicate-right=20(n)=0A+=20=20= "Duplicate=20the=20rectangular=20region=20N=20times=20on=20the=20= right-hand=20side."=0A+=20=20(let=20((cols=20(rectangle--pos-cols=20= (point)=20(mark))))=0A+=20=20=20=20(apply-on-rectangle=0A+=20=20=20=20=20= (lambda=20(startcol=20endcol)=0A+=20=20=20=20=20=20=20(let=20((lines=20= (list=20nil)))=0A+=20=20=20=20=20=20=20=20=20(extract-rectangle-line=20= startcol=20endcol=20lines)=0A+=20=20=20=20=20=20=20=20=20(move-to-column=20= endcol=20t)=0A+=20=20=20=20=20=20=20=20=20(dotimes=20(_=20n)=0A+=20=20=20= =20=20=20=20=20=20=20=20(insert=20(cadr=20lines)))))=0A+=20=20=20=20=20= (region-beginning)=20(region-end))=0A+=20=20=20=20;;=20Recompute=20the=20= rectangle=20state;=20no=20crutches=20should=20be=20needed=20now.=0A+=20=20= =20=20(let=20((p=20(point))=0A+=20=20=20=20=20=20=20=20=20=20(m=20= (mark)))=0A+=20=20=20=20=20=20(rectangle--reset-crutches)=0A+=20=20=20=20= =20=20(goto-char=20m)=0A+=20=20=20=20=20=20(move-to-column=20(cdr=20= cols)=20t)=0A+=20=20=20=20=20=20(set-mark=20(point))=0A+=20=20=20=20=20=20= (goto-char=20p)=0A+=20=20=20=20=20=20(move-to-column=20(car=20cols)=20= t))))=0A+=0A=20(provide=20'rect)=0A=20=0A=20;;;=20rect.el=20ends=20here=0A= diff=20--git=20a/test/lisp/misc-tests.el=20b/test/lisp/misc-tests.el=0A= index=20a56feaa049..83f82d0554=20100644=0A---=20= a/test/lisp/misc-tests.el=0A+++=20b/test/lisp/misc-tests.el=0A@@=20-80,6=20= +80,8=20@@=20misc-test-backward-to-word=0A=20=20=20=20=20= (backward-to-word=203)=0A=20=20=20=20=20(should=20(equal=20(point)=20= 1))))=0A=20=0A+(require=20'rect)=0A+=0A=20(ert-deftest=20= misc--duplicate-line=20()=0A=20=20=20;;=20Duplicate=20a=20line=20= (twice).=0A=20=20=20(with-temp-buffer=0A@@=20-88,13=20+90,41=20@@=20= misc--duplicate-line=0A=20=20=20=20=20(duplicate-line=202)=0A=20=20=20=20= =20(should=20(equal=20(buffer-string)=20"abc\ndefg\ndefg\ndefg\nh\n"))=0A= =20=20=20=20=20(should=20(equal=20(point)=207)))=0A+=0A=20=20=20;;=20= Duplicate=20a=20non-terminated=20line.=0A=20=20=20(with-temp-buffer=0A=20= =20=20=20=20(insert=20"abc")=0A=20=20=20=20=20(goto-char=202)=0A=20=20=20= =20=20(duplicate-line)=0A=20=20=20=20=20(should=20(equal=20= (buffer-string)=20"abc\nabc\n"))=0A-=20=20=20=20(should=20(equal=20= (point)=202))))=0A+=20=20=20=20(should=20(equal=20(point)=202)))=0A+=0A+=20= =20;;=20Duplicate=20a=20region.=0A+=20=20(with-temp-buffer=0A+=20=20=20=20= (insert=20"abc\ndef\n")=0A+=20=20=20=20(set-mark=202)=0A+=20=20=20=20= (goto-char=207)=0A+=20=20=20=20(transient-mark-mode)=0A+=20=20=20=20= (should=20(use-region-p))=0A+=20=20=20=20(duplicate-line)=0A+=20=20=20=20= (should=20(equal=20(buffer-string)=20"abc\ndebc\ndef\n"))=0A+=20=20=20=20= (should=20(equal=20(point)=207))=0A+=20=20=20=20(should=20= (region-active-p))=0A+=20=20=20=20(should=20(equal=20(mark)=202)))=0A+=0A= +=20=20;;=20Duplicate=20a=20rectangular=20region.=0A+=20=20= (with-temp-buffer=0A+=20=20=20=20(insert=20"x\n>a\n>bcde\n>fg\nyz\n")=0A= +=20=20=20=20(goto-char=204)=0A+=20=20=20=20(rectangle-mark-mode)=0A+=20=20= =20=20(goto-char=2015)=0A+=20=20=20=20(rectangle-forward-char=201)=0A+=20= =20=20=20(duplicate-line)=0A+=20=20=20=20(should=20(equal=20= (buffer-string)=20"x\n>a=20=20a=20=20\n>bcdbcde\n>fg=20fg=20\nyz\n"))=0A= +=20=20=20=20(should=20(equal=20(point)=2024))=0A+=20=20=20=20(should=20= (region-active-p))=0A+=20=20=20=20(should=20rectangle-mark-mode)=0A+=20=20= =20=20(should=20(equal=20(mark)=204))))=0A=20=0A=20(provide=20= 'misc-tests)=0A=20;;;=20misc-tests.el=20ends=20here=0A--=20=0A2.32.0=20= (Apple=20Git-132)=0A=0A= --Apple-Mail=_74E5CCB6-E974-4BA0-9790-633FE6ABA147--