Where is the .emacs file?

26

5

I downloaded Emacs 23.1 from GNU's FTP site. I untarred it and built it after configuring.

I do not find the .emacs file in my home directory or anywhere in my system! Am I missing something?

srinivas

Posted 2009-11-20T10:59:51.593

Reputation:

Answers

22

Or, as a much simpler way (as pointed out in the comment), Ctrl+H, v (describe-variable) will bring up nice output describing the variable and its value, like so:

    user-init-file is a variable defined in ‘C source code’.
    Its value is
    "/home/.emacs"

Documentation:
File name, including directory, of user's initialization file. If the file loaded had extension ‘.elc’, and the corresponding source file exists, this variable contains the name of source file, suitable for use by functions like ‘custom-save-all’ which edit the init file. While Emacs loads and evaluates the init file, value is the real name of the file, regardless of whether or not it has the &lsquo'.elc’ extension.

This way is quite verbose. A more concise answer is to start up emacs and, in your Lisp evaluation buffer, type user-init-file and press Ctrl+J to evaluate. This will print out where your init file is, like so:

user-init-file
"/home/.emacs"

Jeff Foster

Posted 2009-11-20T10:59:51.593

Reputation: 526

How is the Lisp evaluation buffer invoked? – Peter Mortensen – 2017-04-16T21:46:43.173

5Ctrl-H v (describe-variable) to look at a variable. – starblue – 2009-11-20T11:27:48.360

12

You have to create the file if you want to configure Emacs. You can just create it and start hacking the file manually or use M-x customize and save the customization.

kjfletch

Posted 2009-11-20T10:59:51.593

Reputation: 843

4

See InitFile chapter in EmacsWiki.

Your init file contains personal EmacsLisp code that you want to execute when you start Emacs.

  • For GnuEmacs, it is ~/.emacs or _emacs or ~/.emacs.d/init.el.
  • For XEmacs, it is ~/.xemacs or ~/.xemacs/init.el.
  • For AquamacsEmacs, it is ~/.emacs or ~/Library/Preferences/Aquamacs Emacs/Preferences.el

viam0Zah

Posted 2009-11-20T10:59:51.593

Reputation: 1 909

1Gabor, what is the difference between file types here? I have .emacs.d/. Should I make a init.el file here in this directory? Does the directory matter as a placement? – Vass – 2016-09-11T22:14:30.953

1

Did you check that neither .emacs nor .emacs.d/init.el exists? Because the latter seems to become more and more the standard (one file less in ~).

quazgar

Posted 2009-11-20T10:59:51.593

Reputation: 437

1What happens if you put it in the wrong place? is the directory arbitrary? – Vass – 2016-09-11T22:16:25.663

1

On Windows, the .emacs file may be called _emacs for backward compatibility with DOS and FAT filesystems where filenames could not start with a dot. Some users prefer to continue using such a name, because Explorer cannot create a file with a name starting with a dot, even though the filesystem and most other programs can handle it. In Emacs 22 and later, the init file may also be called .emacs.d/init.el. Many of the other files that are created by lisp packages are now stored in the .emacs.d directory too, so this keeps all your Emacs related files in one place.

source: http://www.gnu.org/software/emacs/manual/html_mono/efaq-w32.html#Init-file

sivi

Posted 2009-11-20T10:59:51.593

Reputation: 121

so the directory of the init file is just a convention? Simply a standard which emacs automatically looks up and you put your personal choices in a file of lisp commands to tailor emacs? – Vass – 2016-09-11T22:18:58.483

On Windows 10, I have found it to be in two different directories on two different computers: "C:\Users\username" on one, and in "C:\Users\username\AppData\Roaming" on the other. – Kirill Yunussov – 2017-10-02T12:54:06.863

0

Simple answer. You have to start writing some code in Emacs before the .emacs file appears in your home directory. Write some quick Hello, World!s and simple math code, compile and run.

Then look again in home, and type ls -a and you will see it. Then to edit it and type gedit .emacs. I use gedit because I feel weird editing Emacs, with Emacs.

razor

Posted 2009-11-20T10:59:51.593

Reputation: 1

Why would you use anything other than Emacs to edit a file of elisp code? You can always start a new instance (with emacs -q if your init file is broken, and you need to bypass it). Also, there's no requirement for Emacs to generate your init file for you. You can go ahead and create it manually; Emacs will still use it. – phils – 2013-03-07T06:02:40.140

0

Like other programmes, you can copy /etc/[what file do you want] to your home directory that your system uses for its settings.

GmArian

Posted 2009-11-20T10:59:51.593

Reputation: 1

0

You should try ls -a.

ََََََََ

Remo.D

Posted 2009-11-20T10:59:51.593

Reputation: 109

In what context? On the command line (which working directory)? From within Emacs? – Peter Mortensen – 2017-04-16T21:44:51.400

1Also: Have you tried running Emacs once before expecting a configuration file in your home? – Joey – 2009-11-20T11:05:30.353