Set up files
Init file: Emacs can pick up its setup code in the file
[~ is your home directory ie
Alternatively it can take its setup from
I STRONGLY recommend the second ie
But for this to work you need
- to remove
- move/add its contents to
- custom file: I see some of you nicely set up with black color backgrounds etc. The black is nice (and even saves power!).
If you did that you will find that emacs has dumped settings into your
~/.emacsfile (now renamed to
This is very unpleasant because it mixes machine-generated setup (ie customize output) with handwritten setup.
Fortunately emacs allows you to configure this more cleanly.
If you put
(setq custom-file "~/.emacs.d/custom-file.el") (load custom-file)
init.elfile, then emacs will put customize output into
~/.emacs.d/custom-file.eland leave your handwritten options in
Note if you have no customize settings just make an empty
custom-file.elelse emacs barfs on the
- to remove
In short these are the files -- all under ~:
.emacsfile should NOT exist
.emacs.ddirectory should exist
.emacs.d/init.elfile written by you
.emacs.d/custom-file.elfile generated by emacs
Now onwards add setup to
init.el and let emacs itself add to
One nuisance of emacs is that it puts backup files all over the place.
ie if you edit a file
lintel.c it will make a file
Its wonderful to be able to go to a backup but not all over the place.
These settings (put into
init.el ) will put them all in one place:
(setq backup-directory-alist '(("." . "~/emacs-saves")))
[Choose any directory you like in place of
- Add the above like to
- Create the directory
- Check it works... how??? a. Make a new file, add a few lines to it (better not under git) b. Save and exit emacs c. Reopen emacs with that file and add/modify some lines d. Save exit
Emacs comes with org mode builtin but it may be a bit old This will give you the version
< than 8 may not work on everything
How to setup new org
Tags are a way for emacs to find your way round sources. ie if you tag your src directory then emacs can help you find your way around. Here I am explaininig simplest tagging mechanism - etags.
You create tags by running
etags on your source files.
/path/to/my/project to whatever path is appropriate for you on your machine]
$ cd /path/to/my/project $ etags *.[ch]
in your src directory. It will create a TAGS file
If (eg cpython) you have many directories containing source files Run
$ cd /path/to/my/project $ find . -type f -iname "*.[ch]" | etags -
M-.finds a tag
- M-, finds next tag
Note that you dont need to go to the web for that.
The builtin help of emacs called
info has the same information
[Remember M-: means Alt-Shift-Colon (or Escape-Colon)]
M-: (info "(emacs)commands of gud") M-: (info "(emacs)debuggers")
Remember to TYPE the M-: and copy-paste the stuff after that ie
For this you need to have installed these apt-packages
emacs24-el emacs24-common-non-dfsg, emacs24-common
99% these will be there but just in case :-)
Another thing (this is new for us!) to try is inside emacs, after starting gdb, do
Some settings are needed to make it run straight-off -- not sure which
Set emacs as default editor
This expanded but experimental section on how to Make emacs your default editor
About indentation customization, completion of
(),  etc
Suggestions below will not work unless you put them into
init.el and you RESTART EMACS.
ie Trying out the lisp in
*scratch* buffer does not work
As far as I can see adding the following add to
(setq c-default-style "bsd" c-basic-offset 3) (c-set-offset 'substatement-open 0) ;; not necessary usually
should be good. Then use
C-c C-q on a function to check.
Indentation of 3 seems to be what Don uses.
2 is what I usually prefer (otherwise).
But best to stay consistent with existing code.
of brackets quotes etc Insert closing brackets
Short version: put into init
More general snippets
There is yasnippet Though I recommend you dont waste too much time on that now :-)