* [PATCH] ob-core: tangle check library of babel after current buffer
@ 2021-06-16 23:29 Tom Gillespie
2021-07-17 17:42 ` Tom Gillespie
0 siblings, 1 reply; 5+ messages in thread
From: Tom Gillespie @ 2021-06-16 23:29 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 138 bytes --]
Hi,
This is a patch that fixes tangling behavior when a block has been
ingested into the library of babel and then modified. Best!
Tom
[-- Attachment #2: 0001-ob-core-tangle-check-library-of-babel-after-current.patch --]
[-- Type: text/x-patch, Size: 1706 bytes --]
From 22d0689257f977d09b013a143e899f788b45a039 Mon Sep 17 00:00:00 2001
From: Tom Gillespie <tgbugs@gmail.com>
Date: Mon, 14 Jun 2021 19:18:28 -0700
Subject: [PATCH] ob-core: tangle check library of babel after current buffer
* lisp/ob-core.el (org-babel-expand-noweb-references): Fix order when
searching for named babel blocks so that blocks in the current buffer
are always found first. This fixes a bug where stale versions of
blocks that have been ingested into the library of babel were being
preferentially tangled instead of newly modified versions from the
current buffer.
---
lisp/ob-core.el | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 857e03e55..384c06c9a 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2828,8 +2828,6 @@ block but are passed literally to the \"example-block\"."
(setq cache nil)
(let ((raw (org-babel-ref-resolve id)))
(if (stringp raw) raw (format "%S" raw))))
- ;; Retrieve from the Library of Babel.
- ((nth 2 (assoc-string id org-babel-library-of-babel)))
;; Return the contents of headlines literally.
((org-babel-ref-goto-headline-id id)
(org-babel-ref-headline-body))
@@ -2842,6 +2840,8 @@ block but are passed literally to the \"example-block\"."
(not (org-in-commented-heading-p))
(funcall expand-body
(org-babel-get-src-block-info t))))))
+ ;; Retrieve from the Library of Babel.
+ ((nth 2 (assoc-string id org-babel-library-of-babel)))
;; All Noweb references were cached in a previous
;; run. Extract the information from the cache.
((hash-table-p cache)
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ob-core: tangle check library of babel after current buffer
2021-06-16 23:29 [PATCH] ob-core: tangle check library of babel after current buffer Tom Gillespie
@ 2021-07-17 17:42 ` Tom Gillespie
2021-07-17 20:33 ` Nick Dokos
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Tom Gillespie @ 2021-07-17 17:42 UTC (permalink / raw)
To: emacs-orgmode
Pinging on this to see if anyone can test it so that it can be merged.
Tom
On Wed, Jun 16, 2021 at 4:29 PM Tom Gillespie <tgbugs@gmail.com> wrote:
>
> Hi,
> This is a patch that fixes tangling behavior when a block has been
> ingested into the library of babel and then modified. Best!
> Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ob-core: tangle check library of babel after current buffer
2021-07-17 17:42 ` Tom Gillespie
@ 2021-07-17 20:33 ` Nick Dokos
2021-07-17 21:40 ` Rodrigo Morales
2021-07-24 19:41 ` Timothy
2 siblings, 0 replies; 5+ messages in thread
From: Nick Dokos @ 2021-07-17 20:33 UTC (permalink / raw)
To: emacs-orgmode
Tom Gillespie <tgbugs@gmail.com> writes:
> Pinging on this to see if anyone can test it so that it can be merged.
> Tom
>
> On Wed, Jun 16, 2021 at 4:29 PM Tom Gillespie <tgbugs@gmail.com> wrote:
>>
>> Hi,
>> This is a patch that fixes tangling behavior when a block has been
>> ingested into the library of babel and then modified. Best!
>> Tom
>
>
I have not tested it but I reviewed the code and it looks good to me.
--
Nick
"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ob-core: tangle check library of babel after current buffer
2021-07-17 17:42 ` Tom Gillespie
2021-07-17 20:33 ` Nick Dokos
@ 2021-07-17 21:40 ` Rodrigo Morales
2021-07-24 19:41 ` Timothy
2 siblings, 0 replies; 5+ messages in thread
From: Rodrigo Morales @ 2021-07-17 21:40 UTC (permalink / raw)
To: Tom Gillespie; +Cc: emacs-orgmode
Tom Gillespie <tgbugs@gmail.com> writes:
> Pinging on this to see if anyone can test it so that it can be merged.
> Tom
I agree with this patch.
Just to make clear the default behavior and the behavior that would
exist with this patch.
The current behavior
1. You have a code block C1 in a buffer B1.
2. You execute =org-babel-lob-ingest= on B1. This means that C1 now
exists in =org-babel-library-of-babel=.
3. You modify C1.
4. You tangle a code block C2 which includes a noweb reference to C1.
5. The version of =org-babel-library-of-babel= would be used instead of
the one from the current buffer.
The behavior that would be available is
(same steps)
5. The version of the current buffer is used instead.
--
[[[ If you see a signature in spanish below 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. ]]]
--
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ob-core: tangle check library of babel after current buffer
2021-07-17 17:42 ` Tom Gillespie
2021-07-17 20:33 ` Nick Dokos
2021-07-17 21:40 ` Rodrigo Morales
@ 2021-07-24 19:41 ` Timothy
2 siblings, 0 replies; 5+ messages in thread
From: Timothy @ 2021-07-24 19:41 UTC (permalink / raw)
To: Tom Gillespie; +Cc: emacs-orgmode
Hi Tom,
Sorry that it's taken so long for someone to get to this. I've just
applied your patch to my local Org instance, and then tested the
described behaviour before and afterwards. I can confirm that the issue
reported exists, and that your patch fixes this.
In light of this and the two other positive reviews here, I feel it's
pretty safe, and so have applied this patch as f052acee5 :)
--
Timothy
Tom Gillespie <tgbugs@gmail.com> writes:
> Pinging on this to see if anyone can test it so that it can be merged.
> Tom
>
> On Wed, Jun 16, 2021 at 4:29 PM Tom Gillespie <tgbugs@gmail.com> wrote:
>>
>> Hi,
>> This is a patch that fixes tangling behavior when a block has been
>> ingested into the library of babel and then modified. Best!
>> Tom
--
Timothy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-24 19:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-16 23:29 [PATCH] ob-core: tangle check library of babel after current buffer Tom Gillespie
2021-07-17 17:42 ` Tom Gillespie
2021-07-17 20:33 ` Nick Dokos
2021-07-17 21:40 ` Rodrigo Morales
2021-07-24 19:41 ` Timothy
Code repositories for project(s) associated with this public 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).