From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: Elpa packages and macro dependencies. Date: Mon, 20 Oct 2014 10:33:58 +0100 Message-ID: References: <87h9yz5d9h.fsf@yahoo.fr> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1413797655 11900 80.91.229.3 (20 Oct 2014 09:34:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Oct 2014 09:34:15 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Nicolas Richard Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 20 11:34:07 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xg9Lq-00074C-D0 for ged-emacs-devel@m.gmane.org; Mon, 20 Oct 2014 11:34:06 +0200 Original-Received: from localhost ([::1]:43533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xg9Ln-0000zw-K2 for ged-emacs-devel@m.gmane.org; Mon, 20 Oct 2014 05:34:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xg9Lk-0000zm-GE for emacs-devel@gnu.org; Mon, 20 Oct 2014 05:34:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xg9Lj-0007kB-FU for emacs-devel@gnu.org; Mon, 20 Oct 2014 05:34:00 -0400 Original-Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:51943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xg9Lj-0007k2-BT for emacs-devel@gnu.org; Mon, 20 Oct 2014 05:33:59 -0400 Original-Received: by mail-oi0-f50.google.com with SMTP id i138so3347825oig.37 for ; Mon, 20 Oct 2014 02:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=kFaw+JST7OxNoDKmFAvyHgac/XY6De8xQ3i2OouxKTQ=; b=vAoy0JS3ON5xEG/uMtXM4fR0OJNS9fwkHZPQeHWYSuNUpyzUZ8ZUpbJO2n5Ow26y4u QFyWvcV+XqYpyZqvi1q4Hy8LkyCoIdBhTEPxKtkzfnhMeVnOUmr+OjpE4Bq8F1Kri+3S JEWFpXICpcbTwTzSqNO34EJtkfVzHPl2jVXffL2SfJmn3C2WZ6iF5YnrrP5J/MnzvsKL oqXLkYANIeYVa2jt3AHVI1KCEXZ9x9L6C0unICYlGT/++YVEKnpdU+2Rucayd8v7dfHT ++5niSJrW8RlR/Cv1F7dfY+5mx3TWOQNsDuPWn/B70WMjQxcLVUlwIJ9L/6DzF488wRa hf6Q== X-Received: by 10.182.49.198 with SMTP id w6mr1376119obn.43.1413797638402; Mon, 20 Oct 2014 02:33:58 -0700 (PDT) Original-Received: by 10.76.1.137 with HTTP; Mon, 20 Oct 2014 02:33:58 -0700 (PDT) In-Reply-To: <87h9yz5d9h.fsf@yahoo.fr> X-Google-Sender-Auth: WQoRmGml3qI_2rHfpwqP9sxQMR0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c06::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:175580 Archived-At: >> - Packages can include several files, so we have to figure out the set >> of files to load and (here's the rub) the order in which to load them. > > It could be approximated by doing it in the order found in load-history. > Thanks for the idea, Nicolas. I was struggling a bit with that part. Here's what I had in mind. (I can turn this in to a patch, of course) Inside the package-activate-1 function, immediately after loading the =E2=80=9Cautoloads=E2=80=9D file (which happens invariably), we call load o= n each file in this package corresponding to features already loaded. Here's the relevant snippet: ________________________________ (with-demoted-errors (load (expand-file-name autoload-name 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. (mapcar (lambda (file) (load (expand-file-name file pkg-dir) nil t)) ;; The autoloads file is usually not a feature, but better stay s= afe. (remove autoload-name (package-list-loaded-files pkg-dir)))) ________________________________ The package-list-loaded-files function is then defined as follows. We don't need to worry about inter-package dependency here, package.el has already taken care of calling package-install in the right order. We DO need to worry about intra-package dependencies (which files require which), so we load them in the same order in which they were originally added to features (thanks to Nicolas' idea). This should be correct as long as the order in which files require each other doesn't change between versions. And even when it does change, this can only cause problems in situations where the current implementation already causes problems anyway. ________________________________ (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 sorted 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)))))) ________________________________ Haven't had time to test a full installation yet. But I've verified package-list-loaded-files works.