[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs -Q pkg debug helper macro

From: Kaushal Modi
Subject: emacs -Q pkg debug helper macro
Date: Tue, 12 Jul 2016 20:31:26 +0000

Hi all,

Recently while debugging the behavior of an external package in an emacs -Q session, I came up with the below.

Would it be helpful to have this or something similar in the core?

(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 '(((\"org\" . \"http://orgmode.org/elpa/\") . (org)))
       (org-mode)) "
  (declare (indent 1) (debug t))
     (require 'package)
     (setq user-emacs-directory (concat temporary-file-directory
                                        (getenv "USER") "/" ".emacs.d-debug/"))
     (setq package-user-dir (concat user-emacs-directory "elpa/"))
     (let ((pkgs ()))
       (dolist (archive-alist ,pkg-alist)
         (add-to-list 'package-archives (car archive-alist) :append)
         (setq pkgs (append pkgs (cdr archive-alist))))

       (dolist (pkg pkgs)
         (package-install pkg)
         (require pkg))


That way, a user can just add something like below in their emacs bug reports:

(emacs-pkg-debug-setup '((("melpa" . "http://melpa.org/packages/") . (projectile)))

Then anyone can safe evaluate just that little form in a fresh emacs -Q session, and let the emacs-pkg-debug-setup macro handle the package-archives updating and package installation. The packages get installed to "/tmp/$USER/.emacs.d-debug/elpa/" by default.


Kaushal Modi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]