commit/XEmacs: kehoea: Move #'char-width to C,
 implement it in terms of ichar_columns().
                
            
            
                8 years, 4 months
            
            
                
                    
                    
                    
                    
                    Bitbucket
                
 
                
                    
                        
                            1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/97140cfdeca7/
Changeset:   97140cfdeca7
User:        kehoea
Date:        2017-06-28 21:41:35+00:00
Summary:     Move #'char-width to C, implement it in terms of ichar_columns().
src/ChangeLog addition:
2017-06-28  Aidan Kehoe  <kehoea(a)parhasard.net>
	* text.c (Fchar_width):
	* text.c (syms_of_text):
	Move #'char-width to C, to allow it to be implemented in terms of
	ichar_columns(), since with unicode-internal (charset-width
	(char-charset X)) can now error.
lisp/ChangeLog addition:
2017-06-28  Aidan Kehoe  <kehoea(a)parhasard.net>
	* subr.el (char-width): Move this to C, necessary as part of the
	unicode-internal support.
Affected #:  4 files
diff -r b803128e420963ce405b3ac51c7f9a80183c496b -r 97140cfdeca785747a13192343cf357ea21a3dc1 lisp/ChangeLog
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-28  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* subr.el (char-width): Move this to C, necessary as part of the
+	unicode-internal support.
+
 2017-05-30  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* about.el (about-xemacs):
diff -r b803128e420963ce405b3ac51c7f9a80183c496b -r 97140cfdeca785747a13192343cf357ea21a3dc1 lisp/subr.el
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1076,10 +1076,6 @@
 simply returns the length of the string."
   (reduce #'+ (the string string) :initial-value 0 :key #'char-width))
 
-(defun char-width (character)
-  "Return number of columns a CHARACTER occupies when displayed."
-  (charset-width (char-charset character)))
-
 ;; The following several functions are useful in GNU Emacs 20 because
 ;; of the multibyte "characters" the internal representation of which
 ;; leaks into Lisp.  In XEmacs/Mule they are trivial and unnecessary.
diff -r b803128e420963ce405b3ac51c7f9a80183c496b -r 97140cfdeca785747a13192343cf357ea21a3dc1 src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2017-06-28  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* text.c (Fchar_width):
+	* text.c (syms_of_text):
+	Move #'char-width to C, to allow it to be implemented in terms of
+	ichar_columns(), since with unicode-internal (charset-width
+	(char-charset X)) can now error.
+
 2017-05-30  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* emacs.c (vars_of_emacs):
diff -r b803128e420963ce405b3ac51c7f9a80183c496b -r 97140cfdeca785747a13192343cf357ea21a3dc1 src/text.c
--- a/src/text.c
+++ b/src/text.c
@@ -5950,6 +5950,17 @@
     return list2 (XCHARSET_NAME (charset), make_fixnum (c1));
 }
 
+DEFUN ("char-width", Fchar_width, 1, 1, 0, /*
+Return number of columns a CHARACTER occupies when displayed.
+*/
+       (character))
+{
+  CHECK_CHAR_COERCE_INT (character);
+
+  /* #### Consider having this take a graphical context--a buffer or frame or
+     #### whatever. Ditto with #'string-width.  */
+  return make_fixnum (ichar_columns (XCHAR (character)));
+}
 
 /************************************************************************/
 /*                     composite character functions                    */
@@ -6057,6 +6068,7 @@
   DEFSUBR (Fchar_charset);
   DEFSUBR (Fchar_octet);
   DEFSUBR (Fsplit_char);
+  DEFSUBR (Fchar_width);
 
   /* Qfail, Qsubstitute, Qsucceed in general.c */
   DEFSYMBOL (Qsubstitute_negated); /* #### what's this used for? */
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
                        
                     
                    
                 
             
         
        
        
            
        
        
            
                
                    
                    
                    commit/cc-mode: acm: Ensure C++ initializer lists don't get fontified.
                
            
            
                8 years, 4 months
            
            
                
                    
                    
                    
                    
                    Bitbucket
                
 
                
                    
                        
                            1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/2043b63c687f/
