From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pedro Andres Aranda Gutierrez Newsgroups: gmane.emacs.devel Subject: Re: master 6362f65474: Add new command `duplicate-line' Date: Sun, 19 Jun 2022 07:53:39 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000071598705e1c69dd1" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34575"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 19 07:55:14 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 1o2ntx-0008rZ-Gm for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Jun 2022 07:55:13 +0200 Original-Received: from localhost ([::1]:35778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2ntv-0002Ir-TW for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Jun 2022 01:55:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2nsw-0001cL-18 for emacs-devel@gnu.org; Sun, 19 Jun 2022 01:54:10 -0400 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:41702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o2nst-0002cG-9V for emacs-devel@gnu.org; Sun, 19 Jun 2022 01:54:09 -0400 Original-Received: by mail-ed1-x531.google.com with SMTP id cf14so1255695edb.8 for ; Sat, 18 Jun 2022 22:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=pexQdK4rkntHdw9/1Hbh9WHjIZexk+QV19DUyxA3bBg=; b=ZTFs2UDCRkmaQXdsIKxt87YfYNyAxf4JImwMSMuPYX9js4XStcfY0Prrrw8hOfMBBF FgxXPKY1RDHfjr4IQNVTpjEwq1GuKkBEZLtS1/xK54EEI4GU9FLDl3CueFcAczFQ0UEY Z/rYVGXAELPtzMdHD0xjwwzqZe9Sh/E/DftZbHEYryZ4UIIPgL1WzioUw1d+saqzIZ/C sNARNu4azDeArIjJAJaYBQNYX7ZAPopnQArjrwAdnthkBuL+9+cBUgsLOk3mxY7OAoaW fVeDGe8RmUo4BL+HlP+1WJITyfmjmBGgCzVOIzLjftYW50QpJ0SLtz1CHv/CDnm0ZPMs TJ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=pexQdK4rkntHdw9/1Hbh9WHjIZexk+QV19DUyxA3bBg=; b=0ZYY6JdW63fzxsUJmM8PeJAonryMB1HR8AGW4zWWk6dAvwdBn7oySUh805bZmiwRZX HBSQnpTgGJoMrihOS+LwM63cTeGZEEX/UGQaVygJHbxdObwh0CBzg8TlBhf/lJmsiaoh +uvSxV7ScS8HaX+yfqECKEscif/6HkAqMmv/SEudKvr9LIKmHamKF5VtNW9rDHqbasBd OktoHdz4/3DvBRmHalba/f9cxA7JVZ6f7uSuROYQM6z1O/oN+9LTQsZgfjtxX+TmEekM SQ2nk1UlZ2xN5GZbyDuygyXu66ZT3YPUvCIjmj4erhefw6EOZ0wtYdS9lGQX8qNb+Qlh eNFw== X-Gm-Message-State: AJIora/xFT8H92Dd4MHsIVluzCq3muiu+NWoLSHLyCmRCSVHPohaxbkm RSaLyL2LNlwSwHxQ0pS0EIJ/r+YRlpuUGWgJHrS4LpsUig9CWA== X-Google-Smtp-Source: AGRyM1szLJRDeTpvUk1cmxohJSX6/78a3dTWan9jkSoLLIGnwO+gcJuWkaSLhB0v8KLvw47dcUKfoUnO1832oARkQgc= X-Received: by 2002:a05:6402:2806:b0:431:87c8:b45e with SMTP id h6-20020a056402280600b0043187c8b45emr22254296ede.130.1655618044777; Sat, 18 Jun 2022 22:54:04 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=paaguti@gmail.com; helo=mail-ed1-x531.google.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, HTML_MESSAGE=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:291401 Archived-At: --00000000000071598705e1c69dd1 Content-Type: text/plain; charset="UTF-8" Hi I'm lagging behind the list... I recently saw the new duplicate-line function and I feel I have an alternative, which also takes the region into account: ;; ;; Duplicate region ;; (defun duplicate-region-after (beg end add-cr) "Insert a newline and duplicate after selection" (let ((dupstr (buffer-substring-no-properties beg end))) (goto-char end) (when add-cr (insert "\n")) (insert dupstr))) (defun duplicate-line-or-region (arg) "Duplicate the region or the line when nothing is selected" (interactive "p") (save-excursion (let ((b (if mark-active (region-beginning) (line-beginning-position))) (e (if mark-active (region-end) (line-end-position))) _ign) (dotimes (_ign arg) (duplicate-region-after b e (not mark-active))) ))) When and if I have CPU cycles I'd like to expand this to take a rectangular region into account. Best, /PA -- Fragen sind nicht da um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet --00000000000071598705e1c69dd1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

I'm lagging beh= ind the list... I recently saw the new duplicate-line function and I feel I= have an alternative, which also takes the region into account:
<= br>
;;
;; Duplicate region
;;
= (defun duplicate-region-after (beg end add-cr)
=C2=A0 "Inser= t a newline and duplicate after selection"
=C2=A0 =C2=A0 (let ((dupstr (buffer-substring-no-prop= erties beg end)))
=C2=A0 = =C2=A0 =C2=A0 (goto-char end)
=C2=A0 =C2=A0 =C2=A0 (when add-cr (= insert "\n"))
=C2=A0 =C2=A0 =C2=A0 (insert dupstr)))

(defun duplicate-line-or-region (arg)
=C2= =A0 "Duplicate the region or the line when nothing is selected"
=C2=A0 (interactive "p")
=C2=A0 (save-excursio= n
=C2=A0 =C2=A0 (let ((b (if mark-active (region-beginning)
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(line-beginning-position)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (e (if mark-active (region-end)=
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(line-end-position)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 _ign)
=C2=A0 =C2=A0 =C2=A0 (dotimes (_ign arg)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (duplic= ate-region-after b e (not mark-active)))
=C2=A0 =C2=A0 =C2=A0 )))=

When and if I have CPU cycles I'd like to exp= and this to take a rectangular region into account.

Best, /PA
--
Fragen sind nicht da um beantworte= t zu werden,
Fragen sind da um gestellt zu werden
Georg K= reisler

Headaches with a Juju log:
unit-= basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a lea= der-deposed hook here, but we can't yet

=
--00000000000071598705e1c69dd1--