From: John Herrlin <jherrlin@gmail.com> To: ian martins <ianxm@jhu.edu> Cc: org-mode-email <emacs-orgmode@gnu.org> Subject: Re: [PATCH] ob-java: Allow import to end with asterisk Date: Thu, 28 Jan 2021 21:03:32 +0100 Message-ID: <875z3gde25.fsf@gmail.com> (raw) In-Reply-To: <CAC=rjb4Uo2U9DxjKSyuOEgu1KF4Qg_xthkOQsSVL9LerTFcMPw@mail.gmail.com> [-- 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
next prev parent reply other threads:[~2021-01-28 20:05 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-26 7:53 John Herrlin 2021-01-27 3:21 ` ian martins 2021-01-27 7:24 ` John Herrlin 2021-01-28 20:03 ` John Herrlin [this message] 2021-01-30 10:50 ` ian martins
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=875z3gde25.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
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