qemacs-commit
[Top][All Lists]
Advanced

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

[Qemacs-commit] qemacs clang.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs clang.c
Date: Mon, 10 Apr 2017 13:09:22 -0400 (EDT)

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        17/04/10 13:09:22

Modified files:
        .              : clang.c 

Log message:
        clang: improve auto-indentation
        - auto-indent multi-line comments to align initial stars
          such as this:
        
          /* This is a comment
           * with a second line.
           */
        
        and free form comment paragraphs this way:
        
          /* This is a comment
             with a second line.
           */

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.122&r2=1.123

Patches:
Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- clang.c     3 Apr 2017 08:33:57 -0000       1.122
+++ clang.c     10 Apr 2017 17:09:22 -0000      1.123
@@ -932,10 +932,23 @@
         if (qe_isblank(c))
             continue;
         /* if preprocess, no indent */
+        /* XXX: should indent macro definitions and align continuation marks */
         if (style == C_STYLE_PREPROCESS) {
             pos = 0;
             break;
         }
+        if (style == C_STYLE_COMMENT) {
+            if (c == '/') {
+                break;
+            }
+            if (c == '*') {
+                pos += 1;
+                break;
+            }
+            /* comment paragraph alignment should depend on previous line */
+            pos += 3;
+            break;
+        }
         if (qe_isalpha_(c)) {
             j = get_c_identifier(buf1, countof(buf1), buf + i, CLANG_C);
 
@@ -965,6 +978,10 @@
         }
         break;
     }
+    // if (i == len && state is IN_COMMENT) {
+    //     /* XXX: should indent comment paragraphs */
+    //     pos += 3;
+    // }
 
     /* the computed indent is in 'pos' */
     /* if on a blank line, reset indent to 0 unless point is on it */
@@ -2791,7 +2808,7 @@
 
     qe_register_mode(&c_mode, MODEF_SYNTAX);
     qe_register_cmd_table(c_commands, &c_mode);
-    for (p = ";:#&|"; *p; p++) {
+    for (p = ";:#&|*"; *p; p++) {
         qe_register_binding(*p, "c-electric-key", &c_mode);
     }
 



reply via email to

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