From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id kHPCAkLSn2W8dQAAkFu2QA (envelope-from ) for ; Thu, 11 Jan 2024 12:34:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 2LcvO0HSn2XyQAAA62LTzQ (envelope-from ) for ; Thu, 11 Jan 2024 12:34:26 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="J/HttKux"; dmarc=pass (policy=none) header.from=posteo.net; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704972865; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=a5Fiq+r4bOgouDOxoUM1wVr6F1BSEyp8HW22HflCl6w=; b=M8W5wHO6JZaPJoScgHs7lkh7Anvh+iu8szkVIgLoxri5yNKZ0fiMTPfKmd5jSAiDv6x/5N KGpkRktFiAYYA3D7S/4z/I4usBpmb8PLJfb2Pn1m2MbtmYkxDUA0GNz79mLHLsdGrXZpgF qbDSEL6M5XTKBonIhicH07B14Eucd7JW3JL9fTD/tmYq13i/IgtCMsce7UvENygOwkf4QF QcEYbi3slhFQ21NOQJEIbih/iXFPbfZLoD7zZlchqWxkfQ+N29ebBzG7NIKA3bT1v+XUd0 JeS0IsaLf00P9Z5IZ8tTdo8o2R4P60sO/037y1JZnsWDKi8AqZzaG6JYW7MrUg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="J/HttKux"; dmarc=pass (policy=none) header.from=posteo.net; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704972865; a=rsa-sha256; cv=none; b=qAdapqQk825OCOAm7Lk4ucJO2Nh9pw+TTvnu9JQXZF2wqPapnafrVC9X3YLqo9imjHWcPf 8QPI5ShRLffnE8/OeJ++D8xVXW1CRtNww8WFrr7TBeAbgF3TKu5vCIcEszN3MZO2uijc31 WW/b9xGbVYrY1enkvycdoOgkjSzP6BS2suYQ4Y5Mg0i9XqRcDWjFnNKldwhB0W24PPars2 iPlg3Y0z6zDW/SfFfotK3P2VgGiObBirMGBcfk55Um+4NXLyJKw+NmPZBKqzhA1oMI28Mn E6vU68dJl7lrSdBxyXjvA5ycUkmRzugfBDyg94MUqbEcGrtn69kyVXdS6FBAFw== 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 61635325BF for ; Thu, 11 Jan 2024 12:34:25 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNtJU-0001gE-OB; Thu, 11 Jan 2024 06:33:32 -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 1rNtJT-0001e3-3l for emacs-orgmode@gnu.org; Thu, 11 Jan 2024 06:33:31 -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 1rNtJQ-0000Jr-Dq for emacs-orgmode@gnu.org; Thu, 11 Jan 2024 06:33:30 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B5146240101 for ; Thu, 11 Jan 2024 12:33:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1704972803; bh=TKtv/Up76Nm4a5IxCmDhqw5jBMs8Uj/gw0rKyEgb8gQ=; h=MIME-Version:Content-Transfer-Encoding:Date:From:To:Subject: Message-ID:From; b=J/HttKuxTTy+/+no1d2a0jxXgtPNLdaC3h4jLjqZsL1FYp7HCEb4hmGqEWpzs0SWN 3eMXZSHjnmyHohsitNlot46Ie3xw0vJNh0XEJmrsouBmFAmfverhdYxwz0LiqoJldN n2b/Ai4FFN/9M2Q3PwoZ2o7mojBBntLC391xF7ff/vwpgnO55owQJDknCXDRMbGQ0A 9IAHyZ9wpDCyCqitz/BSDeM7TCNoEjhTQkEKP0YNfgBaRdoxi9iIpagUVLX488Hg9a cuS4Aim0TZLxWHW8ghkXDI3uwtL/lxPWSZfglGbiIqcdCPh2l79MYL4eNUkdAJIqLG llZdr8585+ZPQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4T9jGW2bHnz9rxL for ; Thu, 11 Jan 2024 12:33:23 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 11 Jan 2024 11:33:23 +0000 From: gerard.vermeulen@posteo.net To: Emacs orgmode Subject: [BUG]: unexpected behavior related to org-indent-block Message-ID: Received-SPF: pass client-ip=185.67.36.66; envelope-from=gerard.vermeulen@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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Queue-Id: 61635325BF X-Migadu-Spam-Score: -9.98 X-Spam-Score: -9.98 X-TUID: 5aHzFsZhwQBR Below, I show 2 commands to be run with point on a source block. I expect that those commands modify an Org file identically, but they do not. It fails when `org-indent-block' is called in a loop after each `(insert (org-element-interpret-data copy))' and it works when `org-indent-block' is called in a separate loop after insertion of all `(org-element-interpret-data copy)'s: #+begin_src emacs-lisp :results silent (defun make-2-indent-fails () "Make 2 modified blocks, but fails." (interactive) (let ((copy (org-element-copy (org-element-at-point))) (n 0)) (delete-region (org-element-begin copy) (org-element-end copy)) (while (< n 2) (cl-incf n) (org-element-put-property copy :value (format "copy %s" n)) (insert (org-element-interpret-data copy)) (org-indent-block)))) (defun make-2-indent-works () "Make 2 modified blocks, and works." (interactive) (let ((copy (org-element-copy (org-element-at-point))) (n 0)) (delete-region (org-element-begin copy) (org-element-end copy)) (while (< n 2) (cl-incf n) (org-element-put-property copy :value (format "copy %s" n)) (insert (org-element-interpret-data copy))) (org-previous-block n) (while (> n 0) (cl-decf n) (org-indent-block)))) #+end_src Example block: --- #+begin_src emacs-lisp #+end_src --- make-2-indent-fails results in --- #+begin_src emacs-lisp copy 1 #+end_src --- make-2-indent-works results in --- #+begin_src emacs-lisp copy 1 #+end_src #+begin_src emacs-lisp copy 2 #+end_src --- I think that it is also weird that this bug does not show up in this ERT test while it does outside ERT: #+begin_src emacs-lisp :results silent (ert-deftest test-make-2-indent-fails () "Test unfolded `make-2-indent-fails'." (org-test-with-temp-text " ,#+begin_src emacs-lisp ,#+end_src " (let ((copy (org-element-copy (org-element-at-point))) (word "copy") (n 0)) (delete-region (org-element-begin copy) (org-element-end copy)) (while (< n 2) (cl-incf n) (org-element-put-property copy :value (format "%s %s" word n)) ;; Why does this work inside ERT and not outside ERT? (insert (org-element-interpret-data copy)) (org-indent-block)) (message "`%s'" (buffer-substring (point-min) (point-max))) (goto-char (point-min)) (while (> n 0) (cl-decf n) (should (re-search-forward word))) (should-not (re-search-forward word nil 'noerror))))) #+end_src Regards -- Gerard