2

I am trying to add haskell-mode to emacs by following these instructions:

http://doc.gnu-darwin.org/haskell-mode/installation-guide.html

This involves that I add some code to my ~/.emacs init file. However, my issue is that I cannot locate my emacs init file. I tried using find commands to locate it, as so:

find . -name "*emacs*"
find . -name "~/.emacs"

However none of these appear to be very successful, as I get either too many results, or no results.

So, given my situation, since I cannot locate my ~/.emacs init file, does this mean it does not exist? In that case, would it be smart to create one myself using the emacs editor? If so, are there any outstanding things I should know before attempting to create one?

buydadip
  • 8,890
  • 22
  • 79
  • 154

3 Answers3

7

C-x C-f ~/.emacs will take you to it.

See the Emacs manual, nodes Init File and Find Init.

Drew
  • 29,895
  • 7
  • 74
  • 104
  • 1
    Those links were helpful indeed, however when I try opening as you, and as the links suggested, I get an empty text file.. does this mean my init file is empty, or that it does not exist? – buydadip Jan 09 '15 at 22:37
  • 1
    @Bolboa: If you haven't changed it previously, then yes, it is empty. It can change if you edit options in the GUI as well, just to note – Patrick Jan 09 '15 at 22:55
  • 1
    Bolboa: It may well mean it didn't exist. When you ask Emacs to find a filename which doesn't exist, it creates a new empty buffer which, when you save it, will be saved to the filename you specified. Thus the same interface serves both the "open an existing file" and "create a new file" cases. – phils Jan 10 '15 at 02:59
  • 1
    The doc I cited tells you also that Emacs looks in several places for an init file for you. That means that if you are not sure whether you have an existing init file then you too need to look in those places. Alternatively, you can start Emacs with no init file by using `emacs -Q` and see if the behavior is different. If you do not notice a difference then maybe (maybe) you do not have an existing init file anywhere. – Drew Jan 10 '15 at 03:03
  • I started up with emacs -Q, and it appears different. I'm not exactly sure how to go about finding it – JobHunter69 Jul 04 '16 at 18:56
  • What does `C-h v RET user-init-file` tell you? Then try `C-x C-f` with that file name, to edit your init file. – Drew Jul 04 '16 at 22:31
5

To open your emacs init file, type M-: (find-file user-init-file) RET. If you only want to see its path, you can use C-h v user-init-file RET.

cruizh
  • 2,839
  • 3
  • 18
  • 20
0

You can also create it yourself, if I'm not wrong installing emacs doesn't create automatically the file all the times. Just type in the terminal with your text editor (vim, vi, nano, etc) of preference:

vim ~/.emacs

And edit it the way you want :-)