Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-13 Thread Rainer M Krug
Sebastien Vauban 
writes:

> Rainer M Krug wrote:
>> what do you mean by ECM?
>
> http://orgmode.org/worg/org-faq.html#ecm

Ah - learned something.

Merci beaucoup,

Rainer

>
> Best regards,
>   Seb

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature


Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-13 Thread Sebastien Vauban
Rainer M Krug wrote:
> what do you mean by ECM?

http://orgmode.org/worg/org-faq.html#ecm

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-13 Thread Rainer M Krug
Nicolas Goaziou  writes:

> Rainer M Krug  writes:
>
>> I think I will skip the bonus points this time - sorry.
>
> OK. You may also send me a couple of ECM, so I can turn them into tests.

Sorry - what do you mean by ECM?

>
>> I would be very grateful if you could submit the patch without a test.
>
> Applied. Thank you.

Thanks,

Rainer

>
>
> Regards.
>
>

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature


Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-12 Thread Nicolas Goaziou
Rainer M Krug  writes:

> I think I will skip the bonus points this time - sorry.

OK. You may also send me a couple of ECM, so I can turn them into tests.

> I would be very grateful if you could submit the patch without a test.

Applied. Thank you.


Regards.



Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-12 Thread Charles C. Berry

On Thu, 12 Feb 2015, Rainer M Krug wrote:



Rainer M Krug  writes:


Nicolas Goaziou  writes:


Hello,

Rainer M Krug  writes:


Please find attached the below described patch including the fix for the
error reported - function raises error when property value is numeric.


Looks good. Thank you.


Thanks.







Could you provide an appropriate commit message?


Here is the patch attached with the commit message - hope it is OK.


Bonus points if you also add a test.


I think I will skip the bonus points this time - sorry.

I would be very grateful if you could submit the patch without a test.

Cheers,

Rainer



Are there some guidelines on how to write tests? Never done this before...


Alan's suggestions are good. To which I might add browse `testing/README'.

Try this. Evaluate these blocks:

