 
 ;;;;;; Utility functions
 
+;; We don't define `straight--profile-cache' until later. (Should some
+;; things be rearranged to make this unnecessary?)
+(defvar straight--profile-cache)
+
+(cl-defun straight--magit-status (directory)
+  "Like `magit-status', but install Magit if necessary.
+Magit is only installed if the user responds to a `y-or-n-p'
+prompt. Return non-nil if Magit was installed. DIRECTORY is as in
+`magit-status'."
+  (unless (or (require 'magit nil 'noerror)
+              (gethash "magit" straight--profile-cache))
+    (if (y-or-n-p "Install Magit? ")
+        (straight-use-package 'magit)
+      (cl-return-from straight--magit-status)))
+  (prog1 t
+    (magit-status-internal directory)))
+
 (defun straight-vc-git--popup-raw (prompt actions)
   "Same as `straight-popup-raw', but specialized for vc-git methods.
 Two additional actions are inserted at the end of the list: \"e\"

    '(("e" "Dired and open recursive edit"
       (lambda ()
         (dired (or straight--default-directory default-directory))
         (recursive-edit)))
      ("g" "Magit and open recursive edit"
       (lambda ()
         (magit-status-internal
          (or straight--default-directory default-directory))
         (recursive-edit)))))))

(defmacro straight-vc-git--popup (prompt &rest actions)
  "Same as `straight-popup', but specialized for vc-git methods.


;; `magit'
(declare-function magit-status-internal "magit-status")

;; `use-package'
(defvar use-package-defaults)
(defvar use-package-ensure-function)
(defvar use-package-keywords)
(defvar use-package-pre-ensure-function)
(declare-function use-package-as-symbol "use-package")
(declare-function use-package-only-one "use-package")
(declare-function use-package-process-keywords "use-package")

;;;; Customization variables

