emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* tangling seems to have broken today
@ 2021-05-05 13:38 Eric S Fraga
  2021-05-05 13:41 ` Timothy
  2021-05-05 13:54 ` Sébastien Miquel
  0 siblings, 2 replies; 12+ messages in thread
From: Eric S Fraga @ 2021-05-05 13:38 UTC (permalink / raw)
  To: Emacs Org mode mailing list

I note that the git log shows a commit which affects tangling: 501b2a191

I can no longer tangle with a given file name.  The error I get
indicates that the tangling procedure is looking at the first line of
the actual code block.  For instance, if I have

#+begin_src org
  ,#+begin_src julia :exports none :results output :tangle "svfmon.jl"
    using DigitalFilter
    ...
  ,#+end_src
#+end_src

the error message when trying to tangle says:

Wrong type argument: listp, "using DigitalFilter

followed by the full src block in the *Messages* buffer.  So it seems
that the search for the file name is using the contents of the block.

Switching to the wip-cite-new branch (since I'm playing with that in any
case) solves the problem for me so no panic.

thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-505-g0a651b


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

* Re: tangling seems to have broken today
  2021-05-05 13:38 tangling seems to have broken today Eric S Fraga
@ 2021-05-05 13:41 ` Timothy
  2021-05-05 13:45   ` Bastien
  2021-05-05 13:54 ` Sébastien Miquel
  1 sibling, 1 reply; 12+ messages in thread
From: Timothy @ 2021-05-05 13:41 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: emacs-orgmode


I'd just like to chime in to note that I am also experiencing this issue.

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> I note that the git log shows a commit which affects tangling: 501b2a191
>
> I can no longer tangle with a given file name.  The error I get
> indicates that the tangling procedure is looking at the first line of
> the actual code block.  For instance, if I have
>
> #+begin_src org
>   ,#+begin_src julia :exports none :results output :tangle "svfmon.jl"
>     using DigitalFilter
>     ...
>   ,#+end_src
> #+end_src
>
> the error message when trying to tangle says:
>
> Wrong type argument: listp, "using DigitalFilter
>
> followed by the full src block in the *Messages* buffer.  So it seems
> that the search for the file name is using the contents of the block.
>
> Switching to the wip-cite-new branch (since I'm playing with that in any
> case) solves the problem for me so no panic.
>
> thank you,
> eric


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

* Re: tangling seems to have broken today
  2021-05-05 13:41 ` Timothy
@ 2021-05-05 13:45   ` Bastien
  2021-05-05 16:22     ` [PATCH] " Sébastien Miquel
  0 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2021-05-05 13:45 UTC (permalink / raw)
  To: Timothy; +Cc: Sébastien Miquel, emacs-orgmode, Eric S Fraga

Timothy <tecosaur@gmail.com> writes:

> I'd just like to chime in to note that I am also experiencing this
> issue.

Thanks, I guess Sébastien will be able to fix it.

If you and Eric can find how to fix this while addressing the original
issue Sébastien was trying to resolve, feel free to go ahead.

-- 
 Bastien


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

* Re: tangling seems to have broken today
  2021-05-05 13:38 tangling seems to have broken today Eric S Fraga
  2021-05-05 13:41 ` Timothy
@ 2021-05-05 13:54 ` Sébastien Miquel
  2021-05-05 14:08   ` Eric S Fraga
  1 sibling, 1 reply; 12+ messages in thread
From: Sébastien Miquel @ 2021-05-05 13:54 UTC (permalink / raw)
  To: Eric S Fraga, Timothy; +Cc: emacs-orgmode

Hi Eric, Timothy,

Eric S Fraga writes:
> I can no longer tangle with a given file name.  The error I get
> indicates that the tangling procedure is looking at the first line of
> the actual code block.
What command are you using ?

Running `org-babel-tangle` works for me with latest master using your
example.


-- 
Sébastien Miquel



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

* Re: tangling seems to have broken today
  2021-05-05 13:54 ` Sébastien Miquel
@ 2021-05-05 14:08   ` Eric S Fraga
  2021-05-05 14:17     ` Sébastien Miquel
  0 siblings, 1 reply; 12+ messages in thread
From: Eric S Fraga @ 2021-05-05 14:08 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: emacs-orgmode, Timothy

On Wednesday,  5 May 2021 at 13:54, Sébastien Miquel wrote:
> What command are you using ?
>
> Running `org-babel-tangle` works for me with latest master using your
> example.

I was using org-babel-tangle.  Although, in this case, with C-u before
to tangle just the particular block.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-395-g82fbdd


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

* Re: tangling seems to have broken today
  2021-05-05 14:08   ` Eric S Fraga
@ 2021-05-05 14:17     ` Sébastien Miquel
  2021-05-05 14:20       ` Eric S Fraga
  0 siblings, 1 reply; 12+ messages in thread
From: Sébastien Miquel @ 2021-05-05 14:17 UTC (permalink / raw)
  To: Org Mode List

Eric S Fraga writes:
> I was using org-babel-tangle.  Although, in this case, with C-u before
> to tangle just the particular block.
Indeed, I have broken this. I'll provide a patch, shortly.

-- 
Sébastien Miquel



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

* Re: tangling seems to have broken today
  2021-05-05 14:17     ` Sébastien Miquel
