[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 697942f: CC Mode: Fix wrong value of comment-start-skip, fixing h
From: |
Alan Mackenzie |
Subject: |
master 697942f: CC Mode: Fix wrong value of comment-start-skip, fixing half of bug #41952 |
Date: |
Sat, 4 Jul 2020 07:58:10 -0400 (EDT) |
branch: master
commit 697942f9a0d875cb8b00e6de155a34354db1dcba
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
CC Mode: Fix wrong value of comment-start-skip, fixing half of bug #41952
Also add functions to enable correct use of CC Mode's filling functionality
from major modes which don't initialize CC Mode fully. These modes are
currently js-mode and mhtml-mode.
* lisp/progmodes/cc-langs.el (comment-start-skip): Replace "\\(" by "\\(?:"
so
that (match-end 1) isn't falsely taken to be the start of the comment.
* lisp/progmodes/cc-engine.el (c-foreign-truncate-lit-pos-cache)
(c-foreign-init-lit-pos-cache): New functions.
---
lisp/progmodes/cc-engine.el | 18 ++++++++++++++++++
lisp/progmodes/cc-langs.el | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 1977ead..fec1065 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -3186,6 +3186,24 @@ comment at the start of cc-engine.el for more info."
c-semi-near-cache-limit (min c-semi-near-cache-limit pos)
c-full-near-cache-limit (min c-full-near-cache-limit pos)))
+(defun c-foreign-truncate-lit-pos-cache (beg _end)
+ "Truncate CC Mode's literal cache.
+
+This function should be added to the `before-change-functions'
+hook by major modes that use CC Mode's filling functionality
+without initializing CC Mode. Currently (2020-06) these are
+js-mode and mhtml-mode."
+ (c-truncate-lit-pos-cache beg))
+
+(defun c-foreign-init-lit-pos-cache ()
+ "Initialize CC Mode's literal cache.
+
+This function should be called from the mode functions of major
+modes which use CC Mode's filling functionality without
+initializing CC Mode. Currently (2020-06) these are js-mode and
+mhtml-mode."
+ (c-truncate-lit-pos-cache 1))
+
;; A system for finding noteworthy parens before the point.
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 814a85c..b77bf33 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1769,7 +1769,7 @@ ender."
`comment-start-skip' is initialized from this."
;; Default: Allow the last char of the comment starter(s) to be
;; repeated, then allow any amount of horizontal whitespace.
- t (concat "\\("
+ t (concat "\\(?:"
(c-concat-separated
(mapcar (lambda (cs)
(when cs
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 697942f: CC Mode: Fix wrong value of comment-start-skip, fixing half of bug #41952,
Alan Mackenzie <=