qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs perl.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs perl.c
Date: Fri, 21 Dec 2007 14:29:54 +0000

CVSROOT:        /cvsroot/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        07/12/21 14:29:54

Modified files:
        .              : perl.c 

Log message:
        improved Perl mode:
        - fixed multiline format template support
        - fixed multiline here documents
        match mode on file first line, same as /^#!.*/usr/bin/perl.*/

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/perl.c?cvsroot=qemacs&r1=1.1&r2=1.2

Patches:
Index: perl.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/perl.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- perl.c      18 Dec 2007 18:07:03 -0000      1.1
+++ perl.c      21 Dec 2007 14:29:54 -0000      1.2
@@ -38,7 +38,7 @@
 #define IN_FORMAT      0x04    /* format = ... */
 #define IN_INPUT       0x08
 
-/* CG: bogus if multiple regions are colorized */
+/* CG: bogus if multiple regions are colorized, should use signature */
 static unsigned int perl_eos[100];
 static int perl_eos_len;
 
@@ -120,17 +120,21 @@
     } else
     if (colstate & IN_FORMAT) {
        i = n;
-       set_color(str + j, str + i, PERL_STRING);
        if (n == 1 && str[0] == '.')
            colstate &= ~IN_FORMAT;
+       set_color(str + j, str + i, PERL_STRING);
     }
     if (colstate & IN_INPUT) {
        //vdm_noRetrievalKey = 1;
        i = n;
-       set_color(str + j, str + i, PERL_STRING);
-       if (n == perl_eos_len && !umemcmp(perl_eos, str, n))
+       if (n == perl_eos_len && !umemcmp(perl_eos, str, n)) {
            colstate &= ~IN_INPUT;
+            set_color(str + j, str + i, PERL_KEYWORD);
+        } else {
+            set_color(str + j, str + i, PERL_STRING);
     }
+    }
+
     while (i < n) {
        j = i + 1;
        c1 = str[j];
@@ -182,10 +186,11 @@
                /* Should check for unary context */
                s1 = i + 2;
                c2 = str[s1];
-               if (c2 == '"' || c2 == '\'' || c2 == '`')
+               if (c2 == '"' || c2 == '\'' || c2 == '`') {
                    s2 = perl_string(str, c2, ++s1, n);
-               else
+                } else {
                    s2 = perl_var(str, s1, n);
+                }
                if (s2 > s1) {
                    umemcpy(perl_eos, str + s1, s2 - s1);
                    perl_eos_len = s2 - s1;
@@ -287,8 +292,16 @@
                continue;
            }
        keyword:
-           if (j - i == 6 && ustristart(str + i, "format", NULL))
+            if (j - i == 6 && ustristart(str + i, "format", NULL)) {
+                for (s1 = 0; s1 < i; s1++) {
+                    if (!qe_isspace(str[s1]))
+                        break;
+                }
+                if (s1 == i) {
+                    /* keyword is first on line */
                colstate |= IN_FORMAT;
+                }
+            }
            set_color(str + i, str + j, PERL_KEYWORD);
            i = j;
            continue;
@@ -319,6 +332,10 @@
     if (match_extension(p->filename, perl_mode_extensions))
        return 80;
     
+    if (p->buf[0] == '#' && p->buf[1] == '!' &&
+          memstr(p->buf, p->line_len, "/usr/bin/perl"))
+        return 80;
+
     return 0;
 }
 




reply via email to

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