chiark / gitweb /
el/dot-emacs.el: Fix auto-fill magic for `//' comments in C-like modes.
[profile] / el / dot-emacs.el
index 15b156bd22d670bdcce58c3c3f3de6342d9a4610..8d888079074e9f5bc61b14646bdd8d539f2f35c5 100644 (file)
@@ -845,6 +845,15 @@              (defun-open . (add 0 c-indent-one-line-block))
                  (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 @@ (defun mdw-fontify-c-and-c++ ()
   (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 @@ (defun mdw-fontify-apcalc ()
   (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 @@ (defun mdw-fontify-java ()
   (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 @@ (defun mdw-fontify-csharp ()
   (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)