all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: emacs -Q pkg debug helper macro
Date: Tue, 12 Jul 2016 20:31:26 +0000	[thread overview]
Message-ID: <CAFyQvY0rLP+V5d3WOaV2HA8xahuHovx00qZ+T+GGpbgX-Qo=1Q@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1889 bytes --]

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))
  `(progn
     (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))))
       (package-initialize)
       (package-refresh-contents)

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

       ,@body
       )))

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)))
  (projectile-global-mode))

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

[-- Attachment #2: Type: text/html, Size: 2828 bytes --]

             reply	other threads:[~2016-07-12 20:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12 20:31 Kaushal Modi [this message]
2016-07-12 20:44 ` emacs -Q pkg debug helper macro Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFyQvY0rLP+V5d3WOaV2HA8xahuHovx00qZ+T+GGpbgX-Qo=1Q@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.