#+BEGIN_SRC emacs-lisp :var here=(buffer-file-name)
  (add-to-list 'load-path (file-name-directory here))
  (require 'org-test)
#+END_SRC

#+BEGIN_SRC emacs-lisp
(ert-deftest test-org-babel/view-src-block-info-for-identity ()
  "Check `(identity #o444)' in header-args property."
  (org-test-with-temp-text
  "#+PROPERTY: header-args  :tangle-mode (identity #o444)
  ,#+begin_src emacs-lisp
  (+ 1 2)
  ,#+end_src"
(org-mode-restart)
(forward-line 2)
(org-babel-view-src-block-info)))
#+END_SRC

Then do ` M-x ert RET t RET' and a window should pop up showing that
you either passed (with your patch) or failed (without your patch) 1
test.

If that much works, then submit a patch for testing/lisp/test-ob.el.

HTH,

Chuck




Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-12 Thread Rainer M Krug

Rainer M Krug  writes:

> Nicolas Goaziou  writes:
>
>> Hello,
>>
>> Rainer M Krug  writes:
>>
>>> Please find attached the below described patch including the fix for the
>>> error reported - function raises error when property value is numeric.
>>
>> Looks good. Thank you.
>
> Thanks.
>
>>
>
>
>> Could you provide an appropriate commit message?
>
> Here is the patch attached with the commit message - hope it is OK.
>
>> Bonus points if you also add a test.

I think I will skip the bonus points this time - sorry.

I would be very grateful if you could submit the patch without a test.

Cheers,

Rainer

>
> Are there some guidelines on how to write tests? Never done this before...
>
> Rainer
>
>>
>> Regards,

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature


Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-12 Thread Rainer M Krug
Alan Schmitt  writes:

> Hello,
>
> On 2015-02-10 22:58, Rainer M Krug  writes:
>
>> Are there some guidelines on how to write tests? Never done this before...
>
> I recently wrote my first test, so here is how I did it.
>
> - find a similar test in testing/lisp/el (maybe in test-ob-exp.el)
> - load the file testing/org-test.el (it has many helper functions,
>   I needed them when testing links)
> - write and evaluate your ert-deftest
> - call ert to run the test
>

Thanks a lot.

I looked at them, but I think I skip the test (and the bonus-points)
this time (my limited elisp would make it quite a mission, I guess)

Cheers,

Rainer


> Alan

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature


Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-11 Thread Alan Schmitt
Hello,

On 2015-02-10 22:58, Rainer M Krug  writes:

> Are there some guidelines on how to write tests? Never done this before...

I recently wrote my first test, so here is how I did it.

- find a similar test in testing/lisp/el (maybe in test-ob-exp.el)
- load the file testing/org-test.el (it has many helper functions,
  I needed them when testing links)
- write and evaluate your ert-deftest
- call ert to run the test

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7


signature.asc
Description: PGP signature


Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-10 Thread Rainer M Krug
Nicolas Goaziou  writes:

> Hello,
>
> Rainer M Krug  writes:
>
>> Please find attached the below described patch including the fix for the
>> error reported - function raises error when property value is numeric.
>
> Looks good. Thank you.

Thanks.

>From 6461f4de49fbcd002913a58ac5b47453e965ac0d Mon Sep 17 00:00:00 2001
From: "Rainer M. Krug" 
Date: Tue, 10 Feb 2015 09:32:46 +0100
Subject: [PATCH] ob-core.el: Fix numeric error and add header-args

* lisp/ob-core.el (org-babel-view-src-block-info): when a property
  value was numeric, an error was raised. Fixed by converting property
  value to string before evauation.

* lisp/ob-core.el (org-babel-view-src-block-info): Add property string
  "header args" to output of org-babel-view-src-block-info to make
  debugging of header-args setting problems easier.

* lisp/ob-core.el (org-babel-view-src-block-info): Add property string
  for language specific "header args:LANG" to output of org-babel-view-src-block-info to make
  debugging of header-args setting problems easier.
---
 lisp/ob-core.el | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index ceda1aa..aa39c11 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -409,12 +409,16 @@ a window into the `org-babel-get-src-block-info' function."
 	  (header-args (nth 2 info)))
 	  (when name(funcall printf "Name: %s\n" name))
 	  (when lang(funcall printf "Lang: %s\n" lang))
+	  (funcall printf "Properties:\n")
+	  (funcall printf "\t:header-args \t%s\n" (org-entry-get (point) "header-args" t))
+	  (funcall printf "\t:header-args:%s \t%s\n" lang (org-entry-get (point) (concat "header-args:" lang) t))
+
 	  (when (funcall full switches) (funcall printf "Switches: %s\n" switches))
 	  (funcall printf "Header Arguments:\n")
 	  (dolist (pair (sort header-args
 			  (lambda (a b) (string< (symbol-name (car a))
 		 (symbol-name (car b))
-	(when (funcall full (cdr pair))
+	(when (funcall full (format "%s" (cdr pair)))
 	  (funcall printf "\t%S%s\t%s\n"
 		   (car pair)
 		   (if (> (length (format "%S" (car pair))) 7) "" "\t")
-- 
2.3.0


> Could you provide an appropriate commit message?

Here is the patch attached with the commit message - hope it is OK.

> Bonus points if you also add a test.

Are there some guidelines on how to write tests? Never done this before...

Rainer

>
> Regards,

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature


Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-10 Thread Nicolas Goaziou
Hello,

Rainer M Krug  writes:

> Please find attached the below described patch including the fix for the
> error reported - function raises error when property value is numeric.

Looks good. Thank you.

Could you provide an appropriate commit message? Bonus points if you
also add a test.

Regards,

-- 
Nicolas Goaziou



Re: [O] [PATCH]: BUG fix and Add header-args property to source block info

2015-02-10 Thread Rainer M Krug
Please find attached the below described patch including the fix for the
error reported - function raises error when property value is numeric.

Cheers,

Rainer

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index ceda1aa..aa39c11 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -409,12 +409,16 @@ a window into the `org-babel-get-src-block-info' function."
 	  (header-args (nth 2 info)))
 	  (when name(funcall printf "Name: %s\n" name))
 	  (when lang(funcall printf "Lang: %s\n" lang))
+	  (funcall printf "Properties:\n")
+	  (funcall printf "\t:header-args \t%s\n" (org-entry-get (point) "header-args" t))
+	  (funcall printf "\t:header-args:%s \t%s\n" lang (org-entry-get (point) (concat "header-args:" lang) t))
+
 	  (when (funcall full switches) (funcall printf "Switches: %s\n" switches))
 	  (funcall printf "Header Arguments:\n")
 	  (dolist (pair (sort header-args
 			  (lambda (a b) (string< (symbol-name (car a))
 		 (symbol-name (car b))
-	(when (funcall full (cdr pair))
+	(when (funcall full (format "%s" (cdr pair)))
 	  (funcall printf "\t%S%s\t%s\n"
 		   (car pair)
 		   (if (> (length (format "%S" (car pair))) 7) "" "\t")


Rainer M Krug  writes:

> Hi
>
> Following a recent discussion (based on me forgetting a ":" when setting
> the property :header-args), I added the output of the property
> header-args to the output of org-babel-get-src-block-info to make
> debugging easier. Before the function resulted in the following output
> (using my faulty code block):
>
> ,
> | Lang: R
> | Header Arguments:
> | :cache  no
> | :exportsboth
> | :hlines no
> | :noweb  no
> | :resultscode exports output replace
> | :sessionsomename
> | :tangle no
> | 
> `
>
> One only saw that the property :results was not correct but not where it
> came from.
>
> Using the patched version, one gets the following:
>
> ,
> | Lang: R
> | Properties:
> | :header-args:exports both :results output exports code
> | :header-args:R  :session somename
> | Header Arguments:
> | :cache  no
> | :exportsboth
> | :hlines no
> | :noweb  no
> | :resultscode exports output replace
> | :sessionsomename
> | :tangle no
> `
>
> Here one can clearly see that the property :header-args is not set
> correctly and can easily trace it down in the original org file.
>
> Also, actually seeing the property :header-args makes it easier to
> understand the whole inheritance of header arguments and how header-args
> and header-args+ interact. 
>
> The same applir=es to the property :header-args:R (or any language
> specific header-args:language property)
>
> Cheers,
>
> Rainer
>
>
> Here is again the faulty org file which lead to the patch:
>
> #+PROPERTY: header-args:R :session somename
> #+PROPERTY: header-args :exports both
> #+PROPERTY: header-args+ :results output
> * The bug
> This file create an (possibly endless?) loop during export
> * here exports both
> #+begin_src R 
> cat(13+14)
> #+end_src
>
> * and here only code
> :PROPERTIES:
> :header-args+: exports code
> :END:
> #+begin_src R 
> paste(13+14)
> #+end_src
> diff --git a/lisp/ob-core.el b/lisp/ob-core.el
> index ceda1aa..94a07f6 100644
> --- a/lisp/ob-core.el
> +++ b/lisp/ob-core.el
> @@ -409,6 +409,10 @@ a window into the `org-babel-get-src-block-info' 
> function."
> (header-args (nth 2 info)))
> (when name(funcall printf "Name: %s\n" name))
> (when lang(funcall printf "Lang: %s\n" lang))
> +   (funcall printf "Properties:\n")
> +   (funcall printf "\t:header-args \t%s\n" (org-entry-get (point) 
> "header-args" t))
> +   (funcall printf "\t:header-args:%s \t%s\n" lang (org-entry-get 
> (point) (concat "header-args:" lang) t))
> +
> (when (funcall full switches) (funcall printf "Switches: %s\n" 
> switches))
> (funcall printf "Header Arguments:\n")
> (dolist (pair (sort header-args

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


signature.asc
Description: PGP signature