all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacs -Q pkg debug helper macro
@ 2016-07-12 20:31 Kaushal Modi
  2016-07-12 20:44 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Kaushal Modi @ 2016-07-12 20:31 UTC (permalink / raw
  To: Emacs developers

[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: emacs -Q pkg debug helper macro
  2016-07-12 20:31 emacs -Q pkg debug helper macro Kaushal Modi
@ 2016-07-12 20:44 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2016-07-12 20:44 UTC (permalink / raw
  To: emacs-devel

> 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))

FWIW, I'm always uneasy when running foreign code before I can look
at it.


        Stefan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-12 20:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-12 20:31 emacs -Q pkg debug helper macro Kaushal Modi
2016-07-12 20:44 ` Stefan Monnier

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.