jump to navigation

Some ideas on method auto-completion in Padre June 9, 2009

Posted by claudio in Uncategorized.
Tags: , , , , , ,

perlAuto-completion is a nice feature for an IDE. While Padre supports some auto-completion functions, method auto-completion is an important missing feature. This post is a short round-up of features present in other IDEs.

What auto-completion features does Padre support today?

Beside automatic bracket completion, Padre has a nice auto-completion implementation for variables (first character -including sigil- then ctrl + p):


Eclipse + Epic

Epic (an add-on to Eclipse) has a nice working auto-completion feature activated by the method invocator (->).


As a reference, the java auto-completion in Eclipse:


Komodo Edit

Komodo Edit also has auto-completion for methods, but does not show those inherited from parent classes making the feature rather useless for OO development.



Netbeans has no Perl support, nevertheless the java auto-completion feature is a good example:


The method auto-completion feature is activated by the “.” (“->” in Perl). Not only you get a list of accessible methods (with expected parameter type and return value), but also the javadoc documentation for the selected method.

How should Padre support method auto-completion? Some ideas

  1. Method autocomplete should be activated by “->” and “::”. This way class hierarchies can be autocompleted as well. With “::” support for functions can be added.
  2. Private methods should be hidden. By convention, private methods start with “_”.
  3. Linking method autocomplete to perldoc is a winner combination when programming to not yet familiar APIs and certainly friendly to new Perl developers. While Perl is not strictly typed, a well formatted perldoc entry for a method should make clear what kind of parameters are expected and what the return value could be. However, documentation is rather freely formatted, so it would be difficult to implement in a generic way (without adding formatting restriction to classes).


1. Adam Kennedy - June 9, 2009

Luckily, there’s a very common pattern that a CPAN module has a =head1 FUNCTIONS or METHODS or some such, containing a list of =head2 method_name sections.

This is fairly common, so we may well just be able to support that, and wait for the rest of CPAN to change to match our code:)

2. jerome quelin - June 9, 2009

i should say that i dislike having to hit a shortcut (such as ctrl+p) to get autocompletion.

this feels unnatural: autocompletion is here to help typing, and thus the choices should appear when typing, narrow when more letters get typed, and disappear when nothing match anymore. without having to type anything.

3. claudio - June 9, 2009

I agree with Jerome. Maybe ctrl+p could be the alternative for people disabling non-shortcut auto-completion in the configuration?

4. jerome quelin - June 9, 2009

@alias: it’s also common for modules to have
=head1 methods
=head2 topic
=over 4
=item method()


also, how to detect the class of a given variable?

5. claudio - June 9, 2009


Maybe something using Ovid’s Class::Sniff?

6. garu - June 9, 2009

For some reason (maybe visual studio, but it’s been too long for me to remember) I find ctrl+p really counterintuitive, as opposed to ctrl+spacebar – but I guess that’s just me…

Another annoying autocomplete thing for me is not having it autocomplete the name when there’s only one possible choice, instead it shows a one-element list to choose from.

But I really enjoyed the comparison, it clearly points us where to go. Great job!

7. garu - June 9, 2009

@jerome: Maybe we could start just supporting direct class/package calls instead of actual object (variable) methods.

my $obj = Net::SMTP-> (shows autocomplete)

$obj-> (does nothing — yet)

8. claudio - June 9, 2009

Alias on #padre:
18:10 One method for auto-complete might be to perl -c the file
18:10 And whenever you do it, and it works, stash a copy of the method list for that class
18:10 And then auto-complete off that, even once the file changes a bit

9. Steffen Mueller - June 14, 2009

@garu: I implemented experimental Perl::Tags based variable, package, and class method (Foo->…) auto completion the other day. It could do with some polish, though.

In a nutshell, you just generate a file called “perltags” from any number of files/modules using Perl::Tags and put it in your $ENV{PADRE_HOME}. Then, you can auto-complete with Ctrl-P.

claudio - June 14, 2009

I have no idea whatsoever how the tags work, but is it light enough to be generated when use Module or ->new() is first typed?

10. Shawn - June 16, 2009

I wrote this a while ago for Devel::REPL’s method name completion:


It works pretty well and doesn’t include keyword detritus like “extends”.

11. Steffen Mueller - June 16, 2009

claudio: The ctags thing is just a way of storing the information. It’s totally unrelated to how you actually get the information in that format.

Shawn: That’s interesting. One major difference: You’re using run-time information (via Class::MOP). We don’t have that in an editor, unfortunately. One could compile a module, but that is a suboptimal approach for a tool that’s intended to be used in unfinished code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 197 other followers

%d bloggers like this: