From 0e7d960b998e7c6dc781dc37cb703cdb32232a5f Mon Sep 17 00:00:00 2001 Message-Id: <0e7d960b998e7c6dc781dc37cb703cdb32232a5f.1716832589.git.mdw@distorted.org.uk> From: Mark Wooding Date: Tue, 3 Nov 2009 17:21:26 +0000 Subject: [PATCH] el/dot-emacs.el: Fix auto-fill magic for `//' comments in C-like modes. Organization: Straylight/Edgeware From: Mark Wooding 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 | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 15b156b..8d88807 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -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) -- [mdw]