                ;; Replacing the buffer now would undo the user’s changes.
                (user-error (concat "The buffer has been changed "
                                    "before the header could be inserted")))
-             (clang-include-fixer--replace-buffer stdout)))
+             (clang-include-fixer--replace-buffer stdout)
+             (let-alist context
+               (let-alist (car .HeaderInfos)
+                 (run-hook-with-args 'clang-include-fixer-add-include-hook
+                                     (substring .Header 1 -1)
+                                     (string= (substring .Header 0 1) "<"))))))
          (format "-insert-header=%s"
                  (clang-include-fixer--encode-json context)))))))
   nil)

  (let ((symbol (clang-include-fixer--symbol-at-point)))
    (unless symbol
      (user-error "No symbol at current location"))
    (clang-include-fixer--start #'clang-include-fixer--add-header
                                (format "-query-symbol=%s" symbol))))

(defun clang-include-fixer--start (callback &rest args)
  "Asynchronously start clang-include-fixer with parameters ARGS.

(defgroup clang-include-fixer nil
  "Clang-based include fixer."
  :group 'tools)

(defvar clang-include-fixer-add-include-hook nil
  "A hook that will be called for every added include.
The first argument is the filename of the include, the second argument is
non-nil if the include is a system-header.")

(defcustom clang-include-fixer-executable
  "clang-include-fixer"
