all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (no subject)
@ 2012-01-23 12:00 Tom Regner
  2012-01-23 16:34 ` Tom Regner
  2012-01-23 20:31 ` Eric Schulte
  0 siblings, 2 replies; 8+ messages in thread
From: Tom Regner @ 2012-01-23 12:00 UTC (permalink / raw)
  To: emacs-orgmode

From aea3adc952de33aa9acad94fbd9baa717b7b1a1e Mon Sep 17 00:00:00 2001
From: Tom Regner <tom@goochesa.de>
Rcpt To: emacs-orgmode@gnu.org
Date: Mon, 23 Jan 2012 12:39:52 +0100
Subject: [PATCH] ob.el Adhere to current :padline header during noweb dereferencing.

At the moment using the :noweb-ref: property approach on subtrees results in the tangled code beeing broken
because the newlines before the #+end_src line are excluded from the output. This patch uses :padline
to check if a newline should be added. The default being yes, tangling with subtree mangling now produces correct
results; code depending on the (errorneous?) behaviour would be broken though.
---
 lisp/ob.el |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/ob.el b/lisp/ob.el
index 47be708..398a997 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -2211,13 +2211,16 @@ block but are passed literally to the \"example-block\"."
 					     (nth 4 i))
 					 source-name)
 			      (let* ((body (org-babel-expand-noweb-references i))
-				     (full (if comment
+					 (padded (if (not (string= "no" (cdr (assoc :padline (nth 2 i)))))
+								(concat body "\n") 
+								body ))
+					 (full (if comment
 					       ((lambda (cs)
 						  (concat (c-wrap (car cs)) "\n"
-							  body "\n"
+							  padded "\n"
 							  (c-wrap (cadr cs))))
 						(org-babel-tangle-comment-links i))
-					     body)))
+					     padded)))
 				(setq expansion (concat expansion full))))))))
 		    expansion)
 		  ;; possibly raise an error if named block doesn't exist
-- 
1.7.5.4

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

* Re: (no subject)
  2012-01-23 12:00 (no subject) Tom Regner
@ 2012-01-23 16:34 ` Tom Regner
  2012-01-23 20:31 ` Eric Schulte
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Regner @ 2012-01-23 16:34 UTC (permalink / raw)
  To: emacs-orgmode

Tom Regner <tom@goochesa.de> writes:

> From aea3adc952de33aa9acad94fbd9baa717b7b1a1e Mon Sep 17 00:00:00 2001
> From: Tom Regner <tom@goochesa.de>
> Rcpt To: emacs-orgmode@gnu.org
> Date: Mon, 23 Jan 2012 12:39:52 +0100
> Subject: [PATCH] ob.el Adhere to current :padline header during noweb dereferencing.
[...]
I'm awfully sorry -- shall I remail the patch without the errorneous
empty line in between the headers, so that the patchwork server will
receive it?

kind regards,
Tom

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

* Re: (no subject)
  2012-01-23 12:00 (no subject) Tom Regner
  2012-01-23 16:34 ` Tom Regner
@ 2012-01-23 20:31 ` Eric Schulte
  2012-01-24  1:55   ` Tom Regner
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2012-01-23 20:31 UTC (permalink / raw)
  To: Tom Regner; +Cc: emacs-orgmode

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

I'd rather not change the default silently in this way.

Could you provide a minimal example of the difference you describe?  I
just tried viewing the expanded form of the following code block and saw
no difference between :noweb-ref and normal #+name: based expansions.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nowebs.org --]
[-- Type: text/x-org, Size: 175 bytes --]

* examples

#+name: first
#+begin_src sh
  echo 1
#+end_src

#+begin_src sh :noweb-ref second
  echo 2
#+end_src

#+begin_src sh :noweb yes
  <<first>>
  <<second>>
#+end_src

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


Thanks,

Tom Regner <tom@goochesa.de> writes:

> From aea3adc952de33aa9acad94fbd9baa717b7b1a1e Mon Sep 17 00:00:00 2001
> From: Tom Regner <tom@goochesa.de>
> Rcpt To: emacs-orgmode@gnu.org
> Date: Mon, 23 Jan 2012 12:39:52 +0100
> Subject: [PATCH] ob.el Adhere to current :padline header during noweb dereferencing.
>
> At the moment using the :noweb-ref: property approach on subtrees results in the tangled code beeing broken
> because the newlines before the #+end_src line are excluded from the output. This patch uses :padline
> to check if a newline should be added. The default being yes, tangling with subtree mangling now produces correct
> results; code depending on the (errorneous?) behaviour would be broken though.
> ---
>  lisp/ob.el |    9 ++++++---
>  1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/lisp/ob.el b/lisp/ob.el
> index 47be708..398a997 100644
> --- a/lisp/ob.el
> +++ b/lisp/ob.el
> @@ -2211,13 +2211,16 @@ block but are passed literally to the \"example-block\"."
>  					     (nth 4 i))
>  					 source-name)
>  			      (let* ((body (org-babel-expand-noweb-references i))
> -				     (full (if comment
> +					 (padded (if (not (string= "no" (cdr (assoc :padline (nth 2 i)))))
> +								(concat body "\n") 
> +								body ))
> +					 (full (if comment
>  					       ((lambda (cs)
>  						  (concat (c-wrap (car cs)) "\n"
> -							  body "\n"
> +							  padded "\n"
>  							  (c-wrap (cadr cs))))
>  						(org-babel-tangle-comment-links i))
> -					     body)))
> +					     padded)))
>  				(setq expansion (concat expansion full))))))))
>  		    expansion)
>  		  ;; possibly raise an error if named block doesn't exist

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: (no subject)
  2012-01-23 20:31 ` Eric Schulte
