all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Levin Du <zslevin@gmail.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [PATCH] package.el: remove duplicated package path in load-path
Date: Wed, 28 Aug 2013 13:57:53 -0400	[thread overview]
Message-ID: <jwv7gf5hft4.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAN6cQGPuNb9y9ieqkZbrziHdvvMa-Z2Eikf1yR=HpiwtbvoZtw@mail.gmail.com> (Levin Du's message of "Wed, 28 Aug 2013 15:11:25 +0800")

>    I find package.el will add duplicate package path to load-path.
> One is (push pkg-dir load-path) in package-activate-1,
> another is

>    (add-to-list 'load-path (or (file-name-directory #$) (car load-path)))

> in the generated PACKAGE-autoloads.el which will be also loaded in
> package-activate-1.

Indeed, in the past, <pkg>-autoloads.el did not tweak load-path itself,
which is why we do it in package-activate-1.  But I don't understand why
you have duplicate entries, since the first command will be (push
pkg-dir load-path) bu the second (in <pkg>-autoloads.el) is an
`add-to-list' which should hopefully avoid the duplication.

...oh wait, I see, the two directories are not equal (one ends in slash
while the other doesn't).
I installed the patch below to try and address this problem.


        Stefan


=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2013-08-28 16:39:51 +0000
+++ lisp/ChangeLog	2013-08-28 17:56:49 +0000
@@ -1,3 +1,8 @@
+2013-08-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* emacs-lisp/package.el (package-activate-1): Don't add unnecessarily
+	to load-path.
+
 2013-08-28  Juri Linkov  <juri@jurta.org>
 
 	* isearch.el (isearch-reread-key-sequence-naturally): Use non-nil

=== modified file 'lisp/emacs-lisp/package.el'
--- lisp/emacs-lisp/package.el	2013-08-27 08:01:13 +0000
+++ lisp/emacs-lisp/package.el	2013-08-28 17:53:17 +0000
@@ -457,19 +457,26 @@
 
 (defun package-activate-1 (pkg-desc)
   (let* ((name (package-desc-name pkg-desc))
-	 (pkg-dir (package-desc-dir pkg-desc)))
+	 (pkg-dir (package-desc-dir pkg-desc))
+         (pkg-dir-dir (file-name-as-directory pkg-dir)))
     (unless pkg-dir
       (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))
+      (load (expand-file-name (format "%s-autoloads" name) pkg-dir) nil t)
+      (when (and (eq old-lp load-path)
+                 (not (or (member pkg-dir load-path)
+                          (member pkg-dir-dir load-path))))
+        ;; Old packages don't add themselves to the `load-path', so we have to
+        ;; do it ourselves.
+        (push pkg-dir load-path)))
     ;; Add info node.
     (when (file-exists-p (expand-file-name "dir" pkg-dir))
       ;; FIXME: not the friendliest, but simple.
       (require 'info)
       (info-initialize)
       (push pkg-dir Info-directory-list))
-    ;; Add to load path, add autoloads, and activate the package.
-    (push pkg-dir load-path)
-    (load (expand-file-name (format "%s-autoloads" name) pkg-dir) nil t)
     (push name package-activated-list)
     ;; Don't return nil.
     t))




      reply	other threads:[~2013-08-28 17:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-28  7:11 [PATCH] package.el: remove duplicated package path in load-path Levin Du
2013-08-28 17:57 ` Stefan Monnier [this message]

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=jwv7gf5hft4.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=zslevin@gmail.com \
    /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.