aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-04-28 11:08:40 +0100
committerArtur Malabarba2015-04-28 11:08:40 +0100
commitfecd155703ee2e546bee1749e9e0fb97bab357eb (patch)
tree24d35842833a76bc0dc731b9fba6778b6748a14e
parentf660f360908a81a01336af3e0e57f2c921726430 (diff)
downloademacs-fecd155703ee2e546bee1749e9e0fb97bab357eb.tar.gz
emacs-fecd155703ee2e546bee1749e9e0fb97bab357eb.zip
* lisp/emacs-lisp/package.el: Skip space and comments in init file
(package--ensure-init-file): Insert snippet at first non-whitespace non-comments line. Respects local-vars at the top of the file.
-rw-r--r--lisp/emacs-lisp/package.el5
1 files changed, 5 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 81e0ee970e0..bb9a3bb8229 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1813,6 +1813,7 @@ using `package-compute-transaction'."
1813 (widen) 1813 (widen)
1814 (goto-char (point-min)) 1814 (goto-char (point-min))
1815 (search-forward "(package-initialize)" nil 'noerror)))) 1815 (search-forward "(package-initialize)" nil 'noerror))))
1816 ;; Don't visit the file if we don't have to.
1816 (with-temp-buffer 1817 (with-temp-buffer
1817 (insert-file-contents user-init-file) 1818 (insert-file-contents user-init-file)
1818 (goto-char (point-min)) 1819 (goto-char (point-min))
@@ -1825,7 +1826,11 @@ using `package-compute-transaction'."
1825 (save-restriction 1826 (save-restriction
1826 (widen) 1827 (widen)
1827 (goto-char (point-min)) 1828 (goto-char (point-min))
1829 (while (and (looking-at-p "[[:blank:]]*\\(;\\|$\\)")
1830 (not (eobp)))
1831 (forward-line 1))
1828 (insert 1832 (insert
1833 "\n"
1829 ";; Added by Package.el. This must come before configurations of\n" 1834 ";; Added by Package.el. This must come before configurations of\n"
1830 ";; installed packages. Don't delete this line. If you don't want it,\n" 1835 ";; installed packages. Don't delete this line. If you don't want it,\n"
1831 ";; just comment it out by adding a semicolon to the start of the line.\n" 1836 ";; just comment it out by adding a semicolon to the start of the line.\n"