   "Reload init.el. With prefix argument, upgrades packages."
   (interactive "P")
   (message "Reloading init.el...")
-  (setq radian--inhibit-loading-quelpa (not upgrade))
   (radian-load-user-config "init.el")
   (message "Reloading init.el... done."))
 


(advice-add 'use-package
            :around 'radian--use-package-add-dependencies
            '((:depth . -2)))

;; Add an advice to automatically refresh the package list before
;; installing a package (but only once). This has an effect because
;; `use-package' eventually calls through to `package-install'.
;;
;; If we don't do this, then we might get errors when you try to
;; install a package with `use-package' without first manually running
;; `package-refresh-contents'. Specifically, this will happen if the
;; package you are trying to install has been updated since the last
;; time `package-refresh-contents' was run (or, by default, the first
;; time you ever tried to install a package).
;;
;; The issue is discussed at [1], but the solution used here is
;; modified so that it does not require `cl' (currently, Radian only
;; loads `cl-lib').
;;
;; [1]: https://github.com/jwiegley/use-package/issues/256

(defun radian--package-install-refresh-contents (&rest args)
  (package-refresh-contents)
  (advice-remove 'package-install 'radian--package-install-refresh-contents))

(advice-add 'package-install :before 'radian--package-install-refresh-contents)

;; Library for fetching Elisp packages in many different ways and
;; building them from source (client-side MELPA).
(use-package quelpa
  :config

  ;; Tell quelpa not to update MELPA every time Emacs is started.
  (setq quelpa-update-melpa-p nil)

  ;; Automatically upgrade packages. This does not actually take
  ;; effect if the call to quelpa comes from a `:quelpa' keyword in a
  ;; `use-package' form and
  ;; `quelpa-use-package-inhibit-loading-quelpa' is non-nil (as it is
  ;; by default in Radian). It only affects what happens when
  ;; `radian-reload-init' is called with a prefix argument; in that
  ;; case it allows packages to be upgraded, as desired.
  (setq quelpa-upgrade-p t))

;; Add a :quelpa keyword to `use-package', which allows installing
;; packages with quelpa. We have a bit of a chicken and egg problem
;; here. We don't want to load quelpa during startup, because that's
;; slow. But quelpa-use-package loads quelpa eagerly. So we have to
;; use my fork of quelpa-use-package, which fixes that. But installing
;; from a fork requires quelpa. But we don't want to load it eagerly.
;; So we have to use my fork of quelpa-use-package...
;;
;; The solution here is to use two separate code paths. On first
;; install, quelpa will be loaded eagerly and used to install
;; quelpa-use-package. But after that, quelpa-use-package can install
;; itself, thus solving the problem of quelpa being loaded eagerly.
;;
;; (Note that, as long as we are using my fork, loading
;; quelpa-use-package eagerly is not a problem. In fact, it's required
;; because we need to activate its advice before processing
;; use-package forms that might contain `:quelpa' keywords.)
;;
;; To maintain reverse compatibility, my fork of quelpa-use-package
;; only lazily loads quelpa if the variable
;; `quelpa-use-package-inhibit-loading-quelpa' is non-nil (it is nil
;; by default). So we have to set it here. But we also want to allow
;; for disabling that optimization in the case that
;; `radian-reload-init' is called with a prefix argument. To solve
;; this problem we use `defvar', which will only set
;; `radian--inhibit-loading-quelpa' to `t' if that variable has not
;; already been defined. That way, we can override the value of
;; `radian--inhibit-loading-quelpa' in `radian-reload-init' and have
;; that value be transferred to
;; `quelpa-use-package-inhibit-loading-quelpa' below, while
;; maintaining a default value of `t' when Emacs is first started.

(defvar radian--inhibit-loading-quelpa t)
(setq quelpa-use-package-inhibit-loading-quelpa
      radian--inhibit-loading-quelpa)

(if (require 'quelpa-use-package nil 'noerror)
    (progn
      ;; If I don't include this then I get an error about eager
      ;; macro-expansion because the `:quelpa' keyword in the next
      ;; use-package form is not defined for the compiler.
      (eval-when-compile
        (require 'quelpa-use-package))
      (use-package quelpa-use-package
        :quelpa (quelpa-use-package
                 :fetcher github
                 :repo "raxod502/quelpa-use-package")
        :demand t))
  (quelpa '(quelpa-use-package
            :fetcher github
            :repo "raxod502/quelpa-use-package"))
  (require 'quelpa-use-package))

;; Allow the :quelpa keyword to work even when
;; `use-package-always-ensure' is enabled. See [1].
;;
;; [1]: https://github.com/quelpa/quelpa-use-package
(quelpa-use-package-activate-advice)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Packages: Emacs Lisp

;; Future-proof your Emacs Lisp customizations.
(use-package el-patch
  :demand t
  :quelpa (el-patch :fetcher github :repo "raxod502/el-patch"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Startup

;; Remembers your choices in completion menus.
(with-eval-after-load 'ivy
  (use-package historian
    :recipe (:fetcher github
             :repo "PythonNut/historian.el")
    :demand t
    :config