@ 2012-01-24  1:55   ` Tom Regner
  2012-01-24  2:49     ` string joining accumulated noweb references Was: " Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Regner @ 2012-01-24  1:55 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:

> I'd rather not change the default silently in this way.
I understand that.
>
> Could you provide a minimal example of the difference you describe?  I
> just tried viewing the expanded form of the following code block and saw
> no difference between :noweb-ref and normal #+name: based expansions.
>
> * examples
>
> #+name: first
> #+begin_src sh
>   echo 1
> #+end_src
>
> #+begin_src sh :noweb-ref second
>   echo 2
> #+end_src
> #+begin_src sh :noweb yes
>   <<first>>
>   <<second>>
> #+end_src
>
> Thanks,
>

Example document:
--------------------------->%--------------------------------
* Subtree
  :PROPERTIES:
  :noweb-ref: subtree
  :END:
** Part 1
#+begin_src sh  
  Line One
#+end_src sh 
** Part 2
#+begin_src sh 
  Line Two
#+end_src sh
* Assamble it
#+begin_src sh :tangle yes :noweb tangle
  <<subtree>>
#+end_src sh
--------------------------->%--------------------------------


tangled without my patch:

--------------------------->%--------------------------------

Line OneLine Two
--------------------------->%--------------------------------


tangled with my patch

--------------------------->%--------------------------------

Line One
Line Two
--------------------------->%--------------------------------

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

* Re: string joining accumulated noweb references Was: (no subject)
  2012-01-24  1:55   ` Tom Regner
@ 2012-01-24  2:49     ` Eric Schulte
  2012-01-24  4:46       ` string joining accumulated noweb references Tom Regner
  2012-01-24  6:24       ` Achim Gratz
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Schulte @ 2012-01-24  2:49 UTC (permalink / raw)
  To: Tom Regner; +Cc: emacs-orgmode

Tom Regner <tom@goochesa.de> writes:

> Eric Schulte <eric.schulte@gmx.com> writes:
>
>> I'd rather not change the default silently in this way.
> I understand that.

My apologies, now that I understand the issue I see that the current
behavior is most likely confusing and I agree with your original
suggestion to change the default.

> Example document:
> --------------------------->%--------------------------------
> * Subtree
>   :PROPERTIES:
>   :noweb-ref: subtree
>   :END:
> ** Part 1
> #+begin_src sh  
>   Line One
> #+end_src sh 
> ** Part 2
> #+begin_src sh 
>   Line Two
> #+end_src sh
> * Assamble it
> #+begin_src sh :tangle yes :noweb tangle
>   <<subtree>>
> #+end_src sh

I just pushed up a new customization variable named
`org-babel-noweb-separator' which is used to join multiple accumulated
noweb references like the above.  The value defaults to a newline giving
the same behavior resulting from your patch but can be set to any
string.

Thanks for pointing this out,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: string joining accumulated noweb references
  2012-01-24  2:49     ` string joining accumulated noweb references Was: " Eric Schulte
@ 2012-01-24  4:46       ` Tom Regner
  2012-01-24  6:24       ` Achim Gratz
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Regner @ 2012-01-24  4:46 UTC (permalink / raw)
  To: emacs-orgmode


