el/dot-emacs.el: Fix auto-fill magic for `//' comments in C-like modes.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 3 Nov 2009 17:21:26 +0000 (17:21 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 3 Nov 2009 17:21:26 +0000 (17:21 +0000)
Factor out the hairy regexp into a separate variable, and fix it to
recognize a `//' comment properly.

Also remove the override forcing `/* ... */' comments in Java and C#.

el/dot-emacs.el

index 15b156b..8d88807 100644 (file)
@@ -845,6 +845,15 @@ doesn't match any of the regular expressions in
                  (statement-case-intro . +)))
               t))
 
+(defvar mdw-c-comment-fill-prefix
+  `((,(concat "\\([ \t]*/?\\)"
+             "\\(\*\\|//]\\)"
+             "\\([ \t]*\\)"
+             "\\([A-Za-z]+:[ \t]*\\)?"
+             mdw-hanging-indents)
+     (pad . 1) (match . 2) (pad . 3) (pad . 4) (pad . 5)))
+  "Fill prefix matching C comments (both kinds).")
+
 (defun mdw-fontify-c-and-c++ ()
 
   ;; Fiddle with some syntax codes.
@@ -857,12 +866,7 @@ doesn't match any of the regular expressions in
   (setq c-hanging-comment-ender-p nil)
   (setq c-backslash-column 72)
   (setq c-label-minimum-indentation 0)
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1031,12 +1035,7 @@ doesn't match any of the regular expressions in
   (setq c-backslash-column 72)
   (setq comment-start "/* ")
   (setq comment-end " */")
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1090,14 +1089,7 @@ doesn't match any of the regular expressions in
   (mdw-java-style)
   (setq c-hanging-comment-ender-p nil)
   (setq c-backslash-column 72)
-  (setq comment-start "/* ")
-  (setq comment-end " */")
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)
@@ -1159,14 +1151,7 @@ doesn't match any of the regular expressions in
   (mdw-csharp-style)
   (setq c-hanging-comment-ender-p nil)
   (setq c-backslash-column 72)
-  (setq comment-start "/* ")
-  (setq comment-end " */")
-  (setq mdw-fill-prefix
-       `((,(concat "\\([ \t]*/?\\)"
-                   "\\([\*/][ \t]*\\)"
-                   "\\([A-Za-z]+:[ \t]*\\)?"
-                   mdw-hanging-indents)
-          (pad . 1) (match . 2) (pad . 3) (pad . 4))))
+  (setq mdw-fill-prefix mdw-c-comment-fill-prefix)
 
   ;; Now define things to be fontified.
   (make-local-variable 'font-lock-keywords)