From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id cDNxHak6vmVKggEAqHPOHw:P1 (envelope-from ) for ; Sat, 03 Feb 2024 14:07:53 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id cDNxHak6vmVKggEAqHPOHw (envelope-from ) for ; Sat, 03 Feb 2024 14:07:53 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=arHGoB6C; 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=1706965673; 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=KroF8eHwUu8G73h4ky4wQ1j0gJxjD9MZ8eA6yIEYAIc=; b=jaGDJTHF2H465bKN3ciFeA2wkS/3DPxGpOytnlgTuq8vzqjSDVD3rSzJqgxV9S/8y6++p5 0JVIAJcgVol7x/NmsgQcUSL2jL35aBYku9wmEJ/aFZwqkAntABdrIzGyO7zi4RO+UBbbxY mhrL9PnS1AOVZatVnYaRPJdebEfYybTWkArsvJq6+5ArjMF3QmTIx7VxKZhRGBaoWTa1ts rHkwrYpxkxI3G+rkoXFqnuf/chdM+bAfT2zgKOpYTlQKECzCtFb0KlX/VJxYFf10WgtrtU Frv9M83OG0XcLEDhsPx3I22hUWXkUFHazAH4l14FA0SmYKJjxHbkj5SCbysk9w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=arHGoB6C; 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=1706965673; a=rsa-sha256; cv=none; b=hClIkCufJaWmgfbQ5Dq4qAV9fB2TwKDQGQD4hSWDJXgQ+b4NGgN5linyT8pwvelXWhF1ed pdlU0PbG8yud8WG5yLmi2QplaFZlsdBJ2bVdppTXIDacoM9HxNTj0zBqiTL+Wf72FjUxCl cCDG9mBWaUfBS+qhU6i1/EO1lYIphSCHXWFFAg87T2epQJruX9P95hU/dhaU6LRrrZ/yuU Wv+iJA7mYlIproNrNFCT6X+QE1kXnq3zhgFz6OYUgezhQ0cMDA7v4YfVtcTIYCwlPSeFGy K3YAuJenSCcJ9Gu3OlEPNQi0Q7jG9EMpBQEMVM1cGcXfKMFmvH6+sG9KeetABg== 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 47B142141A for ; Sat, 3 Feb 2024 14:07:52 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWFjV-0005H7-Eh; Sat, 03 Feb 2024 08:06:57 -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 1rWFjS-0005Gm-Qm for emacs-orgmode@gnu.org; Sat, 03 Feb 2024 08:06:54 -0500 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 1rWFjQ-00026i-0W for emacs-orgmode@gnu.org; Sat, 03 Feb 2024 08:06:54 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 25E68240027 for ; Sat, 3 Feb 2024 14:06:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1706965609; bh=3BdH7V5q+FdCV/aJ84Cvv89X2W2S48y9egpiP9fvqJk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=arHGoB6CAmPT6Nxu/1ud9n0lHzQF0K5QkQOt2zlvd0fnVq7kPX8lct15M/3yVtIie dYO8Cr+/B0rzHsOM3zHofmZWApIn4ssU3jWqTamSx20qRl8SILAu7epNqbCSYDBLpD Ubx3K9tBZ9MbG5NEG2QhgmI7mx7R6DO4rVrRutSo/m2CGm+8odtkoWl1IAjIT/YwgD UuhaWgDVtrzH0N2l5ssn2zGYZWrzrqHzN6iElb4Uj17c1Q0amXL8ofh925x48Fh7IQ eUQ3zwYpYq2CxZDkV0kBufgcX+so+i/yYe9XVh/m/fwxssUk+Ffbs12jbOT0lsjB+Y 4Hh8bc5WqyzYg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TRtFh2JnQz6tv5; Sat, 3 Feb 2024 14:06:47 +0100 (CET) From: Ihor Radchenko To: Rick Lupton Cc: "Y. E." Subject: Re: [PATCH v2] org-id: allow using parent's existing id in links to headlines In-Reply-To: <70c0e6fb-3e9f-4b84-8d00-1b1e62ec19d0@app.fastmail.com> References: <118435e8-0b20-46fd-af6a-88de8e19fac6@app.fastmail.com> <87edkwsafe.fsf@localhost> <87cywh2ad6.fsf@localhost> <87jzpmqiy0.fsf@localhost> <2cdfefbf-e9e3-4aeb-a410-1ff3a9d6168e@app.fastmail.com> <87zfybzkul.fsf@localhost> <3c5737c8-f489-4144-a27f-c0e0527c79c0@app.fastmail.com> <87bkaqcjpz.fsf@localhost> <87msu7r902.fsf@localhost> <1b50d1a4-8573-4dcc-9427-8970f67e632a@app.fastmail.com> <87r0i0mgzi.fsf@localhost> <70c0e6fb-3e9f-4b84-8d00-1b1e62ec19d0@app.fastmail.com> Date: Sat, 03 Feb 2024 13:10:17 +0000 Message-ID: <87cytdithi.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_H4=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-Spam-Score: -9.88 X-Spam-Score: -9.88 X-Migadu-Queue-Id: 47B142141A X-Migadu-Scanner: mx12.migadu.com X-TUID: il0UzozN4SXh "Rick Lupton" writes: > I see. Updated to get the search string first, before the possible properties draw appears. > > To make this work I changed `org-link-precise-link-target': instead of > accepting the RELATIVE-TO argument and rejecting unsuitable targets > internally, it now sets a marker `org-link-precise-target-marker' > showing where the target that was found is, so the caller can decide > if the found target is suitable. I copied the approach from > `org-entry-property-inherited-from', hope that doesn't cause any other > issues. I'd prefer to avoid using global variables here. `org-entry-property-inherited-from' dates to pre-lexical binding times and is a potential source of subtle bugs if several `org-entry-get' calls happen unexpectedly to the code, changing `org-entry-property-inherited-from' multiple times. Instead, I suggest changing the return value of `org-link-precise-link-target' to a list that includes marker in addition to search string and description. >> The fact that links stored via `org-store-link' cannot be open with >> default settings is not good. >> Also, your patch disregards this setting - it should not match >> non-headline search strings with the default value of >> `org-link-search-must-match-exact-headline'. > > `org-link-search-must-match-exact-headline' affects `org-link-search', which is called by `org-id-open' -- so I think the behaviour for these org-id links should be the same as for other file links? Am I missing something? No, you don't. In my testing, I used #+name: as link target. However, what I missed is that #+name targets are matched even when `org-link-search-must-match-exact-headline' is set to 'query-to-create. The docstring is not accurate there and must be updated. > Or, maybe you mean links that rely on `org-link-search-must-match-exact-headline' should not be stored. That would seem reasonable, but also doesn't need to be part of these changes here? Yes, I also meant this. Indeed, it is out of scope of your patch. It was a comment for future reference. >> Probably, changing the default value of >> `org-link-search-must-match-exact-headline' to nil is due. > > It seems like the behaviour below would be desirable, but doesn't currently exist with any setting of `org-link-search-must-match-exact-headline'? > > (org-link-search "plain text") --> fuzzy search for all text > (org-link-search "*heading") --> search only headings, optionally creating if missing That would also make sense. I like this idea. >>> - (org-insert-heading nil t t) >>> + ;; Find appropriate level for new heading >>> + (let ((level (save-excursion >>> + (goto-char (point-min)) >>> + (+ 1 (or (org-current-level) 0))))) >> >> This is fragile. You assume that `point-min' always contains a heading. >> That may or may not be the case - `org-link-search' may be called by >> third-party code that does not care about setting narrowing in certain >> ways. > > I don't think it's a problem. (org-current-level) returns something suitable whether or not point-min contains a heading. Both the situations below seem reasonable choices for the level of the newly created heading at the end: That's right. > ---start of narrowing--- > Text > * H1 > ** H2 > * A new level 1 heading is created at the end > ---end of narrowing--- > > ---start of narrowing--- > * H1 > ** H2 > ** A new level 2 heading is created at the end > ---end of narrowing--- However, the second scenario is unexpected - consider that your narrowing is not a narrowing but the whole contents of an Org file. Before your patch, in both cases, a new level 1 heading is created. With your patch, the second case will create a new level 2 heading even for [[*Foo]] links. It looks like we cannot simply rely on narrowing to determine the created heading level. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at