Message from discussion
Patch to support "extended completion"
Received: by 10.91.91.8 with SMTP id t8mr102982agl.16.1272528242804;
Thu, 29 Apr 2010 01:04:02 -0700 (PDT)
X-BeenThere: rope-dev@googlegroups.com
Received: by 10.231.13.25 with SMTP id z25ls34101636ibz.1.p; Thu, 29 Apr 2010
01:04:02 -0700 (PDT)
Received: by 10.231.176.11 with SMTP id bc11mr1054593ibb.12.1272528242092;
Thu, 29 Apr 2010 01:04:02 -0700 (PDT)
Received: by 10.231.176.11 with SMTP id bc11mr1054592ibb.12.1272528242033;
Thu, 29 Apr 2010 01:04:02 -0700 (PDT)
Return-Path: <jstpie...@mecheye.net>
Received: from mail-qy0-f200.google.com (mail-qy0-f200.google.com [209.85.221.200])
by gmr-mx.google.com with ESMTP id 19si93567iwn.14.2010.04.29.01.04.01;
Thu, 29 Apr 2010 01:04:01 -0700 (PDT)
Received-SPF: fail (google.com: domain of jstpie...@mecheye.net does not designate 209.85.221.200 as permitted sender) client-ip=209.85.221.200;
Received: by qyk38 with SMTP id 38so18008710qyk.5
for <rope-dev@googlegroups.com>; Thu, 29 Apr 2010 01:03:59 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.229.86.16 with SMTP id q16mr11247077qcl.39.1272528239229; Thu,
29 Apr 2010 01:03:59 -0700 (PDT)
Received: by 10.224.73.200 with HTTP; Thu, 29 Apr 2010 01:03:59 -0700 (PDT)
In-Reply-To: <n2g91b249311004290019y984dff7eq13076190fc146a3a@mail.gmail.com>
References: <m2z2c1d48a71004271857j68014039kc57778f3ef37feac@mail.gmail.com>
<n2g91b249311004290019y984dff7eq13076190fc146a3a@mail.gmail.com>
Date: Thu, 29 Apr 2010 04:03:59 -0400
Message-ID: <z2m2c1d48a71004290103y94bd8b4dt2a31f95b46779c35@mail.gmail.com>
Subject: Re: Patch to support "extended completion"
From: "Jasper St. Pierre" <jstpie...@mecheye.net>
To: rope-dev@googlegroups.com
X-Original-Authentication-Results: gmr-mx.google.com; spf=hardfail
(google.com: domain of jstpie...@mecheye.net does not designate
209.85.221.200 as permitted sender) smtp.mail=jstpie...@mecheye.net
X-Original-Sender: jstpie...@mecheye.net
Reply-To: rope-dev@googlegroups.com
Precedence: list
Mailing-list: list rope-dev@googlegroups.com; contact rope-dev+owners@googlegroups.com
List-ID: <rope-dev.googlegroups.com>
List-Post: <http://groups.google.com/group/rope-dev/post?hl=en_US>,
<mailto:rope-dev@googlegroups.com>
List-Help: <http://groups.google.com/support/?hl=en_US>, <mailto:rope-dev+help@googlegroups.com>
List-Archive: <http://groups.google.com/group/rope-dev?hl=en_US>
Sender: rope-dev@googlegroups.com
List-Subscribe: <http://groups.google.com/group/rope-dev/subscribe?hl=en_US>,
<mailto:rope-dev+subscribe@googlegroups.com>
List-Unsubscribe: <http://groups.google.com/group/rope-dev/subscribe?hl=en_US>,
<mailto:rope-dev+unsubscribe@googlegroups.com>
Content-Type: multipart/alternative; boundary=0016364ee308aa813f04855b91a8
--0016364ee308aa813f04855b91a8
Content-Type: text/plain; charset=ISO-8859-1
It's currently in here:
http://github.com/magcius/auto-complete/
Which I will try to get upstream as soon as the patch is integrated.
<http://github.com/magcius/auto-complete/>
On Thu, Apr 29, 2010 at 3:19 AM, Darren Hoo <darren....@gmail.com> wrote:
> Hi,
>
> On Wed, Apr 28, 2010 at 9:57 AM, Jasper St. Pierre
> <jstpie...@mecheye.net> wrote:
> > I am currently in the process of making a ropemacs auto-complete backend.
> > Here is the patch to support that:
> > diff -r 364ab6aeb8e9 ropemode/interface.py
> > --- a/ropemode/interface.py Tue Apr 27 19:53:45 2010 +0400
> > +++ b/ropemode/interface.py Tue Apr 27 21:55:06 2010 -0400
> > @@ -272,6 +272,10 @@
> > def completions(self):
> > return _CodeAssist(self, self.env).completions()
> >
> > + @decorators.local_command()
> > + def extended_completions(self):
> > + return _CodeAssist(self, self.env).extended_completions()
> > +
> > def _check_autoimport(self):
> > self._check_project()
> > if self.autoimport is None:
> > @@ -590,6 +594,12 @@
> > return [self.env._completion_text(proposal)[prefix:]
> > for proposal in proposals]
> >
> > + def extended_completions(self):
> > + proposals = self._calculate_proposals()
> > + prefix = self.offset - self.starting_offset
> > + return [[proposal.name[prefix:], proposal.get_doc(),
> > + proposal.type] for proposal in proposals]
> > +
> > def _apply_assist(self, assist):
> > if ' : ' in assist:
> > name, module = assist.rsplit(' : ', 1)
> >
> this patch works for me.
>
> People who use company-mode can use this patch to make
> of this extended complete, the info will show in the echo area
>
> --- company-ropemacs.new.el 2010-04-29 14:55:24.766121479 +0800
> +++ company-ropemacs.el 2010-04-29 14:56:15.000000000 +0800
> @@ -63,6 +63,9 @@
> (company-ropemacs--grab-symbol)))
> ('candidates (mapcar (lambda (element) (concat arg element))
> (rope-completions)))
> + ('meta (let* ((completions (rope-extended-completions))
> + (match (assoc arg completions)))
> + (concat (propertize arg 'face 'font-lock-doc-face) ": " (caddr
> match))))
> ('doc-buffer (company-ropemacs-doc-buffer arg))
> ('location (company-ropemacs-location arg))))
>
> there's one nuisance here, that is if the completion is an instance
> for example if it is a string , it will return the documentation of
> string class ,I think this is too much verbose, return something like
> "type String" will be enough IMHO. so I have not added doc in
> the above patch, add it if that's ok for you. also you can press
> F1 on the selected completion candidate to get docuementation of
> it in company-mode.
>
--0016364ee308aa813f04855b91a8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
It's currently in here:<div><br></div><div><a href=3D"http://github.com=
/magcius/auto-complete/">http://github.com/magcius/auto-complete/</a></div>=
<div><br></div><div>Which I will try to get upstream as soon as the patch i=
s integrated.</div>
<div><a href=3D"http://github.com/magcius/auto-complete/"></a><br><div><div=
><div class=3D"gmail_quote">On Thu, Apr 29, 2010 at 3:19 AM, Darren Hoo <sp=
an dir=3D"ltr"><<a href=3D"mailto:darren....@gmail.com">darren.hoo@gmail=
.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;">Hi,<br>
<div><div></div><div class=3D"h5"><br>
On Wed, Apr 28, 2010 at 9:57 AM, Jasper St. Pierre<br>
<<a href=3D"mailto:jstpie...@mecheye.net">jstpie...@mecheye.net</a>> =
wrote:<br>
> I am currently in the process of making a ropemacs auto-complete backe=
nd.<br>
> Here is the patch to support that:<br>
> diff -r 364ab6aeb8e9 ropemode/interface.py<br>
> --- a/ropemode/interface.py Tue Apr 27 19:53:45 2010 +0400<br>
> +++ b/ropemode/interface.py Tue Apr 27 21:55:06 2010 -0400<br>
> @@ -272,6 +272,10 @@<br>
> =A0=A0 =A0 def completions(self):<br>
> =A0=A0 =A0 =A0 =A0 return _CodeAssist(self, self.env).completions()<br=
>
><br>
> + =A0 =...@decorators.local_command()<br>
> + =A0 =A0def extended_completions(self):<br>
> + =A0 =A0 =A0 =A0return _CodeAssist(self, self.env).extended_completio=
ns()<br>
> +<br>
> =A0=A0 =A0 def _check_autoimport(self):<br>
> =A0=A0 =A0 =A0 =A0 self._check_project()<br>
> =A0=A0 =A0 =A0 =A0 if self.autoimport is None:<br>
> @@ -590,6 +594,12 @@<br>
> =A0=A0 =A0 =A0 =A0 return [self.env._completion_text(proposal)[prefix:=
]<br>
> =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for proposal in proposals]<br>
><br>
> + =A0 =A0def extended_completions(self):<br>
> + =A0 =A0 =A0 =A0proposals =3D self._calculate_proposals()<br>
> + =A0 =A0 =A0 =A0prefix =3D self.offset - self.starting_offset<br>
> + =A0 =A0 =A0 =A0return [[<a href=3D"http://proposal.name" target=3D"_=
blank">proposal.name</a>[prefix:], proposal.get_doc(),<br>
> + proposal.type] for proposal in proposals]<br>
> +<br>
> =A0=A0 =A0 def _apply_assist(self, assist):<br>
> =A0=A0 =A0 =A0 =A0 if ' : ' in assist:<br>
> =A0=A0 =A0 =A0 =A0 =A0 =A0 name, module =3D assist.rsplit(' : '=
;, 1)<br>
><br>
</div></div>this patch works for me.<br>
<br>
People who use company-mode can use this patch to make<br>
of this extended complete, the info will show in the echo area<br>
<br>
--- company-ropemacs.new.el =A0 =A0 2010-04-29 14:55:24.766121479 +0800<br>
+++ company-ropemacs.el 2010-04-29 14:56:15.000000000 +0800<br>
@@ -63,6 +63,9 @@<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (company-ropemacs--grab-symbol)))<br>
=A0 =A0 ('candidates (mapcar (lambda (element) (concat arg element))<b=
r>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(rope-completions)))<br=
>
+ =A0 =A0('meta (let* ((completions (rope-extended-completions))<br>
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match (assoc arg completions)))<br>
+ =A0 =A0 =A0 =A0 =A0 =A0(concat (propertize arg 'face 'font-lock-d=
oc-face) ": " (caddr match))))<br>
=A0 =A0 ('doc-buffer (company-ropemacs-doc-buffer arg))<br>
=A0 =A0 ('location (company-ropemacs-location arg))))<br>
<br>
there's one nuisance here, that is if the completion is an instance<br>
for example if it is a string , it will return the documentation of<br>
string class ,I think this is too much verbose, return something like<br>
"type String" will be enough IMHO. so I have not added doc in<br>
the above patch, add it if =A0that's ok for =A0you. also you can press<=
br>
F1 on the selected completion candidate to get docuementation of<br>
it in company-mode.<br>
</blockquote></div><br></div></div></div>