3

I am using the Emacs for Mac OSX app, and I need to modify the init.el file, according to the instructions on MELPA. The problem is I can't find any init.el file. Is there one in an obscure location, or is there some other file serving the same purpose? The goal is to make the MELPA packages available for the Emacs 24 package installer.

==== UPDATE ====

To add the MELPA repository, one should add a few lines "before the call to package-initialize in the init.el file", according to the MELPA page. The Emacs for OSX app doesn't seem to have an init.el file, though. Using the command (suggested by @alexander-poslavsky)

C-H (Control-h) v user-init-file RET

I get "~/.emacs", as predicted by @abo-abo. However, that file doesn't exist, so there is no call to package-initialize. Anyway, I created ~/.emacs and added my custom lines to it, as suggested by @abo-abo, and it works. Thanks!

These are currently the only contents of the .emacs file:

(require 'package)
(add-to-list 'package-archives
  '("melpa" . "http://melpa.milkbox.net/packages/") t)
Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
  • `C-x C-f` `~/.emacs`. – abo-abo Mar 06 '14 at 08:39
  • That command creates a new file. – Per Quested Aronsson Mar 06 '14 at 08:47
  • 1
    OK, put your config in that file and see if it works. This works on Linux and Windows. If it doesn't work on a Mac, then it's a bug that should be fixed. – abo-abo Mar 06 '14 at 09:22
  • You might take a look at the package configuration used [here (stackoverflow link)](http://stackoverflow.com/questions/7302771/dotfiles-repository-switching-from-per-package-git-submodules-to-elpa-while-mai?rq=1). You also might want to rethink using `~/.emacs`, and instead use `~/.emacs.d/init.el`. Elpa stores its packages in `~/.emacs.d/elpa/`. Keeping it all together is easier, as you will probably later put the whole thing under version-control anyway. – Alexander Poslavsky Mar 06 '14 at 15:10
  • "When Emacs is started, it normally tries to load a Lisp program from an initialization file, or init file for short. This file, if it exists, specifies how to initialize Emacs for you. Emacs looks for your init file using the filenames ~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el; you can choose to use any one of these three names (see Find Init). Here, ~/ stands for your home directory." -- http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html – Purplejacket Feb 24 '15 at 18:30

2 Answers2

3

Emacs for OSX uses a 'normal' configuration setup (unlike, for example Aquamacs, or on Windows where the init-file is located somewhere else.

Usually your configuration should be stored in ~/.emacs.d/init.el (see here for a complete explanation.

Your current config-file should be stored in the variable user-init-file:

use C-h (Control-h) v user-init-file RET

This will show whatever Emacs is using (it might be nil, if it is not using anything).

Hope this helps!

0

Here is how to create "init.el".

Run terminal with +spaceterminalRET

Then input these command in terminal.

  1. ls -a .emacs
  2. ls -a .emacs.d

If terminal says

.emacs: No such file or directory

and

.emacs.d: No such file or directory

you need to create emacs config file like these command.

  1. mkdir .emacs.d
  2. touch .emacs.d/init.el

Now you got "init.el". Customize it as you like.

Kei Minagawa
  • 4,395
  • 3
  • 25
  • 43