Skip to content

Commit ef9a146

Browse files
committed
Detect IDL vs. Prolog files (.pro extension)
* Also handle hard tabs properly in the whitespace before a comment character during this detection.
1 parent 0a283a4 commit ef9a146

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

colorize.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/zsh
22

33
# This code is licensed under the GPL v2. See LICENSE.txt for details.
4-
4+
55
# colorize.sh
66
# QLColorCode
77
#
@@ -58,15 +58,24 @@ case $target in
5858
# look for a matlab-style comment in the first 10 lines, otherwise
5959
# assume objective-c. If you never use matlab or never use objc,
6060
# you might want to hardwire this one way or the other
61-
if head -n 10 $target | grep -q "^ *%" &> /dev/null; then
61+
if head -n 10 $target | grep -q "^[ ]*%" &> /dev/null; then
6262
lang=m
6363
else
6464
lang=objc
6565
fi
6666
;;
6767
*.groovy )
68-
lang=java
69-
;;
68+
lang=java
69+
;;
70+
*.pro )
71+
# Can be either IDL or Prolog. Prolog uses /* */ and % for comments.
72+
# IDL uses ;
73+
if head -n 10 $target | grep -q "^[ ]*;" &> /dev/null; then
74+
lang=idlang
75+
else
76+
lang=pro
77+
fi
78+
;;
7079
* )
7180
lang=${target##*.}
7281
;;

0 commit comments

Comments
 (0)