diff options
| author | Artur Malabarba | 2015-04-05 11:01:09 +0100 |
|---|---|---|
| committer | Artur Malabarba | 2015-04-05 11:06:20 +0100 |
| commit | fdc521952e6d68fa603aac899fe4c08e0a2ed480 (patch) | |
| tree | 405c4194a8509a0c762efb8d6b422ace3249b19f | |
| parent | b47fe819f70cd48c5ca26e37843b878ecc0d0b66 (diff) | |
| download | emacs-fdc521952e6d68fa603aac899fe4c08e0a2ed480.tar.gz emacs-fdc521952e6d68fa603aac899fe4c08e0a2ed480.zip | |
emacs-lisp/package.el: Add package-initialize to user-init-file.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 26 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0870f0cad31..fb82b5b574a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2015-04-05 Artur Malabarba <bruce.connor.am@gmail.com> | ||
| 2 | |||
| 3 | * emacs-lisp/package.el: Add package-initialize to user-init-file. | ||
| 4 | (package--ensure-init-file): New function. | ||
| 5 | (package-install, package-install-from-buffer): Use it. | ||
| 6 | |||
| 1 | 2015-04-05 Pete Williamson <petewil@chromium.org> (tiny-change) | 7 | 2015-04-05 Pete Williamson <petewil@chromium.org> (tiny-change) |
| 2 | 8 | ||
| 3 | Fix .emacs and .emacs.d/init file recursion problem for NaCl | 9 | Fix .emacs and .emacs.d/init file recursion problem for NaCl |
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 83c5b2f6b10..18802701a0a 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -1723,6 +1723,30 @@ PACKAGES are satisfied, i.e. that PACKAGES is computed | |||
| 1723 | using `package-compute-transaction'." | 1723 | using `package-compute-transaction'." |
| 1724 | (mapc #'package-install-from-archive packages)) | 1724 | (mapc #'package-install-from-archive packages)) |
| 1725 | 1725 | ||
| 1726 | (defun package--ensure-init-file () | ||
| 1727 | "Ensure that the user's init file calls `package-initialize'." | ||
| 1728 | ;; Don't mess with the init-file from "emacs -Q". | ||
| 1729 | (when user-init-file | ||
| 1730 | (let ((buffer (find-buffer-visiting user-init-file))) | ||
| 1731 | (with-current-buffer (or buffer (find-file-noselect user-init-file)) | ||
| 1732 | (save-excursion | ||
| 1733 | (save-restriction | ||
| 1734 | (widen) | ||
| 1735 | (goto-char (point-min)) | ||
| 1736 | (unless (search-forward "(package-initialize)" nil 'noerror) | ||
| 1737 | (goto-char (point-min)) | ||
| 1738 | (insert | ||
| 1739 | ";; Added by Package.el. This must come before configurations of\n" | ||
| 1740 | ";; installed packages. Don't delete this line. If you don't want it,\n" | ||
| 1741 | ";; just comment it out by adding a semicolon to the start of the line.\n" | ||
| 1742 | "(package-initialize)\n") | ||
| 1743 | (unless (looking-at-p "$") | ||
| 1744 | (insert "\n")) | ||
| 1745 | (let ((file-precious-flag t)) | ||
| 1746 | (save-buffer))) | ||
| 1747 | (unless buffer | ||
| 1748 | (kill-buffer (current-buffer))))))))) | ||
| 1749 | |||
| 1726 | ;;;###autoload | 1750 | ;;;###autoload |
| 1727 | (defun package-install (pkg &optional dont-select) | 1751 | (defun package-install (pkg &optional dont-select) |
| 1728 | "Install the package PKG. | 1752 | "Install the package PKG. |
| @@ -1751,6 +1775,7 @@ to install it but still mark it as selected." | |||
| 1751 | package-archive-contents)) | 1775 | package-archive-contents)) |
| 1752 | nil t)) | 1776 | nil t)) |
| 1753 | nil))) | 1777 | nil))) |
| 1778 | (package--ensure-init-file) | ||
| 1754 | (let ((name (if (package-desc-p pkg) | 1779 | (let ((name (if (package-desc-p pkg) |
| 1755 | (package-desc-name pkg) | 1780 | (package-desc-name pkg) |
| 1756 | pkg))) | 1781 | pkg))) |
| @@ -1794,6 +1819,7 @@ is derived from the main .el file in the directory. | |||
| 1794 | 1819 | ||
| 1795 | Downloads and installs required packages as needed." | 1820 | Downloads and installs required packages as needed." |
| 1796 | (interactive) | 1821 | (interactive) |
| 1822 | (package--ensure-init-file) | ||
| 1797 | (let* ((pkg-desc | 1823 | (let* ((pkg-desc |
| 1798 | (cond | 1824 | (cond |
| 1799 | ((derived-mode-p 'dired-mode) | 1825 | ((derived-mode-p 'dired-mode) |