   (c-add-style "allman" user/allman-style)
   (c-add-style "sane-k&r" user/k&r-style)
   (c-add-style "webkit" user/webkit-style)
+
+  (advice-add 'c-electric-brace :around #'user/cleanup-empty-lines)
 
   (csetq c-default-style '((java-mode . "java")
                            (awk-mode . "awk")

                          (topmost-intro-cont      .  0)
                          (knr-argdecl-intro       . -4)
                          (brace-list-open         .  0)
                          (brace-list-intro        .  4)))))

  (defun user/c-mode-common-hook ()
    "Hook for C/C++ mode."
    ;; (c-toggle-hungry-state t)
    ;; (c-toggle-auto-newline -1)
    (c-toggle-syntactic-indentation t)

    (modify-syntax-entry ?' ".")

                      (join-line -1)))))
            (error nil))))))

  (defun user/cleanup-empty-lines (orig-func &rest args)
    (when (eq last-input-event ?})
      (save-mark-and-excursion
        (when (looking-at-p "\\([[:space:]]*\n\\)+")
          (delete-horizontal-space)
          (delete-blank-lines)

          (when (looking-at-p "^[[:space:]]*\n")
            (kill-line)))))

    (apply orig-func args))

  :ghook ('c-mode-common-hook #'user/c-mode-common-hook)

  :custom
