From: Alan Mackenzie <acm@muc.de>
Date: Tue, 9 Aug 2016 10:23:31 +0000 (+0000)
Subject: Make c-deprepertize-CPP work on deletion/insertion of "s.  Fixes bug #24132.
X-Git-Tag: emacs-26.0.90~1762
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8b789c8cfeaee074f581e10009d781b52bf45c81;p=emacs.git

Make c-deprepertize-CPP work on deletion/insertion of "s.  Fixes bug #24132.

* lisp/progmodes/cc-mode.el (c-depropertize-CPP): Rewrite function.
---

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 04d2ed6e8d5..8d75eea4da7 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -892,24 +892,31 @@ Note that the style variables are always made local to the buffer."
   ;; This function is in the C/C++/ObjC values of
   ;; `c-get-state-before-change-functions' and is called exclusively as a
   ;; before change function.
-  (c-save-buffer-state ()
+  (c-save-buffer-state (m-beg ss-found)
     (goto-char c-new-BEG)
     (while (and (< (point) beg)
-		(search-forward-regexp c-anchored-cpp-prefix beg t))
+		(search-forward-regexp c-anchored-cpp-prefix beg 'bound))
       (goto-char (match-beginning 1))
-      (let ((m-beg (point)))
-	(c-end-of-macro)
-	(c-clear-char-property-with-value
-	 m-beg (min (point) beg) 'syntax-table '(1))))
+      (setq m-beg (point))
+      (c-end-of-macro)
+      (c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
+
+    (while (and (< (point) end)
+		(setq ss-found
+		      (search-forward-regexp c-anchored-cpp-prefix end 'bound)))
+      (goto-char (match-beginning 1))
+      (setq m-beg (point))
+      (c-end-of-macro))
+    (if (and ss-found (> (point) end))
+	(c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
 
-    (goto-char end)
     (while (and (< (point) c-new-END)
-		(search-forward-regexp c-anchored-cpp-prefix c-new-END t))
+		(search-forward-regexp c-anchored-cpp-prefix c-new-END 'bound))
       (goto-char (match-beginning 1))
-      (let ((m-beg (point)))
-	(c-end-of-macro)
-	(c-clear-char-property-with-value
-	 m-beg (min (point) c-new-END) 'syntax-table '(1))))))
+      (setq m-beg (point))
+      (c-end-of-macro)
+      (c-clear-char-property-with-value
+       m-beg (point) 'syntax-table '(1)))))
 
 (defun c-extend-region-for-CPP (beg end)
   ;; Adjust `c-new-BEG', `c-new-END' respectively to the beginning and end of