qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs latex-mode.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs latex-mode.c
Date: Tue, 22 Apr 2014 08:08:49 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        14/04/22 08:08:48

Modified files:
        .              : latex-mode.c 

Log message:
        improve latex mode detection
        
        * detect latex syntax on sty files starting with a latex comment
        * detect latex syntax on files starting with a tex function with 
arguments

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/latex-mode.c?cvsroot=qemacs&r1=1.46&r2=1.47

Patches:
Index: latex-mode.c
===================================================================
RCS file: /sources/qemacs/qemacs/latex-mode.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- latex-mode.c        5 Apr 2014 15:49:15 -0000       1.46
+++ latex-mode.c        22 Apr 2014 08:08:48 -0000      1.47
@@ -125,18 +125,27 @@
     cp->colorize_state = state;
 }
 
-static int latex_mode_probe(ModeDef *mode, ModeProbeData *p)
+static int latex_mode_probe(ModeDef *mode, ModeProbeData *mp)
 {
+    const u8 *p = mp->buf;
+
     /* currently, only use the file extension */
     /* Halibut (by Simon Tatham) has a syntax similar to TeX and uses
      * .but extension */
-    if (match_extension(p->filename, mode->extensions))
+    if (match_extension(mp->filename, mode->extensions))
         return 80;
 
     /* Match TeX style sheets if they start with a comment */
-    if (match_extension(p->filename, "sty") && p->buf[0] == '%')
+    if (match_extension(mp->filename, "sty|cls") && *p == '%')
         return 80;
 
+    if (*p == '\\') {
+        /* match [\][a-z0-0_]+[{] */
+        while (qe_isalnum_(*++p))
+            continue;
+        if (*p == '{')
+            return 60;
+    }
     return 1;
 }
 



reply via email to

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