<commit_before>;;; module-cc.el

(use-package cmake-mode
  :mode "CMakeLists\\.txt$"
  :config
  (require 'company-cmake)
  (define-company-backend! cmake-mode (cmake yasnippet)))

(use-package glsl-mode
  :mode ("\\.glsl\\'" "\\.vert\\'" "\\.frag\\'" "\\.geom\\'"))

(use-package cc-mode
  :defines (c-syntactic-context)
  :functions (c-toggle-electric-state c-toggle-auto-newline
              c-skip-comments-and-strings c-forward-sws c-end-of-macro
              c-font-lock-invalid-string csharp-log c-font-lock-declarators
              c-get-lang-constant c-forward-keyword-clause
              c-fontify-recorded-types-and-refs c-forward-type imenu--split
              c-backward-sws c-determine-limit c-beginning-of-decl-1)
  :commands (c-mode c++-mode objc-mode java-mode)
  :init
  (associate! objc-mode :match "\\.mm$")
  (add-hook! (c-mode c++-mode) '(flycheck-mode narf|init-c/c++-settings))
  :config
  (setq c-basic-offset 4
        c-tab-always-indent nil
        c-electric-flag nil)

  ;; TODO Clang is *really* slow in larger projects, maybe replace it with
  ;; irony-mode or ycmd?
  (define-company-backend! c-mode-common (c-headers clang xcode))

  (map! (:map c-mode-base-map
          (:localleader
            :nv ";" 'narf/append-semicolon)))

  (defun narf/sp-point-is-template-p (id action context)
    (and (sp-in-code-p id action context)
         (sp-point-after-word-p id action context)))

  (sp-local-pair 'c++-mode "<" ">" :when '(narf/sp-point-is-template-p))
  (sp-with-modes '(c-mode c++-mode objc-mode java-mode)
    (sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))

    ;; Doxygen blocks
    (sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
    (sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))

  ;; C/C++ Settings
  (add-hook! (c-mode c++-mode)
    (electric-indent-local-mode +1)
    (setq electric-indent-chars '(?\n ?})))
  (add-hook! c++-mode 'narf|init-c++-C11-highlights)

  (when IS-MAC
    (setq-default company-c-headers-path-system
                  (append '("/usr/include/" "/usr/local/include")
                          (f-directories "/usr/include/c++/")
                          (f-directories "/usr/local/include/c++/")))<commit_msg>cc-mode: ignore errors if include path does not exist<commit_after>;;; module-cc.el

(use-package cmake-mode
  :mode "CMakeLists\\.txt$"
  :config
  (require 'company-cmake)
  (define-company-backend! cmake-mode (cmake yasnippet)))

(use-package glsl-mode
  :mode ("\\.glsl\\'" "\\.vert\\'" "\\.frag\\'" "\\.geom\\'"))

(use-package cc-mode
  :defines (c-syntactic-context)
  :functions (c-toggle-electric-state c-toggle-auto-newline
              c-skip-comments-and-strings c-forward-sws c-end-of-macro
              c-font-lock-invalid-string csharp-log c-font-lock-declarators
              c-get-lang-constant c-forward-keyword-clause
              c-fontify-recorded-types-and-refs c-forward-type imenu--split
              c-backward-sws c-determine-limit c-beginning-of-decl-1)
  :commands (c-mode c++-mode objc-mode java-mode)
  :init
  (associate! objc-mode :match "\\.mm$")
  (add-hook! (c-mode c++-mode) '(flycheck-mode narf|init-c/c++-settings))
  :config
  (setq c-basic-offset 4
        c-tab-always-indent nil
        c-electric-flag nil)

  ;; TODO Clang is *really* slow in larger projects, maybe replace it with
  ;; irony-mode or ycmd?
  (define-company-backend! c-mode-common (c-headers clang xcode))

  (map! (:map c-mode-base-map
          (:localleader
            :nv ";" 'narf/append-semicolon)))

  (defun narf/sp-point-is-template-p (id action context)
    (and (sp-in-code-p id action context)
         (sp-point-after-word-p id action context)))

  (sp-local-pair 'c++-mode "<" ">" :when '(narf/sp-point-is-template-p))
  (sp-with-modes '(c-mode c++-mode objc-mode java-mode)
    (sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))

    ;; Doxygen blocks
    (sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
    (sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))

  ;; C/C++ Settings
  (add-hook! (c-mode c++-mode)
    (electric-indent-local-mode +1)
    (setq electric-indent-chars '(?\n ?})))
  (add-hook! c++-mode 'narf|init-c++-C11-highlights)

  (when IS-MAC
    (setq-default company-c-headers-path-system
                  (append '("/usr/include/" "/usr/local/include")
                          (f-directories "/usr/include/c++/")
                          (ignore-errors (f-directories "/usr/local/include/c++/"))))
{'fraction_non_alphanumeric': 0.21058315334773217, 'fraction_numerical': 0.002591792656587473, 'mean_word_length': 2.5297256097560976, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1736977', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1744, 'n_words': 320}