 
 A string containing the name or the full path of the executable."
   :group 'clang-format
-  :type 'string
+  :type '(file :must-match t)
   :risky t)
 
 (defcustom clang-format-style "file"

;;   M-x package-install clang-format
;;
;; when ("melpa" . "http://melpa.org/packages/") is included in
;; `package-archives'. Alternatively, ensure the directory of this
;; file is in your `load-path' and add
;;
;;   (require 'clang-format)

  (unless style
    (setq style clang-format-style))

  (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate))
        (file-end (clang-format--bufferpos-to-filepos end 'approximate))
        (cursor (clang-format--bufferpos-to-filepos (point) 'exact))
        (temp-buffer (generate-new-buffer " *clang-format-temp*"))
        (temp-file (make-temp-file "clang-format")))
    (unwind-protect
        (let ((status (call-process-region
                       nil nil clang-format-executable
                       nil `(,temp-buffer ,temp-file) nil

                       "-output-replacements-xml"
                       "-assume-filename" (or (buffer-file-name) "")
                       "-style" style
                       "-offset" (number-to-string file-start)
                       "-length" (number-to-string (- file-end file-start))
                       "-cursor" (number-to-string cursor)))
              (stderr (with-temp-buffer
                        (unless (zerop (cadr (insert-file-contents temp-file)))
                          (insert ": "))
                        (buffer-substring-no-properties
                         (point-min) (line-end-position)))))
          (cond
           ((stringp status)
            (error "(clang-format killed by signal %s%s)" status stderr))
           ((not (zerop status))
            (error "(clang-format failed with code %d%s)" status stderr)))

          (cl-destructuring-bind (replacements cursor incomplete-format)
              (with-current-buffer temp-buffer
                (clang-format--extract (car (xml-parse-region))))
            (save-excursion
              (dolist (rpl replacements)
                (apply #'clang-format--replace rpl)))
            (when cursor
              (goto-char (clang-format--filepos-to-bufferpos cursor 'exact)))
            (if incomplete-format
                (message "(clang-format: incomplete (syntax errors)%s)" stderr)
              (message "(clang-format: success%s)" stderr))))
