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 4AGrBAMZE2CgNQAA0tVLHw (envelope-from ) for ; Thu, 28 Jan 2021 20:05:23 +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 cKJRAAMZE2COCAAAB5/wlQ (envelope-from ) for ; Thu, 28 Jan 2021 20:05:23 +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 616EE9402C2 for ; Thu, 28 Jan 2021 20:05:22 +0000 (UTC) Received: from localhost ([::1]:42992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5DXb-00062d-At for larch@yhetil.org; Thu, 28 Jan 2021 15:05:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5DW0-00061Q-HW for emacs-orgmode@gnu.org; Thu, 28 Jan 2021 15:03:40 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:44039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5DVx-0006li-RI for emacs-orgmode@gnu.org; Thu, 28 Jan 2021 15:03:40 -0500 Received: by mail-wr1-x431.google.com with SMTP id d16so6625157wro.11 for ; Thu, 28 Jan 2021 12:03:37 -0800 (PST) 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=E///9o43Isyi07SQzidpV6wYDNGAV89e+ST+pw9TciA=; b=JdkCUcU3W/u2I8RqxPpzKeYdDQvLPrEFlM+vjXc+cL1u1E+KmrlFtMuGfxQXhtn0nG nqIgmdkRLygTCyfZ5zVXfCEOs9CIArB5grNN/xivQRDDpaHTjgjnM+f88oNVyJXKZjNa 2D1ycftmtwh0BFTDq3tETR9lXsaUpIvMcQQfkJiWUp0ANlHLWHax/4WZSknu1cGr5VXL P0EZegLPRS4u4lGbo064nLo8Agn9bV4+RIkSOojSlEudBpeaHl4wyByGqM8K+/+5+v6s KILd2Uoc3dIBeDKthYXlDSL7R9U7qQmKttoLIRSMK5MOahKTsYUdI7W08PNrbFNtZrVQ 3fHw== 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=E///9o43Isyi07SQzidpV6wYDNGAV89e+ST+pw9TciA=; b=IXvipjx5upOMNA37IEvASQpzA5lOU+ePiei4Yio/Kyht6PfKNQapl9d2Nu0Tl5Ynnq qNsSTWHZaMd0BqisX5htRhDl0ntIFrEKDvUy/xt5oFXBpMauXen9A3mk//EYOe4NTt3h d6hH5Dx2wTw4tv2FolwSibar8DLLk1JaVQpGUxqQPc0aarxpJLTDav46xS2DwkRR2528 NVn5NvuZSlN7UWz14Zad9ZI3dIiW6z5e8FAzeHy0FhBLWPpb6QjZOhAsn+i0rokR2lq+ 9X8/JVNQfq9QaxPUgD9UxFtRZEj9FlZBoOpyl7aHvGtXbXJpj4J2Knl6QJxGtmQFNxVM sUuw== X-Gm-Message-State: AOAM533RQMtlSVA7hCrcSuj7ihN7DgTeu1k4TSbqg6VYb23WOPAc1yi1 d3orD8EiEPPwHiT5BnSnn0TQXgppA8o= X-Google-Smtp-Source: ABdhPJzuz0m6iVEU7qqsqgjF6dM8r0LBz+723Hun6qLgxwVSgH1SwHuqjyafRIKjtHyXtMmisyI2Vw== X-Received: by 2002:a5d:6347:: with SMTP id b7mr749807wrw.233.1611864215535; Thu, 28 Jan 2021 12:03:35 -0800 (PST) Received: from fnox ([194.132.212.123]) by smtp.gmail.com with ESMTPSA id s4sm8237451wrt.85.2021.01.28.12.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 12:03:34 -0800 (PST) References: <87sg6o6sn2.fsf@gmail.com> User-agent: mu4e 1.4.13; emacs 27.1 From: John Herrlin To: ian martins Subject: Re: [PATCH] ob-java: Allow import to end with asterisk In-reply-to: Message-ID: <875z3gde25.fsf@gmail.com> Date: Thu, 28 Jan 2021 21:03:32 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=jherrlin@gmail.com; helo=mail-wr1-x431.google.com 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-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.05 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=JdkCUcU3; 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-Migadu-Queue-Id: 616EE9402C2 X-Spam-Score: -3.05 X-Migadu-Scanner: scn1.migadu.com X-TUID: Nn+j9OuLpGqx --=-=-= Content-Type: text/plain ian martins 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! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ob-java-Allow-import-to-end-with-asterisk.patch >From 92c72792fb18a73572ee35d34a5e1d5ce56d8b6a Mon Sep 17 00:00:00 2001 From: John Herrlin 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 --=-=-=--