auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo collision


From: Vincent Belaïche
Subject: Re: [AUCTeX] Problem with latex2e style hook --- LaTeX/Texinfo collision‏
Date: Wed, 17 Sep 2014 23:17:15 +0200

Hello Tassilo,


[...]

>
> Bye,
> Tassilo
>
> BTW: Your patches contained some minor problems in that they introduced
> trailing whitespaces and spaces before tabs in indented code. New
> versions of Git emit warnings for that that and it was easy to fix them
> after applying your patches. But still, it's a good idea to do M-x
> whitespace-cleanup-region on the regions that you've modified before
> creating a patch.


Not sure whether the attached bash script may be useful to other people,
I have written it to detect suspicious blanks on all files that come
into a patch, so that if some day I submit some other patch, the same
problem will not occur.

-----------------------------------------------------------------------
Usage:

vcdiff > my_patch.diff
-----------------------------------------------------------------------

stdout of git diff will go into my_patch.diff, but prior to that
any suspicious blanks is warned for on the stderr.

   Vincent.

PS: I have noticed that there are files, e.g. latex.el with many
problems like leading eight blanks. Surely this is the reason for your
suggesting whitespace-cleanup-region on change region instead of
whitespace-cleanup (on all buffer, ie w/o transient mark mode on changed
region).

#!/bin/sh

# detect VC engine in use
if [ -d .git ]; then
        vcengine=git
elif [ -d .svn ]; then
        vcengine=svn
else
        echo "Can't detect vcengine"
        exit -1
fi

# sanity check
if $vcengine --version > /dev/null; then
        true; # dummy
else
        echo "Can't find $vcengine program!"
        exit -2
fi

files=$($vcengine status | awk '$2 == "modified:" { print $3}')

suspicious_files=''
awkscript=$(mktemp /temp/tmp.awkscript.XXXXXX)

# Note that in the script I set RS to be tolerant to Windows file format. This 
is because I may be handling
# Windows text files (ended in CRLF) in a *nixy (e.g. MSYS) environment
cat > $awkscript <<EOF
BEGIN { r=-1; line=0; STDERR="/dev/stderr"; body=0; empty = 0; RS="\r?\n|\r"}
          {++line}
/^[     ]*\$/ {
        if(body ==0) {r=0; print FILENAME ":line " line ": Leading blank line" 
> STDERR}
        empty = 1}
/[^     ]/ { body = 1; empty = 0}
/^ {8,}/ { r=0; print FILENAME ":line " line ": 8 or more spaces at the 
beginning of a line" > STDERR }
/^ +    / { r=0; print FILENAME ":line " line ": Space(s) followed by a TAB at 
the beginning of a line" > STDERR }
/[^     ][      ]+\$/ { r=0; print FILENAME ":line " line ": Trailing blanks" > 
STDERR }
END {
        if(empty == 1){r=0; print FILENAME ":line " line ": Trailing blank 
line" > STDERR}
        exit(r)}
EOF


# echo "AWKSCRIPT>"
# cat $awkscript
# echo "<AWKSCRIPT"

for w in $files; do
        if awk --re-interval -f $awkscript  --  $w; then
                suspicious_files="$w $suspicious_files"
        fi
done

echo "Files with suspicious white space $suspicious_files" > /dev/stderr
rm -f $awkscript

$vcengine diff


        

# Local Variables:
# mode: sh
# End:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]