emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] change the ob-java default back to scripting mode
@ 2020-10-27 11:50 ian martins
  2020-10-29  1:35 ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: ian martins @ 2020-10-27 11:50 UTC (permalink / raw)
  To: Org-Mode mailing list


[-- Attachment #1.1: Type: text/plain, Size: 48 bytes --]

I mentioned this in another thread. Here it is.

[-- Attachment #1.2: Type: text/html, Size: 73 bytes --]

[-- Attachment #2: 0001-ob-java.el-Change-the-default-back-to-scripting-mode.patch --]
[-- Type: text/x-patch, Size: 6961 bytes --]

From 9ae6cb869ae909396d71000ad7804f49640e51ca Mon Sep 17 00:00:00 2001
From: Ian Martins <ianxm@jhu.edu>
Date: Tue, 27 Oct 2020 07:00:58 -0400
Subject: [PATCH] ob-java.el: Change the default back to scripting mode

* lisp/ob-java.el: Change the default to scripting mode.  Add name to
authors.

* testing/lisp/test-ob-java.el: Modify the first test to use the
default for `:results' and all others to specify it.  Add name to
authors.

A recent commit added functional mode and made it default, but this
would break java source blocks for anyone that relied on the old
default.  This sets the default back to scripting mode.

I missed a name when I put the authors of ob-C and ob-python as the
authors of ob-java.  Added it.
---
 lisp/ob-java.el              | 11 +++++++++--
 testing/lisp/test-ob-java.el | 30 ++++++++++++++++--------------
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index 05231bee2..c08ede1e7 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -3,6 +3,7 @@
 ;; Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
+;;          Thierry Banel
 ;;          Dan Davison
 ;; Maintainer: Ian Martins <ianxm@jhu.edu>
 ;; Keywords: literate programming, reproducible research
@@ -35,8 +36,14 @@
 
 (defvar org-babel-temporary-directory) ; from ob-core
 
-(defvar org-babel-default-header-args:java '()
-  "Default header args for java source blocks.")
+(defvar org-babel-default-header-args:java '((:results . "output"))
+  "Default header args for java source blocks.
+The docs say functional mode should be the default [1], but
+ob-java didn't support functional mode until recently, so we keep
+scripting mode as the default for now to maintain existing
+behavior.
+
+[1] https://orgmode.org/manual/Results-of-Evaluation.html")
 
 (defconst org-babel-header-args:java '((imports . :any))
   "Java-specific header arguments.")
diff --git a/testing/lisp/test-ob-java.el b/testing/lisp/test-ob-java.el
index b8f34253f..b055f5a02 100644
--- a/testing/lisp/test-ob-java.el
+++ b/testing/lisp/test-ob-java.el
@@ -2,6 +2,7 @@
 
 ;; Copyright (c) 2020 Free Software Foundation, Inc.
 ;; Authors: Eric Schulte
+;;          Thierry Banel
 ;;          Dan Davison
 ;; Maintainer: Ian Martins <ianxm@jhu.edu>
 
@@ -37,9 +38,10 @@
 ; simple tests
 
 (ert-deftest ob-java/simple ()
-  "Hello world program that writes output."
+  "Hello world program that writes output. Also tests that
+ob-java defaults to scripting mode."
   (org-test-with-temp-text
-      "#+begin_src java :results output silent
+      "#+begin_src java :results silent
 System.out.print(42);
 #+end_src"
    (should (string= "42" (org-babel-execute-src-block)))))
@@ -63,7 +65,7 @@ System.out.print(\"\\\"42\\\"\");
 (ert-deftest ob-java/simple-return-int ()
   "Hello world program that returns an int value."
   (org-test-with-temp-text
-      "#+begin_src java :results silent
+      "#+begin_src java :results value silent
 return 42;
 #+end_src"
    (should (eq 42 (org-babel-execute-src-block)))))
@@ -71,7 +73,7 @@ return 42;
 (ert-deftest ob-java/simple-return-float ()
   "Hello world program that returns a float value."
   (org-test-with-temp-text
-      "#+begin_src java :results silent
+      "#+begin_src java :results value silent
 return 42.0;
 #+end_src"
    (should (equal 42.0 (org-babel-execute-src-block)))))
@@ -79,7 +81,7 @@ return 42.0;
 (ert-deftest ob-java/simple-return-string ()
   "Hello world program that returns a string value."
   (org-test-with-temp-text
-      "#+begin_src java :results silent
+      "#+begin_src java :results value silent
 return \"forty two\";
 #+end_src"
     (should (string= "forty two" (org-babel-execute-src-block)))))
@@ -291,7 +293,7 @@ System.out.print(String.format(\"%s, len=%d\", a, a.length()));
 (ert-deftest ob-java/return-vector-using-list ()
   "Return a vector using a list."
   (org-test-with-temp-text
-      "#+begin_src java :results vector silent
+      "#+begin_src java :results value vector silent
 import java.util.List;
 import java.util.Arrays;
 List<List<Integer>> a = Arrays.asList(Arrays.asList(4),
@@ -304,7 +306,7 @@ return a;
 (ert-deftest ob-java/return-vector-using-array ()
   "Return a vector using an array."
   (org-test-with-temp-text
-      "#+begin_src java :results vector silent
+      "#+begin_src java :results value vector silent
 Integer[][] a = {{4}, {2}};
 return a;
 #+end_src"
@@ -314,7 +316,7 @@ return a;
 (ert-deftest ob-java/read-return-list ()
   "Read and return a list."
   (org-test-with-temp-text
-      "#+begin_src java :var a=java_list :results silent
+      "#+begin_src java :var a=java_list :results value silent
 import java.util.List;
 import java.util.Arrays;
 List<String> b = Arrays.asList(a.get(0).get(0),
@@ -331,7 +333,7 @@ return b;
 (ert-deftest ob-java/read-list-return-array ()
   "Read a list and return an array."
   (org-test-with-temp-text
-      "#+begin_src java :var a=java_list :results silent
+      "#+begin_src java :var a=java_list :results value silent
 String[] b = {a.get(0).get(0), a.get(1).get(0)};
 return b;
 #+end_src
@@ -345,7 +347,7 @@ return b;
 (ert-deftest ob-java/read-return-list-with-package ()
   "Return a vector."
   (org-test-with-temp-text
-      "#+begin_src java :var a=java_list :results silent
+      "#+begin_src java :var a=java_list :results value silent
 package pkg;
 import java.util.List;
 import java.util.Arrays;
@@ -375,7 +377,7 @@ System.out.println(\"forty two\");
 (ert-deftest ob-java/list-var ()
   "Read and write a list variable."
   (org-test-with-temp-text
-      "#+begin_src java :var a='(\"forty\" \"two\") :results silent
+      "#+begin_src java :var a='(\"forty\" \"two\") :results value silent
 import java.util.List;
 List<String> b = a;
 return b;
@@ -386,7 +388,7 @@ return b;
 (ert-deftest ob-java/vector-var ()
   "Read and write a vector variable."
   (org-test-with-temp-text
-      "#+begin_src java :var a='[\"forty\" \"two\"] :results silent
+      "#+begin_src java :var a='[\"forty\" \"two\"] :results value silent
 import java.util.List;
 List<String> b = a;
 return b;
@@ -397,7 +399,7 @@ return b;
 (ert-deftest ob-java/matrix-var ()
   "Read and write matrix variable."
   (org-test-with-temp-text
-      "#+begin_src java :var a=java_matrix :results silent
+      "#+begin_src java :var a=java_matrix :results value silent
 import java.util.List;
 import java.util.Arrays;
 List<List<Integer>> b = Arrays.asList(Arrays.asList(a.get(0).get(0), a.get(1).get(0)),
@@ -455,7 +457,7 @@ for (int ii=0; ii<a.size(); ii++) {
 (ert-deftest ob-java/inhomogeneous_table ()
   "Read and write an inhomogeneous table."
   (org-test-with-temp-text
-      "#+begin_src java :var a=java_table :results silent
+      "#+begin_src java :var a=java_table :results value silent
 import java.util.List;
 import java.util.Arrays;
 List<List> b = Arrays.asList(Arrays.asList(a.get(0).get(0),
-- 
2.25.1


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

* Re: [PATCH] change the ob-java default back to scripting mode
  2020-10-27 11:50 [PATCH] change the ob-java default back to scripting mode ian martins
@ 2020-10-29  1:35 ` Kyle Meyer
  2020-10-29  8:12   ` ian martins
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle Meyer @ 2020-10-29  1:35 UTC (permalink / raw)
  To: ian martins; +Cc: Org-Mode mailing list

ian martins writes:

> Subject: [PATCH] ob-java.el: Change the default back to scripting mode
>
> * lisp/ob-java.el: Change the default to scripting mode.  Add name to
> authors.

The changelog entry should explicitly list the variables/functions that
are modified.  So in this case

    * lisp/ob-java.el (org-babel-default-header-args:java): ...

> A recent commit added functional mode and made it default, but this
> would break java source blocks for anyone that relied on the old
> default.  This sets the default back to scripting mode.

Thanks for restoring the behavior.

> I missed a name when I put the authors of ob-C and ob-python as the
> authors of ob-java.  Added it.

Please move this unrelated change to a separate commit.


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

* Re: [PATCH] change the ob-java default back to scripting mode
  2020-10-29  1:35 ` Kyle Meyer
@ 2020-10-29  8:12   ` ian martins
  2020-10-30  4:31     ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: ian martins @ 2020-10-29  8:12 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Org-Mode mailing list

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

ok I will do that.

If I make the same change to dozens of tests in the same file, should I
list them as separate bullets, or put the list of function names in
parentheses, or is it better to omit the list if it would be long?

On Wed, Oct 28, 2020 at 9:36 PM Kyle Meyer <kyle@kyleam.com> wrote:

> ian martins writes:
>
> > Subject: [PATCH] ob-java.el: Change the default back to scripting mode
> >
> > * lisp/ob-java.el: Change the default to scripting mode.  Add name to
> > authors.
>
> The changelog entry should explicitly list the variables/functions that
> are modified.  So in this case
>
>     * lisp/ob-java.el (org-babel-default-header-args:java): ...
>
> > A recent commit added functional mode and made it default, but this
> > would break java source blocks for anyone that relied on the old
> > default.  This sets the default back to scripting mode.
>
> Thanks for restoring the behavior.
>
> > I missed a name when I put the authors of ob-C and ob-python as the
> > authors of ob-java.  Added it.
>
> Please move this unrelated change to a separate commit.
>

[-- Attachment #2: Type: text/html, Size: 1495 bytes --]

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

* Re: [PATCH] change the ob-java default back to scripting mode
  2020-10-29  8:12   ` ian martins
@ 2020-10-30  4:31     ` Kyle Meyer
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2020-10-30  4:31 UTC (permalink / raw)
  To: ian martins; +Cc: Org-Mode mailing list

ian martins writes:

> If I make the same change to dozens of tests in the same file, should I
> list them as separate bullets, or put the list of function names in
> parentheses, or is it better to omit the list if it would be long?

The second or third.  I think it's a judgment call (and not worth
thinking too hard about), especially for mechanical and simple changes.
We're following Emacs here, so looking through their commit log in
addition to ours should give a pretty good feel for things.


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

end of thread, other threads:[~2020-10-30  4:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-27 11:50 [PATCH] change the ob-java default back to scripting mode ian martins
2020-10-29  1:35 ` Kyle Meyer
2020-10-29  8:12   ` ian martins
2020-10-30  4:31     ` Kyle Meyer

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