What files Emacs load by default - emacs

I have weird error when I run Emacs it show u when I run Emacs normaly but not when I run emacs -q and then load .emacs by hand using load-file.
So my question is what other files Emacs may load on Init?

Documented in the manual at:
C-hig(emacs) Init File RET

Related

What to do if I cannot find my emacs init file?

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?
C-x C-f ~/.emacs will take you to it.
See the Emacs manual, nodes Init File and Find Init.
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.
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 :-)

Changing the initialization location of Emacs

I used to take the Programming languages course on Coursera and for the sake of the course i installed SML-Mode.
Now, I'd want to set up a Clojure environment in Emacs but instead of initializing Emacs from ~/.emacs.d, it initializes from the Users/karthik/Documents/sml-mode/sml-mode-startup
I deleted the sml-mode folder and on Emacs startup it shows me a warning about the files not being present. How I do point Emacs to load Emacs Live from the home folder.
I'm an Emacs newbie.
One easy way to do it, is
save you closure settings in /some/dir/my-closure-settings.el and call emacs as the following (to learn about -q -l , try emacs --help )
$ emacs -q -l /some/dir/my-closure-settings.el
or even placing an alias in bashrc,
$ alias closure-emacs='emacs -q -l /some/dir/my-closure-settings.el'
$ closure-emacs # will start emacs with your closure settings.
As you progress in learning some elisp, you will want to do it in one folder.
Assuming you installed Emacs yourself, and this SML-mode was an independent package, then I would speculated that it may have modified your site-start.el.
See if running emacs --no-site-file makes a difference.
If that's the issue, you can visit the file with:
M-: (find-library site-run-file) RET
You might also check:
C-hv user-emacs-directory RET
when running emacs in various ways:
emacs
emacs --no-site-file
emacs -q
emacs -Q
Unless it's a custom binary, at some point it should tell you "~/.emacs.d/"
Installing SML-mode does not change the place of the main initialization file, which is one of ~/.emacs or ~/.emacs.d/init.el. So look at those files (which ever of the two is present), and if none is present, then just create it and add what you need in it.
BTW, it looks like you're using an old sml-mode package (the newer one doesn't have an sml-mode-startup.el file). So please try and make sure the documentation that pointed you to that mode is updated: nowaday sml-mode should be installed from GNU ELPA, i.e. via M-x package-list or M-x package-install.

Emacs not recognising .emacs.d folder on startup

I'm new to Emacs. I recently got a dot-emacs configuration from GitHub. Cloned the repo in my home directory as .emacs.d
This is for setting up a clojure environment. When i open Emacs and enter
M-x nrepl-jack-in, the minibuf displays 'No Match'
What am I doing incorrectly? Thanks!
It's possible that nREPL isn't being loaded. Add the following to your init.el:
(autoload 'nrepl-jack-in "nrepl" nil t)
You should be able to run it now with M-x nrepl-jack-in.
If the command doesn't work you'll need to do some troubleshooting.
make sure that nREPL is actually installed. You'll need both the Emacs library and the nREPL server.
check for any errors during startup. Launch Emacs from the terminal using the --d flag:
emacs --d
You will get a backtrace if anything goes wrong during the startup.
verify that your init.el is actually being loaded. Add the following code to the end of your init.el and restart Emacs.
(message "---> LOADED")
This will show in your *Messages* buffer if everything is being loaded.
Edit:
Looks like your init.el isn't being loaded. Check your home folder for files called .emacs or .emacs.el, which might be getting loaded instead.
Otherwise it could still be a path issue. Open a terminal and make sure this is the file you expect:
less ~/.emacs.d/init.el

absolutely pure emacs initialization

I'd like to run emacs without any installed plugins. Emacs manual says that you may use -q option to skip init file. I've tried emacs -q and discovered that plugins from /usr/share/emacs/site-lisp (ubuntu installs plugins here) are still loaded.
I've searched google about emacs's initialization routine and found nothing usefull. I'm curios what emacs do step by step while initializing and what variables, options, evironment, etc. may change default behaviour.
Try emacs -Q
From the manpage:
-Q, --quick
Similar to "-q --no-site-file --no-splash". Also, avoid processing X resources.
If you only want to avoid loading site lisp code, you might want to run
emacs -q --no-site-file
Emacs == self-documenting.
C-hig (emacs) Emacs Invocation RET
If you really want to get into the details, you can peruse startup.el with
M-x find-library RET startup RET

How do I byte-compile everything in my .emacs.d directory?

I have decided to check out Emacs, and I liked it very much. Now, I'm using the Emacs Starter Kit, which sort of provides better defaults and some nice customizations to default install of Emacs.
I have customized it a little, added some stuff like yasnippet, color-themes, unbound, and other stuff. I've set up a github repository where I keep all of the customizations so I can access them from multiple places or in case something goes bad and I lose my .emacs.d directory.
All of this is very nice, but there is a problem: Emacs takes about 1-2 seconds to load. AFAIK I can compile individual .el files with M-x byte-compile-file to .elc, and it works. But there are a lot of .el files, and I wonder if there is a way to compile them all with a simple command or something, to speed up the loading of Emacs. My Emacs is not always open, and I open and close it quite frequently, especially after I've set it up as a default editor for edit command in Total Commander to get used to it faster (yeah, windows xp here).
My Emacs version is 22.3. And yes, the default Emacs installation without any customizations fires up instantly.
I am not sure which version is preferred when loading, the .el or compiled .elc one by the way O.o
So, is there an elisp command or Emacs command line switch to make Emacs byte-compile everything in .emacs.d directory?
C-u 0 M-x byte-recompile-directory
will compile all the .el files in the directory and in all subdirectories below.
The C-u 0 part is to make it not ask about every .el file that does not have a .elc counterpart.
To automatically byte compile everything that needs byte compiling each time I start emacs, I put the following after my changes to load-path at the top of my .emacs file:
(byte-recompile-directory (expand-file-name "~/.emacs.d") 0)
Surprisingly, it doesn't add much to my startup time (unless something needs to be compiled).
To speed up my emacs, I first identified the slow parts using profile-dotemacs.el and then replaced them with autoloads.
You can use the --batch flag to recompile from the command line.
To recompile all, do
emacs --batch --eval '(byte-recompile-directory "~/.emacs.d")'
or to recompile a single file as from a Makefile,
emacs --batch --eval '(byte-compile-file "your-elisp-file.el")'
This is swaying a bit from the question, but to solve the problem of loading slowly you can use the new daemon feature in Emacs 23.
"If you have a lot of support packages,
emacs startup can be a bit slow.
However, emacs 23 brings emacs
--daemon, which enables you to start emacs in the background (for example
when you log in). You can instantly
pop up new emacs windows (frames) with
emacsclient. Of course, you could
already have an emacs 'server' in
older versions, but being able to
start it in the background makes this
a much nicer solution"
From http://emacs-fu.blogspot.com/2009/07/emacs-23-is-very-near.html
The command I use is M-x byte-force-recompile RET, it then asks the directory so, for example, I give it ~/.emacs.d/elpa/. It then recompiles everything in there, usually no need to delete .elc files first or mess with it in other ways.
For my using spacemacs, the command is spacemacs/recompile-elpa. The command byte-recompile-directory does not compile any file.