Org-mode mailing list
 help / color / mirror / Atom feed
From: ian martins <ianxm@jhu.edu>
To: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: [PATCH] change the ob-java default back to scripting mode
Date: Tue, 27 Oct 2020 07:50:26 -0400
Message-ID: <CAC=rjb4CgZQWQBRqJM413FG3KydUVfank-1MQ+KFhE_dmGrRxA@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2020-10-27 12:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 11:50 ian martins [this message]
2020-10-29  1:35 ` Kyle Meyer
2020-10-29  8:12   ` ian martins
2020-10-30  4:31     ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC=rjb4CgZQWQBRqJM413FG3KydUVfank-1MQ+KFhE_dmGrRxA@mail.gmail.com' \
    --to=ianxm@jhu.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git