ciaranm / detectindent

Vim script for automatically detecting indent settings
173 stars 48 forks source link

please add support for Perl #13

Open majewsky opened 12 years ago

majewsky commented 12 years ago

Perl comments are from "#" until line end, like in most contemporary scripting languages.

some_statement(); # this comment lasts until the end of the line

Furthermore, the Perl interpreter skips over documentation written in the POD (Plain Old Documentation) format, so this should be treated like a comment, too. POD looks like this:

some_statement();

=pod

This is documentation.

=cut

some_other_statement();

It is started by any POD command. Such commands always start with "=" and must always appear at the beginning of the line (without any whitespace before them, i.e. column 1). The regexp /^=/ detects POD commands reasonably reliably in Perl code.

A documentation text always ends with the command "=cut", so the end can be found by /^=cut/.

A complete reference of the POD format is available at http://perldoc.perl.org/perlpod.html

ciaranm commented 12 years ago

DetectIndent doesn't generally need to know about comments. The special handling for /* */ is there because a lot of people do this:

/*
 * notice the aligned star character with atypical indenting
 */

Does typical use of POD also screw up indent detection?

majewsky commented 12 years ago

Yes, because you can embed code examples. Everything is a code example if its line starts with any number of spaces. I've opened this issue exactly because unusual indentation in code examples (e.g. one space only) screws up the DetectIndent logic.

ghostwords commented 12 years ago

majewsky, see also https://github.com/ciaranm/detectindent/issues/12