--- ../emacs/lisp/emacs-lisp/package.el 2021-07-11 12:20:59.257657537 +0200 +++ ./package.el 2021-07-22 23:37:15.167925681 +0200 @@ -4137,7 +4137,9 @@ (package-activated-list ()) ;; Make sure we can load this file without load-source-file-function. (coding-system-for-write 'emacs-internal) - (Info-directory-list '(""))) + (Info-directory-list '("")) + (rx-path-beg "^(add-to-list 'load-path (directory-file-name") + path insertion-point temp-point) (dolist (elt package-alist) (condition-case err (package-activate (car elt)) @@ -4155,9 +4157,24 @@ (let ((load-suffixes '(".el" ".elc"))) (locate-library (package--autoloads-file-name pkg)))) (pfile (prin1-to-string file))) + ;; prepare list of all dirs to add to load-path + (push (package-desc-dir pkg) path) (insert "(let ((load-true-file-name " pfile ")\ (load-file-name " pfile "))\n") (insert-file-contents file) + (setq insertion-point (point)) + ;; since we are precomputing and pasting list of package directories + ;; to add to load-path, remove statements to add individual package from + ;; autoloads file + (goto-char insertion-point) + (when (re-search-forward rx-path-beg nil t) + (goto-char (line-beginning-position)) + (setq temp-point (point)) + (forward-sexp) + (when (search-backward file nil t 1) + (goto-char temp-point) + (kill-sexp))) + (goto-char insertion-point) ;; Fixup the special #$ reader form and throw away comments. (while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move) (unless (nth 8 (syntax-ppss)) @@ -4175,6 +4192,10 @@ (setq Info-directory-list (append ',info-dirs Info-directory-list))) (current-buffer)))) + (goto-char (point-min)) + (forward-line 3) + (insert (concat "\n(setq load-path (nconc '" (prin1-to-string path) " load-path))\n")) + (goto-char (point-max)) ;; Use `\s' instead of a space character, so this code chunk is not ;; mistaken for an actual file-local section of package.el. (insert "