 
 Basic examples:
 
-  (set-formatter! '(asm-mode nasm-mode) \"asmfmt\")
-  (set-formatter! 'python-mode \"black -q -\" :install \"pip install black\")
-  (set-formatter! 'tidy \"tidy -q -indent\" :modes '(html-mode web-mode))
+  (set-formatter! 'asmfmt \"asmfmt\" :modes '(asm-mode nasm-mode))
+  (set-formatter! 'black \"black -q -\")
+  (set-formatter! 'html-tidy \"tidy -q -indent\" :modes '(html-mode web-mode))
 
 Advanced examples:
 
   (set-formatter!
+    'clang-format
+    '(\"clang-format\"
+      (\"-assume-filename=%S\" (or buffer-file-name mode-result \"\")))
+    :modes
     '((c-mode \".c\")
       (c++-mode \".cpp\")
       (java-mode \".java\")
       (objc-mode \".m\")
-      (protobuf-mode \".proto\"))
-    '(\"clang-format\"
-      (\"-assume-filename=%S\" (or buffer-file-name mode-result \"\")))
-    :install '(macos \"brew install clang-format\"))
-
-  (set-formatter!
+      (protobuf-mode \".proto\")))
+
+  (set-formatter! 'html-tidy
+    '(\"tidy\" \"-q\" \"-indent\"
+      (\"-xml\" (memq major-mode '(nxml-mode xml-mode))))
+    :modes
     '(html-mode
       (web-mode (and (equal \"none\" web-mode-engine)
                      (car (member web-mode-content-type '(\"xml\" \"html\"))))))
-    '(\"tidy\" \"-q\" \"-indent\"
-      (\"-xml\" (memq major-mode '(nxml-mode xml-mode))))
     :ok-statuses '(0 1)
-    :install '(macos \"brew install tidy-html5\"))
+    :executable \"tidy\")
 
   (set-formatter! 'html-tidy  ; overwrite predefined html-tidy formatter
     '(\"tidy\" \"-q\" \"-indent\"

      (\"-xml\" (memq major-mode '(nxml-mode xml-mode))))
    :ok-statuses '(0 1)))

  (set-formatter! 'elm-mode
    \"elm-format --yes --stdin\"
    :install '(macos \"brew install elm\")
    :filter
    (lambda (output errput first-diff)
      (list output
            (format-all-remove-ansi-color errput)
            first-diff)))"
  (declare (indent defun))
  (cl-check-type name (or symbol null))
  ;; Determine if MODES-OR-NAME means MODES or NAMES
  (if (and (symbolp modes-or-name)
           (not (string-match-p "-mode$" (symbol-name modes-or-name))))
      (setq name modes-or-name)
    (setq modes (doom-enlist modes-or-name)))
  (let* ((command-list (cond ((stringp formatter)   ; shell command
                              (split-string formatter " " t))
                             ((listp formatter)     ; shell command in lists
                              formatter)))
         (name (cond (name)
                     ((car command-list) (intern (car command-list)))
                     ((symbolp formatter) formatter)
                     ((user-error "Anonymous formatter requires a :name"))))
         (formatter
          (cond ((commandp formatter)
                 `(format-all-buffer-thunk
                   (lambda (input)
                     (with-silent-modifications
                       (setq buffer-file-name ,(buffer-file-name (buffer-base-buffer))
                             default-directory ,default-directory)
                       (delay-mode-hooks (funcall ',major-mode))
                       (insert input)
                       (condition-case e
                           (progn (call-interactively #',formatter)
                                  (list nil ""))
                         (error (list t (error-message-string e))))))))
                ((functionp formatter)
                 `(format-all-buffer-thunk #',formatter))
                (`(let (args)
                    (dolist (arg ',command-list)
                      (cond ((stringp arg) (push arg args))
                            ((listp arg)
                             (catch 'skip
                               (let (subargs this)
                                 (while (setq this (pop arg))
                                   (cond ((not (stringp (car arg)))
                                          (let ((val (eval (pop arg) t)))
                                            (unless val (throw 'skip nil))
                                            (push (format this val) subargs)))
                                         ((stringp this)
                                          (push this subargs))))
                                 (setq args (append subargs args)))))))
                    (if ,(and (or ok-statuses error-regexp) t)
                        (apply #'format-all-buffer-hard
                               ',ok-statuses ,error-regexp
                               (reverse args))
                      (apply #'format-all-buffer-easy (reverse args)))))))
         (fn
          `(lambda (executable mode-result)
             (let ((result ,formatter))
               ,(if filter
                    `(apply #',filter result)
                  'result))))
         (install (cond ((null install) install)
                        ((listp install)
                         (cdr (assq (+format--resolve-system) install)))
                        (install))))
    (after! format-all
      (puthash name (eval fn t) format-all-format-table)
      (puthash name (car command-list) format-all-executable-table)
      (puthash name (or install (gethash name format-all-install-table))
               format-all-install-table)
      (dolist (mode (doom-enlist modes))
        (cl-destructuring-bind (m &optional probe)
            (doom-enlist mode)
          (format-all-pushhash
           m (cons name (if probe `(lambda () ,probe)))
           format-all-mode-table))))
    name))

;;; editor/format/autoload/settings.el -*- lexical-binding: t; -*-

;; This must be redefined here because `format-all' only makes it available at
;; compile time.
(defconst +format-system-type
  (cl-case system-type
    (windows-nt 'windows)
