emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 5ef4a76: * sm-c-mode.el (sm-c-font-lock-keywords): Match f


From: Stefan Monnier
Subject: [elpa] master 5ef4a76: * sm-c-mode.el (sm-c-font-lock-keywords): Match function defs.
Date: Sun, 15 Nov 2015 02:45:56 +0000

branch: master
commit 5ef4a76cd1064e95ba3a7db21bb3de6bd9cafb7b
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * sm-c-mode.el (sm-c-font-lock-keywords): Match function defs.
    
    * sm-c-mode-test.c: New file.
---
 packages/sm-c-mode/sm-c-mode-test.c |   50 +++++++++++++++++++++++++++++++++++
 packages/sm-c-mode/sm-c-mode.el     |   20 +++++++++++++-
 2 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/packages/sm-c-mode/sm-c-mode-test.c 
b/packages/sm-c-mode/sm-c-mode-test.c
new file mode 100644
index 0000000..3a1f1b6
--- /dev/null
+++ b/packages/sm-c-mode/sm-c-mode-test.c
@@ -0,0 +1,50 @@
+/* -*- sm-c -*- */
+
+#define toto /* bla
+                bla */ \
+ if (a) { \
+   f \
+ }
+
+DEFUN ()
+
+int main (void)
+{
+  if (a)
+    do
+      if (b)
+        if (c)
+          printf ("hello\n");
+        else
+          printf ("there\n");
+      else
+        printf ("elsewhere\n");        
+    while (6);
+  else if (b)
+    printf ("wow\n");
+  else
+    if (c)
+      printf ("weee\n");
+    else
+      printf ("wop\n");
+    
+  switch (a)
+    {
+    case 1:
+      {
+        if (a)
+          {
+            y = 5;
+    case 2:
+            x = 3;
+          }
+      }
+    }
+}
+
+static struct myownspecialstruct
+  *testfunction
+  (args)
+{
+  return NULL;
+}
diff --git a/packages/sm-c-mode/sm-c-mode.el b/packages/sm-c-mode/sm-c-mode.el
index f582677..3771169 100644
--- a/packages/sm-c-mode/sm-c-mode.el
+++ b/packages/sm-c-mode/sm-c-mode.el
@@ -622,7 +622,25 @@ Typically 2 for GNU style and `tab-width' for Linux style."
                          ;; "case" already handled above.
                          (delete "case" kws)))
                 "\\_>"))
-     (0 font-lock-keyword-face))))
+     (0 font-lock-keyword-face))
+    (,(let* ((spc0 "\\(?:\n?[ \t]\\|/\\*.*?\\*/\\)*")
+             (spc1 (concat "\n?[ \t]" spc0))
+             (id "\\(?:\\sw\\|\\s_\\)+"))
+        (cl-flet ((repeat (repetition &rest res)
+                          (concat "\\(?:" (apply #'concat res) "\\)"
+                                  (pcase repetition
+                                    ((pred symbolp) (symbol-name repetition))
+                                    (1 "")))))
+          (concat
+           "^"
+           (repeat '* "\\*" spc0)
+           (repeat '* id (repeat 1 spc1 "\\|" spc0 "\\*" spc0))
+           "\\(" id "\\)[ \t\n]*(")))
+     (1
+      (prog1 font-lock-function-name-face
+        (if (< (match-beginning 0) (line-beginning-position))
+            (put-text-property (match-beginning 0) (match-end 0)
+                               'font-lock-multiline t)))))))
 
 
 ;;;###autoload



reply via email to

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