From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: master 6362f65474: Add new command `duplicate-line' Date: Sat, 18 Jun 2022 18:30:43 +0200 Message-ID: <20220618163043.g4r2a5inkldmwjue@Ergus> References: <165548727183.24473.6170306052807994962@vcs2.savannah.gnu.org> <20220617173432.17B6FC00BAF@vcs2.savannah.gnu.org> <87ilozrxqp.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17015"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org, Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 18 18:32:26 2022 Return-path: Envelope-to: ged-emacs-devel@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 1o2bN4-0004DI-9h for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Jun 2022 18:32:26 +0200 Original-Received: from localhost ([::1]:53144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2bN2-0003aS-N3 for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Jun 2022 12:32:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2bLv-0002sd-BP for emacs-devel@gnu.org; Sat, 18 Jun 2022 12:31:15 -0400 Original-Received: from sonic302-2.consmr.mail.bf2.yahoo.com ([74.6.135.41]:39837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2bLr-0005Uk-FC for emacs-devel@gnu.org; Sat, 18 Jun 2022 12:31:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1655569851; bh=bzuF5nJGmJQK+SiKi5ZJySmP8FRAh+xjss4PwEJGB2g=; h=Date:From:To:Subject:References:In-Reply-To:From:Subject:Reply-To; b=FwA40u6HoStzmaUqa13Si3uoVt8x+7wuRhyHCrZyprDPVpAPBkQnT6b3yl8tfCdS6viEUMakx7kOeLzjbuCLn+sXNflOAWiML65rZg6DGCa0IjYZJc8wgb6C3fdSA0l+c3zZf23Ykplk7LBITVbeTMS1ej9aoTjBkeQBeDkQflKsuwHM5EUh3QSR+pvBLjZtDNEHkkaXuZEW32IBxnV6aZAhWWPKt1BDydyVhCq49F7CHkd0p9iw7b6DbZDQ7kAH0N9VQ9XnQ3nYOXFY/GcQG6JNCc+CeIL5NE6dxRbGDjzIoOuNdw5ToWMnz0wbllHB8O5bk9SGV0FBJ1sIsrPg3Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1655569851; bh=T1sfF5EeKDXY5lE5fm7Ly9EOSh9Vjkw0lg/CBSKgbdr=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=oVP5FWze3wbxPVuGlO8/n2XQZrnm3LirqfnPh6MIbq2cm9sbTbd5LhVJgPAw7xZJfefE1jmWta/LbLZEqVcHn9NzqOEbvWi2w3mxZSyQqmtIPszpaHZyJkhMeNifbbPJB8zIGyFEybTWVH4RXj+ur1q0dX6OftAf6XzvB5EgGk6TyxfY3LErWRaO5ppLLFanOV9IAjEV0lHG0Ws3cQevFEvhFmTTtCZM1zeByF69SkLY8NUnl8yR+tcPYiKBd11Fta6QVJaVOejvyuCpFQ4KqRtDnxMWbPvxfUWA1fqSCvSRZxEXrMqIUuM9Kv9I8pKB1i7I0CGed05xp/lDVMt4xQ== X-YMail-OSG: hBCWi9MVM1k.dG1xFtmR_ng2TI0Fiz.zxlrXd3cN10hKW.Rj5luRX1FVrwduk8N cAbSj0F_HOZ4c7kL_WCEwoYvfxgeZBTRp32TfMYN3lW3bVwgcfU0obyufc4wd_a85J98xDmZc7_I rNfzVLsLGyn5Nhb1tqYqkTkjcLF3fPvDOAmqV9GXDntMZFdVbRbE0iawK72E0UeQXCkLWbovB3sV a.IN3BF.QEcPHu5xQ_lXHP8.eRn38St8YmtPkCXvIWZ10ntPsdA9vTT1Q3J7yGggS1Jtz4FF6QNY GzmHLlPtcxja0Z5R8OsjQIR7JMHKZeAdOJ.IFqG4d1tMAdfdBo6RV9piv4lKGQ84s.Tmt.54u2.r WpaGUGW0MXhHv_Q4hPw7KbQIVcRj7zYabIM1To4BTwZ4eg5XNwS1Um1diVgVhJj8gN55AM57FVeg Ipwvr4AHB5dw2pNfskC9LBKhgkbtfxpQSLQyojVeprA4e1XqzluqlvojWbUAzt.S8rT9WcCO0TT5 YH6aG.1UVcAP.zYDzyOePMiODNLl1zY.Bk.4KmeseZ.bD_uUX_omt4JZz3KKiO8japC0Tw.135YH qQA98.DRILTHbZP6jhNCjwgJ3_zp5QEtsDwS7cP4z3Z.MU7nADsvEa.o37O6ZfogJjucVpM3sah4 S7myleWx3E_5zU4470iveDDtT3p7AfFL9qA6t7L520xYy1rb9Ynj1FkGeHhcdLr._gWvn05A4Mm1 cHO5AijqXswfaaM2oBDWSDHsc4j7pqvYOlgmkcnzCfjc3HWxfWM2G1iRSQZAR_6JjhcnL1CRQz.2 z6soDRGlVvTCInGfkcnIO0leXYCBaGQXPAwMBcEdpJ X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.bf2.yahoo.com with HTTP; Sat, 18 Jun 2022 16:30:51 +0000 Original-Received: by hermes--canary-production-ir2-c9bf9d9bc-2x4fh (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 57863163dc045ccda299ea920197dfbb; Sat, 18 Jun 2022 16:30:45 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87ilozrxqp.fsf@gmail.com> X-Mailer: WebService/1.1.20280 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.135.41; envelope-from=spacibba@aol.com; helo=sonic302-2.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291377 Archived-At: Hi: I saw this command and I would like to make some suggestions very simple to implement, but that provides some consistency and improve user interaction. 1) Could we consider to move the cursor when duplicate-line based on prefix value? This may be useful to bind the command giving a more intuitive behavior. For example: USERPREFIX- and USERPREFIX-. Actually the current command `duplicate-line' is what I expect for USERPREFIX-, which "emulates" like "we have duplicated before or up". Many packages around try to implement such commands because they are available y sublime ad VS-Code... for example: https://github.com/wyuenho/move-dup/blob/master/move-dup.el 2) From the same package may we consider a command "move-line", which in the same fashion the user could bind to move the current line up/down? 3) Could we provide a consistent alternative to all mark-? commands? Because mark-work selects from the current position to the end of the work, but mark-sexp or mark-paragraph marks the whole current sexp/paragraph... moving the cursor to the beginning maybe as mark-word is a current a long standing command we may provide an alternative like mark-current-word or similes... The idea behind this is to provide a more consistent API that avoids to wrap all per-case commands like transpose-word could have bother like duplicate-work with just a few lines. 4) Could we provide a mark-line command to complete the family of mark-something commands? Actually all this could rely on thing-at-point api right? Best, Ergus On Fri, Jun 17, 2022 at 11:14:14PM +0530, Visuwesh wrote: >[வெள்ளி ஜூன் 17, 2022 13:34] Lars Ingebrigtsen wrote: > >> branch: master >> commit 6362f65474bad81c1d57b9b603c65686a0dd853e >> Author: Lars Ingebrigtsen >> Commit: Lars Ingebrigtsen >> >> Add new command `duplicate-line' >> >> * lisp/misc.el (copy-from-above-command): Mention it. >> (duplicate-line): New command (bug#46621). >> --- >> etc/NEWS | 4 ++++ >> lisp/misc.el | 17 ++++++++++++++++- >> 2 files changed, 20 insertions(+), 1 deletion(-) >> >> diff --git a/etc/NEWS b/etc/NEWS >> index 3b9515c2d4..d27c18f4ec 100644 >> --- a/etc/NEWS >> +++ b/etc/NEWS >> @@ -298,6 +298,10 @@ startup. Previously, these functions ignored >> >> * Changes in Emacs 29.1 >> >> +--- >> +** New command 'duplicate-line'. >> +This command duplicates the current line the specified number of times. >> + >> --- >> ** Files with the '.eld' extension are now visited in 'lisp-data-mode'. >> >> diff --git a/lisp/misc.el b/lisp/misc.el >> index 0bb8ee6c7b..88932681c1 100644 >> --- a/lisp/misc.el >> +++ b/lisp/misc.el >> @@ -33,7 +33,9 @@ >> "Copy characters from previous nonblank line, starting just above point. >> Copy ARG characters, but not past the end of that line. >> If no argument given, copy the entire rest of the line. >> -The characters copied are inserted in the buffer before point." >> +The characters copied are inserted in the buffer before point. >> + >> +Also see the `copy-line' command." > >Shouldn't this be `duplicate-line'? > >> (interactive "P") >> (let ((cc (current-column)) >> n >> @@ -61,6 +63,19 @@ The characters copied are inserted in the buffer before point." >> (+ n (point))))))) >> (insert string))) >> >> +;;;###autoload >> +(defun duplicate-line (&optional n) >> + "Duplicate the current line N times. >> +Also see the `copy-from-above-command' command." >> + (interactive "p") >> + (let ((line (buffer-substring (line-beginning-position) (line-end-position)))) >> + (save-excursion >> + (forward-line 1) >> + (unless (bolp) >> + (insert "\n")) >> + (dotimes (_ n) >> + (insert line "\n"))))) >> + >> ;; Variation of `zap-to-char'. >> >> ;;;###autoload >