From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id MN7YIuigt2VAXAAAe85BDQ:P1 (envelope-from ) for ; Mon, 29 Jan 2024 13:58:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id MN7YIuigt2VAXAAAe85BDQ (envelope-from ) for ; Mon, 29 Jan 2024 13:58:16 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fR2aeKGV; 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=1706533096; 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=jfC65xDlW9r0TvIg7j58wTsoQyJJ4f5D+KMqSpAJ8p8=; b=gGwzIUMvcPjT/9K7se4rSkw3THLB6Nhi0p0zndNIGLG2Muzs7/4yKqbXgJ2cDFds08U/bv LN3X55eNfxTTiKYVPK+oAFjOg7J0cQ4RN8h/G2tmNiPAlir2Jbvt/tazGEVo4h86Z6MQi9 4lsqx7/GZ71ewa7Ndw2zI//M4/4H/Dk1pYB+/9GzWp3Of0thlu0yyYCzMRlOOI208FOlap ZwRxmhhb7M6P7M5H0qM0tMpTsZP8YYbUmAJTw0NdhHWxZE8EEIkGqWjkKy2YZ9sAeSyPaD Z7MlaLCzgKYBI4AME33F1Y62mSLoaac5OZMoTFtgCuten89BpX7eDnZw31VWPg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=fR2aeKGV; 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-Seal: i=1; s=key1; d=yhetil.org; t=1706533096; a=rsa-sha256; cv=none; b=I9i4pY6adiKmke/BvJyIPrgAEfHPe7vt9TjBYoNGqtI5jhMTVB4P0x0tSF6d3IbC1VVwgm SN1Q2chldKqOIHryfRy+4FHJpFT8af1YqcwusZCsU6a5MDt8Cp79B0z3p4VLMyXkI5nIrm M23tQB7Q7pNVDFGITnAMrZdN+HSNRNWct/tnyk/C+oDKmSrlLRZB9njIZ8irSDHo2pXnb/ QTnOMgaoXsgV6P2NO0Nzr04HPBsbq7CrOOX27Ion24YGUAYXrkAjHunGz9pI3xruefWJ09 GztsCJESpZDE1tBvzFKKVn/zt/43x2BitBsc59RnXdfwZJvgqgjs8rslHVSWYA== 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 2B59355D30 for ; Mon, 29 Jan 2024 13:58:15 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rURCb-0003uF-3P; Mon, 29 Jan 2024 07:57:29 -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 1rURCY-0003tm-Qq for emacs-orgmode@gnu.org; Mon, 29 Jan 2024 07:57:26 -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 1rURCW-0006Jq-48 for emacs-orgmode@gnu.org; Mon, 29 Jan 2024 07:57:26 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id BE763240103 for ; Mon, 29 Jan 2024 13:57:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1706533040; bh=a/hU3+ryWagRqZOErpdKG5DazzqopuoUqD9qb5KSD88=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=fR2aeKGVm1ckQVk5PrOJ6p3btEq8FRsWbLVjWdKlpi+/hfTcaA2YeVmQ6D6oac7+9 PWnc0qvLq3VPxMjrKmr+Lnzf8TXPSP67Hm9r5Gr8fkKxFBGZDdjJBa4iYmcFuviOae 0o/NnvmsBRJCPQzbvA9l/RiMCYHHSAQOpSwSkL7j0TqnEje01N7sCWBTxER2Yu6+pb ZviJ5p7BSnQpzKT/ILSQhRA06W7zzpBsKUzt1D5Wwd3nI1c+pyEJEd/hWmq8CYboAR n8nJ7V8j7ou4ShWIixRZjNSNo8Og4rpeKqOFlPIBrVIIWaFYNTmdZyDqNM8m0d1Gxu 6cO3HCoyYgAVA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TNpH33jQTz6twv; Mon, 29 Jan 2024 13:57:19 +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: <1b50d1a4-8573-4dcc-9427-8970f67e632a@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> Date: Mon, 29 Jan 2024 13:00:49 +0000 Message-ID: <87r0i0mgzi.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@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-Spam-Score: -9.88 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: -9.88 X-Migadu-Queue-Id: 2B59355D30 X-TUID: qdsHVps2j0ma "Rick Lupton" writes: > Thanks for trying it out. Updated patches attached, comments below. Thanks! >> 3. Consider >> (setq org-id-link-consider-parent-id t) >> (setq org-id-link-to-org-use-id t) >> >> Then, create a new empty Org file >> M-x org-store-link with create a top-level properties drawer with ID >> and store the link. However, that link will not be a simple ID link, >> but also have ::PROPERTIES search string, which is not expected. > > This is because it is trying to link to the current line of the file, which contains the text "PROPERTIES". On main, with (setq org-id-link-to-org-use-id nil), you see the equivalent behaviour (a link to [[file:test.org:::PROPERTIES:]]) when point is before the first heading. So, this seems consistent with non-org-id links? No. Do note that my instructions start from _empty_ file. With org-id-link-to-org-use-id, PROPERTIES drawer is not created. This is different from what happens with your patch - it is unexpected in your patch that the search string is added for text that did not exist in the buffer previously. > (these links don't actually work with the default value of > `org-link-search-must-match-exact-headline', but I think that's a > separate issue). That's a good catch. 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'. Probably, changing the default value of `org-link-search-must-match-exact-headline' to nil is due. > Subject: [PATCH 2/2] org-id.el: Extend links with search strings, inherit > parent IDs I ran make test, and it looks like one test is failing with your patch: 1 unexpected results: FAILED test-org-link/id-store-link-using-parent ((should (equal '("id:abc" "H1") (test-ol-stored-link-with-text "* H1\n:PROPERTIES:\n:ID: abc\n:END:\n** H2\n" (org-id-store-link)))) :form (equal ("id:abc" "H1") ("id:88e0c8d7-90a6-4628-b35a-cea989e3561b" "H2")) :value nil :explanation (list-elt 0 (arrays-of-different-length 6 39 "id:abc" "id:88e0c8d7-90a6-4628-b35a-cea989e3561b" first-mismatch-at 3))) > + #+vindex: org-id-link-consider-parent-id > + When ~org-id-link-consider-parent-id~ is ~t~ (and > + ~org-context-in-file-links~ and ~org-id-link-use-context~ are both `org-context-in-file-links' is an obsolete name. Use `org-link-context-for-files'. Also, please add `org-id-link-use-context' to #+vindex. > +**** =org-link= store functions are passed an ~interactive?~ argument > + > +The ~:store:~ functions set for link types using > +~org-link-set-parameters~ are now passed an ~interactive?~ argument, > +indicating whether ~org-store-link~ was called interactively. > + > +Existing store functions will continue to work. Please update the docstring of `org-store-link-functions' to specify that an argument is passed to :store functions. (org-link-parameters docstring says :store Function responsible for storing the link. See the function org-store-link-functions for a description of the expected arguments. ) > - (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. It is more reliable to do something like (while (org-up-heading-safe) ...) to find the lowest-level ancestor. > +(defun org-link-precise-link-target (&optional relative-to) > + "Determine search string and description for storing a link. > + > +If a search string (see 'org-link-search') is found, return cons Quoting: `org-link-search'. > + (let* ((element (org-element-at-point)) > + (name (org-element-property :name element)) > + (heading (org-element-lineage element 'headline t)) What about inlinetasks? > + (custom-id (org-entry-get nil "CUSTOM_ID"))) May as well pass HEADING as the first argument of `org-entry-get'. It will be slightly more efficient. > + (org-link--add-to-stored-links link desc) > + ;; In org buffers, store an additional "human-readable" link > + ;; using custom id, if available. > + (when (and (buffer-file-name (buffer-base-buffer)) > + (derived-mode-p 'org-mode) > + (org-entry-get nil "CUSTOM_ID")) > + (setq link (concat "file:" > + (abbreviate-file-name > + (buffer-file-name (buffer-base-buffer))) > + "::#" (org-entry-get nil "CUSTOM_ID"))) This is fragile - you are relying upon the exact code used to store file:...#CUSTOM-ID link. Instead, please refactor the function to re-use that code. > + (id-location (or (and org-entry-property-inherited-from > + (marker-position org-entry-property-inherited-from)) > + (save-excursion (org-back-to-heading-or-point-min) (point)))) > (case-fold-search nil) > (desc (save-excursion > - (org-back-to-heading-or-point-min t) > + (goto-char id-location) You are calling `org-back-to-heading-or-point-min' without optional argument INVISIBLE-OK. This looks like an oversight. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at