-2

I've been told to put a file called NAME.el in my home directory and to add (load "~/.NAME") ;; to the Emacs configuration file .emacs.

(1) Where is this configuration file?

(2) Can I insert this line of code anywhere?

(3) Just out of interest, why is this line of code in parenthesis?

Note: I don't want to know how Emacs works! I just want to change some colours.

User 17670
  • 243
  • 4
  • 9
  • 2
    You can start reading the manual here `https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html`. – abo-abo Oct 19 '13 at 17:04
  • @abo-abo I did try that, but it's incomprehensible to me :( – User 17670 Oct 19 '13 at 17:18
  • 1
    (1) `~/.emacs` (2) yes, usually (3) because it's LISP syntax, you can look it up on Wikipedia. – abo-abo Oct 19 '13 at 17:29
  • Also, it should be `(load "~/NAME")`, i.e. without the dot – abo-abo Oct 19 '13 at 17:30
  • 1
    Create a file called `init.el` and put it inside the hidden folder in your home directory labeled `.emacs.d`. The `.emacs.d` folder is created automatically when you open Emacs. Hidden items in the Finder.app of OSX can be revealed with `Command+Shift+period`.   Then put something simple inside the `init.el` file, like `(defun hello-world () (interactive) (message "My name is User 17670.")) (global-set-key (kbd "") 'hello-world)`  Now restart Emacs and press the F5 key and you should see a message at the bottom of your screen. Be prepared to spend an *enormous* amount of time learning. – lawlist Oct 19 '13 at 17:36
  • 1
    @abo-abo is 100% correct. You must make a minimal effort to learn the basics. This question risks being closed because minimal knowledge isn't demonstrated. See http://stackoverflow.com/questions/how-to-ask and http://catb.org/esr/faqs/smart-questions.html. – Drew Oct 19 '13 at 18:00
  • @lawlist What am I supposed to do with the `NAME.el` file? – User 17670 Oct 19 '13 at 18:41
  • User 17670: this may be helpful: http://stackoverflow.com/questions/10545437/how-to-disable-the-beep-in-emacs-on-windows/10545955#10545955 – phils Oct 19 '13 at 20:50
  • Emacs users normally abbreviate when referring to keyboard shortcuts. For example, if someone is suggesting that you press `C-h`, what that really means is hold the `control` key down and (while holding the `control` key down) then press the letter `h`. The combination `M-x` means press the `escape` key once and release it, and then press the letter `x` and release it. – lawlist Oct 19 '13 at 20:59
  • 1
    User 17670: Please do start the built-in tutorial (it's in the Help menu). Your confusion over the standard key representations would be resolved in the opening few paragraphs, and working your way through the whole thing will will be invaluable for getting started with Emacs. – phils Oct 19 '13 at 21:54

1 Answers1

1

(1) Emacs reads a number of init files, if they exists. The traditional file is named ~/.emacs, i.e. it is named .emacs and it is placed in the root of your home directory. On Unix-like operating system (which Mac OS X is), a file starting with a dot is hidden when listing the content of the directory with the command ls. Nowadays, it is recommended to use the file ~/.emacs.d/init.el, as this would allow you to archive the entire .emacs.d directory in a version control system.

(2) Yes, the content is assumed to be Emacs Lisp (or elisp, for short). The file is evaluated one lisp expression at a time. Normally, things can be placed in any order, as long they do not have anything to do with each other.

(3) The parentheses are a part of the list syntax. A function call is written like (my-function argument-1 argument-2). In this case load is the function you call to load the file into Emacs. Often, of course, it's better to defer the actual loading of the file until it actually is used, you can do this with the function autoload.

Lindydancer
  • 25,428
  • 4
  • 49
  • 68
  • Thanks for your answer but I still can't find the init file. In `~`, I have the `.emacs.d` file, but it only contains an empty folder called `auto-save-list` :S – User 17670 Oct 19 '13 at 18:38
  • @Drew I literally have no idea what that means. Can you please elaborate? – User 17670 Oct 19 '13 at 19:17
  • `C-h r g init file` is how to read the build in help. So first type `Ctrl`and `h` see what happens and add the other characters later... – BHF Oct 19 '13 at 19:39
  • @User17670, all you have to do is to create a new configuration file, just make sure you pick one of the names Emacs look for, like `~/.emacs.d/init.el`. – Lindydancer Oct 19 '13 at 20:46
  • 1
    @User17670: You really need to start at the beginning, and learn at least basic Emacs key-sequence notation. What `C-h r g init-file` means is this: Press and hold the Control key while hitting the `h` key. Then hit the `r` key, then the `g` key. Then type `init file`. (And then hit the `Return` key.) That will show you exactly the part of the manual that explains what you are asking: node `Init File` of the Emacs manual. – Drew Oct 19 '13 at 21:34