summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-langs.el
Commit message (Collapse)AuthorAgeFilesLines
...
* | Enhance CC Mode's fontification, etc., of unterminated strings.Alan Mackenzie2018-05-201-3/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | String delimiters, including escaped new lines, of correctly terminated strings are left in font-lock-string-face. All others get font-lock-warning-face. The latter get syntax-table text properties on the opening string delim and the "terminating EOL". Correct two miscellaneous bugs: the handling of text properties on Java Mode's generic delimiters; the handling of c-just-done-before-change. * lisp/progmodes/cc-defs.el (c-point): New position 'eoll "end of logical line". (c-characterp): New macro. * lisp/progmodes/cc-fonts.el (c-font-lock-invalid-string): Removed. (c-basic-matchers-before): Use a simple matcher in place of the form around c-font-lock-invalid-string. * lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Add c-before-change-check-unbalanced-strings to the value for all modes except AWK Mode. Also add c-before-change-check-<>-operators to Java Mode, correcting an error in that mode's handling of generic delimiters. (c-before-font-lock-functions): Add c-after-change-re-mark-unbalanced-strings to the value for all modes except AWK Mode. (c-single-quotes-quote-strings, c-string-delims): New lang variables for future enhancements. (c-string-innards-re-alist): New lang variable. * lisp/progmodes/cc-mode.el (c-just-done-before-change): Do not set this variable when a change is the alteration of text properties. (c-basic-common-init): Set parse-sexp-lookup-properties (and the XEmacs equivalent) also for Pike Mode. (c-neutralize-CPP-line): No longer neutralize unbalanced quotes here. (c-unescaped-nls-in-string-p, c-multiline-string-start-is-being-detached) (c-pps-to-string-delim, c-before-change-check-unbalanced-strings) (c-after-change-re-mark-unbalanced-strings): New functions. (c-after-change): Fix a bug with the handling of c-just-done-before-change.
* | Amend c-colon-type-list-re also to handle compound identifiersAlan Mackenzie2018-04-191-1/+5
| | | | | | | | | | * lisp/progmodes/cc-langs.el (c-colon-type-list-re): Amend to recognize and skip over "::" in C++ and "." in Java.
* | * lisp/progmodes/cc-{defs,engine,langs,vars}.el: Comment the use of "a\\`"Alan Mackenzie2018-04-021-9/+9
| |
* | Handle C++17's constexpr keyword in if statementsAlan Mackenzie2018-03-281-0/+11
| | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-after-conditional): Test for matches to c-block-stmt-hangon-key. * lisp/progmodes/cc-langs.el (c-block-stmt-hangon-kwds): New lang const. (c-block-stmt-hangon-key): New lang const/var matching any element of the above.
* | Replace faulty non-matching regexp "\\<\\>" with "a\\`"Alan Mackenzie2018-03-281-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The regexp "\\<\\>", which is supposed never to match, actually matches, for instance, where a Chinese character is directly followed by an ASCII letter. So, replace it with "a\\`". * lisp/progmodes/cc-defs.el (cc-fix, c-make-keywords-re) * lisp/progmodes/cc-engine.el (c-beginning-of-statement-1) (c-forward-<>-arglist-recur, c-forward-decl-or-cast-1) (c-looking-at-decl-block) * lisp/progmodes/cc-langs.el (c-assignment-op-regexp) (c-block-comment-ender-regexp, c-block-comment-start-regexp) (c-line-comment-start-regexp, c-doc-comment-start-regexp) (c-decl-start-colon-kwd-re, c-type-decl-prefix-key) (c-type-decl-operator-prefix-key, c-pre-id-bracelist-key) (c-enum-clause-introduction-re, c-nonlabel-token-2-key) * lisp/progmodes/cc-vars.el (c-noise-macro-with-parens-name-re) (c-make-noise-macro-regexps): Replace "\\<\\>" by "a\\`".
* | * lisp/progmodes/cc-langs.el: Silence compiler.Glenn Morris2018-03-231-3/+3
| |
* | Fix some errors in c-display-defun-name when the type is "struct {..}", etc.Alan Mackenzie2018-01-281-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also fix some errors with c-display-defun-name when there are nested classes. * lisp/progmodes/cc-cmds.el (c-in-function-trailer-p): Deal with a struct {..} being merely the type of a function. (c-where-wrt-brace-construct): Deal with a struct {..} being merely the type of a function. Rearrange the order of some Lisp forms. Insert a check for c-protection-key ("private", etc.) alongside the checking for a label. (c-defun-name-1): New function extracted form c-defun-name, which works within the existing restriction. Don't regard 'at-function-end as being within the defun any more. Recognize "struct", etc., with the new c-defun-type-name-decl-key rather than c-type-prefix-key. Make the recognition of a normal function more accurate. (c-defun-name): Part left after extracting the above function. It now just widens and calls c-defun-name-1. (c-declaration-limits-1): New function extracted from c-declaration-limits, which works within the existing restriction. Move LIM back one block to account for the possibility of struct {..} as a function type. Check we're not inside a declaration without braces. (c-declaration-limits): Part left after extracting the above function. It now just narrows to an enclosing decl block and calls c-declaration-limits-1. (c-defun-name-and-limits): New function which identifies the name and limits of the most nested enclosing declaration or macro. (c-display-defun-name): Use c-defun-name-and-limits rather than two separate functions (which didn't always agree on which function). * lisp/progmodes/cc-engine.el (c-beginning-of-statement-1): If we have struct {..} as the type of a function, go back over this, too. * lisp/progmodes/cc-langs.el (c-defun-type-name-decl-kwds) (c-defun-type-name-decl-key): New lang const/var.
* | Handle C99 Compound Literals in return statements and argument lists.Alan Mackenzie2018-01-211-0/+6
|/ | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-looking-at-or-maybe-in-bracelist): Recognize a brace list when preceded by "return" or inside parentheses, either immediately after the "(" or following a comma. (c-looking-at-inexpr-block): Test c-has-compound-literals rather than hard coded C++ Mode. (c-guess-basic-syntax, CASE 7B): Test additionally for not being just inside a parenthesis or being at a Java "new" keyword. CASE 9: Remove the simple minded test on the contents of a block to determine a brace list. * lisp/progmodes/cc-langs.el (c-has-compound-literals): New lang const and lang var.
* Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | Run admin/update-copyright.
* Fontify a CPP construct correctly when a comment follows without spacesAlan Mackenzie2017-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Do this by removing a broken optimization in the state cache which put category text properties on a character between the end of the CPP construct and the beginning of the comment. This can't work when there's no such character. * lisp/progmodes/cc-defs.el (c-cpp-delimiter, c-set-cpp-delimiters) (c-clear-cpp-delimiters, c-comment-out-cpps, c-with-cpps-commented-out) (c-with-all-but-one-cpps-commented-out): Remove. * lisp/progmodes/cc-engine.el (c-no-comment-end-of-macro): Return the comment start position rather than one character before it. (c-invalidate-state-cache, c-parse-state): Remove the invocations of c-with-all-but-one-cpps-commented-out and c-with-cpps-commented-out. * lisp/progmodes/cc-mode.el (c-neutralize-syntax-in-and-mark-CPP): Rename to c-neutralize-syntax-in-CPP and remove the bits which applied category properties. * lisp/progmodes/cc-langs.el (c-before-font-lock-functions): Incorporate the new name of the function c-neutralize-syntax-in-CPP.
* Fix misfontification of C++ member initialization list after "throw"Alan Mackenzie2017-12-141-6/+22
| | | | | | | | | | * lisp/progmodes/cc-engine.el (c-forward-type): Stop recognizing a "type" starting with "throw", by using c-opt-type-modifier-prefix-key. * lisp/progmodes/cc-langs.el (c-type-modifier-prefix-kwds): New lang const which, in C++, doesn't contain "throw", otherwise like c-type-modifier-kwds. (c-opt-type-modifier-prefix-key): New lang const and var, a regexp matching any keyword in the previous lang const.
* Don't misfontify "foo ()" inside C++ initialization parentheses as a typeAlan Mackenzie2017-12-131-0/+10
| | | | | | | | | | | | | | | | | Also recognize and handle function names introduced by "extern" inside a function. * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Add a new element to the result list which is t when our declaration is, or is to be treated as, being at top level. * lisp/progmodes/cc-fonts.el (c-get-fontification-context): Detect being inside a C++ uniform initialization and return (not-decl nil) for this case. (c-font-lock-declarations): Use the new element 4 of the result of c-forward-decl-or-cast-1. * lisp/progmodes/cc-langs.el (c-make-top-level-kwds, c-make-top-level-key): New lang consts/vars.
* Fix irregularities with CC Mode fontification, particularly with "known types"Alan Mackenzie2017-10-051-0/+11
| | | | | | | | | | | | | | | | * lisp/progmodes/cc-fonts.el (c-font-lock-declarators): Introduce a new optional parameter, template-class. In "class <X = Y>", fontify "Y" as a type. (c-font-lock-single-decl): New variable template-class, set to non-nil when we have a construct like the above. Pass this as argument to c-font-lock-declarators. (c-font-lock-cut-off-declarators): Check more rigorously that a declaration being processed starts before the function's starting position. (c-complex-decl-matchers): Remove the redundant clause which fontified "types preceded by, e.g., "struct"". * lisp/progmodes/cc-langs.el (c-template-typename-kwds) (c-template-typename-key): New lang defconsts and defvar.
* Fontify untyped function declarations in C Mode correctly.Alan Mackenzie2017-10-041-0/+5
| | | | | | | | | | | | | | | | | | | | Also correct two bugs where deleting WS at a BOL could leave an untyped function declaration unfontified. * lisp/progmodes/cc-engine.el (c-find-decl-spots): Don't set the flag "top-level" when we're in a macro. (c-forward-decl-or-cast-1): Recognize top-level "foo(bar)" or "foo()" in C Mode as a implicitly typed function declaration. (c-just-after-func-arglist-p): Don't get confused by "defined (foo)" inside a macro. It's not a function plus arglist. * lisp/progmodes/cc-langs.el (c-cpp-expr-functions-key): New defconst and defvar. * lisp/progmodes/cc-mode.el (c-fl-decl-end): After c-forward-declarator, move over any following parenthesis expression (i.e. parameter list). (c-change-expand-fl-region): When c-new-END is at a BOL, include that line in the returned region, to cope with deletions at column 0.
* Cope better with C++ and Objective-C protection keywords in class declarationsAlan Mackenzie2017-09-161-0/+12
| | | | | | | | | | | | | | | | | This fix fixes the fontification of a method inside a class at the time it is typed, when there is a protection keyword clause preceding it. * lisp/progmodes/cc-engine.el (c-forward-keyword-clause): Handle protection keywords. (c-looking-at-decl-block): Avoid scanning forward over protection keyword clauses too eagerly. * lisp/progmodes/cc-langs.el (c-protection-key c-post-protection-token): New lang defconsts and defvars. * lisp/progmodes/cc-mode.el (c-fl-decl-start): When we encounter a protection keyword following a semicolon or brace, move forward over it before attempting to parse a type.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-1/+1
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Spelling fixesPaul Eggert2017-09-101-2/+2
| | | | | | * lisp/progmodes/cc-langs.el: (c-ambiguous-overloadable-or-identifier-prefixes): Rename from c-ambiguous-overloadable-or-identifier-prefices. Caller changed.
* Fix fontification of "operator~" in C++ Mode.Alan Mackenzie2017-09-031-0/+18
| | | | | | | | | * lisp/progmodes/cc-langs.el (c-ambiguous-overloadable-or-identifier-prefices) (c-ambiguous-overloadable-or-identifier-prefix-re): New c-lang-defconsts/vars. * lisp/progmodes/cc-engine.el (c-forward-name): Do not try to parse "~" (and two other symbols) as a cast without good evidence. Prefer an overloaded operator in ambiguous cases.
* * lisp/progmodes/cc-langs.el: Mark unused argsStefan Monnier2017-07-041-11/+4
| | | | | (c-primary-expr-regexp): Remove unused vars ambiguous-prefix-ops and unambiguous-prefix-ops.
* Make C++ digit separators work. Amend the handling of single quotes generallyAlan Mackenzie2017-07-011-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Single quotes, even in strings and comments, are now marked with the "punctuation" syntax-table property, except where they are validly bounding a character literal. They are font locked with font-lock-warning-face except where they are valid. This is done in C, C++, ObjC, and Java Modes. * lisp/progmodes/cc-defs.el (c-clear-char-property-with-value-on-char-function) (c-clear-char-property-with-value-on-char, c-put-char-properties-on-char): New functions/macros. * lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes): New function. (c-basic-matchers-before): invoke c-font-lock-invalid-single-quotes. * lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Remove c-before-after-change-digit-quote from wherever it occurs. Insert c-parse-quotes-before-change into the entries for the languages where it is needed. (c-before-font-lock-functions): Remove c-before-after-change-digit-quote from wherever it occurs. Insert c-parse-quotes-after-change into the entries for the languages which need it. (c-has-quoted-numbers): New lang-defconst/-defvar. * lisp/progmodes/cc-mode.el (c-before-after-change-digit-quote): Remove. (c-maybe-quoted-number-head, c-maybe-quoted-number-tail) (c-maybe-quoted-number): New defconsts. (c-quoted-number-head-before-point, c-quoted-number-tail-after-point) (c-quoted-number-straddling-point, c-parse-quotes-before-change) (c-parse-quotes-after-change): New functions.
* Make CC Mode load cl-lib rather than cl in Emacs 26.Alan Mackenzie2017-06-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-cmds.el (c-declaration-limits): Remove unused local variable. * lisp/progmodes/cc-defs.el (c--mapcan-status): Remove. (c--cl-library): New variable. (Top level): Amend the form which requires library cl or cl-lib. (c--mapcan, c--set-difference, c--intersection, c--macroexpand-all) (c--delete-duplicate): Amend to use c--cl-library instead of c--mapcan-status. * lisp/progmodes/cc-engine.el (c-syntactic-skip-backward) (c-back-over-compound-identifier): Remove unused local variables. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Remove an unused local variable. * lisp/progmodes/cc-langs.el (Top level): Amend to use c--cl-library instead of c--mapcan-status. * lisp/progmodes/cc-styles.el (Top level): Add a cc-bytecomp-defun to try to silence a compiler warning.
* Create a toggle between block and line comments in CC Mode.Alan Mackenzie2017-06-151-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | Also (unrelated change) initialize the modes' keymaps at each loading. * lisp/progmodes/cc-cmds.el (c-update-modeline): amend for the new information on the modeline. (c-block-comment-flag): New variable. (c-toggle-comment-style): New function. * lisp/progmodes/cc-langs.el (c-block-comment-starter) (c-line-comment-starter): Make them c-lang-defvars. (c-block-comment-is-default): New c-lang-defvar. (comment-start, comment-end): Make the default values dependent on c-block-comment-is-default. * lisp/progmodes/cc-mode.el (c-mode-base-map): Define C-c C-k in this map. (c-basic-common-init): Initialize c-block-comment-flag. (c-mode-map, c++-mode-map, objc-mode-map, java-mode-map, idl-mode-map) (pike-mode-map, awk-mode-map): Make entries in these key maps each time the mode is loaded rather than just once per Emacs session. * doc/misc/cc-mode.texi (Comment Commands): Introduce the notion of comment style. (Minor Modes): Define comment style. Describe how comment style influences the information displayed on the modeline. Document c-toggle-comment-style. (FAQ): Add a question about toggling the comment style.
* Fontify C++ for loop variable as variable, even when followed by parenthesesAlan Mackenzie2017-05-121-0/+15
| | | | | | | | | | | | | In the following: "for (auto *Friend : Class->friends()) {", "Friend" was getting fontified as a function, due to insufficient checking of the tokens between it and "()". * lisp/progmodes/cc-langs.el (c-:-op-cont-tokens, c-:-op-cont-regexp): New lang-consts/vars. * lisp/progmodes/cc-engine.el (c-forward-declarator): After finding a putative declarator's identifier, check for a ":" token inside a for's parentheses, and abort the search for "(" if this is found.
* Fix edebug-spec on c-lang-defvar.Alan Mackenzie2017-02-181-5/+3
| | | | | | | | | | This allows c-lang-defvars with the symbol 'dont-doc in the place of the optional documentation to be instrumented for edebug. lisp/progmodes/cc-langs.el (top-level): Amend the edebug-spec for c-lang-defvar. (c-opt-identifier-concat-key, c-decl-prefix-or-start-re): remove redundant 'dont-doc.
* Handle syntactic WS cache properties more accurately at buffer changes.Alan Mackenzie2017-01-111-0/+9
| | | | | | | | | | | | | | | | | | | | | This fixes bug #25362. * lisp/progmodes/cc-engine.el (c-sws-lit-type, c-sws-lit-limits) (c-invalidate-sws-region-before, c-invalidate-sws-region-after-del) (c-invalidate-sws-region-after-ins): New variables and functions. (c-invalidate-sws-region-after): Change from a defsubst to a defun. Also pass it the standard OLD-LEN argument. Call both c-invalidate-sws-region-after-{ins,del} to check for "dangerous" WS cache properties. * lisp/progmodes/cc-langs.el (c-block-comment-ender-regexp): New language variable. * lisp/progmodes/cc-mode.el (c-before-change): Call c-invalidate-sws-region-before. (c-after-change): Pass old-len to c-invalidate-sws-region-after.
* Merge from origin/emacs-25Paul Eggert2017-01-011-1/+1
|\ | | | | | | | | 2e2a806 Fix copyright years by hand 5badc81 Update copyright year to 2017
| * Update copyright year to 2017Paul Eggert2016-12-311-1/+1
| | | | | | | | Run admin/update-copyright.
* | CC Mode: Fix the fontification of a spuriously recognised enum member.Alan Mackenzie2016-12-301-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | The "enum" was in an argument list, but triggered the fontification of a following identifier in the function block as though it were in an enum declaration. * lisp/progmodes/cc-fonts.el (c-font-lock-enum-body): New function. (c-basic-matchers-after): Replace the inline stanza for enum elements with a call to c-font-lock-enum-body. * lisp/progmodes/cc-langs.el (c-enum-clause-introduction-re): New language variable.
* | Partially correct fontification of "(b*3)", and the like, in C++ ModeAlan Mackenzie2016-12-291-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | This problem is caused by the fundamental ambiguity in C++ between argument declarations and initialisation clauses. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): If we have an open paren preceded by an arithmetic operator, we give this the context nil, not 'arglist. * lisp/progmodes/cc-langs.el (c-arithmetic-operators, c-arithmetic-op-regexp): New lang consts and vars.
* | Correctly fontify C++ direct initializations with parens inside functionsAlan Mackenzie2016-09-111-2/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Or, more clearly, when something looks like a function declaration and it's inside a function, fontify it as a direct initialization. For this purpose, introduce a "brace stack" for each buffer, where an entry on the brace stack states how deeply nested a particular position is inside braces inside a "top level", which includes classes and namespaces. Also introduce a new "context", "top", with which c-font-lock-declarations signals to c-forward-decl-or-cast-1 that point is at the top level. * lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): add c-truncate-bs-cache. (c-flat-decl-block-kwds, c-brace-stack-thing-key, c-brace-stack-no-semi-key) (c-type-decl-operator-prefix-key): new language constants/variables. * lisp/progmodes/cc-engine.el (c-bs-interval, c-bs-cache, c-bs-cache-limit) (c-bs-prev-pos, c-bs-prev-stack): New mostly local variables for the brace stack cache. (c-init-bs-cache, c-truncate-bs-cache, c-truncate-bs-cache, c-brace-stack-at) (c-bs-at-toplevel-p): New functions which manipulate the brace stack (cache). (c-find-decl-prefix-search): Keep track of whether we're at top level. (c-find-decl-spots): New local variable cfd-top-level which records what it says. On calling cfd-fun, pass cfd-top-level as an additional argument. (c-forward-declarator): Add new element DECORATED to the result list. Set it to non-nil when a match for c-type-decl-operator-prefix-key is found. (c-forward-decl-or-cast-1): Handle the newly introduced context "top". Introduce "CASE 9.5", which recognizes direct initializations. * lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare) (c-font-lock-enum-tail, c-font-lock-cut-off-declarators) (c-font-lock-enclosing-decls, c-simple-decl-matchers, c-basic-matchers-after): Add appropriate `not-top' argument to calls to c-font-lock-declarators. (c-font-lock-declarators): Additional parameter `not-top'. Use not-top to participate in the decision whether to fontify an identifier as a function or a variable. (c-font-lock-declarations): The internal lambda function takes an additional argument `toplev' from c-find-decl-spots, which it uses in determining the "context" of a declaration. Add appropriate `not-top' argument to calls to c-font-lock-declarators. (c-font-lock-objc-methods): Add extra parameter to internal lambda function, like for c-font-lock-declarators. * lisp/progmodes/cc-mode.el (c-basic-common-init): Initialize the brace stack cache.
* | Handle the C++ "identifiers" "final" and "override" correctly.Alan Mackenzie2016-08-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes bug #24319, allowing destructors affixed with these identifiers to be correctly fontified. * lisp/progmodes/cc-engine.el (c-forward-type, c-forward-decl-or-cast-1): After reaching the "end" of a type expression, skip over any occurrences of c-type-decl-suffix-ws-ids-key. * lisp/progmodes/cc-langs.el (c-type-modifier-kwds): Remove "override" and "final" from the C++ value. (c-type-decl-suffix-ws-ids-kwds, c-type-decl-suffix-ws-ids-key): New lang constants/variables for "final" and "override".
* | Adapt CC Mode for C++11 uniform initialization.Alan Mackenzie2016-08-211-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For fontification, introduce a new "context", 'non-decl, to be used for brace lists; also a new value for the property 'c-type, called 'c-not-decl. * lisp/progmodes/cc-engine.el (c-back-over-compound-identifier): Check that an ostensible symbol we're going to move over isn't a keyword. (c-forward-decl-or-cast-1): CASE 1: Where we have two consecutive identifiers (hence a declaration), and an unmatched open paren, perform c-fdoc-shift-type-backwards to recognize the partial construct correctly. Whilst checking a type decl expression, check for and handle C++11's "copy initialization", where we have <type>(<constant>). Recognize <id><id>(... (where the paren is unclosed) as a declaration. (c-looking-at-or-maybe-in-bracelist): New function, extracted from c-inside-bracelist-p. Recognize as bracelists "{"s which are preceded by valid tokens other than "=". Recognize a bracelist when preceded by a template declaration. (c-inside-bracelist-p): Call c-looking-at-or-maybe-in-bracelist in place of much inline code. (c-looking-at-inexpr-block): Amend so that it won't wrongly recognise an initialization starting "({" as an in-expression block, by checking for semicolons, as opposed to commas, separating elements inside it. (c-guess-continued-construct): (CASE B-2): Recognize a brace-list-open by calling c-looking-at-or-maybe-in-bracelist rather than checking for a preceding "=". (CASE B-5): New code to recognize new construct "return { ...}". (c-guess-basic-syntax): (CASE 5A.3): Additionally recognize a "{" preceded by "return", or "{" preceded by <type><identifier> as a bracelist. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Recognize brace lists, giving them `context' 'non-decl. Pass over elements of one by regexp search for "," rather than calling c-forward-decl-or-cast-1. * lisp/progmodes/cc-langs.el (c-return-kwds, c-return-key): New lang constants/variables to recognize "return". (c-pre-id-bracelist-key): New lang constant/variable to recognize tokens which, when preceding an identifier followed by a brace, signify the brace as a bracelist. * lisp/progmodes/cc-mode.el (c-fl-decl-start): When searching outwards for the start of a "local" declaration, move out from an enclosing brace when that is the start of a brace list.
* | ; Spelling fixesPaul Eggert2016-08-211-1/+1
| |
* | Handle C++11 lambda functions.Alan Mackenzie2016-08-151-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-looking-at-inexpr-block): Enhance also to handle C++ lambda functions. (c-looking-at-c++-lambda-capture-list): New function. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Recognize the parameter list of a lambda function and set `context' and `c-restricted-<>-arglists' suitably for it. (c-font-lock-c++-lambda-captures): New function. (c-complex-decl-matchers): Insert c-font-lock-c++-lambda-captures into it. * lisp/progmodes/cc-langs.el (c-pre-lambda-tokens, c-pre-lambda-tokens-re): New language constants/variables. (c-paren-nontype-kwds): Include "noexcept" in the C++ value. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Handle being in a C++ lambda function capture list.
* | Fontify C++ parameter packs.Alan Mackenzie2016-07-231-0/+12
| | | | | | | | | | | | | | | | | | | | This fixes debbugs #23610. * lisp/progmodes/cc-langs.el (c-pack-ops, c-pack-key): New c-lang-defconsts/defvars. (c-type-decl-prefix-key): Add "..." and "&&" into the C++ version. * lisp/progmodes/cc-engine.el (c-forward-type): Handle matches of c-pack-key.
* | Java Mode: Handle strings as case labels correctly.Alan Mackenzie2016-07-231-2/+2
| | | | | | | | | | | | | | This fixes debbugs #23901. * lisp/progmodes/cc-langs.el (c-nonlabel-token-key): Remove "\"" from the Java value.
* | Implement ' separators in C++ integer literals.Alan Mackenzie2016-06-241-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): insert c-before-after-change-digit-quote into the C++ value. (c-before-font-lock-functions): Insert c-depropertize-new-text into the values for all languages. Insert c-before-after-change-digit-quote into the C++ value. * lisp/progmodes/cc-mode.el (c-depropertize-CPP): Wrap the function in c-save-buffer-state. (c-depropertize-new-text, c-before-after-change-digit-quote): New functions.
* | Handle C++ raw strings.Alan Mackenzie2016-06-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-raw-string-pos, c-depropertize-raw-string) (c-depropertize-raw-strings-in-region, c-before-change-check-raw-strings) (c-propertize-raw-string-opener, c-after-change-re-mark-raw-strings): New functions. * lisp/progmodes/cc-fonts.el (c-basic-matchers-before): Insert a clause for c-font-lock-raw-strings. (c-font-lock-raw-strings): New function. * lisp/progmodes/cc-langs.el (c-get-state-before-change-functions): Insert c-before-change-check-raw-strings into the C++ value, and c-depropertize-CPP into the values for C, C++, and Objective C. (c-before-font-lock-functions): Insert c-after-change-re-mark-raw-strings into the C++ value. * lisp/progmodes/cc-mode.el (c-old-BEG, c-old-END): New variables. (c-depropertize-CPP): New function, extracted from c-neutralize-syntax-in-and-mark-CPP. (c-neutralize-syntax-in-and-mark-CPP): Remove the call to c-clear-char-property-with-value for 'syntax-table value '(1) at the beginning of the function. (c-after-change): Set c-old-BEG and c-old-END to the current values of c-new-BEG and c-new-END.
* | Correct fontification and indentation of C++'s "constexpr" expressionsAlan Mackenzie2016-06-011-3/+3
| | | | | | | | | | * lisp/progmodes/cc-langs.el (c-type-modifier-kwds): Remove "constexpr". (c-modifier-kwds): Add "constexpr".
* | Rationalize the use of c-new-BEG and c-new-END in CC Mode.Alan Mackenzie2016-05-291-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the now redundant c-old-BOM and c-old-EOM. * lisp/progmodes/cc-engine.el (c-macro-cache-syntactic): Change and simplify meaning. (c-macro-cache-no-comment): New variable. (c-invalidate-macro-cache, c-beginning-of-macro, c-end-of-macro): incorporate the new c-macro-cache-no-comment. (c-syntactic-end-of-macro): Make better use of c-macro-cache-syntactic. (c-no-comment-end-of-macro): New function. * lisp/progmodes/cc-langs.el (c-before-font-lock-functions): Add c-extend-font-lock-region-for-macros to C/C++/ObjC value. * lisp/progmodes/cc-mode.el (c-old-BOM, c-old-EOM): Remove. (c-extend-region-for-CPP): Put results in c-new-BEG/END rather than c-old-BOM/EOM. (c-extend-font-lock-region-for-macros): Simplify meaning, no longer returning a cons for the new region, since the function is now called as an after-change function. No longer adjust c-new-END for the length of inserted/deleted text. Move the size restrictions on macros to here from c-neutralize-syntax-in-and-mark-CPP. (c-neutralize-syntax-in-and-mark-CPP): No longer adjust c-new-BEG/END here. Use c-no-comment-end-of-macro rather than c-syntactic-end-of-macro to find the upper boundary to "neutralize" syntactically obtrusive characters. (c-change-expand-fl-region): Don't set c-new-END to next BOL when already at one.
* | C++ Mode: attribute in class declaration fouls up indentation. Fix!Alan Mackenzie2016-05-281-0/+4
| | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-looking-at-decl-block): Add code to skip back over noise clauses and attribute clauses. * lisp/progmodes/cc-langs.el (c-paren-nontype-key): New language variable.
* | c-forward-<>-arglist no longer directly applies face properties in Java Mode.Alan Mackenzie2016-04-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows the calling of c-restore-<>-properties from c-common-init without the test suite giving spurious errors. * lisp/progmodes/cc-engine.el (c-forward-<>-arglist): Remove the form that sets face properties. (c-forward-<>-arglist-recur): Reformulate the bit that handles types inside template brackets using c-inside-<>-type-key. Don't bind c-record-type-identifiers or c-record-found-types around the recursive call, allowing positions of found types to flow back to the caller. * lisp/progmodes/cc-langs.el (c-inside-<>-type-kwds, c-inside-<>-type-key): new lang consts/var. * lisp/progmodes/cc-mode.el (c-common-init): Don't remove c-restore-<>-properties from the list of functions called at mode initialization.
* | Add fontification for a C declaration which looks like a function call.Alan Mackenzie2016-04-251-0/+8
| | | | | | | | | | | | | | | | | | | | | | For example, "t1 *fn (t2 *b);". * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Add new variable at-decl-start, setting it to whether the putative decl starts immediately after ; or { or }. Accept such a construct as a decl when at-decl-start is non-nil. * lisp/progmodes/cc-langs.el (c-pre-start-tokens): New language variable.
* | ; Spelling fixesPaul Eggert2016-04-211-1/+1
| |
* | Don't confuse "::" with ":" when trying to parse member initializers.Alan Mackenzie2016-03-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-back-over-member-initializers): Check more robustly for ":" token when searching backwards for it. * lisp/progmodes/cc-langs (c-:$-multichar-token-regexp): New language variable. [This reapplies commit 9e5452f7166e3634f2d8e943815ed722e1672714, which was inadvertently lost by merge commit 7823745acbe9b87eea2db4ef434e379fc903ec35.]
* | Handle "noise" macros and compiler directives.Alan Mackenzie2016-02-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-langs.el (c-symbol-char-key): New language variable. * lisp/progmodes/cc-vars.el (c-noise-macro-names) (c-noise-macro-with-parens-names): New customizable variables. (c-noise-macro-name-re, c-noise-macro-with-parens-name-re): New variables. (c-make-noise-macro-regexps): New function. * lisp/progmodes/cc-engine.el (c-forward-sws, c-backward-sws): Adapt to treat members of c-noise-macro-names as whitespace. (c-forward-noise-clause): New function. (c-forward-keyword-prefixed-id, c-forward-type, c-forward-declarator) (c-forward-decl-or-cast-1, c-backward-over-enum-header) (c-guess-basic-syntax CASE 5A.3, CASE 5A.5, CASE 9A): Handle "noise clauses" in parallel with, e.g., "hangon key clauses". * lisp/progmodes/cc-fonts.el (c-complex-decl-matchers): Handle "noise clauses" in parallel with "prefix-spec keywords". * lisp/progmodes/cc-mode.el (c-mode, c++-mode, objc-mode): call c-make-noise-macro-regexps to initialize the internal variables. * doc/misc/cc-mode.texi ("Noise Macros"): New section documenting the new facilities.
* | Merge from origin/emacs-25John Wiegley2016-02-151-3/+30
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | d4b93e1 Minor fixes in global-auto-composition-mode 02b037b Allow arithmetic operators inside C++ template constructs. 44b16f6 Avoid crashes in semi-malformed 'condition-case' 652e5b4 Allow arithmetic operators inside C++ template constructs. d9ea795 Fix regression with 'recent-keys' and keyboard macros 903603f Fix wording in a doc-view.el comment cf79616 ; Spelling fixes f8bf1b3 CONTRIBUTE cleanups and updates f3aaca3 Port USE_STACK_LISP_OBJECTS fix to Clang 1834ac7 Port to x86 GCC 4.3.1 and earlier 8482949 Fix point movement under 'scroll-conservatively' c1313b5 Replace colon in file name (not legal on Windows) f7af26c Fix a typo in edt.texi 8badf95 Make 'mmap_realloc' on MS-Windows more reliable 856cd94 Grep alias `all' shall not match parent directory
| * Allow arithmetic operators inside C++ template constructs.Alan Mackenzie2016-02-151-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes debbugs #22486. This corrects the previous patch with this message which was empty. * lisp/progmodes/cc-langs.el (c-multichar->-op-not->>-regexp): New language variable. (c-<>-notable-chars-re): New language variable. * lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur): User c-<>-notable-chars-re in place of the former fixed string in searching for places to stop and examine. Use c-multichar->-op-not->>-regexp to check that a found ">" is not part of a multichar operator in place of the former c->-op-without->-cont-regexp. Add code to skip forwards over a balanced parenthesized expression.
* | Merge from origin/emacs-25Paul Eggert2016-01-301-2/+2
|\| | | | | | | | | | | | | | | | | | | 3f481ad Rename xref-query-replace to xref-query-replace-in-results 62f4ed4 Update cl-defgeneric and cl-defmethod docstrings 2111e0e Comment out next-error-function integration in xref 4e11ad3 Correct a use of "which" in intro.texi a1865bc Distinguish the two meanings of Java's keyword "default". Fixes bug #22358. 76045f7 Don't operate on menu bar of nonexistent frame c32f3bc Unbreak the GNUstep build.
| * Distinguish the two meanings of Java's keyword "default". Fixes bug #22358.Alan Mackenzie2016-01-231-2/+2
| | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-guess-basic-syntax CASE 14): Check the context of case labels (including "default") more rigorously. (c-guess-basic-syntax CASE 15): Consequential amendment. * lisp/progmodes/cc-langs.el (c-modifier-kwds): Add "default" to Java's value.