From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Keybinding to transpose current line with next line Date: Tue, 22 Sep 2020 21:53:47 +0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29309"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 22 17:59:19 2020 Return-path: Envelope-to: geh-help-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 1kKkhK-0007U1-SM for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 22 Sep 2020 17:59:18 +0200 Original-Received: from localhost ([::1]:39848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKkhJ-0007Pe-UZ for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 22 Sep 2020 11:59:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKjgE-00087G-Vn for help-gnu-emacs@gnu.org; Tue, 22 Sep 2020 10:54:06 -0400 Original-Received: from mail-vs1-xe32.google.com ([2607:f8b0:4864:20::e32]:34806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKjgB-0002JW-Sw for help-gnu-emacs@gnu.org; Tue, 22 Sep 2020 10:54:06 -0400 Original-Received: by mail-vs1-xe32.google.com with SMTP id y190so10473408vsy.1 for ; Tue, 22 Sep 2020 07:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Nltm6aC44jRoN7/kf2wuDvF/gMaKRgOOJiDbyGTzh8Q=; b=cJyUVQtxbUL8BWVh5irCtooBOP5idkCsNtCd4uScOFylHi4VLjzNB4Nh9bPExVno/X qijS1Ni1MnwHmJvZJRc9oBv95X/khv9T5BJ/7SEDCg3zrDrsJONqiudFsY0DcFwiZNRi zQqsuDa7YL5sls2615oV7K2FEUH9Hne0+E8aDG/xfVupsjIUfKxBzeKqSA1X+3tqtClu J/BcB2TUVuCOro05owGLMk0be4PCCPCoIgXwM9gSegNJsAJXGFa1IUIzmR/xRuFEvSnW uVP0P37bdi9JikM+cwU0wYXvvG654DHB92xWE69OF3d1NaftZtWm1yic8U3LwInOJoP/ 45Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Nltm6aC44jRoN7/kf2wuDvF/gMaKRgOOJiDbyGTzh8Q=; b=M2GHK6HJ8/dTj430noExkn0j//aVe2+kdAmi0dI4PpsiOxMnUwAshASYSo4lKVDPgu ylNzPXHvblHYvlg7tlpmUHkUixt0g2x6f/rqMrnAwGRcreKaWneTdkzE8wSXMCLakkHw 4bTvHeWY4cwkr+0bnD2FQNRcJBXMuxP5UM0fcxRg3A/MJ1ZP08/jucq5ukdyoM0LF7sc /0gpedUsBw6fpXTgUEQYkbRUpQnyF1yU0/u9Y6p6TwTStl6K7cnbk26HpYTZK++Ic81k ull3GkamWYTfJwMkUXOchtDDuBxZlMeIdSzWj3Bqugrz5H8bOcY+qqBYeaO571wRTEXA 8ZIA== X-Gm-Message-State: AOAM53059mWNQ/MgUamZgpZhZKN4s7o6QlyOxCblsCsG5ABE4NsgtdYl cSSlwUGFz2W6CxKBbmd8cwtaOOyJs2ZxBGn8FEg= X-Google-Smtp-Source: ABdhPJy/F6F/jMw11TPosV8o6SM6VSEqKxbXaVmb2FTh5naAm+uANoHFcM4lfRl9B2h3YXhZMPeV5a4hcd4DNUAmUFw= X-Received: by 2002:a67:fb0f:: with SMTP id d15mr3759637vsr.38.1600786438313; Tue, 22 Sep 2020 07:53:58 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::e32; envelope-from=yurivkhan@gmail.com; helo=mail-vs1-xe32.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124136 Archived-At: On Tue, 22 Sep 2020 at 21:33, Christopher Dimech wrote: > I have written the following keybinding to swap lines. If I have > the cursor on one line, the command swaps the current line with > the previous line. What can I do for the keybinding to swap > the current line with the next line, rather than with the previous one. > > (global-set-key (kbd "C-t l") 'transpose-lines) Firstly, =E2=80=98transpose-lines=E2=80=99 is already bound to C-x C-t. Secondly, transposing lines is a useful low-level primitive, but IMO a much more handy UI metaphor is dragging the line at point up or down through the surrounding lines while preserving the point=E2=80=99s position= in the line. That is implemented in =E2=80=98org-drag-line-forward=E2=80=99 an= d =E2=80=98org-drag-line-backward=E2=80=99. Pretty much nothing in their impl= ementations depends on org-mode, so they can be bound and used in any mode.