          (require pkg))
 
        ,@body)))
-;; (emacs-pkg-debug-setup '((nil . (hydra))
-;;                          (("melpa" . "http://melpa.org/packages/") . (use-package)))
+;; (emacs-pkg-debug-setup '((("melpa" . "https://melpa.org/packages/") . (use-package ox-hugo)))
 ;;   (message "Done!"))
 
 ;; http://stackoverflow.com/a/20747279/1219634

    emacs-build-info))

(defmacro emacs-pkg-debug-setup (pkg-alist &rest body)
  "Install packages in PKG-ALIST and evaluate BODY.
Each element of PKG-ALIST has the form (((ID . LOCATION) . (PKG1 PKG2 ..)) ..).
The ID and LOCATION are the same as the ones in `package-archives'.
PKG1, PKG2, .. are package names from the ID archive.

Example usage:

1. Launch 'emacs -Q'.
2. Copy this macro definition to its scratch buffer and evaluate it.
3. Evaluate a minimum working example using this macro as below:
     (emacs-pkg-debug-setup '(;; Install hydra from GNU Elpa
                              (nil . (hydra))
                              ;; Install org from Org Elpa
                              ((\"org\" . \"http://orgmode.org/elpa/\") . (org)))
       ;; Then evaluate the below forms
       (org-mode)) "
  (declare (indent 1) (debug t))
  `(progn
     (require 'package)

                                  dir))
     (setq package-user-dir (let ((elpa-dir-name (format "elpa_%s" emacs-major-version))) ;default = ~/.emacs.d/elpa/
                              (file-name-as-directory (expand-file-name elpa-dir-name user-emacs-directory))))
     (let (pkgs)
       (dolist (archive-alist ,pkg-alist)
         (when-let* ((archive (car archive-alist)))
           (add-to-list 'package-archives archive :append))
         (setq pkgs (append pkgs (cdr archive-alist))))
       ;; The `package-initialize' call is needed even in Emacs 27+
       ;; because we need to add our custom `package-user-directory'
       ;; and the underlying packages to the `load-path'.
       (package-initialize)
       (package-refresh-contents)

