Received: by 10.224.219.211 with SMTP id hv19mr8543514qab.7.1332679073192; Sun, 25 Mar 2012 05:37:53 -0700 (PDT) X-BeenThere: rope-dev@googlegroups.com Received: by 10.229.166.138 with SMTP id m10ls4036901qcy.3.gmail; Sun, 25 Mar 2012 05:37:51 -0700 (PDT) Received: by 10.224.219.211 with SMTP id hv19mr8543498qab.7.1332679071963; Sun, 25 Mar 2012 05:37:51 -0700 (PDT) Received: by 10.224.219.211 with SMTP id hv19mr8543497qab.7.1332679071953; Sun, 25 Mar 2012 05:37:51 -0700 (PDT) Return-Path: Received: from mail-qc0-f175.google.com (mail-qc0-f175.google.com [209.85.216.175]) by gmr-mx.google.com with ESMTPS id b22si5590680qcs.3.2012.03.25.05.37.51 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Mar 2012 05:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of takafum...@gmail.com designates 209.85.216.175 as permitted sender) client-ip=209.85.216.175; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of takafum...@gmail.com designates 209.85.216.175 as permitted sender) smtp.mail=takafum...@gmail.com; dkim=pass header...@gmail.com Received: by mail-qc0-f175.google.com with SMTP id o7so3171763qcs.34 for ; Sun, 25 Mar 2012 05:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=AMtk00pzjnu7N9jolmqANtKdAm9PcLi3fQ9p21JOisk=; b=jOkUeR8QmA3mYqkyYcvy0WzmEvJYx/9uPyxf5aCQ+pEpzx9epNDzyiD/Swo2eH2rJf fkEwG9Rg7PKXJQKqN+yY+yK/URZpF4KMZyLrcAPvFe9fB7R4lbUf4Yklb7ullSdbdVCe 36cJgzQ92lMzHGh70ME0hZjrPSfnjPBNfji9GvFED0w8XC6Z4/ILvudRBzzJONMjH9Cb LwHmVy9diTAQjNpYBKuWGWsl96NOO6P+u9p1XPHGDDqR10A0oUJH0BDVRbqUPie1GVlW SSsRFhgbAGVagiCaxQD2GYriWwqmwZZ7+ojW3/6dnWGwbaQ2zcOVgyoUI7rCnTfW6vfe W7lg== Received: by 10.229.137.134 with SMTP id w6mr6777386qct.137.1332679071837; Sun, 25 Mar 2012 05:37:51 -0700 (PDT) MIME-Version: 1.0 Sender: takafum...@gmail.com Received: by 10.224.137.72 with HTTP; Sun, 25 Mar 2012 05:37:31 -0700 (PDT) In-Reply-To: <20122503154...@lilem.mirepesht> References: <20122303154...@lilem.mirepesht> <20122403092...@lilem.mirepesht> <20122403165...@lilem.mirepesht> <20122503000...@lilem.mirepesht> <20122503080...@lilem.mirepesht> <20122503083...@lilem.mirepesht> <20122503154...@lilem.mirepesht> From: Takafumi Arakaki Date: Sun, 25 Mar 2012 14:37:31 +0200 Message-ID: Subject: Re: Patches: noerror option to code_assist To: Ali Gholami Rudi Cc: rope-dev Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sun, Mar 25, 2012 at 1:12 PM, Ali Gholami Rudi wrot= e: > Hi Takafumi, > > Takafumi Arakaki wrote: >> diff -r bd969e488130 -r 1e251abf45c2 ropemode/interface.py >> --- a/ropemode/interface.py =A0 Wed Feb 08 12:16:43 2012 +0800 >> +++ b/ropemode/interface.py =A0 Sun Mar 25 10:01:31 2012 +0200 >> @@ -626,13 +626,19 @@ >> >> =A0 =A0 =A0def _calculate_proposals(self): >> =A0 =A0 =A0 =A0 =A0self.interface._check_project() >> =A0 =A0 =A0 =A0 =A0resource =3D self.interface.resource >> =A0 =A0 =A0 =A0 =A0maxfixes =3D self.env.get('codeassist_maxfixes') >> - =A0 =A0 =A0 =A0proposals =3D codeassist.code_assist( >> - =A0 =A0 =A0 =A0 =A0 =A0self.interface.project, self.source, self.offse= t, >> - =A0 =A0 =A0 =A0 =A0 =A0resource, maxfixes=3Dmaxfixes) >> + =A0 =A0 =A0 =A0try: >> + =A0 =A0 =A0 =A0 =A0 =A0proposals =3D codeassist.code_assist( >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.interface.project, self.source, se= lf.offset, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0resource, maxfixes=3Dmaxfixes) >> + =A0 =A0 =A0 =A0except exceptions.ModuleSyntaxError as err: >> + =A0 =A0 =A0 =A0 =A0 =A0if self.env.get('codeassist_noerror'): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0proposals =3D [] >> + =A0 =A0 =A0 =A0 =A0 =A0else: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise err >> =A0 =A0 =A0 =A0 =A0if self.env.get('sorted_completions', True): >> =A0 =A0 =A0 =A0 =A0 =A0 =A0proposals =3D codeassist.sorted_proposals(pro= posals) >> =A0 =A0 =A0 =A0 =A0if self.autoimport is not None: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0if self.starting.strip() and '.' not in self.= expression: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0import_assists =3D self.autoimport.im= port_assist(self.starting) > > Thanks. =A0Only one suggestion: as I mentioned in my previous mail, noerr= or > probably makes sense only for functions, like ropevim_completions, not > for commands like ropevim_codeassist. =A0Almost always, users prefer a > message like "rope failed to ..." =A0when there are errors, rather than a= n > empty response which may mean no completions. =A0For commands, something > like brieferrors makes more sense, though that's another story. > > So I suggest moving the try-expect block to the functions calling > _calculate_proposals(), or passing a noerror argument to it, which > is true only in functions. =A0Like completions() and extended_completions= (). > > Thanks, > Ali > Here you go! https://bitbucket.org/agr/ropemode/pull-request/5/ If it is just for completions() and extended_completions(), isn't it better to use argument instead of a global variable? My aim was to provide a global way to control the error messages because you can call any commands and functions from outside of ropemode and caller may want to suppress the errors. What is the use case you have in mind? (1) rope user may set the default for noerror option but the external module can override the default by dynamically changing it; (2) rope users set the value and external module should not alter the value. if the users want to see the errors while calling completions via the external module, let them see it. I have (1) in mind, so having argument for that makes more sense, if you really want to distinguish APIs (completions and extended_completions) and interactive commands. But if (2) is the goal, having global variable for it is better. I like the idea of (1) because user benefits a lot without a special setup. Best, Takafumi