Changeset:   2043b63c687f
User:        acm
Date:        2017-06-16 11:12:05+00:00
Summary:     Ensure C++ initializer lists don't get fontified.
* cc-cmds.el (c-block-comment-flag): Move declaration to solve compiler
warning.
* cc-fonts.el (c-get-fontification-context): Add an extra clause to handle C++
member initialization lists.
(c-font-lock-single-decl): New function, extracted from
c-font-lock-declarations.
(c-font-lock-declarations): Call c-font-lock-single-decl in place of inline
code.
(c-font-lock-cut-off-declarators): Make more rigorous by calling
c-get-fontification-context, c-forward-decl-or-cast-1, and
c-font-lock-single-decl in place of rather approximate code.
Affected #:  2 files
diff -r 5f3321ca1e03b410108f8014bcd4fd098b93e500 -r 2043b63c687f51363c5f7f3cec974923a29fe4f8 cc-cmds.el
--- a/cc-cmds.el
+++ b/cc-cmds.el
@@ -256,6 +256,11 @@
 
 
 ;; Minor mode functions.
+;; `c-block-comment-flag' gets initialized to the current mode's default in
+;; c-basic-common-init.
+(defvar c-block-comment-flag nil)
+(make-variable-buffer-local 'c-block-comment-flag)
+
 (defun c-update-modeline ()
   (let ((fmt (format "/%s%s%s%s%s"
 		     (if c-block-comment-flag "*" "/")
@@ -359,11 +364,6 @@
   (c-update-modeline)
   (c-keep-region-active))
 
-;; `c-block-comment-flag' gets initialized to the current mode's default in
-;; c-basic-common-init.
-(defvar c-block-comment-flag nil)
-(make-variable-buffer-local 'c-block-comment-flag)
-
 (defun c-toggle-comment-style (&optional arg)
   "Toggle the comment style between block and line comments.
 Optional numeric ARG, if supplied, switches to block comment
diff -r 5f3321ca1e03b410108f8014bcd4fd098b93e500 -r 2043b63c687f51363c5f7f3cec974923a29fe4f8 cc-fonts.el
--- a/cc-fonts.el
+++ b/cc-fonts.el
@@ -1213,6 +1213,12 @@
 		  (and (zerop (c-backward-token-2 2))
 		       (looking-at c-arithmetic-op-regexp))))
 	   (cons nil nil))
