From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id ePzKOItNJWblQwAA62LTzQ:P1 (envelope-from ) for ; Sun, 21 Apr 2024 19:31:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id ePzKOItNJWblQwAA62LTzQ (envelope-from ) for ; Sun, 21 Apr 2024 19:31:56 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=FUyOnlPq; 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713720715; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=+ZQNgkNyeDmvoIoQZ0gNG7Ofs0XmD5j3+3dv8zuBR4w=; b=iMDt8Y+Mb4PsyOHFOxt4LNMDleDVwNuzcchyZJJzWXAOq8kJLSk5BxTtjlvNWMovy74bJs LJIcpdiyR4UP4Ujp3S/ZZjM2odCkAyc2kpc+zaqhejwUiXysfcGM/aA6bgBFRF9ozuQrF5 +f3jMk6+vpY166Kjd9LtcWg1fNqmEjfHyl3OVbUQRGyncZ1Wq7UE98dJsfKpQH8k9GYrHp 1lu9apm8PEYNdhuX6C4qADUGc8fpBT/Fbxgv5zOEXYugcrias8lyg8ipGW17Wct0ZTHCIn 7LIVt82ppaYW1yYOqBSnZv++5/H5+NFGpLhFYsmEofHqo4oP9eMtsoZifhdunA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713720715; a=rsa-sha256; cv=none; b=fdRpi6qX6ZTLdvetsDYsGBIyWeQKlsZ4sgJ0H9s7B8vegN9xbdzd5c9XeFdHwFeJWUKq2g CGEqmDzfvjjf1cPQBRu5K4CgTajQpdhWjVeaq4wxps0Hz99dm7jI1dMmHR8ivKMGe3UeGN RSmydtAk171dIjmLrBQTij3iVn7Ljl0PDQpIoZW8uD3Ai/4yOnYJeRe1VPcVxjpy+eHiXO cjEDlUuiCSzPRxHAuiLdfde0uRj6mth1lDIcRrOhfvqSFPM8nulUlpqRN5eO0TxGWgDP2L W8/V/NESjB8ILrfO6mhvcjTwZzBSQtSdk9Gb23AZs4EBbFsE01fPiMbYFSns/g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=FUyOnlPq; 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 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 359203FC95 for ; Sun, 21 Apr 2024 19:31:55 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryb1a-00052x-Pv; Sun, 21 Apr 2024 13:30:46 -0400 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 1ryb1U-000510-8G for emacs-orgmode@gnu.org; Sun, 21 Apr 2024 13:30:41 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ryb1R-0000lc-MO for emacs-orgmode@gnu.org; Sun, 21 Apr 2024 13:30:39 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 5AEA5240028 for ; Sun, 21 Apr 2024 19:30:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1713720634; bh=oufIrhjD4BJkW+9ZzlhdnAX+ENzy0LiUZ+0ifbDiciA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=FUyOnlPqmNoJVKDpfQPgghOu3H4K3cSjLHaMcFM0ZpT3KzEcjchlar1SvW/SHZMj9 BpLUbFNy2hrh64gBGniM3Bfuy+z3oCi0Di/Ig6AjQbdglqTVlhOnEP01RlCipSly/p UY2zk0jM5fbHkpEpKXZ7vTAsIbWcxlsl88z1Ow9XbAVMVGc+6HofewqzC8bYohBpzj /v14MQsPmHwmmOFuwy7ZwrRo944XgmRHKoHNAvhB3+q/C2zXbBy1Frq2wG58YGATW7 DXXpts3QnRManrsCK/gv8RKGDO70JbTl5ec6lYALPxlqWAZt8SJhds4oNaJsuPymRl XziHJ304giCXQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VMwQ11YT8z6tyf; Sun, 21 Apr 2024 19:30:32 +0200 (CEST) From: Ihor Radchenko To: Morgan Smith Cc: emacs-orgmode@gnu.org Subject: Re: `org-element-cache-map' misses elements at end of buffer In-Reply-To: References: <875xwbq6mb.fsf@localhost> Date: Sun, 21 Apr 2024 17:31:23 +0000 Message-ID: <87edaypqqc.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 X-Migadu-Spam-Score: -6.77 X-Spam-Score: -6.77 X-Migadu-Queue-Id: 359203FC95 X-Migadu-Scanner: mx13.migadu.com X-TUID: gZn9FDSfIS91 Morgan Smith writes: >> It is the time to refactor this function yet again. >> (a tricky endeavour considering all the edge cases we can encounter when >> there are changes in buffer while `org-element-cache-map' is mapping >> over it). > > See attached for a way to break :from-pos as well. I would like to help > refactor but studying this function is a little dizzying for me. At this point, it might be easier to rewrite the whole thing from scratch, just based on the commentary (I tried my best to leave detailed commentary explaining the intended logic). We have a decent test coverage when mapping headings in buffer, so edge cases will be checked by make test. In particular, it might be a good idea to get rid of the idea of START variable and just make use of AFTER-ELEMENT. For now, they serve kinda the same purpose, but the latter was added because START was not enough when the buffer is modified by FUNC. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at