From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wNAAIwMwjWG/xgAAgWs5BA (envelope-from ) for ; Thu, 11 Nov 2021 16:00:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id +LPBHgMwjWElKAAA1q6Kng (envelope-from ) for ; Thu, 11 Nov 2021 15:00:19 +0000 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 4B04F18E60 for ; Thu, 11 Nov 2021 16:00:19 +0100 (CET) Received: from localhost ([::1]:36484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlBYn-0008U0-P3 for larch@yhetil.org; Thu, 11 Nov 2021 10:00:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlBLA-0005eB-Eh for emacs-orgmode@gnu.org; Thu, 11 Nov 2021 09:46:12 -0500 Received: from ciao.gmane.io ([116.202.254.214]:41448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlBL4-0002n9-GU for emacs-orgmode@gnu.org; Thu, 11 Nov 2021 09:46:08 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mlBL2-0008Eh-7q for emacs-orgmode@gnu.org; Thu, 11 Nov 2021 15:46:04 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: Incorrect link is stored (org-elements?) Date: Thu, 11 Nov 2021 21:45:57 +0700 Message-ID: References: <871r3po8l8.fsf@localhost> <87zgqcktob.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <87zgqcktob.fsf@localhost> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-3.999, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1636642819; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=E6tgt0TEqNO9B8xVtnrca9VGROQb01qFZCZPh5ddR38=; b=C89H5Qfp96CqWXMkVtGJDgIGehJPW1nku5EqvWpCugGFGZWCpyNL61XpfyB1NZNwTSqMZV wJFGvMilwqljgQKvGEzZGYSnHs3V/4UEcK2VAePd00TRBzXeCIfMSuBZtKib4Q76Gimyqv LZHB01nxRu0r2nLGpHGwzcw8BzxEIZb+oviSE4PLThjNW27LUpoVx/zL0bSPEQxG500lYN 2RoZ0qeLuGM/TJ1dqJMHa2NYoGSNcJKLYC1Deni/dyBoSMxQ8ykNtwb3xecqZPQilPT4nL ZH142tiP9ErUxRACMbd09h4vd9goRGVu/TFS0z0+vsNb+l6qFXsq1NTQ5ARMrw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636642819; a=rsa-sha256; cv=none; b=rAmmmCWesfj6L1/Du2Gz9E2COizy7MoiDPqsw/QPNnttmbyIdrnibG6WV/5iGhlIMz8u3B n4EBLMsuLIwbXvOR2lrrVyj6Kypno0LKc8jyanxjEUzhacXBFFGRyTPznKDanPsbuPd8nZ SXPC4n6ALO8neaVgI2WwSGCN2ySY9N8RA9mCUqwfNJTI3LhPMKYi9S3xrTDTSF9SJmt4Oo K4HLfXHDySgWY9s+FT+fBkLClj5ZlYKBRzAf5YxHB9Ny8JGkVpuSf3d4tmHqPHvZN/+k7N grnN2Q9zlcexUrwaEI5ku0E7dJdw+Zz6Jm4a+n0x/GrtOdd3Z6Q/S2rA0si3Bw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.23 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 4B04F18E60 X-Spam-Score: -2.23 X-Migadu-Scanner: scn1.migadu.com X-TUID: 5uKbsRT8+o02 On 10/11/2021 20:48, Ihor Radchenko wrote: > > I pushed the patch upstream. > >> P.S. I am puzzled that `org-element-at-point' returns paragraph even >> when patch is not applied. After such call `org-store-link' does what I >> expect. However "after undo" erroneous state survives emacs restart, >> thanks to org-persist, I believe. > > The bug was in very specific case. org-element-at-point now has a > special fast mode of operation when CACHED-ONLY argument is non-nil. In > this mode, it does not try to parse anything, but only checks the > nearest cached element and returns it if point is at the element > beginning, within +begin/end line of the element, or inside a > non-greater element. The error happened when the cached element was a > section and point was within blank lines at the end of the section > exactly one symbol before the following headline. In such cases, > org-element-at-point must follow some special rules (see comments in > org-element--parse-to), but it did not in this specific scenario. > On top of that, org-element-parse-to cannot return section and the > current code assumes that we ever attempt to return section when point > is at the beginning of section. So, it returns > (org-element-at-point (1+ pos)) instead. Hence, the next headline > was wrongly returned when (1) point is 1- beginning of next headline > (2) we are within blank lines at the end of section (3) some edit in > buffer just cleared everything in cache inside current section > (4) org-element-at-point is called with non-nil CACHED-ONLY argument. Thank you for the fix and for the detailed explanation, Ihor. I was naively suspecting some weird issue with undo, maybe similar to the one found with interference of tables and non-latin input methods.