Re: [PATCH] Do not throw error when parameter of :tangle is not a string

2021-07-08 Thread Jacopo De Simoi
Hi Sébastien,

‐‐‐ Original Message ‐‐‐

On Thursday, July 8th, 2021 at 4:44 AM, Sébastien Miquel 
 wrote:

> Hi,
>
> Jacopo De Simoi writes:
>
> > in the current master branch, if the parameter :tangle of a src block is not
> >
> > a string, tangling fails by throwing an error when calling `file-name- 
> > directory' This patch checks if the parameter is a string before calling` 
> > file-name-directory'.
> >
> > This makes construct such as :tangle (when condition-applies "filename") 
> > work
> >
> > again (as they did a few versions ago…)
>
> Thanks for the patch. It looks good to me (had to run `dos2unix' to apply).

Dos2unix? I'll make sure it doesn't happen again. It might have to do with 
having sent the patch from Android.

>To clarify, it fixes` :tangle (when condition-applies "filename")' when the
>
> condition doesn't apply, such as `(when nil "filename")'.

Yes, I will update the commit message and resubmit. Thanks!
>
> Regards,
>
> -
>
> Sébastien Miquel



Re: [PATCH] Do not throw error when parameter of :tangle is not a string

2021-07-08 Thread Sébastien Miquel

Hi,

Jacopo De Simoi writes:

  in the current master branch, if the parameter :tangle of a src block is not
a string, tangling fails by throwing  an error when calling `file-name-
directory'  This patch checks if the parameter is a string before calling
`file-name-directory'.

This makes construct such as :tangle (when condition-applies "filename") work
again (as they did a few versions ago…)

Thanks for the patch. It looks good to me (had to run `dos2unix' to apply).

To clarify, it fixes `:tangle (when condition-applies "filename")' when the
condition doesn't apply, such as `(when nil "filename")'.

Regards,

--
Sébastien Miquel




[PATCH} Do not throw error when parameter of :tangle is not a string

2021-07-01 Thread Jacopo De Simoi
Dear All,

 in the current master branch, if the parameter :tangle of a src block is not
a string, tangling fails by throwing  an error when calling `file-name-
directory'  This patch checks if the parameter is a string before calling
`file-name-directory'.

This makes construct such as :tangle (when condition-applies "filename") work
again (as they did a few versions ago…)

Thanks for your time
Best
 JacopoFrom f08ecdb79ec71ecc94fe006043bd8eacc8ac41a0 Mon Sep 17 00:00:00 2001
From: Jacopo De Simoi 
Date: Mon, 28 Jun 2021 15:42:29 -0400
Subject: [PATCH 1/2] ob-tangle.el: Handle non-string arguments more gracefullu

* lisp/ob-tangle.el (org-babel-tangle-single-block): If the
  argument to :tangle is nil (e.g. when parsing conditional
  tangling such as (when condition "yes") the current code
  throws an error in `file-name-directory'.  This commit
  checks if the argument is a string before calling the fun

TINYCHANGE
---
 lisp/ob-tangle.el | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 562776ae8..02379d44e 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -469,6 +469,7 @@ non-nil, return the full association list to be used by
 			 (match-end 0)
 		   (point-min
 	  (point)
+ (src-tfile (cdr (assq :tangle params)))
 	 (result
 	  (list start-line
 		(if org-babel-tangle-use-relative-file-links
@@ -476,11 +477,12 @@ non-nil, return the full association list to be used by
 		  file)
 		(if (and org-babel-tangle-use-relative-file-links
 			 (string-match org-link-types-re link)
-			 (string= (match-string 1 link) "file"))
+			 (string= (match-string 1 link) "file")
+ (stringp src-tfile))
 		(concat "file:"
 			(file-relative-name (substring link (match-end 0))
 		(file-name-directory
-		 (cdr (assq :tangle params)
+		 src-tfile)))
 		  link)
 		source-name
 		params
@@ -489,8 +491,7 @@ non-nil, return the full association list to be used by
 		  (org-trim (org-remove-indentation body)))
 		comment)))
 (if only-this-block
-(let* ((src-tfile (cdr (assq :tangle (nth 4 result
-   (file-name (org-babel-effective-tangled-filename
+(let* ((file-name (org-babel-effective-tangled-filename
(nth 1 result) src-lang src-tfile)))
   (list (cons file-name (list (cons src-lang result)
   result)))
-- 
2.31.1



attachment.asc
Description: PGP signature