Wow - this is /fast/ development :-); now I'm glad my son kept me awake
this night, so that I could check my mails sooner than I normaly would have...

Eric Schulte <eric.schulte@gmx.com> writes:

> Tom Regner <tom@goochesa.de> writes:
>
>> Eric Schulte <eric.schulte@gmx.com> writes:
>>
>>> I'd rather not change the default silently in this way.
>> I understand that.
>
> My apologies, now that I understand the issue I see that the current
> behavior is most likely confusing and I agree with your original
> suggestion to change the default.

Yes, well -- but changing current behaviour is always tricky -- you
never know, how many people/documents rely on it. That's why I think
that... 

>
>> Example document:
>> --------------------------->%--------------------------------
>> * Subtree
>>   :PROPERTIES:
[...]
>
> I just pushed up a new customization variable named
> `org-babel-noweb-separator' which is used to join multiple accumulated
> noweb references like the above.  The value defaults to a newline giving
> the same behavior resulting from your patch but can be set to any
> string.

...this change is way better than my proposal; as it now does the "right
thing"™ per default, but existing workflows depending on the old
behaviour are easily mended.

Thanks again -- impressive speed in reacting and thinking, and overall a
polite and civil environment for contributors. I like that. 

Kind regards,
Tom

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

* Re: string joining accumulated noweb references
  2012-01-24  2:49     ` string joining accumulated noweb references Was: " Eric Schulte
  2012-01-24  4:46       ` string joining accumulated noweb references Tom Regner
@ 2012-01-24  6:24       ` Achim Gratz
  2012-01-24  7:04         ` Eric Schulte
  1 sibling, 1 reply; 8+ messages in thread
From: Achim Gratz @ 2012-01-24  6:24 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <eric.schulte@gmx.com> writes:
> I just pushed up a new customization variable named
> `org-babel-noweb-separator' which is used to join multiple accumulated
> noweb references like the above.  The value defaults to a newline giving
> the same behavior resulting from your patch but can be set to any
> string.

Now, lets say I'd want to accumulate one set of noweb references with
one separator and another set with a different one, maybe even in the
same document.  How'd I do that?

Also, using a customization variable for the purpose of changing the
semantics of documents is generally fraught with peril: if someone does
customize this variable, their documents will break in subtle ways for
somebody with a different or no customization.  I suggest that such
changes should always be visible in the source document itself.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

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

* Re: string joining accumulated noweb references
  2012-01-24  6:24       ` Achim Gratz
@ 2012-01-24  7:04         ` Eric Schulte
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Schulte @ 2012-01-24  7:04 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Achim Gratz <Stromeko@nexgo.de> writes:

> Eric Schulte <eric.schulte@gmx.com> writes:
>> I just pushed up a new customization variable named
>> `org-babel-noweb-separator' which is used to join multiple accumulated
>> noweb references like the above.  The value defaults to a newline giving
>> the same behavior resulting from your patch but can be set to any
>> string.
>
> Now, lets say I'd want to accumulate one set of noweb references with
> one separator and another set with a different one, maybe even in the
> same document.  How'd I do that?
>

Not possible in the same document, although on a document-by-document
basis I would recommend the use of file local variables.

>
> Also, using a customization variable for the purpose of changing the
> semantics of documents is generally fraught with peril: if someone does
> customize this variable, their documents will break in subtle ways for
> somebody with a different or no customization.  I suggest that such
> changes should always be visible in the source document itself.
>

That is a very good point.  I had originally started to implement this
parameter using a header argument, but then decided that it didn't make
sense to implement a multi-block parameter using a header argument.  Now
that you mention this however I do agree that a customization parameter
is even less appropriate.

Given that header arguments may be set on the file and subtree level, I
suppose they do offer the range of application appropriate for this sort
of parameter, and they are more likely (though not guaranteed) to have
their value present in the buffer.

I've just pushed up a change converting the `org-babel-noweb-separator'
customization variable to the :noweb-sep header argument.

Thanks,

>
>
> Regards,
> Achim.

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

end of thread, other threads:[~2012-01-24  7:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-23 12:00 (no subject) Tom Regner
2012-01-23 16:34 ` Tom Regner
2012-01-23 20:31 ` Eric Schulte
2012-01-24  1:55   ` Tom Regner
2012-01-24  2:49     ` string joining accumulated noweb references Was: " Eric Schulte
2012-01-24  4:46       ` string joining accumulated noweb references Tom Regner
2012-01-24  6:24       ` Achim Gratz
2012-01-24  7:04         ` Eric Schulte

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.