diff options
author | Alan Mackenzie <acm@muc.de> | 2022-05-22 16:55:05 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2022-05-22 17:00:34 +0000 |
commit | 2f68673a712508f70de20f485422c7e01b8ab21b (patch) | |
tree | 1cbe449cc8659307fa1149be1e1b6ddb0ed298da /lisp/progmodes/cc-defs.el | |
parent | 45694a25948146e860738cb4e01de7e7e9aa91b0 (diff) | |
download | emacs-2f68673a712508f70de20f485422c7e01b8ab21b.tar.gz emacs-2f68673a712508f70de20f485422c7e01b8ab21b.tar.bz2 emacs-2f68673a712508f70de20f485422c7e01b8ab21b.zip |
CC Mode: Restore string fence properties at each relevant external entry point
This fixes bug #55230.
* lisp/progmodes/cc-defs.el (c-string-fences-set-flag, c-with-string-fences):
New variable and macro.
* lisp/progmodes/cc-mode.el (c-called-from-text-property-change-p): Add
remove-text-properties to the list of accepted functions.
(c-clear-string-fences, c-restore-string-fences): Surround the functions'
innards with c-save-buffer-state to prevent text property changes causing
change functions to be called.
(c-before-change, c-after-change, c-font-lock-fontify-region): Replace the
explicit calls to c-restore-string-fences and c-clear-string-fences with
invocations of the new macro c-with-string-fences.
* lisp/progmodes/cc-awk.el (c-awk-extend-and-syntax-tablify-region)
(c-awk-end-of-defun)
* lisp/progmodes/cc-cmds.el (c-show-syntactic-information)
(c-electric-backspace, c-hungry-delete-backwards, c-electric-delete-forward)
(c-hungry-delete-forward, c-electric-pound, c-electric-brace)
(c-electric-slash, c-electric-star, c-electric-semi&comma, c-electric-colon)
(c-electric-lt-gt, c-electric-paren, c-beginning-of-defun, c-end-of-defun)
(c-display-defun-name, c-mark-function, c-beginning-of-statement)
(c-end-of-statement, c-indent-command, c-indent-exp, c-indent-defun)
(c-indent-line-or-region, c-fill-paragraph, c-indent-new-comment-line)
(c-context-line-break)
* lisp/progmodes/cc-guess.el (c-guess-region-no-install): These are all
"boundary" functions to CC Mode. Surround each by c-with-string-fences.
Diffstat (limited to 'lisp/progmodes/cc-defs.el')
-rw-r--r-- | lisp/progmodes/cc-defs.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index a1270243550..54bedb4d9ca 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -1563,6 +1563,27 @@ with value CHAR in the region [FROM to)." (forward-char))))) +;; Miscellaneous macro(s) +(defvar c-string-fences-set-flag nil) +;; Non-nil when we have set string fences with `c-restore-string-fences'. +(defmacro c-with-string-fences (&rest forms) + ;; Restore the string fences, evaluate FORMS, then remove them again. It + ;; should only be used at the top level of "boundary" functions in CC Mode, + ;; i.e. those called from outside CC Mode which directly or indirectly need + ;; unbalanced string markers to have their string-fence syntax-table text + ;; properties. This includes all calls to `c-parse-state'. This macro will + ;; be invoked recursively; however the `c-string-fences-set-flag' mechanism + ;; should ensure consistency, when this happens. + `(unwind-protect + (progn + (unless c-string-fences-set-flag + (c-restore-string-fences)) + (let ((c-string-fences-set-flag t)) + ,@forms)) + (unless c-string-fences-set-flag + (c-clear-string-fences)))) + + ;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text. ;; For our purposes, these are characterized by being possible to ;; remove again without affecting the other text properties in the |