summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-engine.el
Commit message (Collapse)AuthorAgeFilesLines
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-2/+2
| | | | | | | | | | | | | 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.
* Don't match C++ template delims starting within a token. FIxes bug #28418.Alan Mackenzie2017-09-121-1/+1
| | | | | | * lisp/progmodes/cc-engine.el (c-restore-<>-properties): After failing an attempted match from the start of a token (in particular, "<<"), move to the next token rather than the nex character before searching for the next "<".
* Fix fontification of "operator~" in C++ Mode.Alan Mackenzie2017-09-031-1/+6
| | | | | | | | | * 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.
* Fix a glitch in CC Mode's syntactic whitespace cache.Alan Mackenzie2017-08-311-11/+4
| | | | | * lisp/progmodes/cc-engine.el (c-forward-sws): Deal correctly with a block comment close at the end of a macro.
* Amend the CC Mode macro cache to cope with changes at the macro startAlan Mackenzie2017-08-271-1/+1
| | | | | | | Fixes bug #28233. * lisp/progmodes/cc-engine.el (c-invalidate-macro-cache): Fix an off-by-1 error.
* Convert CC Mode's c-found-types from an obarray to a hash table.Alan Mackenzie2017-07-231-18/+10
| | | | | | | | | * lisp/progmodes/cc-engine.el (c-clear-found-types): create a hash table rather than an obarray. (c-copy-found-types): Remove. (c-add-type, c-unfind-type, c-check-type, c-list-found-types): Amend to use the new hash table. (c-forward-<>-arglist): Use copy-hash-table rather than c-copy-found-types.
* C++ Mode. Fix anomaly occurring when a ">" is deleted then reinserted.Alan Mackenzie2017-07-131-0/+9
| | | | | | | | | | | | | | | | | This fontification anomaly happened because after deleting the ">", c-forward-<>-arglist parses the preceding identifier as a putative type but stores it in c-found-types before it becomes clear it is not an unambiguous type. c-forward-<>-arglist fails, leaving the spurious type id in c-found-types. Fix this by "binding" c-found-types "to itself" in c-forward-<>-arglist, and restoring the original value when that function call fails. * lisp/progmodes/cc-engine.el (c-copy-found-types): New function. (c-forward-<>-arglist): Record the original value of c-found-types at the beginning of the function, and restore it at the end on failure. * lisp/progmodes/cc-mode.el (c-unfind-coalesced-tokens): Rewrite more accurately.
* * lisp/progmodes/cc-engine.el: Mark unused argsStefan Monnier2017-07-041-31/+22
| | | | | | | | | | | | | | | (c-beginning-of-statement-1, c-guess-basic-syntax): Remove unused var c-in-literal-cache. (c-debug-sws-msg): Silence byte-compiler, even if we don't use the arg. (c-append-to-state-cache): Remove unused var `bra+1s'. (c-remove-stale-state-cache): Remove unused var `pps-point-state'. (c-invalidate-state-cache-1): Remove unused var `pa'. (c-forward-decl-or-cast-1): Change comments so they don't look like outline headers. (c-restricted-<>-arglists, c-parse-and-markup-<>-arglists): Declare before first use. (c-forward-decl-or-cast-1): Remove unused var `backup-kwd-sym'. (c-backward-over-enum-header): Remove unused var `up-sexp-pos'.
* Make CC Mode load cl-lib rather than cl in Emacs 26.Alan Mackenzie2017-06-251-3/+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.
* Fix hang in CC Mode when ":" is typed after identifier at EOB.Alan Mackenzie2017-06-161-3/+3
| | | | | * list/progmodes/cc-engine.el (c-forward-declarator): Fix coding error confusing ":" and EOB.
* Fontify C++ for loop variable as variable, even when followed by parenthesesAlan Mackenzie2017-05-121-2/+23
| | | | | | | | | | | | | 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.
* CC Mode internal cache: Handle a cache pos being inside a two-char construct.Alan Mackenzie2017-05-071-45/+110
| | | | | | | | | | | | | | | | | | Cache c-state-semi-nonlit-pos-cache was failing when a cache position was, e.g., between the two characters of an opening comment "/*", and additionally there were an odd number of quote marks (apostrophes) in the comment. This happened in .../src/xdisp.c in the Emacs master branch around 2017-05-02 at buffer position 615001. * lisp/progmodes/cc-defs.el (c-emacs-features): Repurpose symbol pps-extended-state to mean that there are at least 11 elements in the parser state. * lisp/progmodes/cc-engine.el (c-cache-to-parse-ps-state) (c-parse-ps-state-to-cache): Rewrite these to use enhanced cache element list types which indicate potentially being inside two-char constructs. (c-parse-ps-state-below): Rewrite to use the new versions of the above two functions.
* Fix fontification of C++ declaration with type FOO::FOO.Alan Mackenzie2017-04-221-2/+6
| | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-find-decl-spots): Initialize cfd-top-level properly. (c-forward-decl-or-cast-1): On finding FOO::FOO, check it is followed by "(" before deciding it is a constructor. * lisp/progmodes/cc-fonts.el (c-font-lock-complex-decl-prepare): Negate the result of the c-bs-at-toplevel-p call passed to c-font-lock-declarators (simple bug fix).
* Fix a loop in C Mode caused by inadequate analysis of comments.Alan Mackenzie2017-04-101-32/+73
| | | | | | | | | | | | | | After M-;, and the insertion of the opening "/*", the CC Mode after-change function got confused, since the new comment opener matched the end of a subsequent comment, but moving back over that comment did not come back to the starting point. Fix this. * lisp/progmodes/cc-engine.el (c-end-of-macro): Add a limit parameter, wherer point is left if no end-of-macro is found before it. (c-forward-sws): Change the `safe-start' mechanism. Now `safe-start' is non-nil except where we have an unclosed block comment at the end of a macro. This enables us to populate the cache more fully, at the cost of some run time.
* Fix C++ fontification problems 500 bytes after typing a space, and other bugsAlan Mackenzie2017-03-301-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Also implement the "asymmetric space" rule for fontifying otherwise ambiguous declarations/expressions. * lisp/progmodes/cc-engine.el (c-before-change-check-<>-operators): Don't set c-new-BEG or c-new-END when there is no need. (c-forward-decl-or-cast-1): Add "CASE 17.5" to implement the "asymmetric space" rule. * lisp/progmodes/cc-fonts.el (c-get-fontification-context): New function, extracted from c-font-lock-declarations. Add to this function processing to make `context' 'decl for lines contained within parens when these are also declarations. (c-font-lock-declarations): Call the newly extracted function above in place of inline code. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Set point before calling c-literal-start. * lisp/progmodes/cc-vars.el (c-asymmetry-fontification-flag): New user option. * doc/misc/cc-mode.texi (Misc Font Locking): New node documenting the new "asymmetric fontification" rule, including the variable c-asymmetric-fontification-flag.
* Fix chaotic indentation of C++ lambda. Enhance documentation thereofAlan Mackenzie2017-03-191-1/+2
| | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-looking-at-inexpr-block): qualify an invocation of c-on-identifier with a check we're not at the _end_ of an identifier. * doc/misc/cc-mode.texi: (Tex title page): Remove @subtitlefont because the perl versions of texi2dvi haven't implemented it. (Syntactic Symbols): Note that `inlambda' is also used in C++ Mode, not just in Pike Mode. (Statement Block Symbols): Add a section illustrating a C++ lambda function. (FAQ): Add a question about "excessive" indentation of the contents of a C++ lambda function, and how to get rid of it.
* Allow for the :: operator in C++ "enum class" declarations.Alan Mackenzie2017-02-251-0/+2
| | | | | * lisp/progmodes/cc-engine.el (c-backward-typed-enum-colon): Check for "::".
* Allow C++ nested brace-list-entries to be better indented.Alan Mackenzie2017-02-011-29/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes bug #24431. The key change of this bug fix is correctly analyzing nested brace lists when the opening element stands on the same line as both its introductory brace and an enclosing parameter list parenthesis. * list/progmodes/cc-align.el (c-lineup-under-anchor): New line-up function. * list/progmodes/cc-engine.el (c-looking-at-or-maybe-in-bracelist): Accept the presence of exactly an identifier between an open parenthesis and an open brace as evidence of the brace starting a brace list. (c-looking-at-statement-block): New function, extracted from c-looking-at-inexpr-block. Enhance it to analyze inner blocks recursively when needed. (c-looking-at-inexpr-block): Extract new function (see above) and call it. (c-add-stmt-syntax): Enhance, with new &optional parameter, to supply the prime syntactic symbol with a fixed anchor point. When this is used, restrict all added syntactic symbols to those having an anchor point on the same line. Add, in addition to the current additional symbols, c-brace-list-entry when needed; use c-looking-at-statement-block to determine the latter. (c-guess-basic-syntax, CASE 9D): Use c-add-stmt-syntax rather than just c-add-syntax, to assemble the syntactic context of a 'brace-list-entry, thus getting, possibly, several accompanying syntactic entries. * lisp/progmodes/cc-styles.el (c-style-alist, "gnu" style): New entry for 'brace-list-intro, namely c-lineup-arglist-intro-after-paren. * lisp/progmodes/cc-vars.el (c-offsets-alist): Change the factory default offset for 'brace-list-entry from 0 to c-lineup-under-anchor. * doc/misc/cc-mode.texi (Syntactic Symbols): Amend the definition of brace-list-intro. (Brace List Symbols): Amend the example to show the new analysis of brace lists when the first element comes on the same line as the opening brace. (Misc Line-Up): Document the new line-up function c-lineup-under-anchor.
* Fix low-level handling of (big) C macros.Alan Mackenzie2017-01-211-16/+32
| | | | | | | | | | | | | | | | | | | | In particular, ensure that a comment detected by its syntax is not a CPP construct marked with generic comment delimiter syntax-table text properties. * lisp/progmodes/cc-engine.el (c-beginning-of-macro, c-end-of-macro): Set c-macro-cache-syntactic to nil when the cached macro changes. (c-syntactic-end-of-macro, c-no-comment-end-of-macro) (c-state-semi-pp-to-literal, c-state-full-pp-to-literal) (c-state-pp-to-literal, c-parse-ps-state-to-cache) (c-state-cache-non-literal-place, c-literal-limits, c-literal-start) (c-determine-limit): When checking a parse syntax for a comment, check that we're not in a CPP construct marked by syntax-table generic comment delimiter text property. (c-state-pp-to-literal): Change from a defsubst to a defun. * lisp/progmodes/cc-mode.el (c-neutralize-syntax-in-and-mark-CPP): Check a parse syntax as described above under cc-engine.el.
* Correct c-parse-state-get-strategy for moving HERE backward into a macro.Alan Mackenzie2017-01-141-6/+20
| | | | | | | * list/progmodes/c-engine.el (c-parse-state-get-strategy): When HERE is below its previous value, we chose strategy 'forward, and the new HERE is in a (different) macro, ensure the returned START-POINT is not above the start of the macro.
* Handle syntactic WS cache properties more accurately at buffer changes.Alan Mackenzie2017-01-111-36/+117
| | | | | | | | | | | | | | | | | | | | | 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.
* | * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Fix coding errorAlan Mackenzie2016-09-221-1/+1
| |
* | C Mode: Fix mis-fontification of macro invocation as function declarationAlan Mackenzie2016-09-161-2/+4
| | | | | | | | | | | | | | | | | | This happened with a macro invocation which was followed by a statement block in braces. * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): CASE 11: distinguish between contexts nil and top, being less permissive in the former case. (c-just-after-func-arglist-p): call c-forward-decl-or-cast-1 with context top.
* | Correctly fontify C++ direct initializations with parens inside functionsAlan Mackenzie2016-09-111-14/+243
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | * lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): Fix coding bugAlan Mackenzie2016-09-061-5/+6
| |
* | New options for handling of literals in c-syntactic-re-search-forwardAlan Mackenzie2016-09-061-3/+21
| | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): `noerror' can be given the values `before-literal' and `after-literal', so that when a search fails, and the `bound' is inside a literal, point is left respectively before or after that literal.
* | ; Spelling and quotation fixesPaul Eggert2016-08-301-3/+3
| |
* | Correctly analyze C++ list initialization in member init areas.Alan Mackenzie2016-08-301-144/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-back-over-list-of-member-inits): Remove a superfluous call to c-backward-syntactic-ws. (c-looking-at-or-maybe-in-bracelist): Change calling convention, so that it reports encountering the Java "new" keyword. Add, as an alternative, a check that we can move back over member initializations, and handle this as finding a brace block. (c-looking-at-special-brace-list, c-guess-continued-construct): Adapt to the new calling convention of c-looking-at-or-maybe-in-bracelist. (c-guess-basic-syntax, CASE 5A.3): Replace lots of inline ad-hoc code with calls to c-backward-over-enum-header and c-looking-at-or-maybe-in-bracelist, using the extra info from the value of that function to generate a topmost-into-cont element where needed (in Java). * lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Adapt to the new calling convention of c-looking-at-or-maybe-in-bracelist. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Adapt to the new calling convention of c-looking-at-or-maybe-in-bracelist.
* | Handle the C++ "identifiers" "final" and "override" correctly.Alan Mackenzie2016-08-271-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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".
* | Handle template delimiters in C++ member init constructs.Alan Mackenzie2016-08-271-1/+7
| | | | | | | | | | * lisp/progmodes/cc-engine.el (c-back-over-list-of-member-inits): Add handling for "<....>"s.
* | Analyze and fontify correctly a C++ `enum' with colon, but lacking a tag.Alan Mackenzie2016-08-241-1/+4
| | | | | | | | | | * lisp/progmodes/cc-engine.el (c-backward-typed-enum-colon): Check for "enum" directly preceding the colon, and handle it.
* | Adapt CC Mode for C++11 uniform initialization.Alan Mackenzie2016-08-211-123/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fontify constructs following "::" in C++ argument lists correctly - part 2.Alan Mackenzie2016-08-171-1/+2
| | | | | | | | | | | | | | | | This fixes bug #24246. * lisp/progmodes/cc-engine.el (c-find-decl-prefix-search): Put a `save-match-data' around the new `looking-at' introduced by the previous CC Mode patch this evening.
* | Fontify constructs following "::" in C++ argument lists correctly.Alan Mackenzie2016-08-171-0/+7
| | | | | | | | | | | | | | | | This fixes bug #24246. * lisp/progmodes/cc-engine.el (c-find-decl-prefix-search): In the "pseudo match" loop, test a found string for a match with c-opt-identifier-concat-key (e.g. with "::").
* | Fix minor bug in c-syntactic-re-search-forward.Alan Mackenzie2016-08-151-1/+13
| | | | | | | | | | | | | | | | | | Bug was: when NOERROR is neither nil nor t, BOUND is non-nil, PAREN-LEVEL is non-nil, and the first internal search attempt fails, point wrongly ends up at BOUND, rather than just before the next closing paren. * lisp/progmodes/cc-engine.el (c-syntactic-re-search-forward): Guard against the above situation.
* | Handle C++11 lambda functions.Alan Mackenzie2016-08-151-12/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* | Widen in certain low level CC Mode functions. This fixes bug #24148.Alan Mackenzie2016-08-041-59/+63
| | | | | | | | | | | | | | * lisp/progmodes/cc-engine (c-state-semi-pp-to-literal) (c-state-full-pp-to-literal): Widen around the functionality. (c-parse-ps-state-below): Correct the order of save-excursion and save-restriction.
* | Fontify C++ parameter packs.Alan Mackenzie2016-07-231-0/+3
| | | | | | | | | | | | | | | | | | | | 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.
* | CC Mode: correct incorrect invocation of parse-partial-sexp.Alan Mackenzie2016-07-141-5/+6
| | | | | | | | | | | | | | Fixes bug #23944. * lisp/progmodes/cc-engine.el (c-literal-limits): make the sixth argument of an invocation of parse-partial-sexp 'syntax-table, not the fourth.
* | Amend CC Mode to handle big C++ raw strings correctly.Alan Mackenzie2016-07-121-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problems were caused by such a string spanning jit-lock chunks, and by a flaw in the +-500 bytes boundaries imposed for macros. * lisp/progmodes/cc-mode.el (c-extend-region-for-CPP): Check the +-500 byte macro boundaries here. (c-extend-font-lock-region-for-macros): Remove the check on the +-500 byte lower boundary. Fix the check on the upper boundary. * lisp/progmodes/cc-fonts.el (c-font-lock-raw-strings): Handle the starting point already being within a raw string. * lisp/progmodes/cc-engine.el (c-raw-string-pos) (c-depropertize-raw-strings-in-region, c-after-change-re-mark-raw-strings): Modify regexp element "\\{,16\\}" to "\\{0,16\\}" for greater compatibility with other Emacsen.
* | CC Mode: truncate the semi-nonlit cache when applying syntax-table to a quoteAlan Mackenzie2016-06-301-8/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This applies to applying or removing syntax-table text properties in raw strings which affect the stringiness of a piece of text. This fixes the bug reported in http://lists.gnu.org/archive/html/emacs-devel/2016-06/msg00695.html. * lisp/progmodes/cc-engine.el (c-truncate-semi-nonlit-pos-cache): new defsubst. (c-invalidate-state-cache-1): Call new function in place of inline manipulation. (c-depropertize-raw-string, c-propertize-raw-string-opener): truncate the semi-nonlit cache when pertinent syntax-table text properties get applied to the text.
* | Fix C-M-a in a C function finding the start of a macro preceding it.Alan Mackenzie2016-06-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Also amend some pertinent documentation. This fixes bug #23818. * lisp/progmodes/cc-engine.el (c-beginning-of-decl-1): Also check for a virtual semicolon at a place where we check for other types of statement ends. * lisp/progmodes/cc-vars.el (c-macro-nacmes-with-semicolon): Remove from the doc string the bit saying that the variable is a prototype and liable to change. * doc/misc/cc-mode.texi (Macros with ;): Enhance, stating that configuring macros with semicolon can prevent C-M-a missing the beginning of defun.
* | Amend a cache so that typing into C++ raw strings has no undue delay.Alan Mackenzie2016-06-271-74/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also amend the code so that low-level searches to the end of literals are done only when these positions get used. * lisp/progmodes/cc-engine.el (c-crosses-statement-barrier-p): Use the new c-literal-start instead of c-literal-limit. (c-state-semi-nonlit-pos-cache): Change the structure of this cache, such that it stores details of the literal at a point, rather than merely points outside of literals. (c-state-semi-pp-to-literal, c-state-full-pp-to-literal) (c-cache-to-parse-ps-state, c-parse-ps-state-to-cache, c-ps-state-cache-pos) (c-parse-ps-state-below, c-literal-start): New functions. (c-state-semi-safe-place): Removed. (c-in-literal): Use c-state-semi-pp-to-literal, so as not to scan to its end. (c-literal-limits, c-determine-limit-get-base): consequential amendments. (c-find-decl-spots, c-before-change-check-<>-operators, c-raw-string-pos) (c-guess-basic-syntax (CASE 2)): Avoid needless scans to end of literals. * lisp/progmodes/cc-fonts.el (c-font-lock-doc-comments): Avoid needless scans to end of literals. * lisp/progmodes/cc-mode.el (c-fl-decl-start): Avoid needless scans to end of literals. * lisp/progmodes/cc-cmds.el (c-beginning-of-defun, c-end-of-defun) (c-defun-name, c-declaration-limits): Avoid needless scans to end of literals.
* | ; Spelling fixesPaul Eggert2016-06-261-2/+2
| |
* | Make typing into incomplete C++ raw strings work, and make it work fast enoughAlan Mackenzie2016-06-231-27/+28
| | | | | | | | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-beginning-of-macro, c-state-pp-to-literal): Put `save-match-data' around calls to `looking-at' to enable the use of the match data in higher level functions. * lisp/progmodes/cc-fonts.el (c-font-lock-declarations) (c-font-lock-cut-off-declarators): Use `limit' rather than `(point-max)' as a limit to speed up handling of C++ raw strings.
* | Fix CC Mode fontification problem apparent in test file decls-6.cc.Alan Mackenzie2016-06-191-7/+43
| | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Recognize "bar (gnu);" as a declarator only when the construct is directly inside a class (etc.) called "bar". (c-directly-in-class-called-p): New function.
* | c-renarrow-state-cache: take care when new point is inside old brace pair.Alan Mackenzie2016-06-191-4/+8
| | | | | | | | | | | | | | | | Also add display of point-min to the c-parse-state debugging output. * lisp/progmodes/cc-engine.el (c-renarrow-state-cache): When the new point is inside an old recorded brace pair, clear the cache. (c-debug-parse-state): Output the value of point-min.
* | Parse compound identifiers in C++ member initialization lists.Alan Mackenzie2016-06-151-5/+30
| | | | | | | | | | | | | | * lisp/progmodes/cc-engine.el (c-back-over-compound-identifier): New function. (c-back-over-member-initializer-braces, c-back-over-list-of-member-inits) (c-back-over-member-initializers): Call c-back-over-compound-identifier rather than c-simple-skip-symbol-backward.