@ 2021-05-05 14:20       ` Eric S Fraga
  0 siblings, 0 replies; 12+ messages in thread
From: Eric S Fraga @ 2021-05-05 14:20 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: Org Mode List

On Wednesday,  5 May 2021 at 14:17, Sébastien Miquel wrote:
> Eric S Fraga writes:
>> I was using org-babel-tangle.  Although, in this case, with C-u before
>> to tangle just the particular block.
> Indeed, I have broken this. I'll provide a patch, shortly.

Thank you!  And I should have given full details earlier. 

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-395-g82fbdd


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

* Re: [PATCH] tangling seems to have broken today
  2021-05-05 13:45   ` Bastien
@ 2021-05-05 16:22     ` Sébastien Miquel
  2021-05-06 11:14       ` Bastien
  2021-05-06 11:19       ` Bastien
  0 siblings, 2 replies; 12+ messages in thread
From: Sébastien Miquel @ 2021-05-05 16:22 UTC (permalink / raw)
  To: Bastien; +Cc: Timothy, emacs-orgmode, Eric S Fraga

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

Hi Bastien,

The issue is that currently tangling a single block by calling
`org-babel-tangle` with a prefix argument fails. This is unrelated to
the earlier thread today, but was introduced by my original commit
a2cb9b853d.

Unfortunately, fixing it requires some refactorisation to avoid code
duplication. To keep the patch as simple as possible, I have
introduced a new helper function, I hope this is okay.

I have tested the attached patch with the uses cases shown so far, as
well as my own and the org test suite.

I apologise again for the troubles.

-- 
Sébastien Miquel


[-- Attachment #2: 0001-ob-tangle.el-Fix-single-block-tangle.patch --]
[-- Type: text/x-patch, Size: 3514 bytes --]

From 69be5864d9c936396317d81b6c39ddb166ac45d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= <sebastien.miquel@posteo.eu>
Date: Wed, 5 May 2021 17:45:09 +0200
Subject: [PATCH] ob-tangle.el: Fix single block tangle

lisp/ob-tangle.el (org-babel-tangle-single-block): Fix the result when
`only-this-block' is `t' to match what is expected by
`org-babel-tangle'.
(org-babel-effective-tangled-filename): Extract the
computation of filename of tangled src block.
(org-babel-tangle-collect-blocks): Use `org-babel-effective-tangled-filename'.
---
 lisp/ob-tangle.el | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 8af03b11a..562776ae8 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -350,6 +350,22 @@ that the appropriate major-mode is set.  SPEC has the form:
 	       (org-fill-template
 		org-babel-tangle-comment-format-end link-data)))))

