* [PATCH] ob-java: Allow import to end with asterisk
@ 2021-01-26 7:53 John Herrlin
2021-01-27 3:21 ` ian martins
0 siblings, 1 reply; 8+ messages in thread
From: John Herrlin @ 2021-01-26 7:53 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
Hey,
I found this case:
#+BEGIN_SRC java
import static java.lang.System.*;
out.println("Hejsan");
#+END_SRC
And it seems to me that the import regex dont see the asterisk.
I attached a possible patch.
Stay safe!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-java-Allow-import-to-end-with-asterisk.patch --]
[-- Type: text/x-patch, Size: 1082 bytes --]
From a9c37a8a56fd1f91f4a2789b0d7d983fec9a2c1f Mon Sep 17 00:00:00 2001
From: John Herrlin <jherrlin@gmail.com>
Date: Tue, 26 Jan 2021 08:19:19 +0100
Subject: [PATCH] ob-java: Allow import to end with asterisk
* lisp/ob-java.el (org-babel-java--imports-re): Allow import to end
with asterisk.
TINYCHANGE
---
lisp/ob-java.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index 07ff8e9ab..b205eacd6 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -88,7 +88,7 @@ like javac -verbose."
"Regexp for the package statement.")
(defconst org-babel-java--imports-re (rx line-start (0+ space) "import"
(opt (1+ space) "static")
- (1+ space) (group (1+ (in alnum ?_ ?.))) ; capture the fully qualified class name
+ (1+ space) (group (1+ (in alnum ?_ ?. ?*))) ; capture the fully qualified class name
(0+ space) ?\; line-end)
"Regexp for import statements.")
(defconst org-babel-java--class-re (rx line-start (0+ space) (opt (seq "public" (1+ space)))
--
2.30.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-01-26 7:53 [PATCH] ob-java: Allow import to end with asterisk John Herrlin
@ 2021-01-27 3:21 ` ian martins
2021-01-27 7:24 ` John Herrlin
2021-01-28 20:03 ` John Herrlin
0 siblings, 2 replies; 8+ messages in thread
From: ian martins @ 2021-01-27 3:21 UTC (permalink / raw)
To: John Herrlin; +Cc: org-mode-email
> I found this case:
> And it seems to me that the import regex dont see the asterisk.
>
> I attached a possible patch.
Thanks again, John. You're right the regex is missing the asterisk
include. Thanks for the patch fixing. This works but it will add
redundant includes if the source block includes something that is also
in the list of classes to automatically include.
for example, this:
#+begin_src java :results value
import java.util.*;
return "test";
#+end_src
will end up pulling in
import java.util.List;
import java.util.*;
It wouldn't hurt anything, but could probably be prevented by changing
the regexp in =org-babel-java--import-maybe= to look for asterisk as
well as =class=. Do you feel like updating the patch?
[1] https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-java.el#L314
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-01-27 3:21 ` ian martins
@ 2021-01-27 7:24 ` John Herrlin
2021-01-28 20:03 ` John Herrlin
1 sibling, 0 replies; 8+ messages in thread
From: John Herrlin @ 2021-01-27 7:24 UTC (permalink / raw)
To: ian martins; +Cc: org-mode-email
Thank you for the guidence! I will try to figure it out and sending a
updated patch soon.
ian martins <ianxm@jhu.edu> writes:
>> I found this case:
>> And it seems to me that the import regex dont see the asterisk.
>>
>> I attached a possible patch.
>
> Thanks again, John. You're right the regex is missing the asterisk
> include. Thanks for the patch fixing. This works but it will add
> redundant includes if the source block includes something that is also
> in the list of classes to automatically include.
>
> for example, this:
>
> #+begin_src java :results value
> import java.util.*;
> return "test";
> #+end_src
>
> will end up pulling in
>
> import java.util.List;
> import java.util.*;
>
> It wouldn't hurt anything, but could probably be prevented by changing
> the regexp in =org-babel-java--import-maybe= to look for asterisk as
> well as =class=. Do you feel like updating the patch?
>
> [1] https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-java.el#L314
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-01-27 3:21 ` ian martins
2021-01-27 7:24 ` John Herrlin
@ 2021-01-28 20:03 ` John Herrlin
2021-01-30 10:50 ` ian martins
1 sibling, 1 reply; 8+ messages in thread
From: John Herrlin @ 2021-01-28 20:03 UTC (permalink / raw)
To: ian martins; +Cc: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]
ian martins <ianxm@jhu.edu> writes:
>> I found this case:
>> And it seems to me that the import regex dont see the asterisk.
>>
>> I attached a possible patch.
>
> Thanks again, John. You're right the regex is missing the asterisk
> include. Thanks for the patch fixing. This works but it will add
> redundant includes if the source block includes something that is also
> in the list of classes to automatically include.
>
> for example, this:
>
> #+begin_src java :results value
> import java.util.*;
> return "test";
> #+end_src
>
> will end up pulling in
>
> import java.util.List;
> import java.util.*;
>
> It wouldn't hurt anything, but could probably be prevented by changing
> the regexp in =org-babel-java--import-maybe= to look for asterisk as
> well as =class=. Do you feel like updating the patch?
>
> [1] https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-java.el#L314
Here is an updated patch. It seems to work on my cases.
Of topic, I am very happy with the latest updates on ob-java and I think
it works really good! Thanks for the awesome work Ian!
Stay safe!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-java-Allow-import-to-end-with-asterisk.patch --]
[-- Type: text/x-patch, Size: 1691 bytes --]
From 92c72792fb18a73572ee35d34a5e1d5ce56d8b6a Mon Sep 17 00:00:00 2001
From: John Herrlin <jherrlin@gmail.com>
Date: Tue, 26 Jan 2021 08:19:19 +0100
Subject: [PATCH] ob-java: Allow import to end with asterisk
* lisp/ob-java.el (org-babel-java--imports-re,
org-babel-java--import-maybe): Allow import to end with asterisk.
TINYCHANGE
---
lisp/ob-java.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index 07ff8e9ab..1f2b980f6 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -88,7 +88,7 @@ like javac -verbose."
"Regexp for the package statement.")
(defconst org-babel-java--imports-re (rx line-start (0+ space) "import"
(opt (1+ space) "static")
- (1+ space) (group (1+ (in alnum ?_ ?.))) ; capture the fully qualified class name
+ (1+ space) (group (1+ (in alnum ?_ ?. ?*))) ; capture the fully qualified class name
(0+ space) ?\; line-end)
"Regexp for import statements.")
(defconst org-babel-java--class-re (rx line-start (0+ space) (opt (seq "public" (1+ space)))
@@ -311,7 +311,8 @@ RESULT-FILE is the temp file to write the result."
(goto-char (point-min))
(setq class-found (re-search-forward class nil t))
(goto-char (point-min))
- (setq import-found (re-search-forward (concat "^import .*" package ".*" class ";") nil t))
+ (setq import-found
+ (re-search-forward (concat "^import .*" package ".*\\(?:\\*\\|" class "\\);") nil t))
(when (and class-found (not import-found))
(org-babel-java--move-past org-babel-java--package-re)
(insert (concat "import " package "." class ";\n")))))
--
2.30.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-01-28 20:03 ` John Herrlin
@ 2021-01-30 10:50 ` ian martins
2021-04-25 3:43 ` Timothy
0 siblings, 1 reply; 8+ messages in thread
From: ian martins @ 2021-01-30 10:50 UTC (permalink / raw)
To: John Herrlin; +Cc: org-mode-email
Thanks. And thanks for taking the time to fix issues that you find. It
continues to improve because of your contributions.
The patch looks good. Applied.
On Thu, Jan 28, 2021 at 3:04 PM John Herrlin <jherrlin@gmail.com> wrote:
>
>
> ian martins <ianxm@jhu.edu> writes:
>
> >> I found this case:
> >> And it seems to me that the import regex dont see the asterisk.
> >>
> >> I attached a possible patch.
> >
> > Thanks again, John. You're right the regex is missing the asterisk
> > include. Thanks for the patch fixing. This works but it will add
> > redundant includes if the source block includes something that is also
> > in the list of classes to automatically include.
> >
> > for example, this:
> >
> > #+begin_src java :results value
> > import java.util.*;
> > return "test";
> > #+end_src
> >
> > will end up pulling in
> >
> > import java.util.List;
> > import java.util.*;
> >
> > It wouldn't hurt anything, but could probably be prevented by changing
> > the regexp in =org-babel-java--import-maybe= to look for asterisk as
> > well as =class=. Do you feel like updating the patch?
> >
> > [1] https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-java.el#L314
>
> Here is an updated patch. It seems to work on my cases.
>
> Of topic, I am very happy with the latest updates on ob-java and I think
> it works really good! Thanks for the awesome work Ian!
>
> Stay safe!
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-01-30 10:50 ` ian martins
@ 2021-04-25 3:43 ` Timothy
2021-04-25 10:40 ` ian martins
0 siblings, 1 reply; 8+ messages in thread
From: Timothy @ 2021-04-25 3:43 UTC (permalink / raw)
To: emacs-orgmode
This was not marked as applied on updates.orgmode.org.
Doing so with the X-Woof-Patch header.
ian martins <ianxm@jhu.edu> writes:
> Thanks. And thanks for taking the time to fix issues that you find. It
> continues to improve because of your contributions.
> The patch looks good. Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-04-25 3:43 ` Timothy
@ 2021-04-25 10:40 ` ian martins
2021-04-26 6:52 ` Bastien
0 siblings, 1 reply; 8+ messages in thread
From: ian martins @ 2021-04-25 10:40 UTC (permalink / raw)
To: Timothy; +Cc: Org-Mode mailing list
[-- Attachment #1: Type: text/plain, Size: 609 bytes --]
On Sat, Apr 24, 2021 at 11:44 PM Timothy <tecosaur@gmail.com> wrote:
>
> This was not marked as applied on updates.orgmode.org.
> Doing so with the X-Woof-Patch header.
>
> ian martins <ianxm@jhu.edu> writes:
>
> > Thanks. And thanks for taking the time to fix issues that you find. It
> > continues to improve because of your contributions.
> > The patch looks good. Applied.
>
Thanks for fixing this. I re-read the woof documentation and realized I
needed to put "Applied" at the beginning of the line.
if anyone is curious, to save you a search, the doc is here:
https://github.com/bzg/woof#basic-usage
[-- Attachment #2: Type: text/html, Size: 1199 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] ob-java: Allow import to end with asterisk
2021-04-25 10:40 ` ian martins
@ 2021-04-26 6:52 ` Bastien
0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2021-04-26 6:52 UTC (permalink / raw)
To: ian martins; +Cc: Org-Mode mailing list, Timothy
Hi Ian,
ian martins <ianxm@jhu.edu> writes:
> Thanks for fixing this. I re-read the woof documentation and realized
> I needed to put "Applied" at the beginning of the line.
Yes - and also add a "X-Woof-Patch: applied" header in your reply.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-04-26 6:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-26 7:53 [PATCH] ob-java: Allow import to end with asterisk John Herrlin
2021-01-27 3:21 ` ian martins
2021-01-27 7:24 ` John Herrlin
2021-01-28 20:03 ` John Herrlin
2021-01-30 10:50 ` ian martins
2021-04-25 3:43 ` Timothy
2021-04-25 10:40 ` ian martins
2021-04-26 6:52 ` Bastien
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).