From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GFFUAZ2BkV+UFAAA0tVLHw (envelope-from ) for ; Thu, 22 Oct 2020 12:57:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id cB0sN5yBkV8LKgAAB5/wlQ (envelope-from ) for ; Thu, 22 Oct 2020 12:57:00 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 35F489404D3 for ; Thu, 22 Oct 2020 12:57:00 +0000 (UTC) Received: from localhost ([::1]:36892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVa9L-0000BU-3q for larch@yhetil.org; Thu, 22 Oct 2020 08:56:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVa8t-0000BK-OH for emacs-orgmode@gnu.org; Thu, 22 Oct 2020 08:56:31 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:42961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVa8o-00083m-VB for emacs-orgmode@gnu.org; Thu, 22 Oct 2020 08:56:30 -0400 Received: by mail-ed1-x543.google.com with SMTP id v19so1645161edx.9 for ; Thu, 22 Oct 2020 05:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=ocjuArQAPaC7uOCq6UG4ApzF2BxS5lkb2IgRypSI3vA=; b=uvoRAE519fPQC6BlWRuOEdyHb7voqIiU8WsvPJi5PAhxjdHTYkZucdMusL+uaBi1LG n+fmxDtbGw0o9FLZjxP3A40qQmtoZmHBK01LZvhJwDFicAekNTzCijW16N5tcG30O9Qj teaf5cvEf01CCqtxeL6otSo1rPLEshw8B9CqMpWNr3aHdhivE+ig0RcBa/P4uaP01dPY JqR/6l6mcJYYSzdXrpQtUbx0M4gDv/A8HCplG2effl5DIHt9n0tZ+3Re//MhOi/UvVzo K5/N4lAfZ9ARhXCVfwjj/6MEeOX02igmarEFSEKUWCKtO1rLGkV8S8ST3m8d31SPNsE7 09pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=ocjuArQAPaC7uOCq6UG4ApzF2BxS5lkb2IgRypSI3vA=; b=RpmfV4v1jU66ZPVbC2Eq3cCa8/OvPuNfR8cBLcu25zs+3L/KRhbGENcgKRu+s8EP7V sBV0ZpLXUAstCMtndxxctawMxGVuAmKAHECJ0q7xM0NB1bjRNeI0Hvu2P4fn4xXoSauH RP7+r4epy9k1/R/IgQL+EDRvVCBMmIojozgn2Qz4Rcci6QoT/9vvwj0uaeIkdxqewUzt PhAFIQIUJ56u5LW5M67hZc8j3ihjw5ZQME/Mky7VwnzguOncZTg3t5jvB8pa1YD+NSYP 6NAGXFB9wxcZXJU9LF1Nf7/kEsMqc/pLloiVev2Xm/e1nmTp3v/umQMVx83w+NqijNiZ tOuA== X-Gm-Message-State: AOAM530BUV3K+vVGtAPHb9T0Q1GFWcQ8BXW91CFyXaCm1PhYmpcx30R7 z4HMiOikyE0eY6frAcHD4gqn9Ea9AIw= X-Google-Smtp-Source: ABdhPJy1a69UujnWTYivzER+OtD7zYPTcjME20RqL1B+of0iHPZ4OodDypnN5uUsHcRmzkOnmG/fpQ== X-Received: by 2002:aa7:d0d8:: with SMTP id u24mr2122731edo.349.1603371383687; Thu, 22 Oct 2020 05:56:23 -0700 (PDT) Received: from fnox ([2a02:aa1:1010:dc88:6707:becd:e8ea:e7e]) by smtp.gmail.com with ESMTPSA id i14sm843715ejy.110.2020.10.22.05.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 05:56:22 -0700 (PDT) References: <87h7qohfm8.fsf@gmail.com> <87d01cglvm.fsf@gmail.com> <87eelr1y7p.fsf@gmail.com> User-agent: mu4e 1.4.13; emacs 27.1 From: John Herrlin To: ian martins Subject: Re: [PATCH] ob-java In-reply-to: Message-ID: <87v9f2772l.fsf@gmail.com> Date: Thu, 22 Oct 2020 14:56:19 +0200 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::543; envelope-from=jherrlin@gmail.com; helo=mail-ed1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org-Mode mailing list Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=uvoRAE51; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.21 X-TUID: 6z5Hu7QFFcIk ian martins writes: > Actually I realized if I keep the commits separate and generate a patch set > instead of squashing then I can preserve authorship. Thank you for taking the time! It's not necessary and not important for me! > > These patches, which follow patch 0001, fix the spacing and allow > non-public classes. > > Thanks again for testing, debugging, and reporting. It's been a pleasure! > > On Wed, Oct 21, 2020 at 9:54 AM John Herrlin wrote: > >> >> ian martins writes: >> >> >> >> >> What do you think about having a configurable list where the user can >> >> add =org-babel-java--import-maybe=? In my current use case I could then >> >> add RxJava imports to that list and the imports could be removed from >> >> the source code block. >> > >> > >> > I think this can already be done. imports can be added to the headers, >> and >> > babel allows file-wide headers, so you could add a =#+HEADER: :import >> > rx.Observable= line to the file and all source blocks would get it. it's >> > slightly different in that =org-babel-java--import-maybe= skips imports >> > that it thinks aren't needed. also if there are any non-java source >> blocks >> > in the same file, these imports could be added to them which would be >> bad, >> > so when mixing multiple languages in the same file this wouldn't be an >> > option. >> >> Thanks for pointing that out! It work just fine! >> >> > >> > NIT >> >> Some spacing when writing =public static...= >> >> >> > >> > Thanks for fixing the spacing. I don't think I can give you credit for >> the >> > patch, though, without leaving it out until ob-java is accepted. >> >> I dont need any credits, the important part is the result! >> >> I have made a couple of more runs and I cant find anything that doesnt >> work! >> >> > >> > On Wed, Oct 21, 2020 at 1:59 AM John Herrlin wrote: >> > >> >> >> >> I did and it looks really good. The difference in this example: >> >> >> >> #+BEGIN_SRC java >> >> import rx.Observable; >> >> >> >> Observable.range(5, 3) >> >> .subscribe((Integer i) -> { System.out.println("Got: " + >> i); }, >> >> (Throwable t) -> { t.printStackTrace();}, >> >> () -> { System.out.println("Ending >> >> stream"); }); >> >> #+END_SRC >> >> >> >> from the ones I posted yesterday is tremendous! >> >> >> >> I am not very experienced with Emacs lisp but I think it's pretty easy >> >> to understand how things works and follow the code. The comments are >> >> also of good help. I really appreciate the work you have done! >> >> >> >> >> >> What do you think about having a configurable list where the user can >> >> add =org-babel-java--import-maybe=? In my current use case I could then >> >> add RxJava imports to that list and the imports could be removed from >> >> the source code block. >> >> >> >> >> >> NIT >> >> >> >> Some spacing when writing =public static...= >> >> >> >> #+BEGIN_SRC diff >> >> diff --git a/lisp/ob-java.el b/lisp/ob-java.el >> >> index 94c3f69cf..4f3904871 100644 >> >> --- a/lisp/ob-java.el >> >> +++ b/lisp/ob-java.el >> >> @@ -220,7 +220,7 @@ RESULT-FILE is the temp file to write the >> result." >> >> (org-babel-java--move-past org-babel-java--class-re) >> >> (insert "\n public static void main(String[] args) { >> >> System.out.print(\"success\"); >> >> -}\n\n")) >> >> + }\n\n")) >> >> >> >> ;; special handling to return value >> >> (when (eq result-type 'value) >> >> #+END_SRC >> >> >> >> >> >> >> >> ian martins writes: >> >> >> >> > Thanks for testing, and thanks for pointing that out. I will fix it so >> >> that >> >> > `public` is optional. >> >> > >> >> > btw, in your example you didn't have to specify `:classname` since you >> >> > defined the class name in the source block. >> >> > >> >> > btw2, did you notice that you can C-c C-c on source blocks that don't >> >> have >> >> > main methods and it'll compile without error? >> >> > >> >> > On Tue, Oct 20, 2020 at 3:17 PM John Herrlin >> wrote: >> >> > >> >> >> >> >> >> Hey, >> >> >> >> >> >> Did some debugging and found out that my class didn't contained >> =public= >> >> >> and the patch requires it to be. >> >> >> >> >> >> This works fine: >> >> >> >> >> >> #+HEADER: :classname Main >> >> >> #+HEADER: :dir src >> >> >> #+HEADER: :cmdline -classpath ./rxjava-1.3.8.jar:. >> >> >> #+HEADER: :cmpflag -classpath ./rxjava-1.3.8.jar >> >> >> #+BEGIN_SRC java :results output code >> >> >> import rx.Observable; >> >> >> public class Main { >> >> >> public static void main(String[] args) { >> >> >> Observable.range(5, 5) >> >> >> .subscribe(System.out::println); >> >> >> } >> >> >> } >> >> >> #+END_SRC >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> ian martins writes: >> >> >> >> >> >> > I noticed that the tests didn't run with "make test." This updates >> the >> >> >> > patch so that they can. I didn't add java to the list of default >> >> >> languages >> >> >> > because the java tests are slow. >> >> >> > >> >> >> > On Mon, Oct 5, 2020 at 9:23 AM ian martins wrote: >> >> >> > >> >> >> >> I wrote those examples in an org file so I could test as I wrote >> >> them, >> >> >> and >> >> >> >> then exported it to make it more readable, but the export >> resulted in >> >> >> >> source block headers being lost. Here is the same without export: >> >> >> >> ---- >> >> >> >> * Changes >> >> >> >> >> >> >> >> - support for functional mode (~:results value~) >> >> >> >> - accept variables >> >> >> >> - don't require package, class, and main definitions >> >> >> >> - write source and result tempfiles to >> >> ~org-babel-temporary-directory~, >> >> >> >> but respects the ~:dir~ header >> >> >> >> - work with tramp >> >> >> >> >> >> >> >> * Examples >> >> >> >> ** Example 1 >> >> >> >> This outputs "hello." If class and main definitions aren't given >> the >> >> >> >> code block will be wrapped in generic ones. >> >> >> >> >> >> >> >> #+begin_src java :results output silent >> >> >> >> System.out.print("hello"); >> >> >> >> #+end_src >> >> >> >> >> >> >> >> This is exactly equivalent: >> >> >> >> >> >> >> >> #+begin_src java :results output silent >> >> >> >> public class Main { >> >> >> >> public static void main(String[] args) { >> >> >> >> System.out.print("hello"); >> >> >> >> } >> >> >> >> } >> >> >> >> #+end_src >> >> >> >> >> >> >> >> ** Example 2 >> >> >> >> This also outputs "hello." >> >> >> >> >> >> >> >> #+begin_src java :results value silent >> >> >> >> return "hello"; >> >> >> >> #+end_src >> >> >> >> >> >> >> >> ** Example 3 >> >> >> >> This generates the class "Example" in the package "org.orgmode" in >> >> the >> >> >> >> current directory. >> >> >> >> >> >> >> >> #+begin_src java :results output silent :classname >> >> org.orgmode.Example >> >> >> >> :dir . >> >> >> >> System.out.print("hello, org-mode"); >> >> >> >> #+end_src >> >> >> >> >> >> >> >> ** Example 4 >> >> >> >> The "Hey" class defines a static method but no main. C-c C-c on >> the >> >> >> >> "Hey" source block will write "./org/orgmode/Hey.java" and compile >> >> it. >> >> >> >> >> >> >> >> The "Main" class calls the "Hey" class. C-c C-c on the "Main" >> source >> >> >> >> block will write "./org/orgmode/Main.java" and compile and run it. >> >> >> >> >> >> >> >> #+begin_src java :results output silent :dir . >> >> >> >> package org.orgmode; >> >> >> >> >> >> >> >> public class Hey { >> >> >> >> public static String say() { >> >> >> >> return "hey"; >> >> >> >> } >> >> >> >> } >> >> >> >> #+end_src >> >> >> >> >> >> >> >> #+begin_src java :results output silent :dir . >> >> >> >> package org.orgmode; >> >> >> >> >> >> >> >> public class Main { >> >> >> >> public static void main(String[] args) { >> >> >> >> System.out.print(Hey.say()); >> >> >> >> } >> >> >> >> } >> >> >> >> #+end_src >> >> >> >> >> >> >> >> Instead of C-c C-c, we could have added tangle headers and written >> >> the >> >> >> >> source files out by tangling. >> >> >> >> >> >> >> >> ** Example 5 >> >> >> >> This prints the variable from the header >> >> >> >> >> >> >> >> #+begin_src java :var msg="hello, org-mode" :results output silent >> >> >> >> System.out.print(msg); >> >> >> >> #+end_src >> >> >> >> >> >> >> >> ** Example 6 >> >> >> >> This prints "hello, org-mode." The table is provided to the method >> >> as a >> >> >> >> list of lists. >> >> >> >> >> >> >> >> #+name: table >> >> >> >> | message | hello, org-mode | >> >> >> >> >> >> >> >> #+begin_src java :var tbl=table :results output silent >> >> >> >> System.out.print(tbl.get(0).get(1)); >> >> >> >> #+end_src >> >> >> >> >> >> >> >> ** Example 7 >> >> >> >> This example returns a list. >> >> >> >> >> >> >> >> Note that you're allowed to specify imports without defining the >> >> class >> >> >> >> or main methods. >> >> >> >> >> >> >> >> #+begin_src java :results value :exports both >> >> >> >> import java.util.Arrays; >> >> >> >> >> >> >> >> return Arrays.asList("message", "hello, org-mode"); >> >> >> >> #+end_src >> >> >> >> >> >> >> >> #+RESULTS: >> >> >> >> | message | hello, org-mode | >> >> >> >> >> >> >> >> On Mon, Oct 5, 2020 at 8:35 AM ian martins wrote: >> >> >> >> >> >> >> >>> 1 Changes >> >> >> >>> ========= >> >> >> >>> >> >> >> >>> - support for functional mode (`:results value') >> >> >> >>> - accept variables >> >> >> >>> - don't require package, class, and main definitions >> >> >> >>> - write source and result tempfiles to >> >> >> >>> `org-babel-temporary-directory', but respects the `:dir' >> header >> >> >> >>> - work with tramp >> >> >> >>> >> >> >> >>> >> >> >> >>> 2 Examples >> >> >> >>> ========== >> >> >> >>> Some examples follow. See the tests for more examples. I'll >> write >> >> >> >>> proper docs after review. >> >> >> >>> >> >> >> >>> 2.1 Example 1 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> This outputs "hello." If class and main definitions aren't >> given >> >> the >> >> >> >>> code block will be wrapped in generic ones. >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | System.out.print("hello"); >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> This is exactly equivalent: >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | public class Main { >> >> >> >>> | public static void main(String[] args) { >> >> >> >>> | System.out.print("hello"); >> >> >> >>> | } >> >> >> >>> | } >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> >> >> >> >>> 2.2 Example 2 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> This also outputs "hello." >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | return "hello"; >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> >> >> >> >>> 2.3 Example 3 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> This generates the class "Example" in the package >> "org.orgmode" in >> >> >> the >> >> >> >>> current directory. >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | System.out.print("hello, org-mode"); >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> >> >> >> >>> 2.4 Example 4 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> The "Hey" class defines a static method but no main. C-c C-c on >> >> the >> >> >> >>> "Hey" source block will write "./org/orgmode/Hey.java" and >> compile >> >> >> it. >> >> >> >>> >> >> >> >>> The "Main" class calls the "Hey" class. C-c C-c on the "Main" >> >> source >> >> >> >>> block will write "./org/orgmode/Main.java" and compile and run >> it. >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | package org.orgmode; >> >> >> >>> | >> >> >> >>> | public class Hey { >> >> >> >>> | public static String say() { >> >> >> >>> | return "hey"; >> >> >> >>> | } >> >> >> >>> | } >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | package org.orgmode; >> >> >> >>> | >> >> >> >>> | public class Main { >> >> >> >>> | public static void main(String[] args) { >> >> >> >>> | System.out.print(Hey.say()); >> >> >> >>> | } >> >> >> >>> | } >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> Instead of C-c C-c, we could have added tangle headers and >> written >> >> >> the >> >> >> >>> source files out by tangling. >> >> >> >>> >> >> >> >>> >> >> >> >>> 2.5 Example 5 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> This prints the variable from the header >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | System.out.print(msg); >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> >> >> >> >>> 2.6 Example 6 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> This prints "hello, org-mode." The table is provided to the >> >> method as >> >> >> >>> a list of lists. >> >> >> >>> >> >> >> >>> message hello, org-mode >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | System.out.print(tbl.get(0).get(1)); >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> >> >> >> >>> 2.7 Example 7 >> >> >> >>> ~~~~~~~~~~~~~ >> >> >> >>> >> >> >> >>> This example returns a list. >> >> >> >>> >> >> >> >>> Note that you're allowed to specify imports without defining >> the >> >> >> class >> >> >> >>> or main methods. >> >> >> >>> >> >> >> >>> ,---- >> >> >> >>> | import java.util.Arrays; >> >> >> >>> | >> >> >> >>> | return Arrays.asList("message", "hello, org-mode"); >> >> >> >>> `---- >> >> >> >>> >> >> >> >>> message hello, org-mode >> >> >> >>> >> >> >> >> >> >> >> >> >> >> -- Mvh John