+(defun org-babel-effective-tangled-filename (buffer-fn src-lang src-tfile)
+  "Return effective tangled filename of a source-code block.
+BUFFER-FN is the name of the buffer, SRC-LANG the language of the
+block and SRC-TFILE is the value of the :tangle header argument,
+as computed by `org-babel-tangle-single-block'."
+  (let ((base-name (cond
+                    ((string= "yes" src-tfile)
+                     ;; Use the buffer name
+                     (file-name-sans-extension buffer-fn))
+                    ((> (length src-tfile) 0) src-tfile)))
+        (ext (or (cdr (assoc src-lang org-babel-tangle-lang-exts)) src-lang)))
+    (when base-name
+      ;; decide if we want to add ext to base-name
+      (if (and ext (string= "yes" src-tfile))
+          (concat base-name "." ext) base-name))))
+
 (defun org-babel-tangle-collect-blocks (&optional lang-re tangle-file)
   "Collect source blocks in the current Org file.
 Return an association list of language and source-code block
@@ -378,17 +394,8 @@ be used to limit the collected code blocks by target file."
 	    ;; file name.
 	    (let* ((block (org-babel-tangle-single-block counter))
                    (src-tfile (cdr (assq :tangle (nth 4 block))))
-		   (base-name (cond
-			       ((string= "yes" src-tfile)
-                                ;; buffer name
-				(file-name-sans-extension
-				 (nth 1 block)))
-			       ((> (length src-tfile) 0) src-tfile)))
-		   (ext (or (cdr (assoc src-lang org-babel-tangle-lang-exts)) src-lang))
-		   (file-name (when base-name
-				;; decide if we want to add ext to base-name
-				(if (and ext (string= "yes" src-tfile))
-				    (concat base-name "." ext) base-name)))
+		   (file-name (org-babel-effective-tangled-filename
+                               (nth 1 block) src-lang src-tfile))
 		   (by-fn (assoc file-name blocks)))
 	      (if by-fn (setcdr by-fn (cons (cons src-lang block) (cdr by-fn)))
 		(push (cons file-name (list (cons src-lang block))) blocks)))))))
@@ -482,7 +489,10 @@ non-nil, return the full association list to be used by
 		  (org-trim (org-remove-indentation body)))
 		comment)))
     (if only-this-block
-	(list (cons src-lang (list result)))
+        (let* ((src-tfile (cdr (assq :tangle (nth 4 result))))
+               (file-name (org-babel-effective-tangled-filename
+                           (nth 1 result) src-lang src-tfile)))
+          (list (cons file-name (list (cons src-lang result)))))
       result)))

 (defun org-babel-tangle-comment-links (&optional info)
-- 
2.31.1

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

* Re: [PATCH] tangling seems to have broken today
  2021-05-05 16:22     ` [PATCH] " Sébastien Miquel
@ 2021-05-06 11:14       ` Bastien
  2021-05-06 11:35         ` Sébastien Miquel
  2021-05-06 11:19       ` Bastien
  1 sibling, 1 reply; 12+ messages in thread
From: Bastien @ 2021-05-06 11:14 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: Eric S Fraga, emacs-orgmode, Timothy

Hi Sébastien,

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

> I apologise again for the troubles.

No problem.  So we're all set here?

Also, nitpick: please don't add a full-stop at the end of the first
line of the commit message (or the subject of your patch).

Thanks,

-- 
 Bastien


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

* Re: [PATCH] tangling seems to have broken today
  2021-05-05 16:22     ` [PATCH] " Sébastien Miquel
  2021-05-06 11:14       ` Bastien
@ 2021-05-06 11:19       ` Bastien
  1 sibling, 0 replies; 12+ messages in thread
From: Bastien @ 2021-05-06 11:19 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: Eric S Fraga, emacs-orgmode, Timothy

Hi Sébastien,

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

> The issue is that currently tangling a single block by calling
> `org-babel-tangle` with a prefix argument fails. This is unrelated to
> the earlier thread today, but was introduced by my original commit
> a2cb9b853d.
>
> Unfortunately, fixing it requires some refactorisation to avoid code
> duplication. To keep the patch as simple as possible, I have
> introduced a new helper function, I hope this is okay.
>
> I have tested the attached patch with the uses cases shown so far, as
> well as my own and the org test suite.

I think this should be applied to the maint branch, right?  In this
case, the patch does not apply.  Can you check and repropose a patch
against maint?  Or just let me know if I'm mistaken.

Thanks,

-- 
 Bastien


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

* Re: [PATCH] tangling seems to have broken today
  2021-05-06 11:14       ` Bastien
@ 2021-05-06 11:35         ` Sébastien Miquel
  2021-05-06 11:38           ` Bastien
  0 siblings, 1 reply; 12+ messages in thread
From: Sébastien Miquel @ 2021-05-06 11:35 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Hi Bastien,

Bastien writes:
> Also, nitpick: please don't add a full-stop at the end of the first
> line of the commit message (or the subject of your patch).
Unless I misunderstand what you mean, the patch seems to follow this
style.

> I think this should be applied to the maint branch, right?  In this
> case, the patch does not apply.  Can you check and repropose a patch
> against maint?  Or just let me know if I'm mistaken.
It fixes an issue introduced by a commit in master, so it should be
applied to master.

> So we're all set here?
This should be it!


Regards,

-- 
Sébastien Miquel



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

* Re: [PATCH] tangling seems to have broken today
  2021-05-06 11:35         ` Sébastien Miquel
@ 2021-05-06 11:38           ` Bastien
  0 siblings, 0 replies; 12+ messages in thread
From: Bastien @ 2021-05-06 11:38 UTC (permalink / raw)
  To: Sébastien Miquel; +Cc: emacs-orgmode

Hi Sébastien,

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

> Unless I misunderstand what you mean, the patch seems to follow this
> style.

Yes, sorry, my bad, I was reacting to another patch.

>> I think this should be applied to the maint branch, right?  In this
>> case, the patch does not apply.  Can you check and repropose a patch
>> against maint?  Or just let me know if I'm mistaken.
> It fixes an issue introduced by a commit in master, so it should be
> applied to master.

Applied in master with commit 6e5b39acd.

>> So we're all set here?
> This should be it!

Thanks!

-- 
 Bastien


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

end of thread, other threads:[~2021-05-06 11:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 13:38 tangling seems to have broken today Eric S Fraga
2021-05-05 13:41 ` Timothy
2021-05-05 13:45   ` Bastien
2021-05-05 16:22     ` [PATCH] " Sébastien Miquel
2021-05-06 11:14       ` Bastien
2021-05-06 11:35         ` Sébastien Miquel
2021-05-06 11:38           ` Bastien
2021-05-06 11:19       ` Bastien
2021-05-05 13:54 ` Sébastien Miquel
2021-05-05 14:08   ` Eric S Fraga
2021-05-05 14:17     ` Sébastien Miquel
2021-05-05 14:20       ` Eric S Fraga

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