+	  ;; In a C++ member initialization list.
+	  ((and (eq (char-before match-pos) ?,)
+	  	(c-major-mode-is 'c++-mode)
+	  	(save-excursion (c-back-over-member-initializers)))
+	   (c-put-char-property (1- match-pos) 'c-type 'c-not-decl)
+	   (cons 'not-decl nil))
 	  ;; At start of a declaration inside a declaration paren.
 	  ((save-excursion
 	     (and (memq (char-before match-pos) '(?\( ?\,))
@@ -1234,6 +1240,85 @@
 	   (cons 'decl nil))
 	  (t (cons 'arglist t)))))
 
+(defun c-font-lock-single-decl (limit decl-or-cast match-pos context toplev)
+  ;; Try to fontify a single declaration, together with all its declarators.
+  ;; Return nil if we're successful, non-nil if we fail.  POINT should be
+  ;; positioned at the start of the putative declaration before calling.
+  ;; POINT is left undefined by this function.
+  ;;
+  ;; LIMIT sets a maximum position we'll fontify out to.
+  ;; DECL-OR-CAST has the form of a result from `c-forward-decl-or-cast-1',
+  ;;   and must indicate a declaration (i.e. not be nil or 'cast).
+  ;; MATCH-POS is the position after the last symbol before the decl.
+  ;; CONTEXT is the context of the current decl., as determined by
+  ;;   c-get-fontification-context.
+  ;; TOPLEV is non-nil if the decl. is at the top level (i.e. outside any
+  ;;   braces, or directly inside a class, namespace, etc.)
+
+  ;; Do we have an expression as the second or third clause of
+  ;; a "for" paren expression?
+  (if (save-excursion
+	(and
+	 (car (cddr decl-or-cast))	; maybe-expression flag.
+	 (c-go-up-list-backward)
+	 (eq (char-after) ?\()
+	 (progn (c-backward-syntactic-ws)
+		(c-simple-skip-symbol-backward))
+	 (looking-at c-paren-stmt-key)
+	 (progn (goto-char match-pos)
+		(while (and (eq (char-before) ?\))
+			    (c-go-list-backward))
+		  (c-backward-syntactic-ws))
+		(eq (char-before) ?\;))))
+      ;; We've got an expression in "for" parens.  Remove the
+      ;; "type" that would spuriously get fontified.
+      (let ((elt (and (consp c-record-type-identifiers)
+		      (assq (cadr (cddr decl-or-cast))
+			    c-record-type-identifiers))))
+	(when elt
+	  (setq c-record-type-identifiers
+		(c-delq-from-dotted-list
+		 elt c-record-type-identifiers)))
+	t)
+    ;; Back up to the type to fontify the declarator(s).
+    (goto-char (car decl-or-cast))
+
+    (let ((decl-list
+	   (if (not (memq context '(nil top)))
+	       ;; Should normally not fontify a list of
+	       ;; declarators inside an arglist, but the first
+	       ;; argument in the ';' separated list of a "for"
+	       ;; statement is an exception.
+	       (when (eq (char-before match-pos) ?\()
+		 (save-excursion
+		   (goto-char (1- match-pos))
+		   (c-backward-syntactic-ws)
+		   (and (c-simple-skip-symbol-backward)
+			(looking-at c-paren-stmt-key))))
+	     t)))
+
+      ;; Fix the `c-decl-id-start' or `c-decl-type-start' property
+      ;; before the first declarator if it's a list.
+      ;; `c-font-lock-declarators' handles the rest.
+      (when decl-list
+	(save-excursion
+	  (c-backward-syntactic-ws)
+	  (unless (bobp)
+	    (c-put-char-property (1- (point)) 'c-type
+				 (if (cadr decl-or-cast)
+				     'c-decl-type-start
+				   'c-decl-id-start)))))
+
+      (c-font-lock-declarators
+       (min limit (point-max)) decl-list
+       (cadr decl-or-cast) (not toplev)))
+
+    ;; A declaration has been successfully identified, so do all the
+    ;; fontification of types and refs that've been recorded.
+    (c-fontify-recorded-types-and-refs)
+    nil))
+
+
 (defun c-font-lock-declarations (limit)
   ;; Fontify all the declarations, casts and labels from the point to LIMIT.
   ;; Assumes that strings and comments have been fontified already.
@@ -1435,70 +1520,9 @@
 		      (setq max-type-decl-end-before-token (point)))
 		  (when (> (point) max-type-decl-end)
 		    (setq max-type-decl-end (point))))
-
-		;; Do we have an expression as the second or third clause of
-		;; a "for" paren expression?
-		(if (save-excursion
-		      (and
-		       (car (cddr decl-or-cast)) ; maybe-expression flag.
-		       (goto-char start-pos)
-		       (c-go-up-list-backward)
-		       (eq (char-after) ?\()
-		       (progn (c-backward-syntactic-ws)
-			      (c-simple-skip-symbol-backward))
-		       (looking-at c-paren-stmt-key)
-		       (progn (goto-char match-pos)
-			      (while (and (eq (char-before) ?\))
-					  (c-go-list-backward))
-				(c-backward-syntactic-ws))
-			      (eq (char-before) ?\;))))
-		    ;; We've got an expression in "for" parens.  Remove the
-		    ;; "type" that would spuriously get fontified.
-		    (let ((elt (and (consp c-record-type-identifiers)
-				    (assq (cadr (cddr decl-or-cast))
-					  c-record-type-identifiers))))
-		      (when elt
-			(setq c-record-type-identifiers
-			      (c-delq-from-dotted-list
-			       elt c-record-type-identifiers)))
-		      t)
-		  ;; Back up to the type to fontify the declarator(s).
-		  (goto-char (car decl-or-cast))
-
-		  (let ((decl-list
-			 (if (not (memq context '(nil top)))
-			     ;; Should normally not fontify a list of
-			     ;; declarators inside an arglist, but the first
-			     ;; argument in the ';' separated list of a "for"
-			     ;; statement is an exception.
-			     (when (eq (char-before match-pos) ?\()
-			       (save-excursion
-				 (goto-char (1- match-pos))
-				 (c-backward-syntactic-ws)
-				 (and (c-simple-skip-symbol-backward)
-				      (looking-at c-paren-stmt-key))))
-			   t)))
-
-		    ;; Fix the `c-decl-id-start' or `c-decl-type-start' property
-		    ;; before the first declarator if it's a list.
-		    ;; `c-font-lock-declarators' handles the rest.
-		    (when decl-list
-		      (save-excursion
-			(c-backward-syntactic-ws)
-			(unless (bobp)
-			  (c-put-char-property (1- (point)) 'c-type
-					       (if (cadr decl-or-cast)
-						   'c-decl-type-start
-						 'c-decl-id-start)))))
-
-		    (c-font-lock-declarators
-		     (min limit (point-max)) decl-list
-		     (cadr decl-or-cast) (not toplev)))
-
-		  ;; A declaration has been successfully identified, so do all the
-		  ;; fontification of types and refs that've been recorded.
-		  (c-fontify-recorded-types-and-refs)
-		  nil))
+		(goto-char start-pos)
+		(c-font-lock-single-decl limit decl-or-cast match-pos
+					 context toplev))
 
 	       (t t))))
 
@@ -1583,8 +1607,8 @@
   ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
   ;; fontification".
   (let ((decl-search-lim (c-determine-limit 1000))
-	paren-state bod-res is-typedef encl-pos
-	(here (point))
+	paren-state encl-pos token-end context decl-or-cast
+	start-pos top-level c-restricted-<>-arglists
 	c-recognize-knr-p)		; Strictly speaking, bogus, but it
 					; speeds up lisp.h tremendously.
     (save-excursion
@@ -1598,22 +1622,27 @@
 	  (c-syntactic-skip-backward "^;{}" decl-search-lim t))
 	(when (or (bobp)
 		  (memq (char-before) '(?\; ?{ ?})))
+	  (setq token-end (point))
 	  (c-forward-syntactic-ws)
 	  ;; We're now putatively at the declaration.
+	  (setq start-pos (point))
 	  (setq paren-state (c-parse-state))
 	  ;; At top level or inside a "{"?
 	  (if (or (not (setq encl-pos
 			     (c-most-enclosing-brace paren-state)))
 		  (eq (char-after encl-pos) ?\{))
 	      (progn
-		(when (looking-at c-typedef-key) ; "typedef"
-		  (setq is-typedef t)
-		  (goto-char (match-end 0))
-		  (c-forward-syntactic-ws))
-		;; At a real declaration?
-		(if (memq (c-forward-type t) '(t known found decltype))
-		    (c-font-lock-declarators
-		     limit t is-typedef (not (c-bs-at-toplevel-p here)))))))))
+		(setq top-level (c-at-toplevel-p))
+		(let ((got-context (c-get-fontification-context
+				    token-end nil top-level)))
+		  (setq context (car got-context)
+			c-restricted-<>-arglists (cdr got-context)))
+		(setq decl-or-cast
+		      (c-forward-decl-or-cast-1 token-end context nil))
+		(when (consp decl-or-cast)
+		  (goto-char start-pos)
+		  (c-font-lock-single-decl limit decl-or-cast token-end
+					   context top-level)))))))
     nil))
 
 (defun c-font-lock-enclosing-decls (limit)
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
                        
                     
                    
                 
             
         
        
        
            
        
        
            
                
                    
                    
                    commit/cc-mode: acm: Fix hang in CC Mode when ":" is typed after
 identifier at EOB.
                
            
            
                8 years, 4 months
            
            
                
                    
                    
                    
                    
                    Bitbucket
                
 
                
                    
                        
                            1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/5f3321ca1e03/
Changeset:   5f3321ca1e03
User:        acm
Date:        2017-06-16 10:26:35+00:00
Summary:     Fix hang in CC Mode when ":" is typed after identifier at EOB.
* cc-engine.el (c-forward-declarator): Fix coding error confusing ":" and EOB.
Affected #:  1 file
diff -r e72779a90455e896d708d10f5e549653e0f557dd -r 5f3321ca1e03b410108f8014bcd4fd098b93e500 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -8107,7 +8107,7 @@
 			  (and
 			   (setq found
 				 (c-syntactic-re-search-forward
-				  "[;:,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)"
+				  "[;:,]\\|\\s)\\|\\(=\\|\\s(\\)"
 				  limit t t))
 			   (eq (char-before) ?:)
 			   (if (looking-at c-:-op-cont-regexp)
@@ -8125,8 +8125,8 @@
 		    (eq (char-before) ?\[)
 		    (c-go-up-list-forward))
 	     (setq brackets-after-id t))
-	   (backward-char)
-	   found))
+	   (when found (backward-char))
+	   t))
 	(list id-start id-end brackets-after-id (match-beginning 1) decorated)
 
       (goto-char here)
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
                        
                     
                    
                 
             
         
        
        
            
        
        
            
                
                    
                    
                    commit/cc-mode: acm: Create a toggle between block and line comments
 in CC Mode.
                
            
            
                8 years, 4 months
            
            
                
                    
                    
                    
                    
                    Bitbucket
                
 
                
                    
                        
                            1 new commit in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/e72779a90455/
Changeset:   e72779a90455
User:        acm
Date:        2017-06-15 19:35:17+00:00
Summary:     Create a toggle between block and line comments in CC Mode.
Also (unrelated change) initialize the modes' keymaps at each loading.
* cc-cmds.el (c-update-modeline): amend for the new information on the
modeline.
(c-block-comment-flag): New variable.
(c-toggle-comment-style): New function.
* cc-langs.el (c-block-comment-starter, c-line-comment-starter): Make them
c-lang-defvars.
(c-block-comment-is-default): New c-lang-defvar.
(comment-start, comment-end): Make the default values dependent on
c-block-comment-is-default.
* cc-mode.el (c-mode-base-map): Define C-c C-k in this map.
(c-basic-common-init): Initialize c-block-comment-flag.
(c-mode-map, c++-mode-map, objc-mode-map, java-mode-map, idl-mode-map)
(pike-mode-map, awk-mode-map): Make entries in these key maps each time the
mode is loaded rather than just once per Emacs session.
* cc-mode.texi (Comment Commands): Introduce the notion of comment style.
(Minor Modes): Define comment style.  Describe how comment style influences
the information displayed on the modeline.  Document c-toggle-comment-style.
(FAQ): Add a question about toggling the comment style.
Affected #:  4 files
diff -r 8e6823f66785d1de8e3724962e8e23273be7cd42 -r e72779a90455e896d708d10f5e549653e0f557dd cc-cmds.el
--- a/cc-cmds.el
+++ b/cc-cmds.el
@@ -257,7 +257,8 @@
 
 ;; Minor mode functions.
 (defun c-update-modeline ()
-  (let ((fmt (format "/%s%s%s%s"
+  (let ((fmt (format "/%s%s%s%s%s"
+		     (if c-block-comment-flag "*" "/")
 		     (if c-electric-flag "l" "")
 		     (if (and c-electric-flag c-auto-newline)
 			 "a" "")
@@ -271,9 +272,6 @@
 	(bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name)
 			    (substring mode-name (match-beginning 1) (match-end 1))
 			  mode-name)))
-;;     (setq c-submode-indicators
-;;	  (if (> (length fmt) 1)
-;;	      fmt))
     (setq mode-name
 	  (if (> (length fmt) 1)
 	      (concat bare-mode-name fmt)
@@ -361,6 +359,37 @@
   (c-update-modeline)
   (c-keep-region-active))
 
+;; `c-block-comment-flag' gets initialized to the current mode's default in
+;; c-basic-common-init.
+(defvar c-block-comment-flag nil)
+(make-variable-buffer-local 'c-block-comment-flag)
+
+(defun c-toggle-comment-style (&optional arg)
+  "Toggle the comment style between block and line comments.
+Optional numeric ARG, if supplied, switches to block comment
+style when positive, to line comment style when negative, and
+just toggles it when zero or left out.
+
+This action does nothing when the mode only has one comment style."
+  (interactive "P")
+  (setq c-block-comment-flag
+	(cond
+	 ((and c-line-comment-starter c-block-comment-starter)
+	  (c-calculate-state arg c-block-comment-flag))
+	 (c-line-comment-starter nil)
+	 (t t)))
+  (setq comment-start
+	(concat (if c-block-comment-flag
+		    c-block-comment-starter
+		  c-line-comment-starter)
+		" "))
+  (setq comment-end
+	(if c-block-comment-flag
+	    (concat " " c-block-comment-ender)
+	  ""))
+  (c-update-modeline)
+  (c-keep-region-active))
+
 
 ;; Electric keys
 
diff -r 8e6823f66785d1de8e3724962e8e23273be7cd42 -r e72779a90455e896d708d10f5e549653e0f557dd cc-langs.el
--- a/cc-langs.el
+++ b/cc-langs.el
@@ -1431,6 +1431,7 @@
 properly."
   t    "/*"
   awk  nil)
+(c-lang-defvar c-block-comment-starter (c-lang-const c-block-comment-starter))
 
 (c-lang-defconst c-block-comment-ender
   "String that ends block comments, or nil if such don't exist.
@@ -1440,6 +1441,7 @@
 properly."
   t    "*/"
   awk  nil)
+(c-lang-defvar c-block-comment-ender (c-lang-const c-block-comment-ender))
 
 (c-lang-defconst c-block-comment-ender-regexp
   ;; Regexp which matches the end of a block comment (if such exists in the
@@ -1497,27 +1499,30 @@
 (c-lang-defvar c-doc-comment-start-regexp
   (c-lang-const c-doc-comment-start-regexp))
 
+(c-lang-defconst c-block-comment-is-default
+  "Non-nil when the default comment style is block comment."
+  ;; Note to maintainers of derived modes: You are responsible for ensuring
+  ;; the pertinent `c-block-comment-{starter,ender}' or
+  ;; `c-line-comment-{starter,ender}' are non-nil.
+  t nil
+  c t)
+(c-lang-defvar c-block-comment-is-default
+  (c-lang-const c-block-comment-is-default))
+
 (c-lang-defconst comment-start
   "String that starts comments inserted with M-; etc.
 `comment-start' is initialized from this."
-  ;; Default: Prefer line comments to block comments, and pad with a space.
-  t (concat (or (c-lang-const c-line-comment-starter)
-		(c-lang-const c-block-comment-starter))
-	    " ")
-  ;; In C we still default to the block comment style since line
-  ;; comments aren't entirely portable.
-  c "/* ")
+  t (concat
+     (if (c-lang-const c-block-comment-is-default)
+	 (c-lang-const c-block-comment-starter)
+       (c-lang-const c-line-comment-starter))
+     " "))
 (c-lang-setvar comment-start (c-lang-const comment-start))
 
 (c-lang-defconst comment-end
   "String that ends comments inserted with M-; etc.
 `comment-end' is initialized from this."
-  ;; Default: Use block comment style if comment-start uses block
-  ;; comments, and pad with a space in that case.
-  t (if (string-match (concat "\\`\\("
-			      (c-lang-const c-block-comment-start-regexp)
-			      "\\)")
-		      (c-lang-const comment-start))
+  t (if (c-lang-const c-block-comment-is-default)
 	(concat " " (c-lang-const c-block-comment-ender))
       ""))
 (c-lang-setvar comment-end (c-lang-const comment-end))
diff -r 8e6823f66785d1de8e3724962e8e23273be7cd42 -r e72779a90455e896d708d10f5e549653e0f557dd cc-mode.el
--- a/cc-mode.el
+++ b/cc-mode.el
@@ -381,7 +381,7 @@
   ;;(define-key c-mode-base-map "\C-c\C-v"  'c-version)
   ;; (define-key c-mode-base-map "\C-c\C-y"  'c-toggle-hungry-state)  Commented out by ACM, 2005-11-22.
   (define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode)
-  )
+  (define-key c-mode-base-map "\C-c\C-k" 'c-toggle-comment-style))
 
 ;; We don't require the outline package, but we configure it a bit anyway.
 (cc-bytecomp-defvar outline-level)
@@ -535,7 +535,7 @@
 	(setq yank-handled-properties (remq yank-cat-handler
 					    yank-handled-properties)))))
 
-  ;; For the benefit of adaptive file, which otherwise mis-fills.
+  ;; For the benefit of adaptive fill, which otherwise mis-fills.
   (setq fill-paragraph-handle-comment nil)
 
   ;; Install `c-fill-paragraph' on `fill-paragraph-function' so that a
@@ -615,6 +615,8 @@
   ;; setup the comment indent variable in a Emacs version portable way
   (make-local-variable 'comment-indent-function)
   (setq comment-indent-function 'c-comment-indent)
+  ;; What sort of comments are default for M-;?
+  (setq c-block-comment-flag c-block-comment-is-default)
 
 ;;   ;; Put submode indicators onto minor-mode-alist, but only once.
 ;;   (or (assq 'c-submode-indicators minor-mode-alist)
@@ -1579,12 +1581,9 @@
 
 (defvar c-mode-map ()
   "Keymap used in c-mode buffers.")
-(if c-mode-map
-    nil
-  (setq c-mode-map (c-make-inherited-keymap))
+(setq c-mode-map (c-make-inherited-keymap))
   ;; add bindings which are only useful for C
-  (define-key c-mode-map "\C-c\C-e"  'c-macro-expand)
-  )
+(define-key c-mode-map "\C-c\C-e"  'c-macro-expand)
 
 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
 		  (cons "C" (c-lang-const c-mode-menu c)))
@@ -1665,14 +1664,12 @@
 
 (defvar c++-mode-map ()
   "Keymap used in c++-mode buffers.")
-(if c++-mode-map
-    nil
-  (setq c++-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for C++
-  (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
-  (define-key c++-mode-map "\C-c:"    'c-scope-operator)
-  (define-key c++-mode-map "<"        'c-electric-lt-gt)
-  (define-key c++-mode-map ">"        'c-electric-lt-gt))
+(setq c++-mode-map (c-make-inherited-keymap))
+;; add bindings which are only useful for C++
+(define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
+(define-key c++-mode-map "\C-c:"    'c-scope-operator)
+(define-key c++-mode-map "<"        'c-electric-lt-gt)
+(define-key c++-mode-map ">"        'c-electric-lt-gt)
 
 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
 		  (cons "C++" (c-lang-const c-mode-menu c++)))
@@ -1729,11 +1726,9 @@
 
 (defvar objc-mode-map ()
   "Keymap used in objc-mode buffers.")
-(if objc-mode-map
-    nil
-  (setq objc-mode-map (c-make-inherited-keymap))
+(setq objc-mode-map (c-make-inherited-keymap))
   ;; add bindings which are only useful for Objective-C
-  (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))
+(define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)
 
 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
 		  (cons "ObjC" (c-lang-const c-mode-menu objc)))
@@ -1794,11 +1789,8 @@
 
 (defvar java-mode-map ()
   "Keymap used in java-mode buffers.")
-(if java-mode-map
-    nil
-  (setq java-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for Java
-  )
+(setq java-mode-map (c-make-inherited-keymap))
+;; add bindings which are only useful for Java
 
 ;; Regexp trying to describe the beginning of a Java top-level
 ;; definition.  This is not used by CC Mode, nor is it maintained
@@ -1860,11 +1852,8 @@
 
 (defvar idl-mode-map ()
   "Keymap used in idl-mode buffers.")
-(if idl-mode-map
-    nil
-  (setq idl-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for IDL
-  )
+(setq idl-mode-map (c-make-inherited-keymap))
+;; add bindings which are only useful for IDL
 
 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
 		  (cons "IDL" (c-lang-const c-mode-menu idl)))
@@ -1920,11 +1909,9 @@
 
 (defvar pike-mode-map ()
   "Keymap used in pike-mode buffers.")
-(if pike-mode-map
-    nil
-  (setq pike-mode-map (c-make-inherited-keymap))
-  ;; additional bindings
-  (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))
+(setq pike-mode-map (c-make-inherited-keymap))
+;; additional bindings
+(define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)
 
 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
 		  (cons "Pike" (c-lang-const c-mode-menu pike)))
@@ -1985,20 +1972,18 @@
 
 (defvar awk-mode-map ()
   "Keymap used in awk-mode buffers.")
-(if awk-mode-map
-    nil
-  (setq awk-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for awk.
-  (define-key awk-mode-map "#" 'self-insert-command)
-  (define-key awk-mode-map "/" 'self-insert-command)
-  (define-key awk-mode-map "*" 'self-insert-command)
-  (define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
-  (define-key awk-mode-map "\C-c\C-p" 'undefined)
-  (define-key awk-mode-map "\C-c\C-u" 'undefined)
-  (define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
-  (define-key awk-mode-map "\M-e" 'c-end-of-statement) ; 2003/10/7
-  (define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun)
-  (define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun))
+(setq awk-mode-map (c-make-inherited-keymap))
+;; add bindings which are only useful for awk.
+(define-key awk-mode-map "#" 'self-insert-command)
+(define-key awk-mode-map "/" 'self-insert-command)
+(define-key awk-mode-map "*" 'self-insert-command)
+(define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
+(define-key awk-mode-map "\C-c\C-p" 'undefined)
+(define-key awk-mode-map "\C-c\C-u" 'undefined)
+(define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
+(define-key awk-mode-map "\M-e" 'c-end-of-statement) ; 2003/10/7
+(define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun)
+(define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun)
 
 (easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
 		  (cons "AWK" (c-lang-const c-mode-menu awk)))
diff -r 8e6823f66785d1de8e3724962e8e23273be7cd42 -r e72779a90455e896d708d10f5e549653e0f557dd cc-mode.texi
--- a/cc-mode.texi
+++ b/cc-mode.texi
@@ -827,6 +827,10 @@
 @cindex comments (insertion of)
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
+When the commands in this section add comment delimiters, they use
+either line comments or block comments depending on the setting of the
+comment style (@pxref{Minor Modes}).
+
 @table @asis
 @item @kbd{C-c C-c} (@code{comment-region})
 @kindex C-c C-c
@@ -1148,6 +1152,9 @@
 find useful while writing new code or editing old code:
 
 @table @asis
+@item comment style
+This specifies whether comment commands (such as @kbd{M-;}) insert
+block comments or line comments.
 @item electric mode
 When this is enabled, certain visible characters cause reformatting as
 they are typed.  This is normally helpful, but can be a nuisance when
@@ -1183,20 +1190,32 @@
 You can toggle each of these minor modes on and off, and you can
 configure @ccmode{} so that it starts up with your favorite
 combination of them (@pxref{Sample .emacs File}).  By default, when
-you initialize a buffer, electric mode and syntactic-indentation mode
-are enabled but the other two modes are disabled.
-
-@ccmode{} displays the current state of the first four of these minor
-modes on the mode line by appending letters to the major mode's name,
-one letter for each enabled minor mode - @samp{l} for electric mode,
-@samp{a} for auto-newline mode, @samp{h} for hungry delete mode, and
-@samp{w} for subword mode.  If all these modes were enabled, you'd see
-@samp{C/lahw}@footnote{The @samp{C} would be replaced with the name of
-the language in question for the other languages @ccmode{} supports.}.
+you initialize a buffer, the comment style is set to the default for
+the major mode, electric mode and syntactic-indentation mode are
+enabled, but the other two modes are disabled.
+
+@ccmode{} displays the current state of the first five of these minor
+modes on the mode line by appending characters to the major mode's
+name: @samp{/} or @samp{*} to indicate the comment style (respectively
+line or block), and one letter for each of the other minor modes which
+is enabled - @samp{l} for electric mode, @samp{a} for auto-newline
+mode, @samp{h} for hungry delete mode, and @samp{w} for subword mode.
+If the comment style was block and all the other modes were enabled,
+you'd see @samp{C/*lahw}@footnote{The @samp{C} would be replaced with
+the name of the language in question for the other languages @ccmode{}
+supports.}.
 
 Here are the commands to toggle these modes:
 
 @table @asis
+@item @kbd{C-c C-k} (@code{c-toggle-comment-style})
+@kindex C-c C-k
+@findex c-toggle-comment-style
+@findex toggle-comment-style (c-)
+Toggle the comment style between line style and block style.  In modes
+(such as AWK Mode) which only have one of these styles, this function
+does nothing.
+
 @item @kbd{C-c C-l} (@code{c-toggle-electric-state})
 @kindex C-c C-l
 @findex c-toggle-electric-state
@@ -1234,10 +1253,12 @@
 @end table
 
 Common to all the toggle functions above is that if they are called
-programmatically, they take an optional numerical argument.  A
-positive value will turn on the minor mode (or both of them in the
-case of @code{c-toggle-auto-hungry-state}) and a negative value will
-turn it (or them) off.
+programmatically, they take an optional numerical argument.  For
+@code{c-toggle-comment style}, a positive value will select block
+comments, a negative value will select line comments.  For the other
+functions, a positive value will turn on the minor mode (or both of
+them in the case of @code{c-toggle-auto-hungry-state}) and a negative
+value will turn it (or them) off.
 
 
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -7240,6 +7261,22 @@
 this to be the default behavior, don't lobby us, lobby RMS!  @t{:-)}
 
 @item
+@emph{How do I get block comments in my C++ files?}
+
+Interactively, change the comment style with @kbd{C-c C-k}.
+@xref{Minor Modes}.
+
+To configure this setting, say, for files within the gdb project, you
+could amend your C++ Mode hook like this:
+
+@example
+(defun my-c++-mode-hook ()
+  (if (string-match "/gdb/" (buffer-file-name))
+      (c-toggle-comment-style 1)))
+(add-hook 'c++-mode-hook 'my-c++-mode-hook)
+@end example
+
+@item
 @emph{How do I stop my C++ lambda expressions being indented way over
 to the right?}
Repository URL: https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.