From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SCsVNmbyw2MTmwAAbAwnHQ (envelope-from ) for ; Sun, 15 Jan 2023 13:32:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KOzTNWbyw2NS7QAAauVa8A (envelope-from ) for ; Sun, 15 Jan 2023 13:32:38 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 97AE227A6D for ; Sun, 15 Jan 2023 13:32:38 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pH2Ah-0007Dh-Sa; Sun, 15 Jan 2023 07:31:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH2Ac-0007BQ-GK for emacs-orgmode@gnu.org; Sun, 15 Jan 2023 07:31:30 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pH2Aa-0005Ge-Hh for emacs-orgmode@gnu.org; Sun, 15 Jan 2023 07:31:30 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 49B2E2401BE for ; Sun, 15 Jan 2023 13:31:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1673785887; bh=Gl9LRRjHuxV/tcPSOGE0wY9S9pO+roWAETtcLMWOBGY=; h=From:To:Cc:Subject:Date:From; b=Tx8ymhfCUCVF4nGJd0o+DnE1vADsIVK8HSydY7SH0n/Zd7DPkOJNlV3pLZAHoY1bK a3CZqh36ABlek8tFBfDy2qyYrl2kSWNaUbi9CB9KsB7JW+qDIvFdWtRHuLqAnEsd1u 34QPXkSMx8H4VwE6qlEGdr+euS+Rbdbr7qxOT5m/n845AVLDuy5sHmBWLU5EPHrUCc de3vboTGH5YSSsjiarMzpi0uKGlB7W5QOGpzn53Jnbvu04ChffltnstRJfurPBs2iU ug+YF1emqxCh9r/7abbFL0NQo6yY59cI2x+C6f4Wrd5La2xgln0Ehe2C5mDvPpeIQF f+mTW4m9nncyQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Nvvf65XtYz9rxF; Sun, 15 Jan 2023 13:31:26 +0100 (CET) From: Ihor Radchenko To: emacs-orgmode@gnu.org Cc: Ihor Radchenko Subject: [PATCH 1/4] Preserve active region after structure edits Date: Sun, 15 Jan 2023 12:31:29 +0000 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Tx8ymhfC; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673785958; a=rsa-sha256; cv=none; b=n1tLxjAVvh52HEndDYMj8Ucm/IVwuX8Krh2m10+AKrtWVQsHUwcdDgl9E0X8ZrLrfROU9n SrlqlYzXdGfPQRAdBabpjBgaaMXIkpI/FydBe59uEOV6KqmM/GKNDa7R7OZ7OEzsCRE9H9 tIRy1FD/0lo09CNQePMejVrJrLWGQ8cIuo97lhKq9eMI0iOg/WeFBW3+26JI6jjfx4sesl njSjmzuoZVLPAd9cyeBxhL1dbLH+BK/CKIrPv7duvowR5zWwfP1auWLEJWoJry5MecYT7g z80WOWHpFIkWECgCN9I3O87U5TsUNK6lLeGWUQnNKy217X0/9xdfLrAKe5yY2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673785958; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=jnx7U+yKbxZfMNio0vYOHJ24wWxUSfDvqCnLlFRwj8w=; b=dxMj8I/4xTg1Y2pIqE5tmHpzcc2gNfm6QkyRFJHbdJg5V8bQExYkujZjKBYL8NqD6vj5/r lKkffcM8zqRqKOzZAq2FmQKhy61HCG17TXN75VykY8TE8TaWRb4tKb1z9lxF33mM65oTXZ XmRNEMxJuvgsRlzHRbF+l+BDUK51w1IQy+DK222itBw+Sy+QgUeB81ORiOjGqn0R1zT6tF TKJG5Fm/bFiQjgC4NcyRu5PithJO38aIafVf71ulWuySFkPxTayllF2RIaNADZjqVAOJtx uX/OyzVgiW4KK2Wq1ebK6ES0NMfeY/vzdOYb/NxlNVXAV1Mm2VYqQlAnxUarqA== X-Migadu-Queue-Id: 97AE227A6D X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Tx8ymhfC; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net X-Migadu-Spam-Score: -5.36 X-Spam-Score: -5.36 X-TUID: l51lUUNFiuJT * lisp/org-list.el (org-list-indent-item-generic): * lisp/org.el (org-do-promote): (org-do-demote): Do not deactivate mark after edits. (org-metadown): (org-metaup): Do not deactivate mark and do not exchange point and mark in region. --- lisp/org-list.el | 3 ++- lisp/org.el | 64 ++++++++++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/lisp/org-list.el b/lisp/org-list.el index 1fc99d070..9fa072ce7 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -2688,7 +2688,8 @@ (defun org-list-indent-item-generic (arg no-subtree struct) (no-subtree (1+ (line-beginning-position))) (t (org-list-get-item-end (line-beginning-position) struct)))))) (let* ((beg (marker-position org-last-indent-begin-marker)) - (end (marker-position org-last-indent-end-marker))) + (end (marker-position org-last-indent-end-marker)) + (deactivate-mark nil)) (cond ;; Special case: moving top-item with indent rule. (specialp diff --git a/lisp/org.el b/lisp/org.el index 59fe3d2d3..58a3434f4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6579,7 +6579,8 @@ (defun org-do-promote () (interactive) (save-excursion (if (org-region-active-p) - (org-map-region 'org-promote (region-beginning) (region-end)) + (let ((deactivate-mark nil)) + (org-map-region 'org-promote (region-beginning) (region-end))) (org-promote))) (org-fix-position-after-promote)) @@ -6590,7 +6591,8 @@ (defun org-do-demote () (interactive) (save-excursion (if (org-region-active-p) - (org-map-region 'org-demote (region-beginning) (region-end)) + (let ((deactivate-mark nil)) + (org-map-region 'org-demote (region-beginning) (region-end))) (org-demote))) (org-fix-position-after-promote)) @@ -16884,21 +16886,25 @@ (defun org-metaup (&optional _arg) ((run-hook-with-args-until-success 'org-metaup-hook)) ((org-region-active-p) (let* ((a (save-excursion - (goto-char (region-beginning)) - (line-beginning-position))) - (b (save-excursion - (goto-char (region-end)) - (if (bolp) (1- (point)) (line-end-position)))) - (c (save-excursion - (goto-char a) - (move-beginning-of-line 0) - (point))) - (d (save-excursion - (goto-char a) - (move-end-of-line 0) - (point)))) + (goto-char (region-beginning)) + (line-beginning-position))) + (b (save-excursion + (goto-char (region-end)) + (if (bolp) (1- (point)) (line-end-position)))) + (c (save-excursion + (goto-char a) + (move-beginning-of-line 0) + (point))) + (d (save-excursion + (goto-char a) + (move-end-of-line 0) + (point))) + (deactivate-mark nil) + (swap? (< (point) (mark)))) (transpose-regions a b c d) - (goto-char c))) + (set-mark c) + (goto-char (+ c (- b a))) + (when swap? (exchange-point-and-mark)))) ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up)) ((and (featurep 'org-inlinetask) (org-inlinetask-in-task-p)) @@ -16917,21 +16923,25 @@ (defun org-metadown (&optional _arg) ((run-hook-with-args-until-success 'org-metadown-hook)) ((org-region-active-p) (let* ((a (save-excursion - (goto-char (region-beginning)) - (line-beginning-position))) + (goto-char (region-beginning)) + (line-beginning-position))) (b (save-excursion - (goto-char (region-end)) - (if (bolp) (1- (point)) (line-end-position)))) + (goto-char (region-end)) + (if (bolp) (1- (point)) (line-end-position)))) (c (save-excursion - (goto-char b) - (move-beginning-of-line (if (bolp) 1 2)) - (point))) + (goto-char b) + (move-beginning-of-line (if (bolp) 1 2)) + (point))) (d (save-excursion - (goto-char b) - (move-end-of-line (if (bolp) 1 2)) - (point)))) + (goto-char b) + (move-end-of-line (if (bolp) 1 2)) + (point))) + (deactivate-mark nil) + (swap? (< (point) (mark)))) (transpose-regions a b c d) - (goto-char d))) + (set-mark (+ 1 a (- d c))) + (goto-char (+ 1 a (- d c) (- b a))) + (when swap? (exchange-point-and-mark)))) ((org-at-table-p) (call-interactively 'org-table-move-row)) ((and (featurep 'org-inlinetask) (org-inlinetask-in-task-p)) -- 2.39.0