diff options
author | Alan Mackenzie <acm@muc.de> | 2016-01-04 22:29:33 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2016-01-04 22:35:13 +0000 |
commit | 33219d385bbb271e2812fef615c81df1983e61d9 (patch) | |
tree | 46cac377e8889942a509348739c3a4e5bb00f118 /lisp/progmodes/cc-cmds.el | |
parent | 31a97acf43b7eb95f3ddc6ceca1682b35a5b1945 (diff) | |
download | emacs-33219d385bbb271e2812fef615c81df1983e61d9.tar.gz emacs-33219d385bbb271e2812fef615c81df1983e61d9.tar.bz2 emacs-33219d385bbb271e2812fef615c81df1983e61d9.zip |
Apply text properties for <, > in new after-change function (C++ Java Modes).
These are category/syntax-table properties to give < and > paren syntax.
Also apply certain `c-type' text properties to the insides of <..> constructs
to ensure that identifiers contained by them get fontified. This patch fixes
bug #681.
* lisp/progmodes/cc-cmds.el (c-electric-lt-gt): Reformulate due to new
after-change action.
* lisp/progmodes/cc-engine.el (c-before-change-check-<>-operators): Expand
change region to include <s and >s which might not be already marked as
parens, rather than just when paren text properties are removed.
(c-restore-<>-properties): New after-change function, which applies text
properties marking < and > with paren syntax.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Ensure `c-type'
properties are applied to the interiors of <...> constructs, to ensure
fontification of identifiers there.
* lisp/progmodes/cc-langs.el (c-before-font-lock-functions): Add
c-restore-<>-properties to this list for C++ and Java.
* lisp/progmodes/cc-mode.el (c-common-init): When invoking
c-before-font-lock-functions, exclude c-restore-<>-properties from the
functions invoked.
(c-before-change): Initialize c-new-BEG/END here (rather than c-after-change)
to allow modification by before-change functions.
(c-after-change): Amend c-new-END here, rather than initializing it and
c-new-BEG.
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r-- | lisp/progmodes/cc-cmds.el | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index a46f0488e76..6761de11700 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -1121,35 +1121,15 @@ numeric argument is supplied, or the point is inside a literal." (looking-at "<<")) (>= (match-end 0) final-pos))) - ;; It's a >. Either a C++ >> operator. ...... - (or (and (c-major-mode-is 'c++-mode) + ;; It's a >. Either a template/generic terminator ... + (or (c-get-char-property (1- final-pos) 'syntax-table) + ;; or a C++ >> operator. + (and (c-major-mode-is 'c++-mode) (progn (goto-char (1- final-pos)) (c-beginning-of-current-token) (looking-at ">>")) - (>= (match-end 0) final-pos)) - ;; ...., or search back for a < which isn't already marked as an - ;; opening template delimiter. - (save-restriction - (widen) - ;; Narrow to avoid `c-forward-<>-arglist' below searching past - ;; our position. - (narrow-to-region (point-min) final-pos) - (goto-char final-pos) - (while - (and - (progn - (c-syntactic-skip-backward "^<;}" nil t) - (eq (char-before) ?<)) - (progn - (backward-char) - (looking-at "\\s(")))) - (and (eq (char-after) ?<) - (not (looking-at "\\s(")) - (progn (c-backward-syntactic-ws) - (c-simple-skip-symbol-backward)) - (or (looking-at c-opt-<>-sexp-key) - (not (looking-at c-keywords-regexp))))))))) + (>= (match-end 0) final-pos)))))) (goto-char final-pos) (when found-delim @@ -1157,11 +1137,9 @@ numeric argument is supplied, or the point is inside a literal." (when (and (eq (char-before) ?>) (not executing-kbd-macro) blink-paren-function) - ;; Currently (2014-10-19), the syntax-table text properties on < and > - ;; are only applied in code called during Emacs redisplay. We thus - ;; explicitly cause a redisplay so that these properties have been - ;; applied when `blink-paren-function' gets called. - (sit-for 0) + ;; From now (2016-01-01), the syntax-table text properties on < and > + ;; are applied in an after-change function, not during redisplay. Hence + ;; we no longer need to call (sit-for 0) for blink paren to work. (funcall blink-paren-function))))) (defun c-electric-paren (arg) |