emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug] Setting org-id-link-to-org-use-id to t creates IDs properties when tangling
@ 2021-07-10 10:35 Rodrigo Morales
  2021-07-10 18:39 ` Jonathan McHugh
  2021-07-11 12:28 ` [PATCH] " Ihor Radchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Rodrigo Morales @ 2021-07-10 10:35 UTC (permalink / raw)
  To: emacs-orgmode

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


* 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.

* Reproducing this issue

1. Start emacs -Q

2. Open a "*.org" file at a location where you have write permissions
(this is because, apparently, tangling only works when the file is
correctly saved so this way we get rid of this possible issue)

3. Insert the following minimal working example into the buffer (you can
find the Org Mode file attached to this mail)

#+BEGIN_SRC org
,* foo

,#+HEADER: :tangle ~/Downloads/main.txt
,#+BEGIN_SRC text
a
,#+END_SRC

,* bar

,#+HEADER: :tangle ~/Downloads/main.txt
,#+BEGIN_SRC text
a
,#+END_SRC

,* fizz

,#+BEGIN_SRC text
a
,#+END_SRC
#+END_SRC

4. Execute the following commands

#+BEGIN_SRC emacs-lisp
(require 'org-id)
(setq org-id-link-to-org-use-id t)
#+END_SRC

5. Now, execute org-babel-tangle (C-c C-v C-t).

At this point, a id property is created for the "foo" and "bar"
headlines because those are the only headlines that contain a code
block. This is what I got in emacs -Q

#+BEGIN_SRC org
,* foo
  :PROPERTIES:
  :ID:       358560b4-2426-4d42-a498-ae16195daf3a
  :END:

,#+HEADER: :tangle ~/Downloads/main.txt
,#+BEGIN_SRC text
a
,#+END_SRC

,* bar
  :PROPERTIES:
  :ID:       02217461-a744-42b2-b582-1a836568d686
  :END:

,#+HEADER: :tangle ~/Downloads/main.txt
,#+BEGIN_SRC text
a
,#+END_SRC

,* fizz

,#+BEGIN_SRC text
a
,#+END_SRC
#+END_SRC

* Personal thoughts

In my opinion, this is undesired behavior because the goal of
org-id-link-to-org-use-id isn't creating an ID property for each
headline when performing tangling.

* Major undesired consequences

The following is an scenario in which this issue causes major undesired
consequences: Consider the following scenario

+ you have 1000 headlines in an Org Mode file

+ all of those headlines don't have an ID property (because you are not
  interested in uniquely identifying all of those headlines through an ID)
  
+ all of those headlines contain at least one code block that is tangled

Because of this issue, the following would be added for each headline

#+BEGIN_SRC org
,* my headline
:PROPERTIES:
:ID: <<an auto-generated id>>
:END:
#+END_SRC

and this have the following undesired consequences

+ You would end up with 3000 lines in your Org Mode file because of the
  id properties even when you weren't interested in creating an ID for
  each of those headlines.
  
+ You would have 1000 more entries in org-id-locations-file (again, even
  where you weren't interested in creating an ID for each of those
  headlines)


-- 
La información contenida en este e-mail y sus anexos es confidencial, 
privilegiada y está dirigida exclusivamente a su destinatario, en 
consecuencia, solo puede ser utilizada por aquel. Si usted no es el 
destinatario original, no deberá examinar, usar, copiar o distribuir este 
mensaje o la información que contiene. Si lo recibe por error, por favor 
reenvíelo a la persona que se lo envió y elimínelo. Cualquier retención o 
uso total o parcial no autorizada de este mensaje está estrictamente 
prohibida y sancionada por ley.

