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: Wed, 23 Sep 2020 11:29:31 +0700 Message-ID: References: <87zh5h37bs.fsf@ebih.ebihd> 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="33643"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 23 06:30:14 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 1kKwQ2-0008gY-5R for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 23 Sep 2020 06:30:14 +0200 Original-Received: from localhost ([::1]:57622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKwQ1-00067b-4h for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 23 Sep 2020 00:30:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKwPb-00067P-Pt for help-gnu-emacs@gnu.org; Wed, 23 Sep 2020 00:29:47 -0400 Original-Received: from mail-vk1-xa32.google.com ([2607:f8b0:4864:20::a32]:38297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKwPZ-0000aK-RQ for help-gnu-emacs@gnu.org; Wed, 23 Sep 2020 00:29:47 -0400 Original-Received: by mail-vk1-xa32.google.com with SMTP id n7so4834807vkq.5 for ; Tue, 22 Sep 2020 21:29:45 -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 :content-transfer-encoding; bh=r4lx+vuKE5ZtHNpAiZCbTknH7uF+PaGFbVsmRnEiN/4=; b=Ajdi20twCOs0buZ7s+TntvJiSUifxWScXcZTwaN3cqtMr6FHb+GYJvA6A+GLwO2pS4 RIxkSqMdzvvViedMVozG6wzpT2BtoS988gj5MfREG5g9MlUUEMgf3YgGae/dpsbyUvcs 4AeF9WbWQhYbGzcXVsDF/dBPGztirwtIdniuM3UtZx5IMyqG24jxe5E2LTVrNlnq3/IV KkHuF3SzSCgHMOmV2yo+s4CCqGu40veQVM0/gJz3v2VfWRN0YcDcShzeIMCadPonaYoR v2+pqFQvXYblPiNf9sMUCDoa7LV4Qz49ZC0vg71xTrrvL23H9BwPTTKMvjWN3wxVreWN qT1Q== 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:content-transfer-encoding; bh=r4lx+vuKE5ZtHNpAiZCbTknH7uF+PaGFbVsmRnEiN/4=; b=oR9uSy555tZgItuaLcP+yNhbKGvVduvx982kMG+XkHnnTod7HxtdfI7JyjBj0nnp1K 4sEuskcxDa+69lQiKpA2bw/5/GXrpyVj/ObsGedkbDq+a1/M4HEKWGCD/qfo5OTJbRYm Ec/83hh1gI7VHiUfCdr5sPdikcs0cfOeqyXXow4Xh33ChDLolfeVsbDpxMLOJMTGLS1I tZSakezKyWdhPQc1IlpibuD2LyIntRUHsiMwtlNz8cjYiSDElIdiQu0DvA9ixAgFWIOU 088bp9SBr4iBNkeEnNH50Y4Cc7YcSyKh+yfulUtcBkIUePMmHFkkC9bPi2j44x95dHLY EvCg== X-Gm-Message-State: AOAM531KFDW8KHBKhwvJ+LSPREeyGb98EJ1ueeZIynpdunmc7eadMoOf C22v1+dvXDXSXr58fDd4X308UJnEBNdes5JVHQ8= X-Google-Smtp-Source: ABdhPJw99/wA8kzkkzJrM9BKbLfkA8s9hhtOyKPwKEH5nfCw595uLVba00Sk4L/d/e7ThgyRh9+EBhUlJTyRuQPHFec= X-Received: by 2002:a1f:8d8a:: with SMTP id p132mr5506573vkd.14.1600835383383; Tue, 22 Sep 2020 21:29:43 -0700 (PDT) In-Reply-To: <87zh5h37bs.fsf@ebih.ebihd> Received-SPF: pass client-ip=2607:f8b0:4864:20::a32; envelope-from=yurivkhan@gmail.com; helo=mail-vk1-xa32.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:124148 Archived-At: On Wed, 23 Sep 2020 at 03:06, Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > 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. > > You mean like this? > > (defun transpose-next-line () > (interactive) > (let ((beg (point)) > (lin (line-number-at-pos) )) > (beginning-of-line) > (kill-line) > (yank) > (kill-line) > (forward-line -1) > (yank) > (goto-char beg) > (unless (=3D lin (line-number-at-pos)) > (goto-char (point-min)) > (forward-line (1- lin)) > (end-of-line) ))) > (defalias 'tnl #'transpose-next-line) ; [1] This might be good for you but org-drag-line-* have a couple advantages over this: * They do not pollute the kill ring. * As you drag the line, point stays on the same character where you started= . Lorem ips|um dolor =E2=86=93 (org-drag-line-down) Lorem dolor ips|um