diff options
| author | Alan Mackenzie | 2021-06-27 12:59:18 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2021-06-27 12:59:18 +0000 |
| commit | ef5f3d5ee7211430e5af4952042a0bebdcbc27ff (patch) | |
| tree | 887d7d11a2c0d7698d7b9a253bff4d1105d60fb9 | |
| parent | 7722b510aae119162a20cfc67d3057152835a4ba (diff) | |
| download | emacs-ef5f3d5ee7211430e5af4952042a0bebdcbc27ff.tar.gz emacs-ef5f3d5ee7211430e5af4952042a0bebdcbc27ff.zip | |
C++ Mode: Handle new keywords static_cast, etc., wrt angle brackets
* lisp/progmodes/cc-langs.el (c-<>-arglist-kwds): Add const_cast,
dynamic_cast, reinterpret_cast and static_cast into this lang const.
* lisp/progmodes/cc-engine.el (c-clear-<-pair-props, c-clear->-pair-props)
(c-clear-<-pair-props-if-match-after, c-clear->-pair-props-if-match-before)
(c-forward-<>-arglist-recur):
Invalidate caches with c-trunctate-lit-pos-cache.
(c-forward-<>-arglist-recur): If in a matching <...> expression, the < has a
syntax-table property, but the > not, remove that property.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 33 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 3 |
2 files changed, 28 insertions, 8 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 5a0f9350755..9cba87f4d91 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -6868,8 +6868,10 @@ comment at the start of cc-engine.el for more info." | |||
| 6868 | (c-go-list-forward)) | 6868 | (c-go-list-forward)) |
| 6869 | (when (equal (c-get-char-property (1- (point)) 'syntax-table) | 6869 | (when (equal (c-get-char-property (1- (point)) 'syntax-table) |
| 6870 | c->-as-paren-syntax) ; should always be true. | 6870 | c->-as-paren-syntax) ; should always be true. |
| 6871 | (c-unmark-<->-as-paren (1- (point)))) | 6871 | (c-unmark-<->-as-paren (1- (point))) |
| 6872 | (c-unmark-<->-as-paren pos)))) | 6872 | (c-truncate-lit-pos-cache (1- (point)))) |
| 6873 | (c-unmark-<->-as-paren pos) | ||
| 6874 | (c-truncate-lit-pos-cache pos)))) | ||
| 6873 | 6875 | ||
| 6874 | (defun c-clear->-pair-props (&optional pos) | 6876 | (defun c-clear->-pair-props (&optional pos) |
| 6875 | ;; POS (default point) is at a > character. If it is marked with | 6877 | ;; POS (default point) is at a > character. If it is marked with |
| @@ -6885,8 +6887,10 @@ comment at the start of cc-engine.el for more info." | |||
| 6885 | (c-go-up-list-backward)) | 6887 | (c-go-up-list-backward)) |
| 6886 | (when (equal (c-get-char-property (point) 'syntax-table) | 6888 | (when (equal (c-get-char-property (point) 'syntax-table) |
| 6887 | c-<-as-paren-syntax) ; should always be true. | 6889 | c-<-as-paren-syntax) ; should always be true. |
| 6888 | (c-unmark-<->-as-paren (point))) | 6890 | (c-unmark-<->-as-paren (point)) |
| 6889 | (c-unmark-<->-as-paren pos)))) | 6891 | (c-truncate-lit-pos-cache (point))) |
| 6892 | (c-unmark-<->-as-paren pos) | ||
| 6893 | (c-truncate-lit-pos-cache pos)))) | ||
| 6890 | 6894 | ||
| 6891 | (defun c-clear-<>-pair-props (&optional pos) | 6895 | (defun c-clear-<>-pair-props (&optional pos) |
| 6892 | ;; POS (default point) is at a < or > character. If it has an | 6896 | ;; POS (default point) is at a < or > character. If it has an |
| @@ -6919,7 +6923,8 @@ comment at the start of cc-engine.el for more info." | |||
| 6919 | (equal (c-get-char-property (1- (point)) 'syntax-table) | 6923 | (equal (c-get-char-property (1- (point)) 'syntax-table) |
| 6920 | c->-as-paren-syntax)) ; should always be true. | 6924 | c->-as-paren-syntax)) ; should always be true. |
| 6921 | (c-unmark-<->-as-paren (1- (point))) | 6925 | (c-unmark-<->-as-paren (1- (point))) |
| 6922 | (c-unmark-<->-as-paren pos)) | 6926 | (c-unmark-<->-as-paren pos) |
| 6927 | (c-truncate-lit-pos-cache pos)) | ||
| 6923 | t))) | 6928 | t))) |
| 6924 | 6929 | ||
| 6925 | (defun c-clear->-pair-props-if-match-before (lim &optional pos) | 6930 | (defun c-clear->-pair-props-if-match-before (lim &optional pos) |
| @@ -6940,6 +6945,7 @@ comment at the start of cc-engine.el for more info." | |||
| 6940 | (equal (c-get-char-property (point) 'syntax-table) | 6945 | (equal (c-get-char-property (point) 'syntax-table) |
| 6941 | c-<-as-paren-syntax)) ; should always be true. | 6946 | c-<-as-paren-syntax)) ; should always be true. |
| 6942 | (c-unmark-<->-as-paren (point)) | 6947 | (c-unmark-<->-as-paren (point)) |
| 6948 | (c-truncate-lit-pos-cache (point)) | ||
| 6943 | (c-unmark-<->-as-paren pos)) | 6949 | (c-unmark-<->-as-paren pos)) |
| 6944 | t))) | 6950 | t))) |
| 6945 | 6951 | ||
| @@ -7980,13 +7986,14 @@ comment at the start of cc-engine.el for more info." | |||
| 7980 | ;; bracket arglist. It's propagated through the return value | 7986 | ;; bracket arglist. It's propagated through the return value |
| 7981 | ;; on successful completion. | 7987 | ;; on successful completion. |
| 7982 | (c-record-found-types c-record-found-types) | 7988 | (c-record-found-types c-record-found-types) |
| 7989 | (syntax-table-prop-on-< (c-get-char-property (point) 'syntax-table)) | ||
| 7983 | ;; List that collects the positions after the argument | 7990 | ;; List that collects the positions after the argument |
| 7984 | ;; separating ',' in the arglist. | 7991 | ;; separating ',' in the arglist. |
| 7985 | arg-start-pos) | 7992 | arg-start-pos) |
| 7986 | ;; If the '<' has paren open syntax then we've marked it as an angle | 7993 | ;; If the '<' has paren open syntax then we've marked it as an angle |
| 7987 | ;; bracket arglist before, so skip to the end. | 7994 | ;; bracket arglist before, so skip to the end. |
| 7988 | (if (and (not c-parse-and-markup-<>-arglists) | 7995 | (if (and (not c-parse-and-markup-<>-arglists) |
| 7989 | (c-get-char-property (point) 'syntax-table)) | 7996 | syntax-table-prop-on-<) |
| 7990 | 7997 | ||
| 7991 | (progn | 7998 | (progn |
| 7992 | (forward-char) | 7999 | (forward-char) |
| @@ -8071,8 +8078,20 @@ comment at the start of cc-engine.el for more info." | |||
| 8071 | (c-put-c-type-property (1- (car arg-start-pos)) | 8078 | (c-put-c-type-property (1- (car arg-start-pos)) |
| 8072 | 'c-<>-arg-sep) | 8079 | 'c-<>-arg-sep) |
| 8073 | (setq arg-start-pos (cdr arg-start-pos))) | 8080 | (setq arg-start-pos (cdr arg-start-pos))) |
| 8081 | (when (and (not syntax-table-prop-on-<) | ||
| 8082 | (c-get-char-property (1- (point)) | ||
| 8083 | 'syntax-table)) | ||
| 8084 | ;; Clear the now spuriously matching < of its | ||
| 8085 | ;; syntax-table property. This could happen on | ||
| 8086 | ;; inserting "_cast" into "static <" with C-y. | ||
| 8087 | (save-excursion | ||
| 8088 | (and (c-go-list-backward) | ||
| 8089 | (eq (char-after) ?<) | ||
| 8090 | (c-truncate-lit-pos-cache (point)) | ||
| 8091 | (c-unmark-<->-as-paren (point))))) | ||
| 8074 | (c-mark-<-as-paren start) | 8092 | (c-mark-<-as-paren start) |
| 8075 | (c-mark->-as-paren (1- (point)))) | 8093 | (c-mark->-as-paren (1- (point))) |
| 8094 | (c-truncate-lit-pos-cache start)) | ||
| 8076 | (setq res t) | 8095 | (setq res t) |
| 8077 | nil)) ; Exit the loop. | 8096 | nil)) ; Exit the loop. |
| 8078 | 8097 | ||
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index acdb72fb7b7..86627d9502b 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -2719,7 +2719,8 @@ if this isn't nil." | |||
| 2719 | `c-recognize-<>-arglists' for details. That language constant is | 2719 | `c-recognize-<>-arglists' for details. That language constant is |
| 2720 | assumed to be set if this isn't nil." | 2720 | assumed to be set if this isn't nil." |
| 2721 | t nil | 2721 | t nil |
| 2722 | c++ '("template") | 2722 | c++ '("template" "const_cast" "dynamic_cast" "reinterpret_cast" |
| 2723 | "static_cast") | ||
| 2723 | idl '("fixed" "string" "wstring")) | 2724 | idl '("fixed" "string" "wstring")) |
| 2724 | 2725 | ||
| 2725 | (c-lang-defconst c-<>-sexp-kwds | 2726 | (c-lang-defconst c-<>-sexp-kwds |