[-- Attachment #2: main.org --]
[-- Type: text/plain, Size: 189 bytes --]

* foo

#+HEADER: :tangle ~/Downloads/main.txt
#+BEGIN_SRC text
a
#+END_SRC

* bar

#+HEADER: :tangle ~/Downloads/main.txt
#+BEGIN_SRC text
a
#+END_SRC

* fizz

#+BEGIN_SRC text
a
#+END_SRC

[-- Attachment #3: Type: text/plain, Size: 237 bytes --]



-- 
[[[ If you see a signature in spanish below/above this message, please
omit it. It is automatically inserted in all my messages due to the
internal privacy policies of the organization that owns the domain of my
email address. ]]]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug] Setting org-id-link-to-org-use-id to t creates IDs properties when tangling
  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 ` [PATCH] " Ihor Radchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan McHugh @ 2021-07-10 18:39 UTC (permalink / raw)
  To: Rodrigo Morales, emacs-orgmode; +Cc: bugs

Hi Rodrigo,

Regarding the problem of large content volumes and unique identifiers I thought Id CC Jean Marc Louis.

He has been building an Emacs approach to Hyperscope and has been considering this facet (and others). 
=> https://hyperscope.link/

Perhaps he may have some input?


Jonathan McHugh
====================
indieterminacy@libre.brussels

July 10, 2021 12:36 PM, "Rodrigo Morales" <rodrigo.morales@utec.edu.pe> wrote:

> * 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.
> 
> * Reproducing this issue
> 
> 1. Start emacs -Q
> 
> 2. Open a "*.org" file at a location where you have write permissions
> (this is because, apparently, tangling only works when the file is
> correctly saved so this way we get rid of this possible issue)
> 
> 3. Insert the following minimal working example into the buffer (you can
> find the Org Mode file attached to this mail)
> 
> #+BEGIN_SRC org
> ,* foo
> 
> ,#+HEADER: :tangle ~/Downloads/main.txt
> ,#+BEGIN_SRC text
> a
> ,#+END_SRC
> 
> ,* bar
> 
> ,#+HEADER: :tangle ~/Downloads/main.txt
> ,#+BEGIN_SRC text
> a
> ,#+END_SRC
> 
> ,* fizz
> 
> ,#+BEGIN_SRC text
> a
> ,#+END_SRC
> #+END_SRC
> 
> 4. Execute the following commands
> 
> #+BEGIN_SRC emacs-lisp
> (require 'org-id)
> (setq org-id-link-to-org-use-id t)
> #+END_SRC
> 
> 5. Now, execute org-babel-tangle (C-c C-v C-t).
> 
> At this point, a id property is created for the "foo" and "bar"
> headlines because those are the only headlines that contain a code
> block. This is what I got in emacs -Q
> 
> #+BEGIN_SRC org
> ,* foo
> :PROPERTIES:
> :ID: 358560b4-2426-4d42-a498-ae16195daf3a
> :END:
> 
> ,#+HEADER: :tangle ~/Downloads/main.txt
> ,#+BEGIN_SRC text
> a
> ,#+END_SRC
> 
> ,* bar
> :PROPERTIES:
> :ID: 02217461-a744-42b2-b582-1a836568d686
> :END:
> 
> ,#+HEADER: :tangle ~/Downloads/main.txt
> ,#+BEGIN_SRC text
> a
> ,#+END_SRC
> 
> ,* fizz
> 
> ,#+BEGIN_SRC text
> a
> ,#+END_SRC
> #+END_SRC
> 
> * Personal thoughts
> 
> In my opinion, this is undesired behavior because the goal of
> org-id-link-to-org-use-id isn't creating an ID property for each
> headline when performing tangling.
> 
> * Major undesired consequences
> 
> The following is an scenario in which this issue causes major undesired
> consequences: Consider the following scenario
> 
> + you have 1000 headlines in an Org Mode file
> 
> + all of those headlines don't have an ID property (because you are not
> interested in uniquely identifying all of those headlines through an ID)
> 
> + all of those headlines contain at least one code block that is tangled
> 
> Because of this issue, the following would be added for each headline
> 
> #+BEGIN_SRC org
> ,* my headline
> :PROPERTIES:
> :ID: <<an auto-generated id>>
> :END:
> #+END_SRC
> 
> and this have the following undesired consequences
> 
> + You would end up with 3000 lines in your Org Mode file because of the
> id properties even when you weren't interested in creating an ID for
> each of those headlines.
> 
> + You would have 1000 more entries in org-id-locations-file (again, even
> where you weren't interested in creating an ID for each of those
> headlines)
> 
> -- 
> La información contenida en este e-mail y sus anexos es confidencial, 
> privilegiada y está dirigida exclusivamente a su destinatario, en 
> consecuencia, solo puede ser utilizada por aquel. Si usted no es el 
> destinatario original, no deberá examinar, usar, copiar o distribuir este 
> mensaje o la información que contiene. Si lo recibe por error, por favor 
> reenvíelo a la persona que se lo envió y elimínelo. Cualquier retención o 
> uso total o parcial no autorizada de este mensaje está estrictamente 
> prohibida y sancionada por ley.
> 
> -- 
> [[[ If you see a signature in spanish below/above this message, please
> omit it. It is automatically inserted in all my messages due to the
> internal privacy policies of the organization that owns the domain of my
> email address. ]]]


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Re: [bug] Setting org-id-link-to-org-use-id to t creates IDs properties when tangling
  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
  2021-09-26  6:59   ` Bastien
  1 sibling, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2021-07-11 12:28 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: emacs-orgmode

[-- 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Re: [bug] Setting org-id-link-to-org-use-id to t creates IDs properties when tangling
  2021-07-11 12:28 ` [PATCH] " Ihor Radchenko
@ 2021-09-26  6:59   ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2021-09-26  6:59 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Rodrigo Morales, emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> The fix is attached.

Applied, thanks!

-- 
 Bastien


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-26  7:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH] " Ihor Radchenko
2021-09-26  6:59   ` Bastien

Code repositories for project(s) associated with this inbox:

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).