                     (car e)
                     (buffer-string))))))))
 
+(defun doom--find-emacsapp-path ()
+  (or (getenv "EMACS_APP_PATH")
+      (cl-find-if #'file-directory-p
+                  (list "/usr/local/opt/emacs"
+                        "/usr/local/opt/emacs-plus"
+                        "/Applications"
+                        "~/Applications")
+                  :key (lambda (x) (concat x "/Emacs.app")))
+      (user-error "Couldn't find Emacs.app")))
+
 (defun doom-quickstart ()
   "Quickly deploy a private module and Doom.
 

        (with-temp-file config-file (insert ""))
        (print! (green "Done!")))))
  ;; Ask if Emacs.app should be patched
  (condition-case e
      (when IS-MAC
        (message "MacOS detected")
        (let ((appdir (cl-find-if #'file-directory-p
                                  (list "/Applications/Emacs.app"
                                        "~/Applications/Emacs.app"))))
          (unless appdir
            (user-error "Couldn't find Emacs.app in /Applications or ~/Applications"))
          (when (file-exists-p! "Contents/MacOS/RunEmacs" appdir)
            (user-error "Emacs.app is already patched"))
          (unless (or doom-auto-accept
                      (y-or-n-p
                       (concat "Doom would like to patch your Emacs.app bundle so that it respects\n"
                               "your shell configuration. For more information on why and how, run\n\n"
                               "  bin/doom help patch-macos\n\n"
                               "Patch Emacs.app?")))
            (user-error "Will not patch Emacs.app"))
          (doom-patch-macos nil)))
    (user-error (message "%s" (error-message-string e))))
  ;; Install Doom packages
  (print! "Installing plugins")
  (doom-packages-install doom-auto-accept)

  3. Add or remove autoloaded functions in module autoloaded files.
  4. Update Doom outside of Doom (e.g. with git)")

(dispatcher! (patch-macos)
  (doom-patch-macos (or (member "--undo" args)
                        (member "-u" args))
                    (doom--find-emacsapp-path))
  "Patches Emacs.app to respect your shell environment.

A common issue with GUI Emacs on MacOS is that it launches in an environment
