From: Alan Mackenzie Date: Mon, 6 Apr 2015 22:20:16 +0000 (+0000) Subject: Fix miscellaneous glitches in cc-mode.el. Fixes debbugs#20245. X-Git-Tag: emacs-25.0.90~2541 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4d748735d5c49f73e1d49123f7188c9a2fd7d252;p=emacs.git Fix miscellaneous glitches in cc-mode.el. Fixes debbugs#20245. * progmodes/cc-mode.el (c-common-init): bind \(before\|after\)-change-functions to nil around invocations of c-get-state-before-change-functions and c-before-font-lock-functions to prevent recursive invocations. (c-neutralize-syntax-in-and-mark-CPP): On c-beginning-of-macro, check that point has actually moved back. (c-fl-decl-start): Check whether c-beginning-of-decl-1 has actually found a boundary (as contrasted with hitting a search limit). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 38bb8afa15c..1d25e8f870e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,17 @@ +2015-04-06 Alan Mackenzie + + Fix miscellaneous glitches in cc-mode.el. Fixes debbugs#20245. + + * progmodes/cc-mode.el (c-common-init): bind + \(before\|after\)-change-functions to nil around invocations of + c-get-state-before-change-functions and + c-before-font-lock-functions to prevent recursive invocations. + (c-neutralize-syntax-in-and-mark-CPP): On c-beginning-of-macro, + check that point has actually moved back. + (c-fl-decl-start): Check whether c-beginning-of-decl-1 has + actually found a boundary (as contrasted with hitting a search + limit). + 2015-02-01 Alan Mackenzie CC Mode: Stop Font Lock forcing fontification from BOL. Fixes diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index d88fe702c59..1f58ba1ee9b 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -659,13 +659,14 @@ compatible with old code; callers should always specify it." (setq c-new-BEG (point-min)) (setq c-new-END (point-max)) (save-excursion - (mapc (lambda (fn) - (funcall fn (point-min) (point-max))) - c-get-state-before-change-functions) - (mapc (lambda (fn) - (funcall fn (point-min) (point-max) - (- (point-max) (point-min)))) - c-before-font-lock-functions))) + (let (before-change-functions after-change-functions) + (mapc (lambda (fn) + (funcall fn (point-min) (point-max))) + c-get-state-before-change-functions) + (mapc (lambda (fn) + (funcall fn (point-min) (point-max) + (- (point-max) (point-min)))) + c-before-font-lock-functions)))) (set (make-local-variable 'outline-regexp) "[^#\n\^M]") (set (make-local-variable 'outline-level) 'c-outline-level) @@ -972,7 +973,9 @@ Note that the style variables are always made local to the buffer." (unless (or (save-excursion (goto-char (match-beginning 0)) - (c-beginning-of-macro)) + (let ((here (point))) + (and (save-match-data (c-beginning-of-macro)) + (< (point) here)))) (progn (setq pps-state (parse-partial-sexp pps-position (point) nil nil pps-state) @@ -1170,6 +1173,7 @@ Note that the style variables are always made local to the buffer." ;; Go to a less nested declaration each time round this loop. (and (eq (car (c-beginning-of-decl-1 bod-lim)) 'same) + (> (point) bod-lim) (progn (setq bo-decl (point)) ;; Are we looking at a keyword such as "template" or ;; "typedef" which can decorate a type, or the type itself?