From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: org-metaup destructive when region active? Date: Fri, 15 Jun 2018 18:59:35 +0200 Message-ID: <87zhzwj894.fsf@nicolasgoaziou.fr> References: <87wov0hkw8.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTs4h-0006r3-Dx for emacs-orgmode@gnu.org; Fri, 15 Jun 2018 12:59:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTs4g-00028U-BE for emacs-orgmode@gnu.org; Fri, 15 Jun 2018 12:59:47 -0400 In-Reply-To: <87wov0hkw8.fsf@alphapapa.net> (Adam Porter's message of "Thu, 14 Jun 2018 20:57:11 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Adam Porter Cc: Bastien Guerry , emacs-orgmode@gnu.org Hello, Adam Porter writes: > I noticed that using org-metaup when a region is active seems to behave > in an unintuitive and potentially dangerous way. I would expect that it > would behave similarly to org-refile when a region is active, but it > doesn't. > > Looking at the code, I see that it does this: > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > =E2=94=82 (let* ((a (min (region-beginning) (region-end))) > =E2=94=82 (b (1- (max (region-beginning) (region-end)))) > =E2=94=82 (c (save-excursion (goto-char a) > =E2=94=82 (move-beginning-of-line 0))) > =E2=94=82 (d (save-excursion (goto-char a) > =E2=94=82 (move-end-of-line 0) (point)))) > =E2=94=82 (transpose-regions a b c d) > =E2=94=82 (goto-char c)) > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > > It was difficult for me to understand what that would do, and the > docstring of transpose-regions didn't help. So I did a small > experiment, defining that code as a command and calling it in this > buffer (where the region is marked with brackets): > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > =E2=94=82 abcd > =E2=94=82 [efgh > =E2=94=82 hijk] > =E2=94=82 lmno > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > > The result was this: > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > =E2=94=82 efgh > =E2=94=82 hij > =E2=94=82 abcdk > =E2=94=82 lmno > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 This is now fixed. Thank you. > Now for an example with Org headings, before: > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > =E2=94=82 * A > =E2=94=82 ** A1 > =E2=94=82 ** A2 > =E2=94=82 [* B > =E2=94=82 ** B1 > =E2=94=82 ** B2] > =E2=94=82 * C > =E2=94=82 ** C1 > =E2=94=82 ** C2 > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > > After: > > =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > =E2=94=82 * A > =E2=94=82 ** A1 > =E2=94=82 * B > =E2=94=82 ** B1 > =E2=94=82 ** B > =E2=94=82 ** A22 > =E2=94=82 * C > =E2=94=82 ** C1 > =E2=94=82 ** C2 This is partly fixed, i.e., there is no more "2" left over. > Ideally it would act on all headings in the region, but given the > complexity of doing that correctly, would it be a good first step to > simply do nothing when org-metaup is called and a region is active? It > would at least avoid corrupting data. I think that's a non-trivial > risk, because when I noticed this behavior, it was in a partially > collapsed outline, and some of the headings in the region (and their > entry content) seemed to vanish altogether; I only recovered them with > undo. I have no strong opinion on the subject. However, I agree this feature, i.e., `org-metaup' (or `org-metadown') on a region can be removed altogether, since this is but a glorified kill'n'yank process. Nevertheless, I'm Cc'ing Bastien for his opinion, as he introduced the feature in the first place. I didn't write tests for the function because its specifications are not completely defined yet. Regards, --=20 Nicolas Goaziou