6

I've just installed Emacs 25.1. My .emacs works well on Emacs 24.5. But now that I'm on Emacs 25.1, when I do M-x package-list-packages, Emacs modifies and write .emacs in the background with the following modifications in custom-set-variables and custom-set-faces :

(custom-set-variables
 '(package-selected-packages
   (quote
    (yaml-mode w3m toml-mode thing-cmds slime-company rust-mode revive proc-net paredit monky minibuf-isearch markdown-mode magit list-processes+ imenu-list google-this ggtags expand-region emacs-cl elnode elisp-slime-nav company-c-headers common-lisp-snippets column-enforce-mode cl-generic cl-format aggressive-indent))))

and that :

(custom-set-faces
 '(default ((t (:height 110 :family "Monospace")))))

How can I prevent Emacs doing this ?

  • You have two options :- 1. stop emacs from writing to your .emacs file (which is a bad idea) 2. make emacs write all the customize options to some other file. – Chakravarthy Raghunandan Sep 24 '16 at 11:21
  • 1
    check this reddit thread for more info – Chakravarthy Raghunandan Sep 24 '16 at 11:21
4

I've managed to prevent Emacs from modifying and writing my .emacs by setting the package-selected-packages to my list of packages I want to have installed by default.

For example, I have this configuration now:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives
         '("marmalade" .
           "https://marmalade-repo.org/packages/"))

(package-initialize)

(setq package-selected-packages
      '(
    aggressive-indent
    column-enforce-mode
    common-lisp-snippets
    company
    company-c-headers
    elisp-slime-nav
    expand-region
    ggtags
    google-this
    imenu-list
    macrostep
    magit
    markdown-mode
    monky
    paredit
    slime
    slime-company
    yaml-mode
    yasnippet
    ))

(defun install-packages ()
  "Install all required packages."
  (interactive)
  (unless package-archive-contents
    (package-refresh-contents))
  (dolist (package package-selected-packages)
    (unless (package-installed-p package)
      (package-install package))))

(install-packages)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.