unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Artur Malabarba <bruce.connor.am@gmail.com>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Elpa packages and macro dependencies.
Date: Thu, 13 Nov 2014 11:57:06 +0000	[thread overview]
Message-ID: <CAAdUY-+4QaDidiD=LRpe-r5q5OOb2dg3OUBUGoT2ShQzNXC1Ww@mail.gmail.com> (raw)
In-Reply-To: <CAAdUY-JO=7Yu19JQfFYZ9yHeDHRfpUTkn=tAit5o77TahT-sxw@mail.gmail.com>

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

2014-10-20 10:33 GMT+01:00 Artur Malabarba <bruce.connor.am@gmail.com>:

> Here's what I had in mind. [...]

So, where are we on this?

I'm attaching a proper patch.
To reiterate, this makes package.el, after installing a package, call
`load` on any file which corresponds to an already loaded fature.
This should fix packages whose upgrade is messed up because of macro
dependencies.

Is it ok to apply or is it too hacky?

[-- Attachment #2: 0001-lisp-emacs-lisp-package.el-Reload-loaded-packages-af.patch --]
[-- Type: application/octet-stream, Size: 2819 bytes --]

From d3f79fe7d21f804a90ac055bddb0427e0d6da19d Mon Sep 17 00:00:00 2001
From: Artur Malabarba <bruce.connor.am@gmail.com>
Date: Thu, 13 Nov 2014 11:51:35 +0000
Subject: [PATCH] lisp/emacs-lisp/package.el: Reload loaded packages after
 installation.

---
 lisp/emacs-lisp/package.el | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 4e5c397..34e200e 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -524,9 +524,16 @@ Return the max version (as a string) if the package is held at a lower version."
       (error "Internal error: unable to find directory for `%s'"
 	     (package-desc-full-name pkg-desc)))
     ;; Add to load path, add autoloads, and activate the package.
-    (let ((old-lp load-path))
-      (with-demoted-errors
-        (load (expand-file-name (format "%s-autoloads" name) pkg-dir) nil t))
+    (let ((old-lp load-path)
+          (autoloads-file (format "%s-autoloads" name)))
+      (with-demoted-errors (format "Error loading %s: %%s" name)
+        (load (expand-file-name autoloads-file pkg-dir) nil t)
+        ;; Call `load' on all files in `pkg-dir' which correspond to
+        ;; provided features. Skip autoloads file since we already
+        ;; evaluated it above.
+        (mapc (lambda (file) (load (expand-file-name file pkg-dir) nil t))
+              ;; The autoloads file is usually not a feature, but better stay safe.
+              (remove autoloads-file (package-list-loaded-files pkg-dir))))
       (when (and (eq old-lp load-path)
                  (not (or (member pkg-dir load-path)
                           (member pkg-dir-dir load-path))))
@@ -543,6 +550,24 @@ Return the max version (as a string) if the package is held at a lower version."
     ;; Don't return nil.
     t))
 
+(defun package-list-loaded-files (dir)
+  "List all files in DIR which correspond to loaded features.
+Returns the `file-name-base' of each file, sorted by most
+recently loaded last."
+  (mapcar
+   ;; Turn the list of cons back into a list of files.
+   #'car
+   (sort
+    (remove nil (mapcar 
+                 (lambda (x) (let* ((name (file-name-base x))
+                               (hist (memq (intern-soft name) features)))
+                          ;; Return (FILENAME . HISTORY-POSITION)
+                          (when hist
+                            (cons name (length hist)))))
+                 (directory-files "./" nil "^[^\\.].*\\.el\\'" 'nosort)))
+    ;; The cdr is the position in history
+    (lambda (x y) (< (cdr x) (cdr y))))))
+
 (defun package-built-in-p (package &optional min-version)
   "Return true if PACKAGE is built-in to Emacs.
 Optional arg MIN-VERSION, if non-nil, should be a version list
-- 
1.7.12.4


  parent reply	other threads:[~2014-11-13 11:57 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-16 16:06 Elpa packages and macro dependencies bruce.connor.am
2014-10-16 16:09 ` Glenn Morris
2014-10-16 16:56   ` bruce.connor.am
2014-10-16 16:59   ` Thierry Volpiatto
2014-10-16 17:44   ` Stefan Monnier
2014-10-16 17:57     ` bruce.connor.am
2014-10-16 19:57       ` Stefan Monnier
2014-10-17  8:28         ` bruce.connor.am
2014-10-17 15:54           ` bruce.connor.am
2014-10-17 16:36             ` Stefan Monnier
2014-10-17 21:24               ` bruce.connor.am
2014-10-18 21:41                 ` Stefan Monnier
2014-10-20  8:58                   ` Nicolas Richard
2014-10-20  9:33                     ` Artur Malabarba
2014-10-20 19:04                       ` Stefan Monnier
2014-10-20 20:25                         ` Artur Malabarba
2014-10-20 20:40                           ` Stefan Monnier
2014-11-13 11:57                       ` Artur Malabarba [this message]
2014-11-13 17:34                         ` Stefan Monnier
2014-12-10 18:38                           ` Artur Malabarba
2014-12-10 19:14                             ` Stefan Monnier
2014-10-19  6:57               ` Achim Gratz
2014-10-20 15:29                 ` Stefan Monnier
2014-10-20 16:34                   ` Achim Gratz
2014-10-20 18:00                     ` Stefan Monnier
2014-10-20 19:16                       ` Achim Gratz
2014-10-20 21:04                         ` Stefan Monnier
2014-10-21 17:41                           ` Achim Gratz
2014-10-16 21:05     ` Achim Gratz
2014-10-17  3:03       ` Stefan Monnier
2014-10-17  8:01         ` Achim Gratz
2014-10-17 12:03           ` Phillip Lord
2014-10-17 13:51             ` Tom Tromey
2014-10-17 12:39           ` Stefan Monnier
2014-10-17  8:39       ` bruce.connor.am

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CAAdUY-+4QaDidiD=LRpe-r5q5OOb2dg3OUBUGoT2ShQzNXC1Ww@mail.gmail.com' \
    --to=bruce.connor.am@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).