From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Cut and paste an entry programmatically Date: Thu, 16 May 2019 18:40:48 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:52200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRJRH-0005xa-AV for emacs-orgmode@gnu.org; Thu, 16 May 2019 12:41:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRJRG-0004WI-Fp for emacs-orgmode@gnu.org; Thu, 16 May 2019 12:41:03 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:40961) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hRJRG-0004Tr-8e for emacs-orgmode@gnu.org; Thu, 16 May 2019 12:41:02 -0400 Received: by mail-lj1-x22f.google.com with SMTP id k8so3693322lja.8 for ; Thu, 16 May 2019 09:41:01 -0700 (PDT) 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: Org Mode Hi all I would like to ask for some help to understand what am I doing wrong with this minimal complete example: #+begin_src org ,* 1 ,* 2 ,* 3 ,* 4 #+end_src #+begin_src emacs-lisp :results silent (defun temp () (org-cut-subtree) (org-forward-heading-same-level 2) (org-paste-subtree)) #+end_src When with point on 1 you do M-: (progn (save-excursion (temp)) (save-excursion (temp))) RET the resulting buffer is the expected reordered 3, 1, 2, 4. When you do M-: (save-excursion (temp)) RET M-: (save-excursion (temp)) RET the resulting buffer is 3, 1, 1, 2, 4 which is not what I want (Emacs 26.1 and today's Org mode master). Why is this and how to resolve? Michael