all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Rodrigo Morales <rodrigo.morales@utec.edu.pe>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Re: [bug] Setting org-id-link-to-org-use-id to t creates IDs properties when tangling
Date: Sun, 11 Jul 2021 20:28:25 +0800	[thread overview]
Message-ID: <87h7h1kpau.fsf@localhost> (raw)
In-Reply-To: <87tul2ihhy.fsf@utec.edu.pe>

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

Rodrigo Morales <rodrigo.morales@utec.edu.pe> writes:

> * The issue
>
> When setting org-id-link-to-org-use-id to t, an :ID: property is created
> for each headline that contain at least one code block that is
> tangled.

Confirmed

The fix is attached.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-creating-ID-property-during-tangling.patch --]
[-- Type: text/x-diff, Size: 2779 bytes --]

From 0ed6b52b8ded461ad6d172b9c2d49fd36d5df129 Mon Sep 17 00:00:00 2001
Message-Id: <0ed6b52b8ded461ad6d172b9c2d49fd36d5df129.1626006467.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sun, 11 Jul 2021 20:25:21 +0800
Subject: [PATCH] Avoid creating ID property during tangling

* lisp/ob-tangle.el (org-babel-tangle-single-block,
org-babel-tangle-comment-links): Suppress org-id-link-to-org-use-id
during tangling.  The links used during tangle process are transient
and do not really need to use ID.  Using ID may create unexpected
edits in the tangled Org buffer when org-id-link-to-org-use-id is set
to t.  Fixes [1].

[1] https://orgmode.org/list/9eb31da73b12fcaf6820484834cc8cd3@libre.brussels/T/#t
---
 lisp/ob-tangle.el | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2f60ef9a4..cec658f66 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -420,7 +420,14 @@ (defun org-babel-tangle-single-block (block-counter &optional only-this-block)
 	 (extra (nth 3 info))
          (coderef (nth 6 info))
 	 (cref-regexp (org-src-coderef-regexp coderef))
-	 (link (let ((l (org-no-properties (org-store-link nil))))
+	 (link (let* (
+                      ;; The created link is transient.  Using ID is
+                      ;; not necessary, but could have side-effects if
+                      ;; used.  An ID property may be added to
+                      ;; existing entries thus creatin unexpected file
+                      ;; modifications.
+                      (org-id-link-to-org-use-id nil)
+                      (l (org-no-properties (org-store-link nil))))
                  (and (string-match org-link-bracket-re l)
                       (match-string 1 l))))
 	 (source-name
@@ -506,7 +513,13 @@ (defun org-babel-tangle-comment-links (&optional info)
 					   (number-to-string
 					    (line-number-at-pos))))
 			("file" . ,(buffer-file-name))
-			("link" . ,(org-no-properties (org-store-link nil)))
+			("link" . ,(let (;; The created link is transient.  Using ID is
+                                         ;; not necessary, but could have side-effects if
+                                         ;; used.  An ID property may be added to
+                                         ;; existing entries thus creatin unexpected file
+                                         ;; modifications.
+                                         (org-id-link-to-org-use-id nil))
+                                     (org-no-properties (org-store-link nil))))
 			("source-name" . ,name))))))
     (list (org-fill-template org-babel-tangle-comment-format-beg link-data)
 	  (org-fill-template org-babel-tangle-comment-format-end link-data))))
-- 
2.31.1


  parent reply	other threads:[~2021-07-11 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-10 10:35 [bug] Setting org-id-link-to-org-use-id to t creates IDs properties when tangling Rodrigo Morales
2021-07-10 18:39 ` Jonathan McHugh
2021-07-11 12:28 ` Ihor Radchenko [this message]
2021-09-26  6:59   ` [PATCH] " Bastien
2023-07-29  7:01     ` Ihor Radchenko
2023-08-08 12:56       ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7h1kpau.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rodrigo.morales@utec.edu.pe \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.