From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2M6DG+zNi2F5sQAAgWs5BA (envelope-from ) for ; Wed, 10 Nov 2021 14:49:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id kNFeF+zNi2E/OwAA1q6Kng (envelope-from ) for ; Wed, 10 Nov 2021 13:49:32 +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 07D1C36EC6 for ; Wed, 10 Nov 2021 14:49:32 +0100 (CET) Received: from localhost ([::1]:37562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mknyk-0004Dk-6B for larch@yhetil.org; Wed, 10 Nov 2021 08:49:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mknwn-0002MM-I9 for emacs-orgmode@gnu.org; Wed, 10 Nov 2021 08:47:29 -0500 Received: from [2a00:1450:4864:20::22f] (port=36710 helo=mail-lj1-x22f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mknwl-0005RT-9j for emacs-orgmode@gnu.org; Wed, 10 Nov 2021 08:47:29 -0500 Received: by mail-lj1-x22f.google.com with SMTP id i63so5416334lji.3 for ; Wed, 10 Nov 2021 05:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=HdKR+nTuvFI23A40Nq2gBkiPZ35uMe8Dj1w9LWJBlqE=; b=E7x7BuS5qKLyWQlORYARc9jx2feW5EhlL8VpjJsrRpsfVPzuIrLcaJsRAPaVTwyipT XpfdqYq+l857bOP+W45VK/C8yM2vumFygkOfFWz1oQOFddY9BgjJ3U/6MqfyIqbsbfdQ w7mHTgmjjEsSQC9Jg+LXEqAQuDgojdZtZm0wzyspD9DU66YmBaNI0esQyxMtFwRPdhfv hWr//vgLPVogmQWZ4+3uWOquVuivtQkzb8COvRX+tsnuQG4IGSkOcO8cmD2FwnzKELkn blCSkqr1R0fmzo3bh259lEsiQK0M6d0YmqwVBHcAzgRv8GJq/b7y4mTJ+rdIabrgEsAm KA2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=HdKR+nTuvFI23A40Nq2gBkiPZ35uMe8Dj1w9LWJBlqE=; b=v6lPNo9XyPEqZlsYcp+IprUtKOrLyVUmSJSSY03JbiueobJ9kCIgN3Wg9WI3b3H/Tm 6UBd2KzfT68Xuf/XjnRi0zswRYAcBiXa/Pn/bVzGXPM2xC5r8HZkuxzgCzeXkMum8kPe /EwHKO7ZERJBXvNRjd88mIj/wtRtM+bNmOTY7dfLNeskjcGY3jJ9bZ0A76gFqRzUDsH0 8rAAkas9a31zI4wwEeHvn9JYy/FFkrHXnieDYggIHd42NvcezIyVY3V2wHJxMe6vcDWU 77OWLjKb218qM51gjIw+sRGkJ5YPTVuUELfyU4x1ov1SkX6YcwnE9l96OvW7VM60PCjz 0/Mw== X-Gm-Message-State: AOAM5306td49PJtFyDoNugohr9FESVhXrvhKsanz90r1ucRKI/V6wJGt 0HBbpLovcIdbda8Q90RoZXQ= X-Google-Smtp-Source: ABdhPJxmgeQCpq1HmLctj6bvozxVq5asD7kY6I6gfncYzxUiSFvm9qsm/j8fDfbGe7cGGOJO7rpdqw== X-Received: by 2002:a2e:a7c6:: with SMTP id x6mr16143342ljp.328.1636552044877; Wed, 10 Nov 2021 05:47:24 -0800 (PST) Received: from localhost ([141.105.67.194]) by smtp.gmail.com with ESMTPSA id l11sm2475672lfg.79.2021.11.10.05.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 05:47:24 -0800 (PST) From: Ihor Radchenko To: Max Nikulin Subject: Re: Incorrect link is stored (org-elements?) In-Reply-To: References: <871r3po8l8.fsf@localhost> Date: Wed, 10 Nov 2021 21:48:52 +0800 Message-ID: <87zgqcktob.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22f (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=yantar92@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, 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: , Cc: emacs-orgmode@gnu.org 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=1636552172; 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=HdKR+nTuvFI23A40Nq2gBkiPZ35uMe8Dj1w9LWJBlqE=; b=izNtZWWMN9Zxf4nwhx2Jt1nl8mnKS74NiZ8pZQkLaarJUUFljb7q0l5mrDybzAzI4ighaO 6Z5niRXt7x6N2v+b8A/0qaB1uKoFy/cOmBZ+XZa8w/DZwAdmQbs6LbuZaL7ix1dppdw7XZ 09CueuTdJbBuge8ycnTpOOG3ZMGexRKOUGt2RdF4Qpq76gUTPYlX8Bj1CrrjOGF7DYzyl2 kETAMLFwW8Nq2qAisAmXv2GsLSFEMtKkRpmCEEzVEdO+ZeZTwaARTJYbyr0G53ZfxLfgGl fCGiqGB32lUV7DuMyc9YIJoV24QctS/9165oOg3mEOZx5Odkgxi2TYOKJkT9Kg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1636552172; a=rsa-sha256; cv=none; b=ISnK36TKPrqxmpTJj3l8WEN/p2APpYQtukeHw26Zi4dCNdGQVWlH5Dvkuhylsm/eJkIp4X sDZrk11H/oHoa+eN/2EgW4YkCN1Kr1XBGd85DYrnxCCebNUqEexdRyJX1IK3GkUM2hVs/6 sc46pEypNPlG+b9nxE+9ZkOxUQPsh5rstmsstMRzLJXaOh6rYKh4W24BjOf2XeXgLp5zFm 0+F/afThE7auIxkuCG0exV1eBMtOI3FwvNPqcWDZuMd8JmhTVnwWbgGz8ZzhHAv6danhSx XLBYRpr7zN2e4ACCZOv1gZweR7D5rA6wiZrMMLT5Swxk8zvDvTV9zvZ64z1CGg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E7x7BuS5; dmarc=pass (policy=none) header.from=gmail.com; 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: -3.52 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E7x7BuS5; dmarc=pass (policy=none) header.from=gmail.com; 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: 07D1C36EC6 X-Spam-Score: -3.52 X-Migadu-Scanner: scn1.migadu.com X-TUID: XsXwlNRY8w63 Max Nikulin writes: > With equivalent patch (attached one has additional differences in spaces > around) my particular case works. I have no idea which additional > scenarios it may affect. I did not test the patch extensively. I faced > the issue while I was preparing a patch to fix storing double #CUSTOM_ID > links. 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. Just calling org-element-at-point did not trigger error. You would need to call (org-element-at-point nil 'cached) Best, Ihor