From: John Herrlin <jherrlin@gmail.com>
To: ian martins <ianxm@jhu.edu>
Cc: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: ob-java compile only
Date: Sun, 27 Sep 2020 23:19:31 +0200 [thread overview]
Message-ID: <87imbyapel.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 697 bytes --]
Hey Ian!
Happy to see you as the maintainer of the ob-java!
I would like to propose a feature to ob-java. The feature allows a
source code block to write and compile only, without executing.
Here is a common use case for me.
Class without a entry point have an :compile-only header.
#+HEADER: :classname se/my_test_package/Hey
#+HEADER: :dir src
#+HEADER: :compile-only t
#+HEADER: :results none
#+BEGIN_SRC java
package se.my_test_package;
public class Hey {
public static String hey(String name) {
return "Hey " + name;
}
}
#+END_SRC
The provided diff works for my small use case. What do you think?
--
Best regards
John
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ob-java-compile-only-header.diff --]
[-- Type: text/x-patch, Size: 2145 bytes --]
diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index fee695bb9..5c98a0417 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -60,6 +60,7 @@ parameters may be used, like javac -verbose"
(cmpflag (or (cdr (assq :cmpflag params)) ""))
(cmdline (or (cdr (assq :cmdline params)) ""))
(cmdargs (or (cdr (assq :cmdargs params)) ""))
+ (compile-only (assq :compile-only params))
(full-body (org-babel-expand-body:generic body params)))
;; created package-name directories if missing
(unless (or (not packagename) (file-exists-p packagename))
@@ -67,18 +68,19 @@ parameters may be used, like javac -verbose"
(with-temp-file src-file (insert full-body))
(org-babel-eval
(concat org-babel-java-compiler " " cmpflag " " src-file) "")
- (let ((results (org-babel-eval (concat org-babel-java-command
- " " cmdline " " classname " " cmdargs) "")))
- (org-babel-reassemble-table
- (org-babel-result-cond (cdr (assq :result-params params))
- (org-babel-read results t)
- (let ((tmp-file (org-babel-temp-file "c-")))
- (with-temp-file tmp-file (insert results))
- (org-babel-import-elisp-from-file tmp-file)))
- (org-babel-pick-name
- (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
- (org-babel-pick-name
- (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))
+ (unless compile-only
+ (let ((results (org-babel-eval (concat org-babel-java-command
+ " " cmdline " " classname " " cmdargs) "")))
+ (org-babel-reassemble-table
+ (org-babel-result-cond (cdr (assq :result-params params))
+ (org-babel-read results t)
+ (let ((tmp-file (org-babel-temp-file "c-")))
+ (with-temp-file tmp-file (insert results))
+ (org-babel-import-elisp-from-file tmp-file)))
+ (org-babel-pick-name
+ (cdr (assq :colname-names params)) (cdr (assq :colnames params)))
+ (org-babel-pick-name
+ (cdr (assq :rowname-names params)) (cdr (assq :rownames params))))))))
(provide 'ob-java)
next reply other threads:[~2020-09-27 21:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-27 21:19 John Herrlin [this message]
2020-09-28 1:53 ` ob-java compile only ian martins
2020-09-28 8:11 ` John Herrlin
2020-09-29 2:18 ` ian martins
2020-09-29 19:22 ` John Herrlin
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://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imbyapel.fsf@gmail.com \
--to=jherrlin@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=ianxm@jhu.edu \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).