1. 15 Apr, 2021 1 commit
  2. 14 Apr, 2021 1 commit
  3. 10 Apr, 2021 1 commit
    • Alan Mackenzie's avatar
      Convert CC Mode to lexical binding in Emacs · 3e0f3c4c5b5d
      Alan Mackenzie authored
      cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-defs.el, cc-engine.el,
      cc-fonts.el, cc-guess.el, cc-langs.el, cc-menus.el, cc-mode.el, cc-styles.el,
      cc-subword.el, cc-vars.el: Mark these files with a `lexical-binding' setting
      in line 1.
      
      cc-align.el, cc-cmds.el, cc-engine.el, cc-vars.el (c-syntactic-context)
      (c-syntactic-element): Declare these as special variables.
      
      cc-bytecomp.el (cc-bytecomp-debug-msg): prefix the parameter ARGS with a _.
      
      cc-cmds.el (c--call-post-self-insert-hook-more-safely-1): Use mapc on
      functions in a lexical variable rather than a local variable as a hook.
      (c-where-wrt-brace-construct): Remove `kluge-start', an unused variable.
      (c-while-widening-to-decl-block): Add an extra parameter, which suppresses
      the generation of a setting of variable `where'.
      (c-defun-name-and-limits): Remove variable `where' from the function and use
      the new argument to the previous macro.
      
      cc-engine.el (c-cache-to-parse-ps-state): Remove two unneeded variables,
      `last' and `intermediate'.
      
      cc-guess.el (c-guess-view-reorder-offsets-alist-in-style): Remove the
      erroneous binding of `guessed-syntactic-symbols' (which is supplied as a
      parameter).
      
      cc-langs.el (c-vsemi-status-unknown-p-fn): Shorten the first line of the doc
      string to less than 80 characters.
      
      cc-mode.el (top-level): Add (cc-bytecomp-defun c-awk-unstick-NL-prop).
      
      cc-styles.el (c-set-offset): Give the `ignored' parameter a leading _.
      
      cc-vars.el (c-doc-comment-style): Shorten a line of the doc string to less
      than 80 characters.
      3e0f3c4c5b5d
  4. 09 Apr, 2021 1 commit
    • Alan Mackenzie's avatar
      CC Mode: fix c-where-wrt-brace-construct to cope with class declarations · 0f14e43254e6
      Alan Mackenzie authored
      Make the function correctly recognize a brace block preceded by an
      introductory line without a parameter list.
      
      * cc-cmds.el (c-where-wrt-brace-contruct): Reintroduce the use of
      c-beginning-of-decl-1, which was removed some weeks ago, in place of a
      c-syntactic-skip-backward.  Reformulate the code generally.
      0f14e43254e6
  5. 29 Mar, 2021 1 commit
    • Alan Mackenzie's avatar
      Fix an infinite loop in C++ Mode redisplay. This was bug #47191. · 7c948d8b9927
      Alan Mackenzie authored
      * cc-defs.el (c-forward-syntactic-ws, c-backward-syntactic-ws): When point is
      on the wrong side of a supplied search limit, leave point unmoved rather than
      setting it to that limit.
      
      * cc-engine.el (c-forward-name): After scanning a template argument list
      (which is not itself subject to a search limit) recalculate the search limit
      starting from the end point, since these argument lists can legitimately be
      long.  At each of the scanning loops, check point hasn't gone past the limit.
      7c948d8b9927
  6. 06 Mar, 2021 1 commit
  7. 03 Mar, 2021 1 commit
  8. 02 Mar, 2021 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Fix analysis of brace lists, particularly in C++ Mode · fd6fc4a4be6e
      Alan Mackenzie authored
      Fix some alignment functionality in cc-align.el.
      
      * cc-align.el (c-lineup-arglist-intro-after-paren): Align the next line under
      the previous entry rather than one to the right of the paren.
      (c-lineup-2nd-brace-entry-in-arglist): Take the anchor point from the
      brace-list-entry element, not the brace-list-intro one.
      
      * cc-engine.el (c-looking-at-decl-block): Use c-looking-at-statement-block to
      test whether "struct A {" begins a brace list or a struct declaration.
      (c-looking-at-or-maybe-in-bracelist): Several detailed amendments, correctly
      to recognize brace lists.
      (c-looking-at-statement-block): No longer search for commas, as they are not
      reliable indicators of a brace list.  Search now for a restricted set of
      keywords, since some can appear in brace lists in C++ mode.
      
      * cc-langs.el (c-stmt-block-only-keywords, c-stmt-block-only-keywords-regexp):
      New lang consts/vars.
      (c-pre-id-bracelist-kwds): New lang const.
      (c-pre-id-bracelist-key): Derive now from the above.
      (c-pre-brace-non-bracelist-key): New lang const/var.
      fd6fc4a4be6e
  9. 01 Mar, 2021 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Amend C-M-a/e to handle lambda function in C++ arglist · df51bfc8e6e6
      Alan Mackenzie authored
      * cc-cmds.el (c-where-wrt-brace-construct): Reformulate latter part such that
      the least enclosing braces and parentheses are used when determining
      containment in such.  c-beginning-of-decl-1 has been superseded by list
      movement and syntactic whitespace movement.
      (c-backward-to-nth-BOF-{): Work on least enclosing parens rather than parens
      at any level when moving back to an opening brace.
      (c-forward-to-nth-EOF-\;-or-}): Work on least enclosing parens, as above.
      Move the correction of point when in a "function trailer" to after the main
      loop, correcting a minor bug.
      df51bfc8e6e6
  10. 23 Feb, 2021 1 commit
  11. 02 Feb, 2021 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Prevent "const" inside an identifier being recognized as the keyword · 524031e9e284
      Alan Mackenzie authored
      This fixes bug #45560.
      
      * cc-engine.el (c-forward-declarator, c-forward-decl-or-cast-1): Amend certain
      regexp match numbers on account of the change below.  Surround some looking-at
      calls with save-match-data.
      
      * cc-langs.el (c-type-decl-prefix-keywords-key): New lang const.
      (c-type-decl-prefix-key): Reformulate to match operators and keywords
      separately, using the new lang const (above).
      524031e9e284
  12. 31 Dec, 2020 3 commits
  13. 30 Dec, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: correct the handling of empty strings, also in test program · 2ab971738b2c
      Alan Mackenzie authored
      In particular, have the macro cache invalidated after its last use in
      c-before-change.
      
      * cc-engine.el (top level): Enclose five def-edebug-spec's in
      eval-after-load's.
      
      * cc-langs.el (c-get-state-before-change-functions): Remove
      c-invalidate-macro-cache from the entries it's in, moving it to....
      
      * cc-mode.el (c-before-change): Call c-invalidate-macro-cache directly from
      the functions, after the call to c-invalidate-state-cache.
      2ab971738b2c
  14. 28 Dec, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Add newish AWK Mode facilities, as used in gawk-4. · 92794c7bd79d
      Alan Mackenzie authored
      * cc-awk.el (c-awk-font-lock-invalid-namespace-separators): New function.
      (c-awk-context-expand-fl-region): New function.
      (awk-font-lock-keywords): Enhance handling of function declarations to include
      :: tokens.  Fontify new system variable names FPAT, FUNCTAB, PREC, ROUNDMODE,
      SYNTAB.  Fontify new keywords BEGINFILE and ENDFILE.  Fontify new system
      functions asorti, dcngettext, isarray, patsplit, typeof.  Fontify the new
      directives @include, @load, @namespace.  Call
      c-awk-font-lock-invalid-namespace-separators as a matcher.
      
      * cc-fonts.el (top level): No longer require 'cc-awk.
      
      * cc-langs.el (c-before-context-fontification-functions): Give AWK the value
      c-awk-context-expand-fl-region rather than nil.
      
      * cc-mode.el (top level): Declare awk-mode-syntax-table as a variable.
      
      * awk-face-1.{awk,face}: Add tests for the new attributes, for the new system
      variables, and for the new keywords.
      
      * funcs-5.{awk,face}: New test files for new function declarations.
      
      * statement-22.{awk,face,res}: Add erroneous use of the :: token into
        statements.  The .res file has been converted to "new" style.
      92794c7bd79d
  15. 24 Dec, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: introduce a new cache for brace structures. This fixes bug #45248 · 93043918481d
      Alan Mackenzie authored
      Also fix three infinite loops.  The new cache accelerates backward searches
      for struct beginnings in c-looking-at-or-maybe-in-bracelist.
      
      * cc-engine.el (c-beginning-of-statement-1): In the final loop over unary
      operators, add a check (> (point) lim) to avoid certain infinite loops.
      (c-beginning-of-decl-1): In the first loop add a similar check on point and
      lim.
      (c-laomib-loop): New function extracted from
      c-looking-at-or-maybe-in-bracelist.
      (c-laomib-cache): New buffer local variable.
      (c-laomib-get-cache, c-laomib-put-cache, c-laomib-fix-elt)
      (c-laomib-invalidate-cache): New functions which implement the cache.
      (c-looking-at-or-maybe-in-bracelist): Replace two invocations of
      c-go-up-list-backwards with calls to c-parse-state.  Extract the new function
      c-laomib-loop.  Insert code which calls c-laomib-loop minimally, with the help
      of the new cache.
      
      * cc-mode.el (c-basic-common-init): Initialise the new cache (at mode start).
      (c-before-change): Invalidate the new cache.
      (c-fl-decl-start): Add an extra check (> (point) bod-lim) to prevent looping.
      Determine the enclosing brace to pass as arguments to
      c-looking-at-or-maybe-in-bracelist.
      93043918481d
  16. 15 Dec, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Optimize for scrolling large buffers containing few braces · 967655828f50
      Alan Mackenzie authored
      This fixes bug #25706.  It particularly pertains to .h files which contain
      only macro definitions.  Many of these files are to be found, for example, in
      the driver sections of the Linux kernel.
      
      * cc-engine.el (c-beginning-of-statement-1, c-on-identifier)
      (c-syntactic-skip-backward, c-find-decl-prefix-search, c-find-decl-spots)
      (c-forward-name, c-back-over-list-of-member-inits)
      (c-back-over-member-initializers, c-looking-at-inexpr-block)
      (c-guess-basic-syntax): Give search limits to, or amend existing ones to
      c-backward-syntactic-ws, c-forward-syntactic-ws, c-backward-token-2,
      c-beginning-of-statement-1.
      (c-determine-limit-no-macro): New function.
      (c-determine-limit-get-base): Remove unlimted invocation of
      c-backward-syntactic-ws.
      (c-determine-limit): Exclude movement between two different macros.  Use new
      function c-determine-limit-no-macro.
      (c-back-over-list-of-member-inits): New parameter `limit'.
      
      * cc-mode.el (c-unfind-coalesced-tokens, c-before-change, c-fl-decl-end):
      Give search limits to, or amend existing ones to c-backward-syntactic-ws,
      c-forward-syntactic-ws, skip-chars-backward, skip-chars-forward.
      967655828f50
  17. 14 Dec, 2020 3 commits
    • Alan Mackenzie's avatar
      Optimise c-font-lock-<>-arglists, particularly for buffers with few <..> pairs · 36aacde9e66b
      Alan Mackenzie authored
      * cc-fonts.el (c-font-lock-<>-arglists): In place of a regexp search for a
      complicated and slow regexp, search simply for "<" ouside of literals together
      with add hoc testing of other requirements for a <...> match.
      
      * cc-langs.el (c-nonsymbol-key): New c-lang-defvar from the c-lang-const.
      36aacde9e66b
    • Alan Mackenzie's avatar
      Optimise c-parse-state for large buffers with few (if any) braces. · f27f3b95798d
      Alan Mackenzie authored
      * cc-engine (c-get-fallback-scan-pos): Search a maximum of 50,000 characters
      back for the two BODs.  Return nil if we dont' find them.
      (c-parse-state-get-strategy): For strategy `forward', always use the position
      `good-pos' for `start-point', even when there's a change of current macro.
      Deal with a possible return value of nil from c-get-fallback-scan-pos (as
      above).
      (c-invalidate-state-cache-1): For `c-state-cache-good-pos', instead of
      sometimes using the minimum scan pos (leading to extensive scanning of the
      entire buffer) use a point close to `here'.
      f27f3b95798d
    • Alan Mackenzie's avatar
      CC Mode: fix small incompatibilities between Emacs and XEmacs · 9c9162f6c944
      Alan Mackenzie authored
      * cc-engine.el (c-parse-ps-state-to-cache)
      * cc-fonts.el (c-maybe-font-lock-wrong-style-comments): When testing (nth 7
      s), where s is a parser state, check for both values 1 (Emacs) and t
      (XEmacs).
      
      * cc-mode.el (c-populate-abbrev-table): Do not try to run abbrev-table-p on
      XEmacs, since it doesn't exist there.
      9c9162f6c944
  18. 12 Dec, 2020 1 commit
  19. 11 Dec, 2020 1 commit
  20. 26 Nov, 2020 1 commit
  21. 15 Nov, 2020 1 commit
  22. 09 Nov, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: fix many compiler warnings which would appear with lexical binding · 824214fc4b6b
      Alan Mackenzie authored
      * cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-defs.el, cc-engine.el
      cc-fonts.el, cc-langs.el, cc-mode.el, cc-subword.el, cc-vars.el: In many
      places, where function parameters are not used, prefix their names with _.
      
      * cc-cmds.el (c-electric-brace, c-defun-name-and-limits)
      cc-engine.el (c-cache-to-parse-ps-state, c-full-trim-near-cache)
      (c-after-change-unmark-raw-strings, c-maybe-re-mark-raw-string)
      (c-forward-decl-or-cast-1): Remove unused local variables.
      
      * cc-defs.el (c-will-be-unescaped): Remove unused parameter end.
      * cc-engine.el (c-looking-at-decl-block): Remove unused parameter
      containing-sexp.
      (c-looking-at-special-brace-list): Remove unused parameter lim.
      (c-add-class-syntax): Remove unused parameter paren-state.
      824214fc4b6b
  23. 28 Oct, 2020 1 commit
  24. 08 Oct, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Move the handling of keyword auto into type handling for C++. · 7b896f471f96
      Alan Mackenzie authored
      This should allow auto, const, static, ... to be in any order.
      
      * cc-engine.el (c-forward-type): New return value 'no-id for when auto
      precludes the parsing of a type identifier.  Adapt processing for this.
      (c-forward-decl-or-cast-1): Use the new facility from c-forward-type.
      
      * cc-langs.el (c-type-modifier-prefix-kwds): Insert the value of
      c-no-type-kwds into the value.
      (c-no-type-kwds, c-no-type-key): New lang consts/vars, basically "auto".
      (c-typeless-decl-kwds, c-modifier-kwds): Remove "auto" from the C++ value.
      7b896f471f96
  25. 02 Oct, 2020 1 commit
  26. 20 Sep, 2020 1 commit
    • Alan Mackenzie's avatar
      C++ Mode: Modernize the fontification of "using" · 1eafa3102499
      Alan Mackenzie authored
      Since "using" is now used in three distinct ways in C++, write a special
      function to handle these rather than attempting to adapt the old regular
      expressions.
      
      * cc-fonts.el (c-font-lock-declarators): Amend to allow the argument TYPES to
      be a face.  This face is given to the declarator being processed.
      (c-font-lock-single-decl): Make an argument to c-font-lock-declarators nil or
      t, not merely nil or non-nil.
      (c-complex-decl-matchers): Include c-font-lock-c++-using in the C++ value of
      this variable.
      (c-font-lock-c++-using): New function.
      
      * cc-langs.el (c-using-kwds, c-using-key): New lang consts/vars.
      1eafa3102499
  27. 12 Sep, 2020 1 commit
    • Alan Mackenzie's avatar
      C++ Mode: handle __attribute__,etc. inside constructor argument lists · 0a6dfbea463d
      Alan Mackenzie authored
      This corrects both the fontification and indentation of these things, fixing
      bug #42270.
      
      * cc-engine.el (c-do-declarators): Skip over "hangon keys" and noise macros
      whilst scanning a putative C++ function.
      (c-forward-decl-or-cast-1): When checking for typeless functions, skip over
      "hangon keys" and noise macros.
      
      * cc-mode.el (c-fl-decl-end): Deal with certain invalid "nested declarators"
      by scanning over them with a recursive call of c-fl-decl-end.
      
      * cc-vars.el (c-noise-macro-names, c-noise-macro-with-parens-names): State in
      the doc strings that if either of these is a regexp, it must have a submatch 1
      which matches the noise macro exactly.
      0a6dfbea463d
  28. 11 Sep, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: Fix minor bugs in the string handling functions · 383b8279a135
      Alan Mackenzie authored
      These sometimes gave rise to the tail of a buffer being "stringed out".
      
      * cc-defs.el (c-will-be-unescaped): New macro.
      
      * cc-mode.el (c-before-change-check-unbalanced-strings)
      (c-after-change-mark-abnormal-strings): Fix bugs in the handling of string
      fence syntax-table text properties.
      383b8279a135
  29. 04 Sep, 2020 1 commit
    • Alan Mackenzie's avatar
      C++ Mode: handle comma separated brace initializers. · c5eea696449b
      Alan Mackenzie authored
      This includes both indentation and fontification.
      
      * cc-engine.el (c-do-declarators): Handle brace initializers without =
      correctly.
      (c-looking-at-or-maybe-in-bracelist): Use c-do-declarators with a simple
      inline function to check that after-type-id-pos points to the start of a
      declarator.
      
      * cc-langs.el (c-recognize-bare-brace-inits): New lang const/variable.
      c5eea696449b
  30. 29 Aug, 2020 1 commit
  31. 19 Jul, 2020 1 commit
  32. 04 Jul, 2020 2 commits
  33. 02 Jul, 2020 1 commit
  34. 29 Jun, 2020 1 commit
    • Alan Mackenzie's avatar
      CC Mode: optimize for repeated simple operations. · dff5956ce70a
      Alan Mackenzie authored
      Do this by recognising that unterminated strings in a buffer are typically
      going to be few and close together.  Also optimize code for C++ attributes.
      
      * cc-defs.el (c-previous-single-property-change): New macro.
      (c-put-syn-tab, c-clear-syn-tab): Turned from macros into functions, and moved
      to cc-mode.el.
      (c-clear-syn-tab-properties): Amended to use c-min/max-syn-tab-mkr.
      (c-with-extended-string-fences): Removed.
      
      * cc-engine-el (c-enclosing-c++-attribute): Rewritten for speed.
      (c-slow-enclosing-c++-attribute): Removed.
      (c-semi-pp-to-literal): Remove a superfluous call to
      c-with-extended-string-fences.
      
      * cc-mode.el (c-min-syn-tab-mkr, c-max-syn-tab-mkr): two new marker variables
      which bound the region occupied by positions with c-fl-syn-tab text
      properties.
      (c-basic-common-init): Initialize these two variables.
      (c-fl-syn-tab-region): Removed.
      (c-put-syn-tab, c-clear-syn-tab): Functions moved from cc-defs.el.
      (c-clear-string-fences): Amended to use the new scheme.
      (c-restore-string-fences): Now takes no arguments; amended to use the new
      scheme.
      (c-font-lock-fontify-region): Amended to use the new scheme.
      dff5956ce70a
  35. 25 Jun, 2020 1 commit