[perl #42170] [PATCH] Report line numbers on trailing_space.t

0 views
Skip to first unread message

Will Coleda

unread,
Mar 29, 2007, 11:28:52 PM3/29/07
to bugs-bi...@rt.perl.org
# New Ticket Created by Will Coleda
# Please include the string: [perl #42170]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42170 >


For steve_p on #parrot.

I find this a little too verbose, but would not object if someone
applied it.

=== t/codingstd/trailing_space.t
==================================================================
--- t/codingstd/trailing_space.t (revision 4828)
+++ t/codingstd/trailing_space.t (local)
@@ -50,14 +50,13 @@
# slurp in the file
open( my $fh, '<', $path )
or die "Cannot open '$path' for reading: $!\n";
+
+ while (my $line=<$fh>)
{
- local $/;
- $buf = <$fh>;
+ if ( $line =~ m{.?[ \t]+$} ) {
+ push @failed_files, "$path:$.";
+ }
}
-
- if ( $buf =~ m{.?[ \t]+$}m ) {
- push @failed_files, $path;
- }
}
# check the file

--
Will "Coke" Coleda
wi...@coleda.com


Jerry Gay

unread,
Mar 30, 2007, 1:14:05 AM3/30/07
to perl6-i...@perl.org, bugs-bi...@rt.perl.org
do you really need a line number in test output? in vim:
/ $

will find you every line with trailing spaces.
better yet, do like i do, and set this in your .vimrc:
set list
set listchars=trail:-,tab:\.\

NOTE: there is a trailing space on the line above. it's IMPORTANT.
not only will this show you trailing spaces (as dashes), but leading
tabs (as dot followed by space). that way you'll notice and fix them
before you commit. i've never run emacs, so i don't know the lispy
analog. i'm sure somebody will chime in with it.
~jerry

Eric Hanchrow

unread,
Mar 30, 2007, 4:42:10 AM3/30/07
to perl6-i...@perl.org
>>>>> "jerry" == jerry gay <jerr...@gmail.com> writes:

jerry> i've never run emacs, so i don't know the lispy analog.
jerry> i'm sure somebody will chime in with it.

This does what you think it does:
(setq-default show-trailing-whitespace t)

Emacs 22 users can highlight tabs like this:
(global-hi-lock-mode 1)
(highlight-regexp "\t")
--
... apart from the sanitation, the medicine,education, wine,
public order, irrigation, roads, a fresh water system, and public
health, what have the Romans ever done for us?
-- Reg, JPF

Paul Cochrane

unread,
Apr 1, 2007, 3:32:31 AM4/1/07
to Eric Hanchrow, perl6-i...@perl.org
On 30/03/07, Eric Hanchrow <off...@blarg.net> wrote:
> >>>>> "jerry" == jerry gay <jerr...@gmail.com> writes:
>
> jerry> i've never run emacs, so i don't know the lispy analog.
> jerry> i'm sure somebody will chime in with it.
>
> This does what you think it does:
> (setq-default show-trailing-whitespace t)
>
> Emacs 22 users can highlight tabs like this:
> (global-hi-lock-mode 1)
> (highlight-regexp "\t")

These configuration options (both emacs and vim) have been added to
docs/project/cage_cleaners_guide.pod if people wish to refer to them
again.

Paul

Reply all
Reply to author
Forward
0 new messages